{{ 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/99designs/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 -}}
================================================
FILE: .chglog/config.yml
================================================
style: github
template: CHANGELOG-full-history.tpl.md
info:
title: CHANGELOG
repository_url: https://github.com/99designs/gqlgen
options:
commits:
# filters:
# Type: []
commit_groups:
# title_maps: []
header:
pattern: "^(.*)$"
pattern_maps:
- Subject
notes:
keywords:
- BREAKING CHANGE
================================================
FILE: .dockerignore
================================================
/**/node_modules
/codegen/tests/gen
/vendor
================================================
FILE: .editorconfig
================================================
# top-most EditorConfig file
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
# Ignore yaml https://learn.microsoft.com/en-us/visualstudio/code-quality/use-roslyn-analyzers?view=vs-2022
[*.{yaml,yml,yml.j2,yaml.j2}]
generated_code = true
# charset = unset
# end_of_line = unset
# insert_final_newline = unset
# trim_trailing_whitespace = unset
# indent_style = unset
# indent_size = unset
# These often end up with go code inside, so lets keep tabs
[*.{html,md}]
indent_size = 2
indent_style = tab
================================================
FILE: .gitattributes
================================================
/codegen/templates/data.go linguist-generated
/_examples/dataloader/*_gen.go linguist-generated
generated.go linguist-generated
================================================
FILE: .github/CODEOWNERS
================================================
# SEE:
# https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-code-owners#codeowners-syntax
# These owners will be the default owners for these directories.
# Unless a later match takes precedence,
# @StevenACoffman will be requested for
# review when someone opens a pull request.
* @StevenACoffman
================================================
FILE: .github/ISSUE_TEMPLATE.md
================================================
### What happened?
### What did you expect?
### Minimal graphql.schema and models to reproduce
### versions
- `go tool gqlgen version`?
- `go version`?
================================================
FILE: .github/PULL_REQUEST_TEMPLATE.md
================================================
Describe your PR and link to any relevant issues.
I have:
- [ ] Added tests covering the bug / feature (see [testing](https://github.com/99designs/gqlgen/blob/master/TESTING.md))
- [ ] Updated any relevant documentation (see [docs](https://github.com/99designs/gqlgen/tree/master/docs/content))
================================================
FILE: .github/dependabot.yml
================================================
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
# Maintain dependencies for Go Modules
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
ignore:
- dependency-name: "github.com/gorilla/websocket"
# For websocket, v1.5.1 has serious bugs
versions: ["v1.5.1"]
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/_examples" # Location of package manifests
schedule:
interval: "weekly"
ignore:
- dependency-name: "github.com/gorilla/websocket"
# For websocket, v1.5.1 has serious bugs
versions: ["v1.5.1"]
# Maintain dependencies for npm
- package-ecosystem: "npm" # See documentation for possible values
directory: "integration" # Location of package manifests
schedule:
interval: "weekly"
- package-ecosystem: "npm" # See documentation for possible values
directory: "_examples/chat" # Location of package manifests
schedule:
interval: "weekly"
- package-ecosystem: "npm" # See documentation for possible values
directory: "_examples/federation" # Location of package manifests
schedule:
interval: "weekly"
================================================
FILE: .github/fmt-actions.sh
================================================
#!/bin/bash
# fmt-actions - reformats github actions
# intended to be invoked from this directory
#
# see https://til.simonwillison.net/yaml/yamlfmt
function is_bin_in_path {
builtin type -P "$1" &> /dev/null
}
export GOBIN="$HOME/go/bin"
mkdir -p "$GOBIN"
# we installed go binaries to $GOBIN
# so we ensure that is in the PATH and takes precedence
export PATH="$GOBIN:$PATH"
! is_bin_in_path yamlfmt && GOBIN=$HOME/go/bin go install -v github.com/google/yamlfmt/cmd/yamlfmt@latest
# -formatter indentless_arrays=true,retain_line_breaks=true
yamlfmt \
-conf ./linters/.yamlfmt.yaml ./workflows/*.y*ml
# -formatter indentless_arrays=true,retain_line_breaks=true
yamlfmt \
-conf ./linters/.yamlfmt.yaml ./linters/*.y*ml
# -formatter indentless_arrays=true,retain_line_breaks=true
yamlfmt \
-conf ./linters/.yamlfmt.yaml ./*.y*ml
================================================
FILE: .github/fmt-md.sh
================================================
#!/bin/bash
# fmt-md - Intended to be run from root directory of repository
# to format markdown to pass linting rules.
# Works on all machines, but will install missing requirements
# using homebrew as those who use linux will have no need because:
# 1. Linux users will manage their own requirement installation
# 2. Linux users will not make markdown formatting mistakes :)
# Requirements:
# uv - to install python tools idempotently
# go - any recent version
# shfmt - mvdan.cc/sh/v3/cmd/shfmt
# mdformat and extensions
function is_bin_in_path {
builtin type -P "$1" &> /dev/null
}
export GOBIN="$HOME/go/bin"
mkdir -p "$GOBIN"
# uv installs things to $HOME/.local/bin
# we installed go binaries to $GOBIN
# so we ensure those both are in the PATH and take precedence
export PATH="$HOME/.local/bin:$GOBIN:$PATH"
! is_bin_in_path uv && brew install uv
! is_bin_in_path shfmt && go install mvdan.cc/sh/v3/cmd/shfmt@latest
! is_bin_in_path mdformat && uv tool install --with mdformat-gfm --with mdformat-shfmt --with mdformat-tables --with mdformat-toc --with mdformat-config --with mdformat-gofmt mdformat
# clean all Script files (possibly makes mistakes?):
# find .. -name '*.sh' -type f -print0 | xargs -0 -n1 -P4 shfmt -bn -ci -d -i 2 -ln bash -s -sr
# ensure all files have trailing line endings
# find -type f | while read f; do tail -n1 $f | read -r _ || echo >> $f; done
# clean all markdown files
find . -type d -name node_modules -prune -o -name '*.md' -type f -print0 | xargs -0 -n1 -P4 mdformat --wrap keep --number
================================================
FILE: .github/lint-actions.sh
================================================
#!/bin/bash
function is_bin_in_path {
builtin type -P "$1" &> /dev/null
}
export GOBIN="$HOME/go/bin"
! is_bin_in_path yamllint && go install -v github.com/wasilibs/go-yamllint/cmd/yamllint@latest
! is_bin_in_path actionlint && go install -v github.com/rhysd/actionlint/cmd/actionlint@latest
! is_bin_in_path shellcheck && go install -v github.com/wasilibs/go-shellcheck/cmd/shellcheck@latest
! is_bin_in_path ghalint && go install -v github.com/suzuki-shunsuke/ghalint/cmd/ghalint@latest
export PATH="$GOBIN:$PATH"
# Note that due to the sandboxing of the filesystem when using Wasm,
# currently only files that descend from the current directory when executing the tool
# are accessible to it, i.e., ../yaml/my.yaml or /separate/root/my.yaml will not be found.
yamllint -c ./linters/.yamllint.yaml .
# https://www.shellcheck.net/wiki/SC2086 https://www.shellcheck.net/wiki/SC2129
export SHELLCHECK_OPTS='-e SC2086 -e SC2129'
actionlint -config-file=./linters/actionlint.yaml -shellcheck="$(which shellcheck)"
cd ..
ghalint run
================================================
FILE: .github/linters/.editorconfig-checker.json
================================================
{
"Verbose": false,
"Debug": false,
"IgnoreDefaults": false,
"SpacesAfterTabs": false,
"NoColor": false,
"Exclude": [],
"AllowedContentTypes": [],
"PassedFiles": [],
"Disable": {
"EndOfLine": false,
"Indentation": false,
"IndentSize": false,
"InsertFinalNewline": false,
"TrimTrailingWhitespace": false,
"MaxLineLength": false
}
}
================================================
FILE: .github/linters/.hadolint.yaml
================================================
ignored:
- DL3007 # use latest tag
- DL3018 # apk should not pin all package versions
- DL3041 # dnf should not pin all package versions
- DL3008 # apt should not pin all package versions
- DL3003 # don't use workdir, this is readable when workdir isn't created yet
- SC2086 # double quote to prevent globbing and word splitting
trustedRegistries:
- docker.io
- quay.io
- ghcr.io
- registry.access.redhat.com
- cgr.dev
================================================
FILE: .github/linters/.markdownlint.json
================================================
{
"line-length": false,
"MD033": { "allowed_elements": ["br", "summary", "details", "div"] }
}
================================================
FILE: .github/linters/.markdownlint.yml
================================================
line-length: false
MD033:
allowed_elements:
- br
- summary
- details
- div
================================================
FILE: .github/linters/.shellcheckrc
================================================
# Look for 'source'd files relative to the checked script
source-path=SCRIPTDIR
# source-path=/mnt/chroot
# Since 0.9.0, values can be quoted with '' or "" to allow spaces
# source-path="My Documents/scripts"
# Allow opening any 'source'd file, even if not specified as input
external-sources=true
# Turn on warnings for unquoted variables with safe values
# enable=quote-safe-variables
# Turn on warnings for unassigned uppercase variables
# enable=check-unassigned-uppercase
# See https://www.shellcheck.net/wiki/SC2086 https://www.shellcheck.net/wiki/SC2129
disable=SC2086,SC2129
================================================
FILE: .github/linters/.yamlfmt.yaml
================================================
# yamlfmt is an extensible command line tool or library to format yaml files.
#
# Get it from: https://github.com/google/yamlfmt/releases
# Config is here: https://github.com/google/yamlfmt/blob/main/docs/config-file.md
formatter:
type: basic
indentless_arrays: true
indent: 2
line_ending: lf
================================================
FILE: .github/linters/.yamllint.yaml
================================================
extends: default
rules:
braces: disable
brackets: disable
colons: enable
commas: disable
comments: disable
comments-indentation: disable
document-end: disable
document-start: disable
empty-lines: disable
empty-values: disable
hyphens: enable
indentation:
spaces: 2
check-multi-line-strings: false
indent-sequences: false
key-duplicates: enable
key-ordering: disable
line-length: disable
new-line-at-end-of-file: disable
new-lines: enable
octal-values: disable
quoted-strings: disable
trailing-spaces: disable
truthy:
allowed-values: ['true', 'false', 'on'] # 'on' for GH action trigger
check-keys: false
================================================
FILE: .github/linters/actionlint.yaml
================================================
self-hosted-runner:
# Labels of self-hosted runner in array of strings.
labels: []
# Configuration variables in array of strings defined in your repository or
# organization. `null` means disabling configuration variables check.
# Empty array means no configuration variable is allowed.
config-variables: null
# Configuration for file paths. The keys are glob patterns to match to file
# paths relative to the repository root. The values are the configurations for
# the file paths. Note that the path separator is always '/'.
# The following configurations are available.
#
# "ignore" is an array of regular expression patterns. Matched error messages
# are ignored. This is similar to the "-ignore" command line option.
# Path-specific configurations.
paths:
# Glob pattern relative to the repository root for matching files. The path separator is always '/'.
# This example configures any YAML file under the '.github/workflows/' directory.
.github/workflows/**/*.{yml,yaml}:
# List of regular expressions to filter errors by the error messages. # Ignore the specific error from shellcheck '-e SC2086 -e SC2129 -e SC2164 -e SC2155 -e SC2103'
ignore:
- 'shellcheck reported issue in this script: SC2086:.+'
- 'shellcheck reported issue in this script: SC2129:.+'
- 'shellcheck reported issue in this script: SC2164:.+'
- 'shellcheck reported issue in this script: SC2155:.+'
- 'shellcheck reported issue in this script: SC2103:.+'
================================================
FILE: .github/pin-actions.sh
================================================
#!/bin/bash
# pin-actions.sh - pins all actions to Git SHA1, run from repo root
function is_bin_in_path {
builtin type -P "$1" &> /dev/null
}
export GOBIN="$HOME/go/bin"
mkdir -p "$GOBIN"
# we installed go binaries to $GOBIN
# so we ensure that is in the PATH and takes precedence
export PATH="$GOBIN:$PATH"
! is_bin_in_path yamlfmt && GOBIN=$HOME/go/bin go install -v github.com/sethvargo/ratchet@latest
export SED_COMMAND="gsed"
! is_bin_in_path gsed && export SED_COMMAND="sed"
find . -name '*.y*l' | sort -u | grep '.github/workflows' | xargs -I {} ratchet pin '{}'
cd .github
find . -name '*.y*l' -exec ${SED_COMMAND} -i'' 's/ratchet:.*\/.*\@//g' {} \;
./fmt-actions.sh
cd ..
================================================
FILE: .github/workflows/GOVERSION.txt
================================================
1.25.0
================================================
FILE: .github/workflows/actionlint.yaml
================================================
name: action-lint
on:
push:
branches:
- main
- master
paths:
- .github/**
pull_request:
branches:
- main
- master
paths:
- .github/**
workflow_dispatch:
inputs:
git-ref:
description: Git Ref (Optional)
required: false
# only on merge to main/master unless debugging this workflow
# pull_request:
# branches:
# - main
# - master
# we do NOT use pull_request_target because
# workflow runs that are triggered by forks from events:
# - push,
# - pull_request,
# - pull_request_review
# - pull_request_review_comment
# will be treated as if they were opened from a repository fork.
# This means they will receive a read-only GITHUB_TOKEN
# and will not have access to any secrets available in the repository.
# This will cause any workflows that attempt to write to the repository to fail.
#
# 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:
github-lint:
runs-on: ubuntu-latest
# runs-on: [self-hosted, linux, x64]
timeout-minutes: 30
permissions:
# needed for the checkout action
contents: read
# needed to annotate the files in a pull request with comments
pull-requests: write
steps:
- name: Clone Repository (Latest)
if: github.event.inputs.git-ref == ''
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v5
with:
persist-credentials: "false"
- name: Clone Repository (Custom Ref)
if: github.event.inputs.git-ref != ''
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v5
with:
persist-credentials: "false"
ref: ${{ github.event.inputs.git-ref }}
- name: Run actionlint
if: ${{ always() }}
uses: devops-actions/actionlint@469810fd82c015d3c43815cd2b0e4d02eecc4819 # v0.1.11
with: # https://www.shellcheck.net/wiki/SC2086 https://www.shellcheck.net/wiki/SC2129
shellcheck_opts: '-e SC2086 -e SC2129'
- name: Lint Any Shell scripts
if: ${{ always() }}
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # 2.0.0
env:
SHELLCHECK_OPTS: '-e SC2086 -e SC2129 -e SC2164 -e SC2155 -e SC2103'
- name: Install Go
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6
- name: Install GHALINT
run: go install github.com/suzuki-shunsuke/ghalint/cmd/ghalint@v1.5.3 # v1.5.3
- run: cd ..; ghalint run
env:
GHALINT_LOG_COLOR: always
================================================
FILE: .github/workflows/check-coverage
================================================
#!/bin/bash
# Script to check the coverage by running tests and merging profiles
set -o errexit
set -o nounset
set -o xtrace
set -o pipefail
# set -euxo pipefail is short for:
# set -e, -o errexit: stop the script when an error occurs
# set -u, -o nounset: detects uninitialised variables in your script and exits with an error (including Env variables)
# set -x, -o xtrace: prints every expression before executing it
# set -o pipefail: If any command in a pipeline fails, use that return code for whole pipeline instead of final success
#set -euo pipefail
function is_bin_in_path {
builtin type -P "$1" &> /dev/null
}
export SED_COMMAND="gsed"
! is_bin_in_path gsed && export SED_COMMAND="sed"
join () {
local IFS="$1"
shift
echo "$*"
}
echo "Installing goveralls latest"
go install github.com/mattn/goveralls@latest
echo "Collecting Test Package List"
# ${SED_COMMAND} 's/^\|$/"/g'|
pkgs="$(go list github.com/99designs/gqlgen/... 2> /dev/null | grep -v "integration" | grep -v "_examples" |grep -v "plugin/resolvergen/testdata" | grep -v "plugin/federation/testdata" | grep -v "plugin/resolvergen/testdata" | grep -v "invalid-packagename" | grep -v "generated-default")"
deps=$(echo "${pkgs}" | tr ' ' ",")
# -covermode atomic
echo "mode: atomic" > /tmp/coverage.out.tmp
echo "Attempting to create initial coverage profile"
for pkg in $pkgs; do
go test -v -race -cover -coverpkg "$deps" -coverprofile=/tmp/profile.tmp "${pkg}"
if [ -f /tmp/profile.tmp ]; then
tail -n +2 /tmp/profile.tmp >> /tmp/coverage.out.tmp
rm /tmp/profile.tmp
fi
done;
# this was the old way and it did not work very well:
# go test -covermode atomic -coverprofile=/tmp/coverage.out.tmp -coverpkg=./...
# ignore protobuf files
grep -v ".pb.go" < /tmp/coverage.out.tmp > /tmp/coverage.out
ignore_list=(
'_examples/*/*'
'_examples/*/*/*'
'integration/*'
'integration/*/*'
'codegen/testserver/**/*generated*'
'codegen/testserver/**/*generated*/**'
'codegen/testserver/**/models-gen.go'
'codegen/testserver/**/resolver.go'
'plugin/resolvergen/testdata/*/*'
'plugin/modelgen/*/*'
'plugin/federation/testdata/*/*/*'
'*/generated.go'
'*/*/generated.go'
'*/*/*/generated.go'
'graphql/executable_schema_mock.go'
)
ignore=$(join , "${ignore_list[@]}")
goveralls -coverprofile=/tmp/coverage.out -service=github "-ignore=$ignore"
================================================
FILE: .github/workflows/check-federation
================================================
#!/bin/bash
set -euo pipefail
export GO111MODULE=on
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"
npx vitest --color --run
================================================
FILE: .github/workflows/check-fmt
================================================
#!/bin/bash
set -exuo pipefail
export GO111MODULE=on
export GOTOOLCHAIN=local
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
================================================
FILE: .github/workflows/check-generate
================================================
#!/bin/bash
set -exuo pipefail
export GO111MODULE=on
echo Generating code
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
================================================
FILE: .github/workflows/check-gomod.sh
================================================
#!/bin/bash
set -euo pipefail
export GOVERSION="$(cat GOVERSION.txt)"
export GOTOOLCHAIN="go${GOVERSION}"
go get go@${GOVERSION} || true
go get toolchain@none || true
go mod tidy || true
STATUS=$( git status --porcelain go.mod go.sum )
if [ ! -z "$STATUS" ]; then
echo "Running go mod tidy modified go.mod and/or go.sum"
echo "Please run the following then make a git commit:"
echo "go get go@${GOVERSION}"
echo "go get toolchain@none"
echo "go mod tidy"
echo "export GOTOOLCHAIN=${GOTOOLCHAIN}"
exit 1
fi
exit 0
================================================
FILE: .github/workflows/check-init
================================================
#!/bin/bash
set -euo pipefail
export GO111MODULE=on
gqlgen_dir=$(pwd)
cd "$(mktemp -d)"
go mod init inittest
go get -tool github.com/99designs/gqlgen
go mod edit -replace=github.com/99designs/gqlgen="$gqlgen_dir"
go mod tidy
if ! go tool gqlgen init ; then
echo "gqlgen init failed"
exit 125
fi
if ! go tool gqlgen generate ; then
echo "gqlgen generate failed"
exit 125
fi
================================================
FILE: .github/workflows/check-integration
================================================
#!/bin/bash
set -euo pipefail
export GO111MODULE=on
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
================================================
FILE: .github/workflows/coverage.yml
================================================
name: Coverage
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize]
env:
GOTOOLCHAIN: local
# 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:
coverage:
timeout-minutes: 10
permissions:
contents: read
pull-requests: write
strategy:
matrix:
go: ["1.26"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v5
with:
persist-credentials: "false"
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6
with:
go-version: ${{ matrix.go }}
- run: go mod download
- run: .github/workflows/check-coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
================================================
FILE: .github/workflows/fmt-and-generate.yml
================================================
name: Format and Generate
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize]
env:
GOTOOLCHAIN: local
# 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:
fmt-and-lint:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
pull-requests: write
strategy:
matrix:
go: ["1.26", "1.25"]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v5
with:
persist-credentials: "false"
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6
with:
go-version: ${{ matrix.go }}
- run: go mod download
- run: .github/workflows/check-fmt
- run: .github/workflows/check-generate
================================================
FILE: .github/workflows/gomod-clean.yml
================================================
name: GoModVersion
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize]
env:
GOTOOLCHAIN: local
# 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:
gomodclean:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
pull-requests: write
strategy:
matrix:
go: ["1.26"]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v5
with:
persist-credentials: "false"
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6
with:
go-version: ${{ matrix.go }}
- run: .github/workflows/check-fmt
================================================
FILE: .github/workflows/integration.yml
================================================
name: Integration
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize]
env:
GOTOOLCHAIN: local
# 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:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
pull-requests: write
strategy:
matrix:
go: ["1.26", "1.25"]
node: [22]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v5
with:
persist-credentials: "false"
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6
with:
go-version: ${{ matrix.go }}
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v5
with:
node-version: ${{ matrix.node }}
- run: go mod download
- run: cd integration ; npm ci
- run: .github/workflows/check-integration
federation:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
pull-requests: write
strategy:
matrix:
go: ["1.26", "1.25"]
node: [22]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v5
with:
persist-credentials: "false"
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6
with:
go-version: ${{ matrix.go }}
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v5
with:
node-version: ${{ matrix.node }}
- run: go mod download
- run: cd _examples/federation ; npm install
- run: .github/workflows/check-federation
init:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
pull-requests: write
strategy:
matrix:
go: ["1.26", "1.25"]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v5
with:
persist-credentials: "false"
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6
with:
go-version: ${{ matrix.go }}
- run: .github/workflows/check-init
================================================
FILE: .github/workflows/lint.yml
================================================
name: Lint
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize]
# 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
env:
GOTOOLCHAIN: local
GOFLAGS: "-trimpath"
jobs:
golangci-lint:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
pull-requests: write
env:
GOLANGCI_LINT_VERSION: latest
strategy:
matrix:
go: ["1.26", "1.25"]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v5
with:
persist-credentials: "false"
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6
with:
go-version: ${{ matrix.go }}
- name: golangci-lint
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
verify: false
- name: golangci-lint examples
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
working-directory: _examples
================================================
FILE: .github/workflows/report.yml
================================================
name: test report
on:
workflow_run:
workflows: ["Test"]
types:
- completed
permissions:
checks: write
jobs:
checks:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
pull-requests: write
steps:
- name: Download Test Report
uses: dawidd6/action-download-artifact@2536c51d3d126276eb39f74d6bc9c72ac6ef30d3 # v16
with:
name: junit-test-results
workflow: ${{ github.event.workflow.id }}
run_id: ${{ github.event.workflow_run.id }}
- name: Publish Test Report
uses: mikepenz/action-junit-report@49b2ca06f62aa7ef83ae6769a2179271e160d8e4 # v5
with:
commit: ${{github.event.workflow_run.head_sha}}
report_paths: '**/*.xml'
================================================
FILE: .github/workflows/security.yml
================================================
name: Security
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize]
env:
GOTOOLCHAIN: "local"
# 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:
check-secret:
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
pull-requests: write
outputs:
my-secret-exists: ${{ steps.my-secret-check.outputs.defined }}
steps:
- name: Check for Secret availability
id: my-secret-check
# perform secret check and write boolean as output
shell: bash
run: |
if [ "${{ secrets.OSSI_TOKEN }}" != '' ]; then
echo "defined=true" >> $GITHUB_OUTPUT;
else
echo "defined=false" >> $GITHUB_OUTPUT;
fi
nancy: # only run when not in fork and secret is available
runs-on: ubuntu-latest
needs: [check-secret]
if: needs.check-secret.outputs.my-secret-exists == 'true'
timeout-minutes: 10
permissions:
contents: read
pull-requests: write
strategy:
matrix:
go: ["1.25"] # nancy is a little flaky running more than once
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v5
with:
persist-credentials: "false"
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6
with:
go-version: ${{ matrix.go }}
- run: go mod download && go list -json -deps all > go.list
- uses: sonatype-nexus-community/nancy-github-action@395e2fb168f674f96502e5652103d112899ea369 # main
env:
OSSI_USERNAME: "${{ secrets.OSSI_USERNAME }}"
OSSI_TOKEN: "${{ secrets.OSSI_TOKEN }}"
================================================
FILE: .github/workflows/test.yml
================================================
name: Test
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize]
env:
GOTOOLCHAIN: local
# 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
permissions:
# Required: allow read access to the content for analysis.
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
pull-requests: read
# Optional: allow write access to checks to allow the action to annotate code in the PR.
checks: write
jobs:
test:
timeout-minutes: 10
permissions:
contents: read
pull-requests: write
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
go: ["1.26", "1.25"]
runs-on: ${{ matrix.os }}
continue-on-error: true
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v5
with:
persist-credentials: "false"
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6
with:
go-version: ${{ matrix.go }}
# Install gotestsum on the VM running the action.
- name: Setup gotestsum
run: go install gotest.tools/gotestsum@latest
- name: Core tests
shell: bash
run: |
set -euo pipefail
go mod download
gotestsum --jsonfile go_test.json --junitfile report.xml --format-icons=hivis --format=pkgname-and-test-fails -- -race ./... -trimpath
- name: Example tests
shell: bash
if: success() || failure() # always run even if the previous step fails
run: |
cd _examples
go mod download
gotestsum --junitfile ../go_examples_report.xml --format-icons=hivis --format=pkgname-and-test-fails -- -race ./... -trimpath
- name: Upload Test Report
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
if: always() # always run even if the previous step fails
with:
name: test-junit-${{ matrix.os }}-${{ matrix.go }}
path: '*.xml'
retention-days: 1
- name: action-junit-report
shell: bash
if: success() || failure() # always run even if the previous step fails
run: |
echo "### mikepenz/action-junit-report! :rocket:" >> $GITHUB_STEP_SUMMARY
- name: Publish Test Report
uses: mikepenz/action-junit-report@49b2ca06f62aa7ef83ae6769a2179271e160d8e4 # v5
if: success() || failure() # always run even if the previous step fails
with:
report_paths: |
report.xml
go_examples_report.xml
- name: robherley/go-test-action announcement
shell: bash
if: success() || failure() # always run even if the previous step fails
run: |
echo "### robherley/go-test-action! :rocket:" >> $GITHUB_STEP_SUMMARY
# - name: Annotate tests does not work on pull-requests for security
# if: success() || failure() # always run even if the previous step fails
# uses: guyarb/golang-test-annotations@v0.8.0
# with:
# test-results: go_test.json
- name: Publish go-test-action Report
if: success() || failure() # always run even if the previous step fails
uses: robherley/go-test-action@42a1975c97156330b5126c2f35ef0fb78c4c7154 # v0.7.1
with:
# Parse an exisiting [test2json](https://pkg.go.dev/cmd/test2json) file, instead of executing go test.
# Will always exit(0) on successful test file parse.
# Optional. No default
fromJSONFile: go_test.json
omit: |
untested
successful
- name: test-summary/action announcement
shell: bash
if: success() || failure() # always run even if the previous step fails
run: |
echo "### test-summary/action! :rocket:" >> $GITHUB_STEP_SUMMARY
- name: Publish Test Summary Report
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4
if: success() || failure() # always run even if the previous step fails
with:
show: "fail, skip"
paths: |
report.xml
go_examples_report.xml
================================================
FILE: .gitignore
================================================
/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
node_modules
# generated files
/api/testdata/default/graph/generated.go
/api/testdata/federation2/graph/federation.go
/api/testdata/federation2/graph/generated.go
================================================
FILE: .golangci.yml
================================================
# All settings can be found here https://github.com/golangci/golangci-lint/blob/HEAD/.golangci.reference.yml
version: "2"
run:
concurrency: 8
modules-download-mode: readonly
issues-exit-code: 1
tests: true
allow-parallel-runners: false
issues:
# Maximum count of issues with the same text.
# Set to 0 to disable.
# Default: 3
max-issues-per-linter: 0
max-same-issues: 0
new: false
formatters:
exclusions:
paths:
- codegen/testserver/followschema/resolver.go
- codegen/testserver/singlefile/resolver.go
- codegen/testserver/usefunctionsyntaxforexecutioncontext/resolver.go
- generated
enable:
- golines
- gofumpt
- gci
settings:
gci:
sections:
- standard
- default
- prefix(github.com/99designs/gqlgen)
golines:
# Target maximum line length.
# Default: 100
max-len: 100
linters:
default: none
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- copyloopvar
- dupl
- dupword
- durationcheck
- errcheck
- gocritic
- govet
- ineffassign
- misspell
- modernize
- nakedret
- nolintlint
- perfsprint
- reassign
- revive
- staticcheck
- testableexamples
- testifylint
- unconvert
- unparam
- unused
- usestdlibvars
- usetesting
- wastedassign
# - prealloc # disabled because it is a huge pain
settings:
errcheck:
exclude-functions:
- (io.Writer).Write
- (http.ResponseWriter).Write
- (*bytes.Buffer).WriteByte
- (*strings.Builder).WriteByte
- (*strings.Builder).WriteString
- io.Copy
- io.WriteString
- fmt.Fprintln
gocritic:
enabled-checks:
- emptyStringTest
- equalFold
- httpNoBody
- nilValReturn
- paramTypeCombine
- preferFprint
- yodaStyleExpr
govet:
disable:
- fieldalignment
- shadow
- unusedwrite
enable-all: true
modernize:
disable:
- any
- fmtappendf
- minmax
- rangeint
- reflecttypefor
- stditerators
- stringscut
- stringscutprefix
- stringsseq
perfsprint:
int-conversion: false
err-error: false
errorf: true
sprintf1: false
strconcat: false
revive:
enable-all-rules: false
rules:
- name: empty-lines
- name: use-any
# https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#struct-tag
- name: struct-tag
exclude: ["**/*_go124_test.go"]
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: error-return
- name: error-naming
- name: exported
disabled: true
- name: if-return
- name: increment-decrement
- name: var-declaration
- name: package-comments
disabled: true
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
- name: superfluous-else
- name: unused-parameter
disabled: true
- name: unreachable-code
- name: redefines-builtin-id
testifylint:
disable-all: true
enable:
- blank-import
- bool-compare
- compares
- empty
- encoded-compare
- error-is-as
- error-nil
- expected-actual
- float-compare
- go-require
- len
- negative-positive
- nil-compare
- require-error
- useless-assert
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- dupl
- errcheck
path: _test\.go
- linters:
- gocritic
path: codegen/testserver/.*/resolver\.go
- linters:
- gocritic
path: _examples/federation/products/graph/entity.resolvers.go
# revive.use-any causes problems in some generated files
- path: graphql/map.go
text: 'use-any'
- path: codegen/testserver/followschema/resolver.go
text: 'use-any'
- path: codegen/testserver/singlefile/resolver.go
text: 'use-any'
- linters:
- staticcheck
path: codegen/testserver/generated_test.go
text: SA1019
- linters:
- staticcheck
path: plugin/modelgen/models_test.go
text: SA1019
paths:
- bin
- third_party$
- builtin$
- examples$
- generated$
================================================
FILE: CHANGELOG.md
================================================
# 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/99designs/gqlgen/compare/v0.17.50...HEAD)
## [v0.17.50](https://github.com/99designs/gqlgen/compare/v0.17.49...v0.17.50) - 2024-09-13
- a6d5d843 release v0.17.50
- f154d99d Fix Nancy to use Go 1.22
- 6b9e40e8 make rewrite default for resolver layout single-file (#3243)
1855758d chore(deps): bump dset in /integration in the npm_and_yarn group (#3268)
Bumps the npm_and_yarn group in /integration with 1 update: [dset](https://github.com/lukeed/dset).
Updates `dset` from 3.1.3 to 3.1.4
- [Release notes](https://github.com/lukeed/dset/releases)
- [Commits](https://github.com/lukeed/dset/compare/v3.1.3...v3.1.4)
---
updated-dependencies:
- dependency-name: dset
dependency-type: indirect
dependency-group: npm_and_yarn
...
fda0539e Bump some more module versions (#3262)
* Bump some more module versions
* Update aurora
* Avoid upgrade to go 1.23
* downgrade goquery to support pre-Go 1.23 for now
* Downgrade moq to support pre-Go 1.23 as well
---------
cf42b253 chore(deps): bump golang.org/x/text from 0.17.0 to 0.18.0 (#3259)
Bumps [golang.org/x/text](https://github.com/golang/text) from 0.17.0 to 0.18.0.
- [Release notes](https://github.com/golang/text/releases)
- [Commits](https://github.com/golang/text/compare/v0.17.0...v0.18.0)
---
updated-dependencies:
- dependency-name: golang.org/x/text
dependency-type: direct:production
update-type: version-update:semver-minor
...
b728c12f chore(deps): bump golang.org/x/text from 0.17.0 to 0.18.0 in /_examples (#3256)
Bumps [golang.org/x/text](https://github.com/golang/text) from 0.17.0 to 0.18.0.
- [Release notes](https://github.com/golang/text/releases)
- [Commits](https://github.com/golang/text/compare/v0.17.0...v0.18.0)
---
updated-dependencies:
- dependency-name: golang.org/x/text
dependency-type: direct:production
update-type: version-update:semver-minor
...
cba40a38 chore(deps-dev): bump vite from 5.4.2 to 5.4.3 in /integration (#3257)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.4.2 to 5.4.3.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.4.3/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-type: direct:development
update-type: version-update:semver-patch
...
81ac627d chore(deps): bump robherley/go-test-action from 0.4.1 to 0.5.0 (#3255)
Bumps [robherley/go-test-action](https://github.com/robherley/go-test-action) from 0.4.1 to 0.5.0.
- [Release notes](https://github.com/robherley/go-test-action/releases)
- [Commits](https://github.com/robherley/go-test-action/compare/v0.4.1...v0.5.0)
---
updated-dependencies:
- dependency-name: robherley/go-test-action
dependency-type: direct:production
update-type: version-update:semver-minor
...
86ac6b36 internal/code: `Unalias` element of pointer (#3250) (closes #3247)
This reverts commit 4c4be0aeaaad758e703724fe4a6575768017ac53.
* code: `Unalias` element of pointer
* chore: added comment
- 4c4be0ae codegen: Unalias before lookup type (#3247)
ab1781b1 codegen: Go 1.23 alias support (#3246)
* code: added `Unalias` for Go 1.22
* codegen: Go 1.23 alias support
814f7c71 chore(deps): bump actions/upload-artifact from 4.3.6 to 4.4.0 (#3235)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.3.6 to 4.4.0.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v4.3.6...v4.4.0)
---
updated-dependencies:
- dependency-name: actions/upload-artifact
dependency-type: direct:production
update-type: version-update:semver-minor
...
1cbbc120 chore(deps): bump github.com/rs/cors from 1.11.0 to 1.11.1 in /_examples (#3236)
Bumps [github.com/rs/cors](https://github.com/rs/cors) from 1.11.0 to 1.11.1.
- [Commits](https://github.com/rs/cors/compare/v1.11.0...v1.11.1)
---
updated-dependencies:
- dependency-name: github.com/rs/cors
dependency-type: direct:production
update-type: version-update:semver-patch
...
0b9bd5ee refactor: don't extract [@goField](https://github.com/goField) twice (#3234)
We already extract the values in config.Init(). Remove the duplicate logic in the modelgen plugin.
We leave the reference to GoFieldHook even though it's a noop since it's public. This makes this a non-breaking change. We will remove this during the next breaking release.
18378f90 feat: allow argument directives to be called even if the argument is null (#3233) (closes #3188)
The existing implementation assumes that if an input argument is null, you don't want to call the directive. This is a very constraining assumption — directives may want to not just mutate an argument but to actually outright set it.
This is a breaking change as argument directives now need to handle null input values. Added a new config switch:
call_argument_directives_with_nulls: bool
to control this new behavior.
* Run go generate ./...
256794aa chore(deps-dev): bump vite from 5.4.0 to 5.4.2 in /integration (#3229)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.4.0 to 5.4.2.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.4.2/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-type: direct:development
update-type: version-update:semver-patch
...
6acc182c Go 1.23 support (#3226)
* Added support for go 1.23
* Added handling for *types.Alias
* Updated golang ci lint to 1.60.2
* Fixed lint issues and ignore SA1019 on generated test files
* Update coverage.yml
* Update fmt-and-generate.yml
* Update integration.yml
* Update lint.yml
* Update test.yml
---------
f6a82204 chore(deps): bump golang.org/x/tools from 0.23.0 to 0.24.0 (#3219)
* chore(deps): bump golang.org/x/tools from 0.23.0 to 0.24.0
Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.23.0 to 0.24.0.
- [Release notes](https://github.com/golang/tools/releases)
- [Commits](https://github.com/golang/tools/compare/v0.23.0...v0.24.0)
---
updated-dependencies:
- dependency-name: golang.org/x/tools
dependency-type: direct:production
update-type: version-update:semver-minor
...
* _examples fixup
---------
1849e124 chore(deps): bump golang.org/x/text from 0.16.0 to 0.17.0 (#3218)
Bumps [golang.org/x/text](https://github.com/golang/text) from 0.16.0 to 0.17.0.
- [Release notes](https://github.com/golang/text/releases)
- [Commits](https://github.com/golang/text/compare/v0.16.0...v0.17.0)
---
updated-dependencies:
- dependency-name: golang.org/x/text
dependency-type: direct:production
update-type: version-update:semver-minor
...
2f7772c9 [proposal] Add [@concurrent](https://github.com/concurrent) directive for types (#3203)
* Issue 3202
* Issue 3202
* Issue 3202
* Make optional concurrent for fields of objects
* Make optional concurrent for fields of objects
3556475a Fix marshaling interfaces and union types (#3211)
* Fixed marshaling interfaces and union
* Fixed marshaling interfaces and union
23abdc56 chore(deps): bump github.com/urfave/cli/v2 from 2.27.3 to 2.27.4 (#3217)
Bumps [github.com/urfave/cli/v2](https://github.com/urfave/cli) from 2.27.3 to 2.27.4.
- [Release notes](https://github.com/urfave/cli/releases)
- [Changelog](https://github.com/urfave/cli/blob/main/docs/CHANGELOG.md)
- [Commits](https://github.com/urfave/cli/compare/v2.27.3...v2.27.4)
---
updated-dependencies:
- dependency-name: github.com/urfave/cli/v2
dependency-type: direct:production
update-type: version-update:semver-patch
...
edca7992 chore(deps-dev): bump vite from 5.3.5 to 5.4.0 in /integration (#3216)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.3.5 to 5.4.0.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
---
updated-dependencies:
- dependency-name: vite
dependency-type: direct:development
update-type: version-update:semver-minor
...
f0b7ee3f chore(deps): bump actions/upload-artifact from 4.3.5 to 4.3.6 (#3220)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.3.5 to 4.3.6.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v4.3.5...v4.3.6)
---
updated-dependencies:
- dependency-name: actions/upload-artifact
dependency-type: direct:production
update-type: version-update:semver-patch
...
719b7af3 chore(deps): bump golang.org/x/text from 0.16.0 to 0.17.0 in /_examples (#3221)
Bumps [golang.org/x/text](https://github.com/golang/text) from 0.16.0 to 0.17.0.
- [Release notes](https://github.com/golang/text/releases)
- [Commits](https://github.com/golang/text/compare/v0.16.0...v0.17.0)
---
updated-dependencies:
- dependency-name: golang.org/x/text
dependency-type: direct:production
update-type: version-update:semver-minor
...
d14fd791 chore(deps): bump actions/upload-artifact from 4.3.4 to 4.3.5 (#3208)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.3.4 to 4.3.5.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v4.3.4...v4.3.5)
---
updated-dependencies:
- dependency-name: actions/upload-artifact
dependency-type: direct:production
update-type: version-update:semver-patch
...
564e2dc5 chore(deps): bump golangci/golangci-lint-action from 6.0.1 to 6.1.0 (#3207)
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 6.0.1 to 6.1.0.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v6.0.1...v6.1.0)
---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
dependency-type: direct:production
update-type: version-update:semver-minor
...
d3d147e6 chore(deps): bump golang.org/x/tools from 0.22.0 to 0.23.0 (#3172)
* chore(deps): bump golang.org/x/tools from 0.22.0 to 0.23.0
Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.22.0 to 0.23.0.
- [Release notes](https://github.com/golang/tools/releases)
- [Commits](https://github.com/golang/tools/compare/v0.22.0...v0.23.0)
---
updated-dependencies:
- dependency-name: golang.org/x/tools
dependency-type: direct:production
update-type: version-update:semver-minor
...
---------
2d7e00b5 chore(deps-dev): bump typescript from 5.5.3 to 5.5.4 in /integration (#3196)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.5.3 to 5.5.4.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v5.5.3...v5.5.4)
---
updated-dependencies:
- dependency-name: typescript
dependency-type: direct:development
update-type: version-update:semver-patch
...
552bb4b9 chore(deps-dev): bump vite from 5.3.4 to 5.3.5 in /integration (#3199)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.3.4 to 5.3.5.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.3.5/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-type: direct:development
update-type: version-update:semver-patch
...
45a29fe0 chore(deps): bump github.com/urfave/cli/v2 from 2.27.2 to 2.27.3 (#3200)
Bumps [github.com/urfave/cli/v2](https://github.com/urfave/cli) from 2.27.2 to 2.27.3.
- [Release notes](https://github.com/urfave/cli/releases)
- [Changelog](https://github.com/urfave/cli/blob/main/docs/CHANGELOG.md)
- [Commits](https://github.com/urfave/cli/compare/v2.27.2...v2.27.3)
---
updated-dependencies:
- dependency-name: github.com/urfave/cli/v2
dependency-type: direct:production
update-type: version-update:semver-patch
...
3c2443e4 chore(deps): bump golang.org/x/sync from 0.7.0 to 0.8.0 in /_examples (#3206)
Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.7.0 to 0.8.0.
- [Commits](https://github.com/golang/sync/compare/v0.7.0...v0.8.0)
---
updated-dependencies:
- dependency-name: golang.org/x/sync
dependency-type: direct:production
update-type: version-update:semver-minor
...
52f65d0f chore(deps-dev): bump vitest from 2.0.4 to 2.0.5 in /integration (#3209)
Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 2.0.4 to 2.0.5.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v2.0.5/packages/vitest)
---
updated-dependencies:
- dependency-name: vitest
dependency-type: direct:development
update-type: version-update:semver-patch
...
- 9b031e4d chore: fix typos in comments, tests and unexported vars (#3193)
- 892c4842 refactor: decrease indentation in api.ReplacePlugin (#3194)
d1682f7c chore(deps-dev): bump vite from 5.3.3 to 5.3.4 in /integration (#3190)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.3.3 to 5.3.4.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.3.4/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-type: direct:development
update-type: version-update:semver-patch
...
cfc9863a chore(deps-dev): bump vitest from 2.0.2 to 2.0.4 in /integration (#3189)
Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 2.0.2 to 2.0.4.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v2.0.4/packages/vitest)
---
updated-dependencies:
- dependency-name: vitest
dependency-type: direct:development
update-type: version-update:semver-patch
...
1cc0a17b Revert "feat: allow argument directives to be called even if the argument is …" (#3191)
This reverts commit 0fb31a3ed2a63552eddcf7c2a6c40aa0d59bd4cc.
0fb31a3e feat: allow argument directives to be called even if the argument is null (#3188)
The existing implementation assumes that if an input argument is null, you don't want to call the directive. This is a very constraining assumption — directives may want to not just mutate an argument but to actually outright set it.
This is a breaking change as argument directives now need to handle null input values. Added a new config switch:
call_argument_directives_with_nulls: bool
to control this new behavior.
cd82be01 refactor: significantly clean up the federation.gotpl template (#3187) (closes #2991)
* fix: fix Federation example
Some configurations weren't working due to a missing resolver.
* chore: Introduce mechanism for running all example Federation subgraphs
This enables engineers to more easily run the debugger on the Federation example. Updated README to show how to use it.
* refactor: significantly clean up the federation.gotpl template
There were a number of inline structs and inline functions that made it extremely hard to reason about what the code is doing. Split these out into smaller functions with less closures and mutation.
a63f94bb chore(deps-dev): bump vitest from 1.6.0 to 2.0.2 in /integration (#3185)
Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 1.6.0 to 2.0.2.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v2.0.2/packages/vitest)
---
updated-dependencies:
- dependency-name: vitest
dependency-type: direct:development
update-type: version-update:semver-major
...
de315d3d chore: Refactor federation.go to make it easier to read (#3183) (closes #2991)
* chore: Refactor federation.go
- Cut functions into smaller functions
- Remove mutation in several locations
* Refactor InjectSourcesLate
Easier to reason about and read this way.
* Re-run go generate ./...
* regenerate
---------
4d8d93cd Make cache generic to avoid casting (#3179)
* Make cache generic to avoid casting
* Update handler/handler.go
---------
fc150db0 chore(deps-dev): bump typescript from 5.5.2 to 5.5.3 in /integration (#3175)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.5.2 to 5.5.3.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v5.5.2...v5.5.3)
---
updated-dependencies:
- dependency-name: typescript
dependency-type: direct:development
update-type: version-update:semver-patch
...
60c9f671 chore(deps): bump actions/upload-artifact from 4.3.3 to 4.3.4 (#3176)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.3.3 to 4.3.4.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v4.3.3...v4.3.4)
---
updated-dependencies:
- dependency-name: actions/upload-artifact
dependency-type: direct:production
update-type: version-update:semver-patch
...
59bdde19 chore(deps-dev): bump vite from 5.3.2 to 5.3.3 in /integration (#3173)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.3.2 to 5.3.3.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.3.3/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-type: direct:development
update-type: version-update:semver-patch
...
0ca3b19e chore(deps): bump github.com/rs/cors (#3171)
Bumps the go_modules group with 1 update in the /_examples/websocket-initfunc/server directory: [github.com/rs/cors](https://github.com/rs/cors).
Updates `github.com/rs/cors` from 1.9.0 to 1.11.0
- [Commits](https://github.com/rs/cors/compare/v1.9.0...v1.11.0)
---
updated-dependencies:
- dependency-name: github.com/rs/cors
dependency-type: direct:production
dependency-group: go_modules
...
d0e68928 Nulls are now unmarshalled as zero values for primitive types (#3162)
* Nulls are now unmarshalled as zero values for primitive types
* Address uint and run gofumpt
---------
dce2e353 chore(deps): bump test-summary/action from 2.3 to 2.4 (#3163)
Bumps [test-summary/action](https://github.com/test-summary/action) from 2.3 to 2.4.
- [Release notes](https://github.com/test-summary/action/releases)
- [Commits](https://github.com/test-summary/action/compare/v2.3...v2.4)
---
updated-dependencies:
- dependency-name: test-summary/action
dependency-type: direct:production
update-type: version-update:semver-minor
...
28b2f494 chore(deps-dev): bump vite from 5.3.1 to 5.3.2 in /integration (#3166)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.3.1 to 5.3.2.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.3.2/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-type: direct:development
update-type: version-update:semver-patch
...
- feab5f51 fix bug: POST Insufficient rigorous judgment leads to invalid SSE (#3153)
- 7c8bc50d Add failing test as example (#3151)
d00ace38 Add prettier test results (#3148)
* Add prettier test results
641377d7 chore(deps-dev): bump ws in /integration in the npm_and_yarn group (#3147)
Bumps the npm_and_yarn group in /integration with 1 update: [ws](https://github.com/websockets/ws).
Updates `ws` from 8.16.0 to 8.17.1
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/8.16.0...8.17.1)
---
updated-dependencies:
- dependency-name: ws
dependency-type: indirect
dependency-group: npm_and_yarn
...
- e724bde5 docs: missing 'repeatable' in [@goExtraField](https://github.com/goExtraField) directive (#3150)
- 85459a32 Fix typo in config field names (#3149)
- 1422ff25 feat: Change plugin signatures (#2011)
04b13fdb chore(deps-dev): bump vite from 5.2.13 to 5.3.1 in /integration (#3144)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.2.13 to 5.3.1.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.3.1/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-type: direct:development
update-type: version-update:semver-minor
...
f813598b#3118 Add token limit option to fix CVE-2023-49559 (#3136)
* Use ParseQueryWithLmit and add parserTokenLimit to executor
* add parser token limit test
* remove failing test
* move default token limit to const
---------
ee1e18c7 chore(deps-dev): bump braces in /integration in the npm_and_yarn group (#3134)
Bumps the npm_and_yarn group in /integration with 1 update: [braces](https://github.com/micromatch/braces).
Updates `braces` from 3.0.2 to 3.0.3
- [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md)
- [Commits](https://github.com/micromatch/braces/compare/3.0.2...3.0.3)
---
updated-dependencies:
- dependency-name: braces
dependency-type: indirect
dependency-group: npm_and_yarn
...
d6226db6 chore(deps): bump github.com/vektah/gqlparser/v2 from 2.5.12 to 2.5.14 in the go_modules group (#3133)
* chore(deps): bump github.com/vektah/gqlparser/v2 in the go_modules group
Bumps the go_modules group with 1 update: [github.com/vektah/gqlparser/v2](https://github.com/vektah/gqlparser).
Updates `github.com/vektah/gqlparser/v2` from 2.5.12 to 2.5.14
- [Release notes](https://github.com/vektah/gqlparser/releases)
- [Commits](https://github.com/vektah/gqlparser/compare/v2.5.12...v2.5.14)
---
updated-dependencies:
- dependency-name: github.com/vektah/gqlparser/v2
dependency-type: direct:production
dependency-group: go_modules
...
* Update to v2.5.16
---------
e6860c35 chore(deps): bump golang.org/x/tools from 0.21.0 to 0.22.0 (#3125)
Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.21.0 to 0.22.0.
- [Release notes](https://github.com/golang/tools/releases)
- [Commits](https://github.com/golang/tools/compare/v0.21.0...v0.22.0)
---
updated-dependencies:
- dependency-name: golang.org/x/tools
dependency-type: direct:production
update-type: version-update:semver-minor
...
3bad9617 chore(deps): bump golang.org/x/text from 0.15.0 to 0.16.0 (#3124)
* chore(deps): bump golang.org/x/text from 0.15.0 to 0.16.0
Bumps [golang.org/x/text](https://github.com/golang/text) from 0.15.0 to 0.16.0.
- [Release notes](https://github.com/golang/text/releases)
- [Commits](https://github.com/golang/text/compare/v0.15.0...v0.16.0)
---
updated-dependencies:
- dependency-name: golang.org/x/text
dependency-type: direct:production
update-type: version-update:semver-minor
...
* Update examples go mod
---------
4492b3c0 chore(deps-dev): bump vite from 5.2.12 to 5.2.13 in /integration (#3126)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.2.12 to 5.2.13.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v5.2.13/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.2.13/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-type: direct:development
update-type: version-update:semver-patch
...
8ec8d795 chore(deps): bump golang.org/x/text from 0.15.0 to 0.16.0 in /_examples (#3123)
Bumps [golang.org/x/text](https://github.com/golang/text) from 0.15.0 to 0.16.0.
- [Release notes](https://github.com/golang/text/releases)
- [Commits](https://github.com/golang/text/compare/v0.15.0...v0.16.0)
---
updated-dependencies:
- dependency-name: golang.org/x/text
dependency-type: direct:production
update-type: version-update:semver-minor
...
fbf73ee1 chore(deps-dev): bump vite from 5.2.11 to 5.2.12 in /integration (#3117)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.2.11 to 5.2.12.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.2.12/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-type: direct:development
update-type: version-update:semver-patch
...
e07134ab add option to omit panic handlers during development (#3114)
see docs for motivation
- 1a7c6090 refactor: fix gocritic lint issues (#3113)
- 4114515f refactor: use errors.New instead of fmt.Errorf (#3112)
- 93f6366d Omit gqlgen version in config files used for tests (#3111)
dae915d2 Correct dataloader example (#3110)
Dataloader requires the value and error slice to be of equal length, in order to correctly return the values.
Link: https://github.com/vikstrous/dataloadgen/blob/7de6ebe3d882737607ce2ba646e8d6ec652b32e3/dataloadgen_test.go#L19-L20
bd9219dd Go template function to split string into array of strings. (#3108)
* added new template function to split string
* StrSplit func to upper
---------
90f2271e refactor: use t.Log instead of fmt.Print (#3099)
* refactor: use t.Log instead of fmt.Printf
* Add back failure context as to what errors happened and where
---------
- d7447c69 refactor: rename local variables to match Go codestyle (#3100)
- 834d832c refactor: avoid panic in tests (#3098)
- 71845858 Ignore gorilla/websocket 1.5.1 in dependabot (#3097)
- 4ecfec90 Fix go install gqlgen binary (#3095)
- 866075cd refactor: simplify with strconv.FormatBool (#3094)
- ab19907d refactor: UnmarshalID implementation (#3093)
- a9965fbd refactor: use 'any' instead of 'interface{}' for consistency (#3090)
d5c9f896 Embed extra fields config (#3088)
---------
3a5827d4 Fix #2856: resolver receive previous implementation on render (#2886)
* pass previous impl to resolver
* pass previous only and not default
- e0125301 bugfix for [@goField](https://github.com/goField) + [@goExtraField](https://github.com/goExtraField) combination (#3078)
e61a7200 Federation: Update docs to use IntrospectAndCompose (#3077)
`serviceList` now gets a deprecation warning to use IntrospectAndCompose
instead. We update our docs to avoid referring to deprecated services
de31828a Ability to inline extraFields configuration. New [@goExtraField](https://github.com/goExtraField) directive. (#3076)
---------
1ee0fa80 chore(deps-dev): bump vite from 5.2.10 to 5.2.11 in /integration (#3047)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.2.10 to 5.2.11.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.2.11/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-type: direct:development
update-type: version-update:semver-patch
...
ddd9a6ba chore(deps): bump golang.org/x/text from 0.14.0 to 0.15.0 (#3052)
Bumps [golang.org/x/text](https://github.com/golang/text) from 0.14.0 to 0.15.0.
- [Release notes](https://github.com/golang/text/releases)
- [Commits](https://github.com/golang/text/compare/v0.14.0...v0.15.0)
---
updated-dependencies:
- dependency-name: golang.org/x/text
dependency-type: direct:production
update-type: version-update:semver-minor
...
36b66607 chore(deps): bump github.com/PuerkitoBio/goquery from 1.9.1 to 1.9.2 (#3051)
* chore(deps): bump github.com/PuerkitoBio/goquery from 1.9.1 to 1.9.2
Bumps [github.com/PuerkitoBio/goquery](https://github.com/PuerkitoBio/goquery) from 1.9.1 to 1.9.2.
- [Release notes](https://github.com/PuerkitoBio/goquery/releases)
- [Commits](https://github.com/PuerkitoBio/goquery/compare/v1.9.1...v1.9.2)
---
updated-dependencies:
- dependency-name: github.com/PuerkitoBio/goquery
dependency-type: direct:production
update-type: version-update:semver-patch
...
* go mod tidy
---------
ad91bf6c chore(deps-dev): bump vitest from 1.5.2 to 1.6.0 in /integration (#3048)
Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 1.5.2 to 1.6.0.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v1.6.0/packages/vitest)
---
updated-dependencies:
- dependency-name: vitest
dependency-type: direct:development
update-type: version-update:semver-minor
...
b3a10547 Add initial cache tests for MapCache and NoCache (#3040)
* Add initial cache tests for MapCache and NoCache
* Add edge case testing to MapCache and NoCache
* Reformat, regenerate
---------
- 16854647 chore: lint _examples directory (#3042)
- 2bb32fe7 chore: remove deprecated build tag (#3041)
- 4b559b33 Fix codegen config tests: add file closing (#3037)
- 293991e9 docs: fix links to the docs latest version (#3038)
- 79dc5e03 refactor: change test asserts to be more idiomatic (#3036)
- a1989525 chore: remove unnecessary empty lines (#3035)
- 6998f19f chore: `run.skip-dirs` is deprecated in golangci-lint v1.57 (#3034)
835c2d11 Improve federation resolver selection (#3029)
* Improve federation resolver selection
Just checking for existence of keys in the representations isn't enough. If the values are null, we should skip the resolver.
* Run go generate ./...
* Add test cases
* Fix linter
9e8e7edd refactor: simplify tests for `api.Generate` (#3031)
* refactor: simplify tests for Generate
* Add deleted files to git ignore
---------
- 28405ac1 Fix test asserts: reverse expected and actual params (#3027)
75326bc7 Bump github.com/sosodev/duration from 1.2.0 to 1.3.0 (#3024)
* Bump github.com/sosodev/duration from 1.2.0 to 1.3.0
Bumps [github.com/sosodev/duration](https://github.com/sosodev/duration) from 1.2.0 to 1.3.0.
- [Release notes](https://github.com/sosodev/duration/releases)
- [Commits](https://github.com/sosodev/duration/compare/v1.2.0...v1.3.0)
---
updated-dependencies:
- dependency-name: github.com/sosodev/duration
dependency-type: direct:production
update-type: version-update:semver-minor
...
* go mod tidy
---------
bf4406a1 Bump vitest from 1.5.0 to 1.5.2 in /integration (#3021)
Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 1.5.0 to 1.5.2.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v1.5.2/packages/vitest)
---
updated-dependencies:
- dependency-name: vitest
dependency-type: direct:development
update-type: version-update:semver-patch
...
1a8ebe9b Bump [@apollo](https://github.com/apollo)/client from 3.9.11 to 3.10.1 in /integration (#3022)
- [Release notes](https://github.com/apollographql/apollo-client/releases)
- [Changelog](https://github.com/apollographql/apollo-client/blob/main/CHANGELOG.md)
- [Commits](https://github.com/apollographql/apollo-client/compare/v3.9.11...v3.10.1)
---
updated-dependencies:
dependency-type: direct:development
update-type: version-update:semver-minor
...
bacaab8e Bump github.com/urfave/cli/v2 from 2.27.1 to 2.27.2 (#3023)
Bumps [github.com/urfave/cli/v2](https://github.com/urfave/cli) from 2.27.1 to 2.27.2.
- [Release notes](https://github.com/urfave/cli/releases)
- [Changelog](https://github.com/urfave/cli/blob/main/docs/CHANGELOG.md)
- [Commits](https://github.com/urfave/cli/compare/v2.27.1...v2.27.2)
---
updated-dependencies:
- dependency-name: github.com/urfave/cli/v2
dependency-type: direct:production
update-type: version-update:semver-patch
...
3f515543 Bump github.com/rs/cors from 1.10.1 to 1.11.0 in /_examples (#3025)
Bumps [github.com/rs/cors](https://github.com/rs/cors) from 1.10.1 to 1.11.0.
- [Commits](https://github.com/rs/cors/compare/v1.10.1...v1.11.0)
---
updated-dependencies:
- dependency-name: github.com/rs/cors
dependency-type: direct:production
update-type: version-update:semver-minor
...
ced2189d Bump golangci/golangci-lint-action from 4.0.0 to 5.0.0 (#3026)
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 4.0.0 to 5.0.0.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v4.0.0...v5.0.0)
---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
dependency-type: direct:production
update-type: version-update:semver-major
...
8bd35429 chore: fix some typos in comments (#3020)
* chore: fix some typos in comments
* Apply suggestions from code review
---------
e1ef86e7 Bump vite from 5.2.8 to 5.2.10 in /integration (#3015)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.2.8 to 5.2.10.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.2.10/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-type: direct:development
update-type: version-update:semver-patch
...
ecc3f647 Bump [@apollo](https://github.com/apollo)/client from 3.9.10 to 3.9.11 in /integration (#3011)
- [Release notes](https://github.com/apollographql/apollo-client/releases)
- [Changelog](https://github.com/apollographql/apollo-client/blob/main/CHANGELOG.md)
- [Commits](https://github.com/apollographql/apollo-client/compare/v3.9.10...v3.9.11)
---
updated-dependencies:
dependency-type: direct:development
update-type: version-update:semver-patch
...
c92b511c Bump typescript from 5.4.4 to 5.4.5 in /integration (#3010)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.4.4 to 5.4.5.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v5.4.4...v5.4.5)
---
updated-dependencies:
- dependency-name: typescript
dependency-type: direct:development
update-type: version-update:semver-patch
...
cc2d95a2 Bump vitest from 1.4.0 to 1.5.0 in /integration (#3012)
Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 1.4.0 to 1.5.0.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v1.5.0/packages/vitest)
---
updated-dependencies:
- dependency-name: vitest
dependency-type: direct:development
update-type: version-update:semver-minor
...
c17a4b6f fix: codegen will _ the fieldset parameter if its not needed (#3006)
* fix: codegen will _ the fieldset parameter if its not needed
* update generated examples
- 0b0f6592 chore: update Automatic Persisted Queries Link (#3005)
79aa0ceb Mark ctx as unused when no arguments for FieldContextFunc (#2999)
* Mark ctx as unused when no arguments for FieldContextFunc
* Regenerate
---------
f3b34683 Bump urql from 4.0.6 to 4.0.7 in /integration (#2995) (closes #2998)
* Bump urql from 4.0.6 to 4.0.7 in /integration
Bumps [urql](https://github.com/urql-graphql/urql/tree/HEAD/packages/react-urql) from 4.0.6 to 4.0.7.
- [Release notes](https://github.com/urql-graphql/urql/releases)
- [Changelog](https://github.com/urql-graphql/urql/blob/main/packages/react-urql/CHANGELOG.md)
---
updated-dependencies:
- dependency-name: urql
dependency-type: direct:development
update-type: version-update:semver-patch
...
client.
---------
8ab31646 Bump graphql-ws from 5.15.0 to 5.16.0 in /integration (#2986)
Bumps [graphql-ws](https://github.com/enisdenjo/graphql-ws) from 5.15.0 to 5.16.0.
- [Release notes](https://github.com/enisdenjo/graphql-ws/releases)
- [Changelog](https://github.com/enisdenjo/graphql-ws/blob/master/CHANGELOG.md)
- [Commits](https://github.com/enisdenjo/graphql-ws/compare/v5.15.0...v5.16.0)
---
updated-dependencies:
- dependency-name: graphql-ws
dependency-type: direct:development
update-type: version-update:semver-minor
...
45fafedc Bump golang.org/x/tools from 0.19.0 to 0.20.0 (#2996)
* Bump golang.org/x/tools from 0.19.0 to 0.20.0
Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.19.0 to 0.20.0.
- [Release notes](https://github.com/golang/tools/releases)
- [Commits](https://github.com/golang/tools/compare/v0.19.0...v0.20.0)
---
updated-dependencies:
- dependency-name: golang.org/x/tools
dependency-type: direct:production
update-type: version-update:semver-minor
...
* Update examples to match root go.mod
---------
4c45be21 Bump vite from 5.2.7 to 5.2.8 in /integration (#2992)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.2.7 to 5.2.8.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.2.8/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-type: direct:development
update-type: version-update:semver-patch
...
6352b800 Bump vite from 5.2.6 to 5.2.7 in /integration (#2984)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.2.6 to 5.2.7.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.2.7/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-type: direct:development
update-type: version-update:semver-patch
...
2286b0e8 Bump graphql-sse from 2.5.2 to 2.5.3 in /integration (#2985)
Bumps [graphql-sse](https://github.com/enisdenjo/graphql-sse) from 2.5.2 to 2.5.3.
- [Release notes](https://github.com/enisdenjo/graphql-sse/releases)
- [Changelog](https://github.com/enisdenjo/graphql-sse/blob/master/CHANGELOG.md)
- [Commits](https://github.com/enisdenjo/graphql-sse/compare/v2.5.2...v2.5.3)
---
updated-dependencies:
- dependency-name: graphql-sse
dependency-type: direct:development
update-type: version-update:semver-patch
...
8ab2c27a Bump [@graphql](https://github.com/graphql)-codegen/client-preset from 4.2.4 to 4.2.5 in /integration (#2983)
- [Release notes](https://github.com/dotansimha/graphql-code-generator/releases)
- [Changelog](https://github.com/dotansimha/graphql-code-generator/blob/master/packages/presets/client/CHANGELOG.md)
---
updated-dependencies:
dependency-type: direct:development
update-type: version-update:semver-patch
...
d192a591 Bump [@apollo](https://github.com/apollo)/client from 3.9.7 to 3.9.9 in /integration (#2977)
- [Release notes](https://github.com/apollographql/apollo-client/releases)
- [Changelog](https://github.com/apollographql/apollo-client/blob/main/CHANGELOG.md)
- [Commits](https://github.com/apollographql/apollo-client/compare/v3.9.7...v3.9.9)
---
updated-dependencies:
dependency-type: direct:development
update-type: version-update:semver-patch
...
62289425 Bump vite from 5.1.6 to 5.2.6 in /integration (#2978)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.1.6 to 5.2.6.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.2.6/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-type: direct:development
update-type: version-update:semver-minor
...
105ec44b Bump typescript from 5.4.2 to 5.4.3 in /integration (#2979)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.4.2 to 5.4.3.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v5.4.2...v5.4.3)
---
updated-dependencies:
- dependency-name: typescript
dependency-type: direct:development
update-type: version-update:semver-patch
...
ee526b05 Bump vite from 5.1.5 to 5.1.6 in /integration (#2971)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.1.5 to 5.1.6.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.1.6/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-type: direct:development
update-type: version-update:semver-patch
...
00bf8ef3 Bump vitest from 1.3.1 to 1.4.0 in /integration (#2972)
Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 1.3.1 to 1.4.0.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v1.4.0/packages/vitest)
---
updated-dependencies:
- dependency-name: vitest
dependency-type: direct:development
update-type: version-update:semver-minor
...
bdbdddf5 Bump [@apollo](https://github.com/apollo)/client from 3.9.6 to 3.9.7 in /integration (#2970)
- [Release notes](https://github.com/apollographql/apollo-client/releases)
- [Changelog](https://github.com/apollographql/apollo-client/blob/main/CHANGELOG.md)
- [Commits](https://github.com/apollographql/apollo-client/compare/v3.9.6...v3.9.7)
---
updated-dependencies:
dependency-type: direct:development
update-type: version-update:semver-patch
...
a854eb65 Bump golang.org/x/tools from 0.18.0 to 0.19.0 (#2963)
* Bump golang.org/x/tools from 0.18.0 to 0.19.0
Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.18.0 to 0.19.0.
- [Release notes](https://github.com/golang/tools/releases)
- [Commits](https://github.com/golang/tools/compare/v0.18.0...v0.19.0)
---
updated-dependencies:
- dependency-name: golang.org/x/tools
dependency-type: direct:production
update-type: version-update:semver-minor
...
* Go mod tidy examples and websocket
---------
908498e3 Bump typescript from 5.3.3 to 5.4.2 in /integration (#2960)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.3.3 to 5.4.2.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v5.3.3...v5.4.2)
---
updated-dependencies:
- dependency-name: typescript
dependency-type: direct:development
update-type: version-update:semver-minor
...
6e77359b Bump vite from 5.1.4 to 5.1.5 in /integration (#2961)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.1.4 to 5.1.5.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.1.5/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-type: direct:development
update-type: version-update:semver-patch
...
361cb189 Bump [@apollo](https://github.com/apollo)/client from 3.9.5 to 3.9.6 in /integration (#2962)
- [Release notes](https://github.com/apollographql/apollo-client/releases)
- [Changelog](https://github.com/apollographql/apollo-client/blob/main/CHANGELOG.md)
- [Commits](https://github.com/apollographql/apollo-client/compare/v3.9.5...v3.9.6)
---
updated-dependencies:
dependency-type: direct:development
update-type: version-update:semver-patch
...
d2271d8f Bump google.golang.org/protobuf from 1.32.0 to 1.33.0 (#2964)
Bumps google.golang.org/protobuf from 1.32.0 to 1.33.0.
---
updated-dependencies:
- dependency-name: google.golang.org/protobuf
dependency-type: direct:production
update-type: version-update:semver-minor
...
- caf1faa7 Add case for resolvers_always_return_pointers:false (#2966)
- 0d24aa9b handle models in federation pkg (#2965)
- 2aa9bbb4 fix(docs): convert an unnecessarily capitalized word in the middle of sentences to lowercase (#2959)
- bc72cd8c Add option to omit resolver fields from models (#2957)
95f9dc79 Bump github.com/stretchr/testify from 1.8.4 to 1.9.0 (#2953)
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.4 to 1.9.0.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.8.4...v1.9.0)
---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
dependency-type: direct:production
update-type: version-update:semver-minor
...
fbcceec2 Bump github.com/PuerkitoBio/goquery from 1.9.0 to 1.9.1 (#2954)
* Bump github.com/PuerkitoBio/goquery from 1.9.0 to 1.9.1
Bumps [github.com/PuerkitoBio/goquery](https://github.com/PuerkitoBio/goquery) from 1.9.0 to 1.9.1.
- [Release notes](https://github.com/PuerkitoBio/goquery/releases)
- [Commits](https://github.com/PuerkitoBio/goquery/compare/v1.9.0...v1.9.1)
---
updated-dependencies:
- dependency-name: github.com/PuerkitoBio/goquery
dependency-type: direct:production
update-type: version-update:semver-patch
...
* mod tidy examples
---------
c15af8ce Bump github.com/stretchr/testify from 1.8.4 to 1.9.0 in /_examples (#2955)
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.4 to 1.9.0.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.8.4...v1.9.0)
---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
dependency-type: direct:production
update-type: version-update:semver-minor
...
1993b3aa Bump vitest from 1.3.0 to 1.3.1 in /integration (#2946)
Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 1.3.0 to 1.3.1.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v1.3.1/packages/vitest)
---
updated-dependencies:
- dependency-name: vitest
dependency-type: direct:development
update-type: version-update:semver-patch
...
d16c6adc Bump github.com/PuerkitoBio/goquery from 1.8.1 to 1.9.0 (#2943)
* Bump github.com/PuerkitoBio/goquery from 1.8.1 to 1.9.0
Bumps [github.com/PuerkitoBio/goquery](https://github.com/PuerkitoBio/goquery) from 1.8.1 to 1.9.0.
- [Release notes](https://github.com/PuerkitoBio/goquery/releases)
- [Commits](https://github.com/PuerkitoBio/goquery/compare/v1.8.1...v1.9.0)
---
updated-dependencies:
- dependency-name: github.com/PuerkitoBio/goquery
dependency-type: direct:production
update-type: version-update:semver-minor
...
* Tidy examples
---------
be74b6a0 Bump [@graphql](https://github.com/graphql)-codegen/client-preset from 4.2.2 to 4.2.4 in /integration (#2945)
- [Release notes](https://github.com/dotansimha/graphql-code-generator/releases)
- [Changelog](https://github.com/dotansimha/graphql-code-generator/blob/master/packages/presets/client/CHANGELOG.md)
---
updated-dependencies:
dependency-type: direct:development
update-type: version-update:semver-patch
...
90aa9243 Bump [@graphql](https://github.com/graphql)-codegen/introspection from 4.0.2 to 4.0.3 in /integration (#2944)
- [Release notes](https://github.com/dotansimha/graphql-code-generator/releases)
- [Changelog](https://github.com/dotansimha/graphql-code-generator/blob/master/packages/plugins/other/introspection/CHANGELOG.md)
---
updated-dependencies:
dependency-type: direct:development
update-type: version-update:semver-patch
...
137ddbd3 Bump vite from 5.1.3 to 5.1.4 in /integration (#2947)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.1.3 to 5.1.4.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.1.4/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-type: direct:development
update-type: version-update:semver-patch
...
15cef76f Optionally render entity requires populator function for advanced [@requires](https://github.com/requires) use cases (#2884) (closes #1)
* Adding generation of new functions to populate requires representations. WIP.
* Something.
* Adding config option for Package to allow for enabling flags. Added flag to render explicit requires function.
* Adding explicit requires testsing and make requires follow federation package.
* Fix test failure.
* Using embeded template like federation gotpl. Fix rewriter not using correct dir.
* Update generated code.
* Adding initial docs for explicit requires
* Add example docs for explicit requires
* Adding ordering fix.
* Regenerate.
---------
e186813e Bump golang.org/x/tools from 0.17.0 to 0.18.0 (#2940)
* Bump golang.org/x/tools from 0.17.0 to 0.18.0
Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.17.0 to 0.18.0.
- [Release notes](https://github.com/golang/tools/releases)
- [Commits](https://github.com/golang/tools/compare/v0.17.0...v0.18.0)
---
updated-dependencies:
- dependency-name: golang.org/x/tools
dependency-type: direct:production
update-type: version-update:semver-minor
...
* Update example module
---------
e1fb6c03 Bump vite from 5.1.1 to 5.1.3 in /integration (#2936)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.1.1 to 5.1.3.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.1.3/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-type: direct:development
update-type: version-update:semver-patch
...
1ff1107e Bump graphql-ws from 5.14.3 to 5.15.0 in /integration (#2935)
Bumps [graphql-ws](https://github.com/enisdenjo/graphql-ws) from 5.14.3 to 5.15.0.
- [Release notes](https://github.com/enisdenjo/graphql-ws/releases)
- [Changelog](https://github.com/enisdenjo/graphql-ws/blob/master/CHANGELOG.md)
- [Commits](https://github.com/enisdenjo/graphql-ws/compare/v5.14.3...v5.15.0)
---
updated-dependencies:
- dependency-name: graphql-ws
dependency-type: direct:development
update-type: version-update:semver-minor
...
d4696f88 Bump vitest from 1.2.2 to 1.3.0 in /integration (#2937)
Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 1.2.2 to 1.3.0.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v1.3.0/packages/vitest)
---
updated-dependencies:
- dependency-name: vitest
dependency-type: direct:development
update-type: version-update:semver-minor
...
4808f0db Bump [@apollo](https://github.com/apollo)/client from 3.9.4 to 3.9.5 in /integration (#2938)
- [Release notes](https://github.com/apollographql/apollo-client/releases)
- [Changelog](https://github.com/apollographql/apollo-client/blob/main/CHANGELOG.md)
- [Commits](https://github.com/apollographql/apollo-client/compare/v3.9.4...v3.9.5)
---
updated-dependencies:
dependency-type: direct:development
update-type: version-update:semver-patch
...
a96e3395 Bump github.com/matryer/moq from 0.3.3 to 0.3.4 (#2939)
Bumps [github.com/matryer/moq](https://github.com/matryer/moq) from 0.3.3 to 0.3.4.
- [Release notes](https://github.com/matryer/moq/releases)
- [Changelog](https://github.com/matryer/moq/blob/main/.goreleaser.yml)
- [Commits](https://github.com/matryer/moq/compare/v0.3.3...v0.3.4)
---
updated-dependencies:
- dependency-name: github.com/matryer/moq
dependency-type: direct:production
update-type: version-update:semver-patch
...
e85ce95b Bump react-dom from 16.14.0 to 18.2.0 in /_examples/chat (#2930)
Bumps [react-dom](https://github.com/facebook/react/tree/HEAD/packages/react-dom) from 16.14.0 to 18.2.0.
- [Release notes](https://github.com/facebook/react/releases)
- [Changelog](https://github.com/facebook/react/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/react/commits/v18.2.0/packages/react-dom)
---
updated-dependencies:
- dependency-name: react-dom
dependency-type: direct:production
update-type: version-update:semver-major
...
c88cf024 Bump github.com/sosodev/duration from 1.1.0 to 1.2.0 (#2927)
* Bump github.com/sosodev/duration from 1.1.0 to 1.2.0
Bumps [github.com/sosodev/duration](https://github.com/sosodev/duration) from 1.1.0 to 1.2.0.
- [Release notes](https://github.com/sosodev/duration/releases)
- [Commits](https://github.com/sosodev/duration/compare/v1.1.0...v1.2.0)
---
updated-dependencies:
- dependency-name: github.com/sosodev/duration
dependency-type: direct:production
update-type: version-update:semver-minor
...
* Tidy example go mod
---------
848fd835 Bump [@graphql](https://github.com/graphql)-codegen/cli from 4.0.1 to 5.0.2 in /integration (#2932)
- [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-type: direct:development
update-type: version-update:semver-major
...
900040c4 Bump vite from 4.5.2 to 5.1.1 in /integration (#2931)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 4.5.2 to 5.1.1.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.1.1/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-type: direct:development
update-type: version-update:semver-major
...
e329cf83 Bump react from 16.14.0 to 18.2.0 in /_examples/chat (#2929)
Bumps [react](https://github.com/facebook/react/tree/HEAD/packages/react) from 16.14.0 to 18.2.0.
- [Release notes](https://github.com/facebook/react/releases)
- [Changelog](https://github.com/facebook/react/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/react/commits/v18.2.0/packages/react)
---
updated-dependencies:
- dependency-name: react
dependency-type: direct:production
update-type: version-update:semver-major
...
9faad588 Bump google.golang.org/protobuf from 1.30.0 to 1.32.0 (#2926)
Bumps google.golang.org/protobuf from 1.30.0 to 1.32.0.
---
updated-dependencies:
- dependency-name: google.golang.org/protobuf
dependency-type: direct:production
update-type: version-update:semver-minor
...
92b3871b Bump github.com/stretchr/testify from 1.8.2 to 1.8.4 (#2925)
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.2 to 1.8.4.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.8.2...v1.8.4)
---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
dependency-type: direct:production
update-type: version-update:semver-patch
...
3f5e1f28 Bump github.com/google/uuid from 1.3.0 to 1.6.0 (#2924)
Bumps [github.com/google/uuid](https://github.com/google/uuid) from 1.3.0 to 1.6.0.
- [Release notes](https://github.com/google/uuid/releases)
- [Changelog](https://github.com/google/uuid/blob/master/CHANGELOG.md)
- [Commits](https://github.com/google/uuid/compare/v1.3.0...v1.6.0)
---
updated-dependencies:
- dependency-name: github.com/google/uuid
dependency-type: direct:production
update-type: version-update:semver-minor
...
fd97abcd Bump golangci/golangci-lint-action from 3.7.0 to 4.0.0 (#2928)
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3.7.0 to 4.0.0.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v3.7.0...v4.0.0)
---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
dependency-type: direct:production
update-type: version-update:semver-major
...
64d0f07c graphql/uint: Fix unmarshalling of negative numbers (#2922)
Converting a negative number to uint directly returns a really big number. For
example,
v := -5
fmt.Println(uint(v)) // 18446744073709551611
So we should handle this cases explicitly and return an error.
e223f1d2 Bump node-fetch from 2.7.0 to 3.3.2 in /_examples/federation (#2916)
* Bump node-fetch from 2.7.0 to 3.3.2 in /_examples/federation
Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.7.0 to 3.3.2.
- [Release notes](https://github.com/node-fetch/node-fetch/releases)
- [Commits](https://github.com/node-fetch/node-fetch/compare/v2.7.0...v3.3.2)
---
updated-dependencies:
- dependency-name: node-fetch
dependency-type: direct:development
update-type: version-update:semver-major
...
* Try updating require to import
* Try updating Apollo server and gateway
* Change versions of everything in npm
* Rever to node 16
* Switch to apollo Link
* Use more better newer thingy
* Change federation node version back to 16
* Apollo Link uses uri now instead of link
* Change inmemory cache import
* Remove node fetch from integration test
* Add cross fetch
* Adjust cross fetch to dev dependency
* Fixup package-lock
* Try again
* Switch to node 18 to get fetch
* Add type module to package.json
* export default
* Re-order?
* Add external
* add experimental vm modules to jest
* Update git ignore for node_modules
* Add some more jest stuff
* refmt and regenerate
* Add rehackt to dev dependencies
* Change to core import
* Aaaand do it over here too
* Some of each
* Move to different HTTP Link
* Try again
* add gql from apollo core
* Change link to uri
* Try just passing a string
---------
9a3694e5 Bump github.com/hashicorp/golang-lru/v2 from 2.0.3 to 2.0.7 (#2915)
* Bump github.com/hashicorp/golang-lru/v2 from 2.0.3 to 2.0.7
Bumps [github.com/hashicorp/golang-lru/v2](https://github.com/hashicorp/golang-lru) from 2.0.3 to 2.0.7.
- [Release notes](https://github.com/hashicorp/golang-lru/releases)
- [Commits](https://github.com/hashicorp/golang-lru/compare/v2.0.3...v2.0.7)
---
updated-dependencies:
- dependency-name: github.com/hashicorp/golang-lru/v2
dependency-type: direct:production
update-type: version-update:semver-patch
...
* mod tidy for examples
---------
4b7eec41 Bump urql from 4.0.4 to 4.0.6 in /integration (#2906)
Bumps [urql](https://github.com/urql-graphql/urql/tree/HEAD/packages/react-urql) from 4.0.4 to 4.0.6.
- [Release notes](https://github.com/urql-graphql/urql/releases)
- [Changelog](https://github.com/urql-graphql/urql/blob/main/packages/react-urql/CHANGELOG.md)
---
updated-dependencies:
- dependency-name: urql
dependency-type: direct:development
update-type: version-update:semver-patch
...
8874254a Bump github.com/mattn/go-isatty from 0.0.19 to 0.0.20 (#2908)
* Bump github.com/mattn/go-isatty from 0.0.19 to 0.0.20
Bumps [github.com/mattn/go-isatty](https://github.com/mattn/go-isatty) from 0.0.19 to 0.0.20.
- [Commits](https://github.com/mattn/go-isatty/compare/v0.0.19...v0.0.20)
---
updated-dependencies:
- dependency-name: github.com/mattn/go-isatty
dependency-type: direct:production
update-type: version-update:semver-patch
...
* Go mod tidy
---------
9a6b5655 Bump [@graphql](https://github.com/graphql)-codegen/schema-ast from 4.0.0 to 4.0.2 in /integration (#2918)
- [Release notes](https://github.com/dotansimha/graphql-code-generator/releases)
- [Changelog](https://github.com/dotansimha/graphql-code-generator/blob/master/packages/plugins/other/schema-ast/CHANGELOG.md)
---
updated-dependencies:
dependency-type: direct:development
update-type: version-update:semver-patch
...
76c02143 Bump typescript from 5.1.3 to 5.3.3 in /integration (#2921)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.1.3 to 5.3.3.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v5.1.3...v5.3.3)
---
updated-dependencies:
- dependency-name: typescript
dependency-type: direct:development
update-type: version-update:semver-minor
...
dca5109c Bump jest from 25.5.4 to 29.7.0 in /_examples/federation (#2920)
Bumps [jest](https://github.com/jestjs/jest/tree/HEAD/packages/jest) from 25.5.4 to 29.7.0.
- [Release notes](https://github.com/jestjs/jest/releases)
- [Changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jestjs/jest/commits/v29.7.0/packages/jest)
---
updated-dependencies:
- dependency-name: jest
dependency-type: direct:development
update-type: version-update:semver-major
...
4d77a4f0 Bump graphql from 14.7.0 to 16.8.1 in /_examples/chat (#2899)
Bumps [graphql](https://github.com/graphql/graphql-js) from 14.7.0 to 16.8.1.
- [Release notes](https://github.com/graphql/graphql-js/releases)
- [Commits](https://github.com/graphql/graphql-js/compare/v14.7.0...v16.8.1)
---
updated-dependencies:
- dependency-name: graphql
dependency-type: direct:production
update-type: version-update:semver-major
...
76f1a55b Bump github.com/rs/cors from 1.9.0 to 1.10.1 in /_examples (#2904)
Bumps [github.com/rs/cors](https://github.com/rs/cors) from 1.9.0 to 1.10.1.
- [Release notes](https://github.com/rs/cors/releases)
- [Commits](https://github.com/rs/cors/compare/v1.9.0...v1.10.1)
---
updated-dependencies:
- dependency-name: github.com/rs/cors
dependency-type: direct:production
update-type: version-update:semver-minor
...
bfa9ed8b Bump github.com/google/uuid from 1.3.0 to 1.6.0 in /_examples (#2909)
Bumps [github.com/google/uuid](https://github.com/google/uuid) from 1.3.0 to 1.6.0.
- [Release notes](https://github.com/google/uuid/releases)
- [Changelog](https://github.com/google/uuid/blob/master/CHANGELOG.md)
- [Commits](https://github.com/google/uuid/compare/v1.3.0...v1.6.0)
---
updated-dependencies:
- dependency-name: github.com/google/uuid
dependency-type: direct:production
update-type: version-update:semver-minor
...
524fdf78 Bump subscriptions-transport-ws from 0.9.19 to 0.11.0 in /_examples/chat (#2911)
Bumps [subscriptions-transport-ws](https://github.com/apollostack/subscriptions-transport-ws) from 0.9.19 to 0.11.0.
- [Release notes](https://github.com/apollostack/subscriptions-transport-ws/releases)
- [Changelog](https://github.com/apollographql/subscriptions-transport-ws/blob/master/CHANGELOG.md)
- [Commits](https://github.com/apollostack/subscriptions-transport-ws/compare/v0.9.19...v0.11.0)
---
updated-dependencies:
- dependency-name: subscriptions-transport-ws
dependency-type: direct:production
update-type: version-update:semver-minor
...
ed5f0bc2 Bump github.com/urfave/cli/v2 from 2.25.5 to 2.27.1 (#2912)
Bumps [github.com/urfave/cli/v2](https://github.com/urfave/cli) from 2.25.5 to 2.27.1.
- [Release notes](https://github.com/urfave/cli/releases)
- [Changelog](https://github.com/urfave/cli/blob/main/docs/CHANGELOG.md)
- [Commits](https://github.com/urfave/cli/compare/v2.25.5...v2.27.1)
---
updated-dependencies:
- dependency-name: github.com/urfave/cli/v2
dependency-type: direct:production
update-type: version-update:semver-minor
...
5346a37c Bump react-scripts from 2.1.8 to 5.0.1 in /_examples/chat (#2914)
Bumps [react-scripts](https://github.com/facebook/create-react-app/tree/HEAD/packages/react-scripts) from 2.1.8 to 5.0.1.
- [Release notes](https://github.com/facebook/create-react-app/releases)
- [Changelog](https://github.com/facebook/create-react-app/blob/main/CHANGELOG-2.x.md)
---
updated-dependencies:
- dependency-name: react-scripts
dependency-type: direct:production
update-type: version-update:semver-major
...
8f8c38db Bump typescript from 4.9.5 to 5.3.3 in /_examples/chat (#2917)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.9.5 to 5.3.3.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.9.5...v5.3.3)
---
updated-dependencies:
- dependency-name: typescript
dependency-type: direct:production
update-type: version-update:semver-major
...
6d847969 Bump graphql-sse from 2.1.4 to 2.5.2 in /integration (#2913)
Bumps [graphql-sse](https://github.com/enisdenjo/graphql-sse) from 2.1.4 to 2.5.2.
- [Release notes](https://github.com/enisdenjo/graphql-sse/releases)
- [Changelog](https://github.com/enisdenjo/graphql-sse/blob/master/CHANGELOG.md)
- [Commits](https://github.com/enisdenjo/graphql-sse/compare/v2.1.4...v2.5.2)
---
updated-dependencies:
- dependency-name: graphql-sse
dependency-type: direct:development
update-type: version-update:semver-minor
...
14e321ad Bump styled-components from 5.3.11 to 6.1.8 in /_examples/chat (#2905)
Bumps [styled-components](https://github.com/styled-components/styled-components) from 5.3.11 to 6.1.8.
- [Release notes](https://github.com/styled-components/styled-components/releases)
- [Commits](https://github.com/styled-components/styled-components/compare/v5.3.11...v6.1.8)
---
updated-dependencies:
- dependency-name: styled-components
dependency-type: direct:production
update-type: version-update:semver-major
...
76312bc6 Bump vitest from 0.32.0 to 1.2.2 in /integration (#2919)
Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 0.32.0 to 1.2.2.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v1.2.2/packages/vitest)
---
updated-dependencies:
- dependency-name: vitest
dependency-type: direct:development
update-type: version-update:semver-major
...
7b67b2e4 Bump github.com/matryer/moq from 0.2.7 to 0.3.3 (#2902)
Bumps [github.com/matryer/moq](https://github.com/matryer/moq) from 0.2.7 to 0.3.3.
- [Release notes](https://github.com/matryer/moq/releases)
- [Changelog](https://github.com/matryer/moq/blob/main/.goreleaser.yml)
- [Commits](https://github.com/matryer/moq/compare/v0.2.7...v0.3.3)
---
updated-dependencies:
- dependency-name: github.com/matryer/moq
dependency-type: direct:production
update-type: version-update:semver-minor
...
96c064c4 Bump github.com/gorilla/websocket from 1.5.0 to 1.5.1 in /_examples (#2901)
Bumps [github.com/gorilla/websocket](https://github.com/gorilla/websocket) from 1.5.0 to 1.5.1.
- [Release notes](https://github.com/gorilla/websocket/releases)
- [Commits](https://github.com/gorilla/websocket/compare/v1.5.0...v1.5.1)
---
updated-dependencies:
- dependency-name: github.com/gorilla/websocket
dependency-type: direct:production
update-type: version-update:semver-patch
...
8719860b Bump github.com/stretchr/testify from 1.8.2 to 1.8.4 in /_examples (#2897)
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.2 to 1.8.4.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.8.2...v1.8.4)
---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
dependency-type: direct:production
update-type: version-update:semver-patch
...
6d3c5a82 Bump golangci/golangci-lint-action from 3.5.0 to 3.7.0 (#2896)
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3.5.0 to 3.7.0.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v3.5.0...v3.7.0)
---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
dependency-type: direct:production
update-type: version-update:semver-minor
...
ad4d7f25 Bump nick-fields/retry from 2 to 3 (#2907)
Bumps [nick-fields/retry](https://github.com/nick-fields/retry) from 2 to 3.
- [Release notes](https://github.com/nick-fields/retry/releases)
- [Changelog](https://github.com/nick-fields/retry/blob/master/.releaserc.js)
- [Commits](https://github.com/nick-fields/retry/compare/v2...v3)
---
updated-dependencies:
- dependency-name: nick-fields/retry
dependency-type: direct:production
update-type: version-update:semver-major
...
912cc8da Bump actions/setup-node from 3 to 4 (#2910)
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 3 to 4.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v3...v4)
---
updated-dependencies:
- dependency-name: actions/setup-node
dependency-type: direct:production
update-type: version-update:semver-major
...
2f3d96ab Bump actions/checkout from 3 to 4 (#2903)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)
---
updated-dependencies:
- dependency-name: actions/checkout
dependency-type: direct:production
update-type: version-update:semver-major
...
34f8d084 Bump actions/setup-go from 3 to 5 (#2900)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 3 to 5.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v3...v5)
---
updated-dependencies:
- dependency-name: actions/setup-go
dependency-type: direct:production
update-type: version-update:semver-major
...
143edebe Update x/tools and add go v1.21,v1.22 in CI workflows (#2894)
* Update golang.org/x/tools
* Update Go versions to 1.21 and 1.22 in CI workflows
* Run go mod tidy on submodule _examples
* Update to Go 1.20
* go modules on for all checks
* reduce redundant invocations
* add echo to non-sensitive checks
* More comments
* Make submodule go generate chain differently
* Add which cd
* Try to figure out why cd is not in path
* set CWD to examples in go generate instead
* Try export
* Use env in go generate comment
* make go generate comment always successful
* Try shelling out
* Update our github actions, npm, and go modules via dependabot
---------
- e174d59e Work with https://specs.apollo.dev/federation/v2.x (#2891)
4d8b6edb Update federation plugin (#2876)
* update 2.7 impl, add missing 2.6 support
* address feedback
* go fmt
5524a399 Bump vite from 4.3.9 to 4.5.2 in /integration (#2885)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 4.3.9 to 4.5.2.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v4.5.2/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v4.5.2/packages/vite)
---
updated-dependencies:
- dependency-name: vite
dependency-type: direct:development
...
- 41b14fcf v0.17.43 postrelease bump
## [v0.17.43](https://github.com/99designs/gqlgen/compare/v0.17.42...v0.17.43) - 2024-01-18
- 0d5519cf release v0.17.43
- 5779ac21 Update gqlparser to v2.5.11 (#2882)
- f06f58b0 add omitempty config to example gqlgen.yml (#2880)
- 32bdbdd1 Add config option to omit root objects from models (#2878)
5b656891 Fix code generation for federated multi-key, multi-entity types (#2877)
* fix codegen for multi-key, multi-entity type
* adding tests
* updated generated code
---------
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
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
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.
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
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/99designs/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
---------
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
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/99designs/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
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/99designs/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/99designs/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`
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
---------
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
---------
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
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)
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/99designs/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
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/99designs/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
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/99designs/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.
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/99designs/gqlgen/compare/v0.17.25...v0.17.26) - 2023-03-07
- 8ad59302 release v0.17.26
- cac5f0f4 Post release version bump for examples
- 9e9af41a Update Changelog
- a8f647cb v0.17.25 postrelease bump
## [v0.17.25](https://github.com/99designs/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/99designs/gqlgen/compare/v0.17.23...v0.17.24) - 2023-01-23
- 77c63865 release v0.17.24
## [v0.17.23](https://github.com/99designs/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/99designs/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/99designs/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
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/99designs/gqlgen/graphql/introspection.InputValue. need import github.com/99designs/gqlgen/graphql/introspection .
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
...
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/99designs/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/99designs/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
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
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
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
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/99designs/gqlgen/issues/2286
* Update error.go
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/99designs/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
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/99designs/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
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/99designs/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:99designs/gqlgen
- d91080be Update changelog
- 752d2d7e v0.17.7 postrelease bump
## [v0.17.7](https://github.com/99designs/gqlgen/compare/v0.17.6...v0.17.7) - 2022-05-24
- 2b1dff1b release v0.17.7
- b2087f94 Update module dependencies (#2192)
- 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
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/99designs/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.
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.
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
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.
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
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)
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
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/99designs/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 99designs/cleanup-main
Cleanup main
42f32432 Merge pull request #1957 from 99designs/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
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
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/99designs/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/99designs/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/99designs/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/99designs/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.
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
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
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/99designs/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/99designs/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/99designs/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.
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
- 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/99designs/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
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/99designs/gqlgen/example/todo; to add it:
go get github.com/99designs/gqlgen/example/todo
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 99designs/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 99designs/go-1.16
Also test against 1.16
- 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/99designs/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
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 99designs/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 99designs/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 99designs/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 99designs/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 99designs/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 99designs/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 99designs/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 99designs/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 99designs/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
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.
bf2fdf44 Merge pull request #1514 from 99designs/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)
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 99designs/fix-init-1.16
Run go mod tidy after code generation
9a4c80ab Merge pull request #1502 from 99designs/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
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 99designs/sanstale
Remove stale bot
34a442c7 Merge pull request #1399 from 99designs/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
- 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/99designs/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 99designs/error-wrapping
Always wrap user errors
9b948a5f Merge pull request #1316 from skaji/is-resolver
Add IsResolver to FieldContext
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
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 99designs/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/99designs/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/99designs/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 99designs/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 99designs/go-1.14
Target multiple go versions for CI
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
- 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 99designs/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 99designs/named_map_references
Do not use pointers on named map types
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
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/99designs/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.
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
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/99designs/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 99designs/update-upload-docs
Update file upload docs with Apollo client usage
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
b788cce5 Merge pull request #1054 from 99designs/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/99designs/gqlgen/issues/954 was tagged as 'need documentation'
a53ce377 Merge pull request #1051 from 99designs/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/99designs/gqlgen/compare/v0.11.0...v0.11.1) - 2020-02-19
- 11af15a1 release v0.11.1
bc07188c Merge pull request #1038 from 99designs/feat-check-len
check slice length
- 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/99designs/gqlgen/compare/v0.10.2...v0.11.0) - 2020-02-17
- 368597aa release v0.11.0
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 99designs/handle-interfaces-implementing-interfaces
Handle interfaces that implement interfaces
- b7a58a1c Handle interfaces that implement interfaces
ab8d62b6 Merge pull request #1019 from 99designs/remove-source-reprinting
Remove source reprinting
656a07d1 Merge pull request #1016 from 99designs/federation-entity-type
Create a non generated federation _Entity type
- 8850a527 Create a non generated federation _Entity type
1d41c2eb Merge pull request #1012 from 99designs/federation-config
Allow configuring the federation output file location
afa9a150 Merge pull request #1013 from 99designs/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 99designs/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 99designs/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 99designs/fix-chat-example
fix chat example
8ed2ec59 Merge pull request #988 from 99designs/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 99designs/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 99designs/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 99designs/fix-intermittent-test-ka-failure
Fix intermittent websocket ka test failure
- 76035df5 Fix intermittent websocket ka test failure
aa407b1f Merge pull request #979 from 99designs/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 99designs/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)
5106480b Merge pull request #947 from 99designs/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/99designs/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
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`.
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 99designs/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 99designs/gqlparser-1.2.0
Update to gqlparser-1.2.0
0bc3cc86 Merge pull request #875 from 99designs/fix-clientwide-opts
Fix client global options
b43edf5d Merge pull request #874 from 99designs/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 99designs/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 99designs/ws-init-ctx
Allow changing context in websocket init func
034aa627 Merge pull request #871 from 99designs/subscription-middleware
Call middleware and directives for subscriptions
7b41ca3c Merge pull request #872 from 99designs/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 99designs/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 99designs/refactor-test-client
Refactor test client
- 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 99designs/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 99designs/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/99designs/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 99designs/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 99designs/autobinding
Autobind models
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 99designs/fix-globbing-windows
fix globbing on windows
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 99designs/ws-connection-param-check
[websocket] Add a config to reject initial connection
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
f3c8406d Merge pull request #710 from 99designs/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 99designs/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 99designs/gomodules-performance
make gqlgen generate 10x faster in some projects
ab961ce0 Merge pull request #705 from 99designs/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 99designs/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
0bd90809 Merge pull request #700 from 99designs/fix-interface-caseing
Fix interface casing
5586ee2c Merge pull request #702 from 99designs/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
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
- 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/99designs/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 99designs/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
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
8ac8a1f8 Merge pull request #635 from 99designs/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 99designs/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 99designs/fix-union-pointers
Fix Having Pointers to Union Types
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 99designs/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 99designs/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
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 99designs/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/99designs/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
737a59a3 Merge pull request #579 from 99designs/fix-camelcase
Take care about commonInitialisms in ToGo
- 52838cca fix ci
- 2c3783f1 some refactoring
- eb453674 address comment
- dcd208d9 Merge pull request #584 from 99designs/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
56163b45 Merge pull request #553 from 99designs/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 99designs/improved-collect-fields-api
Improved Collect Fields API and Documentation
6439f197 Merge pull request #552 from 99designs/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 99designs/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 99designs/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 99designs/check-is-zero
Automatically convert IsZero to null
03a655dc Merge pull request #526 from 99designs/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 99designs/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
48a7e07f Merge pull request #537 from 99designs/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 99designs/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 99designs/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/99designs/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/99designs/gqlgen/issues/519
== Notes:
- Add checks for JSON Content-Type checks in decode bad queries tests
a7c8abe6 Merge pull request #529 from 99designs/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 99designs/stop-grc-panic
Stop GetResolverContext from panicking when missing
78cfff48 Merge pull request #528 from 99designs/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 99designs/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 99designs/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 99designs/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 99designs/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 99designs/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 99designs/performance-improvments
Performance improvments
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/99designs/gqlgen/example/starwars
BenchmarkSimpleQueryNoArgs-8 200000 32125 ns/op 6277 B/op 118 allocs/op
PASS
ok github.com/99designs/gqlgen/example/starwars 9.768s
2cf5a5b8 Add a benchmark
go test -benchtime=5s -bench=. -benchmem
goos: linux
goarch: amd64
pkg: github.com/99designs/gqlgen/example/starwars
BenchmarkSimpleQueryNoArgs-8 200000 32680 ns/op 6357 B/op 126 allocs/op
PASS
ok github.com/99designs/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/99designs/gqlgen/compare/v0.7.1...v0.7.2) - 2019-02-05
- da1e07f5 release v0.7.2
8c0562c1 Merge pull request #530 from 99designs/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.
3a7f37c7 Merge pull request #455 from 99designs/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/99designs/gqlgen/compare/v0.6.0...v0.7.0) - 2018-11-28
- a81fe503 release v0.7.0
4bfc82d7 Merge pull request #453 from 99designs/deprecate-binary
Add Deprecation Warning to Binary
8dd29b85 Merge pull request #454 from 99designs/update-gqlparser
Update gqlparser to latest
d6d9885f Merge pull request #416 from 99designs/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 99designs/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 99designs/increase-float-precision
Increase float precision
c5589792 Merge pull request #450 from 99designs/import-refactor
Refactor import handling
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 99designs/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
9f4afe3a Merge pull request #425 from 99designs/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 99designs/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 99designs/feat-geterrors
add GetErrors to RequestContext
53f33f77 Merge pull request #410 from 99designs/move-tracing-to-contrib
Move tracing to contrib
- 19403832 add GetErrors to RequestContext
- f0dbce5a Move tracing to contrib
a3a92775 Merge pull request #409 from 99designs/graphql-playground-1.7.8
Bump to the latest version of graphql-playground
d2648580 Merge pull request #402 from 99designs/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 99designs/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 99designs/feat-apollo-tracing
add apollo-tracing support
1b17b5a2 Merge pull request #392 from 99designs/feat-tracer
Add Tracer layer
184e48cb Merge pull request #396 from 99designs/remove-ci-exclusion
Run generate ./... and test ./... in circle
fd5d9eca Merge pull request #395 from 99designs/feat-extension-example
add Type System Extension syntax example
- 686c71a4 Run generate ./... and test ./... in circle
- 304d3495 fix https://github.com/99designs/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 99designs/multiple-schemas
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/99designs/gqlgen/compare/v0.5.1...v0.6.0) - 2018-10-03
- 6f486bde release v0.6.0
7833d0cb Merge pull request #365 from 99designs/dont-guess-imports
Don't let goimports guess import paths
bc35d730 Merge pull request #335 from 99designs/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.
- 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 99designs/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/99designs/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 99designs/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
- 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/99designs/gqlgen/compare/v0.4.4...v0.5.0) - 2018-08-31
- 5bc4665f release v0.5.0
b48c6b92 Merge pull request #326 from 99designs/version
Add version const
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:99designs/gqlgen into tags
- 56768d6b adds tests for findField
- 556b93ac Run go generate ./...
2dcb2dd8 Merge pull request #314 from 99designs/directive-obj
Add obj to Directives
- 0e2aaa9e Merge branch 'master' of github.com:99designs/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 99designs/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 99designs/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 99designs/validate-gopath
Validate gopath when running gqlgen
77e69552 Merge pull request #310 from 99designs/sitemap-404s
Remove 404s from sitemap
0b6cedfb Merge pull request #311 from jekaspekas/fix-mapstructure-err
fix mapstructure unit test error
4a6f505d Merge pull request #309 from 99designs/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 99designs/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 99designs/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 99designs/fix-starwars-connection-example
fix connection example
- d6acec16 fix connection example
- 7d1cdaca Nulls in required fields should cause errors and bubble
bf235296 Merge pull request #282 from 99designs/flakey-tests
Remove sleeps in tests
- e9c68f08 make appveyor less flakey
## [0.4.2](https://github.com/99designs/gqlgen/compare/0.4.1...0.4.2) - 2018-08-10
- 06b00d45 Update README.md
5c379a33 Merge pull request #279 from 99designs/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 99designs/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 99designs/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 99designs/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 99designs/init-improvements
Init Config Improvement
336b62ec Merge pull request #266 from 99designs/lint-friendly-decollision
Make keyword decollision more lint friendly
- 2acbc245 Make keyword decollision more lint friendly
f12f08a7 Merge pull request #264 from 99designs/docs
CORS docs
0ab1c685 Merge pull request #263 from 99designs/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/99designs/gqlgen/compare/0.4.0...0.4.1) - 2018-08-04
42f10ec9 Merge pull request #255 from 99designs/introspection-fixes
Fix introspection api
- 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.
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.
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/99designs-announcement
Announcement: 99designs is now sponsoring gqlgen
c2f1570d Merge pull request #204 from vektah/gqlparser-prelude
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
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/99designs/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/99designs/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
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/99designs/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.
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/99designs/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
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
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
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
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
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
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
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.
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
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.
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.
- 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
================================================
FILE: CONTRIBUTING.md
================================================
# 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/99designs/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/99designs/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.
================================================
FILE: LICENSE
================================================
Copyright (c) 2025 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.
================================================
FILE: README.md
================================================

# gqlgen [](https://github.com/99designs/gqlgen/actions) [](https://coveralls.io/github/99designs/gqlgen?branch=master) [](https://goreportcard.com/report/github.com/99designs/gqlgen) [](https://pkg.go.dev/github.com/99designs/gqlgen) [](http://gqlgen.com/)
## What is gqlgen?
[gqlgen](https://github.com/99designs/gqlgen) is a Go library for building GraphQL servers without any fuss.
- **gqlgen is based on a Schema first approach** — You get to Define your API using the GraphQL [Schema Definition Language](http://graphql.org/learn/schema/).
- **gqlgen prioritizes Type safety** — You should never see `map[string]interface{}` here.
- **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)
```shell
mkdir example
cd example
go mod init example
```
2. Add `github.com/99designs/gqlgen` to your project, as a [tool dependency](https://go.dev/doc/modules/managing-dependencies#tools)
```shell
go get -tool github.com/99designs/gqlgen
```
3. Initialise gqlgen config and generate models
```shell
go tool gqlgen init
```
4. Start the graphql server
```shell
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/99designs/gqlgen/tree/master/_examples) show how to create GraphQL applications
- [Reference docs](https://pkg.go.dev/github.com/99designs/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/99designs/gqlgen/issues) on GitHub.
## Contributing
We welcome contributions, Read our [Contribution Guidelines](https://github.com/99designs/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
type: String
autoBindGetterHaser: Boolean
forceGenerate: Boolean
batch: 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)
# When omit_resolver_fields is enabled, this field will still be generated in the struct
data: String! @goField(forceResolver: true, forceGenerate: true)
}
```
The field resolvers will be executed concurrently in separate goroutines. The degree of concurrency can be customized with the [`worker_limit` configuration attribute](https://gqlgen.com/config/).
### 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/99designs/gqlgen/graphql.IntID # a go integer
- github.com/99designs/gqlgen/graphql.ID # or a go string
- github.com/99designs/gqlgen/graphql.UintID # or a go uint
```
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://99designs.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/)
================================================
FILE: RELEASE-CHECKLIST.md
================================================
# 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/99designs/gqlgen/blob/master/bin/release:
```
./bin/release $NEW_VERSION
```
2. git-chglog -o CHANGELOG.md
3. go generate ./...
4. git commit and push the CHANGELOG.md
5. Go to https://github.com/99designs/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.
================================================
FILE: TESTING.md
================================================
How to write tests for gqlgen
===
Testing generated code is a little tricky, here's 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.
================================================
FILE: _examples/batchresolver/batchresolver_test.go
================================================
package batchresolver
import (
"encoding/json"
"fmt"
"sort"
"testing"
"github.com/stretchr/testify/require"
"github.com/99designs/gqlgen/client"
"github.com/99designs/gqlgen/codegen/config"
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/handler/transport"
)
type gqlError struct {
Message string `json:"message"`
Path []any `json:"path"`
}
func newTestClient(r *Resolver) *client.Client {
srv := handler.New(NewExecutableSchema(Config{Resolvers: r}))
srv.AddTransport(transport.POST{})
return client.New(srv)
}
func marshalJSON(t *testing.T, v any) string {
t.Helper()
blob, err := json.Marshal(v)
require.NoError(t, err)
return string(blob)
}
func requireErrorJSON(t *testing.T, err error, expected string) {
t.Helper()
require.Error(t, err)
actual := normalizeErrorJSON(t, err.Error())
expectedNorm := normalizeErrorJSON(t, expected)
require.Equal(t, expectedNorm, actual)
}
func normalizeErrorJSON(t *testing.T, jsonStr string) string {
t.Helper()
if jsonStr == "" {
return ""
}
var list []gqlError
require.NoError(t, json.Unmarshal([]byte(jsonStr), &list))
sort.Slice(list, func(i, j int) bool {
return errorKey(t, list[i]) < errorKey(t, list[j])
})
blob, err := json.Marshal(list)
require.NoError(t, err)
return string(blob)
}
func errorKey(t *testing.T, err gqlError) string {
t.Helper()
blob, marshalErr := json.Marshal(err.Path)
require.NoError(t, marshalErr)
return err.Message + "|" + string(blob)
}
func TestBatchResolver_Parity_NoError(t *testing.T) {
resolver := &Resolver{
users: []*User{{}, {}},
profiles: []*Profile{{ID: "p1"}, {ID: "p2"}},
profileErrIdx: -1,
}
c := newTestClient(resolver)
var resp struct {
Users []struct {
NullableBatch *struct {
ID string `json:"id"`
} `json:"nullableBatch"`
NullableNonBatch *struct {
ID string `json:"id"`
} `json:"nullableNonBatch"`
} `json:"users"`
}
err := c.Post(`query { users { nullableBatch { id } nullableNonBatch { id } } }`, &resp)
require.NoError(t, err)
require.JSONEq(
t,
`{"users":[{"nullableBatch":{"id":"p1"},"nullableNonBatch":{"id":"p1"}},{"nullableBatch":{"id":"p2"},"nullableNonBatch":{"id":"p2"}}]}`,
marshalJSON(t, resp),
)
}
func TestBatchResolver_Parity_WithArgs(t *testing.T) {
resolver := &Resolver{
users: []*User{{}, {}},
profiles: []*Profile{{ID: "p1"}, {ID: "p2"}, {ID: "p3"}},
profileErrIdx: -1,
}
c := newTestClient(resolver)
var resp struct {
Users []struct {
NullableBatchWithArg *struct {
ID string `json:"id"`
} `json:"nullableBatchWithArg"`
NullableNonBatchWithArg *struct {
ID string `json:"id"`
} `json:"nullableNonBatchWithArg"`
} `json:"users"`
}
err := c.Post(`
query {
users {
nullableBatchWithArg(offset: 1) { id }
nullableNonBatchWithArg(offset: 1) { id }
}
}`, &resp)
require.NoError(t, err)
require.JSONEq(
t,
`{"users":[{"nullableBatchWithArg":{"id":"p2"},"nullableNonBatchWithArg":{"id":"p2"}},{"nullableBatchWithArg":{"id":"p3"},"nullableNonBatchWithArg":{"id":"p3"}}]}`,
marshalJSON(t, resp),
)
}
func TestBatchResolver_Parity_Error(t *testing.T) {
resolver := &Resolver{
users: []*User{{}, {}},
profiles: []*Profile{{ID: "p1"}, {ID: "p2"}},
profileErrIdx: 1,
}
c := newTestClient(resolver)
var resp struct {
Users []struct {
NullableBatch *struct {
ID string `json:"id"`
} `json:"nullableBatch"`
NullableNonBatch *struct {
ID string `json:"id"`
} `json:"nullableNonBatch"`
} `json:"users"`
}
err := c.Post(`query { users { nullableBatch { id } nullableNonBatch { id } } }`, &resp)
requireErrorJSON(t, err, `[
{"message":"profile error at index 1","path":["users",1,"nullableBatch"]},
{"message":"profile error at index 1","path":["users",1,"nullableNonBatch"]}
]`)
require.JSONEq(
t,
`{"users":[{"nullableBatch":{"id":"p1"},"nullableNonBatch":{"id":"p1"}},{"nullableBatch":null,"nullableNonBatch":null}]}`,
marshalJSON(t, resp),
)
}
func TestBatchResolver_Parity_GqlErrorList(t *testing.T) {
resolver := &Resolver{
users: []*User{{}, {}},
profiles: []*Profile{{ID: "p1"}, {ID: "p2"}},
profileErrListIdxs: map[int]struct{}{0: {}},
profileErrIdx: -1,
}
c := newTestClient(resolver)
var resp struct {
Users []struct {
NullableBatch *struct {
ID string `json:"id"`
} `json:"nullableBatch"`
NullableNonBatch *struct {
ID string `json:"id"`
} `json:"nullableNonBatch"`
} `json:"users"`
}
err := c.Post(`query { users { nullableBatch { id } nullableNonBatch { id } } }`, &resp)
requireErrorJSON(t, err, `[
{"message":"profile list error 1 at index 0","path":["users",0,"nullableBatch"]},
{"message":"profile list error 2 at index 0","path":["users",0,"nullableBatch"]},
{"message":"profile list error 1 at index 0","path":["users",0,"nullableNonBatch"]},
{"message":"profile list error 2 at index 0","path":["users",0,"nullableNonBatch"]}
]`)
require.JSONEq(
t,
`{"users":[{"nullableBatch":null,"nullableNonBatch":null},{"nullableBatch":{"id":"p2"},"nullableNonBatch":{"id":"p2"}}]}`,
marshalJSON(t, resp),
)
}
func TestBatchResolver_Parity_GqlErrorPathNil(t *testing.T) {
resolver := &Resolver{
users: []*User{{}, {}},
profiles: []*Profile{{ID: "p1"}, {ID: "p2"}},
profileGqlErrNoPathIdxs: map[int]struct{}{0: {}},
profileErrIdx: -1,
}
c := newTestClient(resolver)
var resp struct {
Users []struct {
NullableBatch *struct {
ID string `json:"id"`
} `json:"nullableBatch"`
NullableNonBatch *struct {
ID string `json:"id"`
} `json:"nullableNonBatch"`
} `json:"users"`
}
err := c.Post(`query { users { nullableBatch { id } nullableNonBatch { id } } }`, &resp)
requireErrorJSON(t, err, `[
{"message":"profile gqlerror path nil at index 0","path":["users",0,"nullableBatch"]},
{"message":"profile gqlerror path nil at index 0","path":["users",0,"nullableNonBatch"]}
]`)
require.JSONEq(
t,
`{"users":[{"nullableBatch":null,"nullableNonBatch":null},{"nullableBatch":{"id":"p2"},"nullableNonBatch":{"id":"p2"}}]}`,
marshalJSON(t, resp),
)
}
func TestBatchResolver_Parity_GqlErrorPathSet(t *testing.T) {
resolver := &Resolver{
users: []*User{{}, {}},
profiles: []*Profile{{ID: "p1"}, {ID: "p2"}},
profileGqlErrPathIdxs: map[int]struct{}{0: {}},
profileErrIdx: -1,
}
c := newTestClient(resolver)
var resp struct {
Users []struct {
NullableBatch *struct {
ID string `json:"id"`
} `json:"nullableBatch"`
NullableNonBatch *struct {
ID string `json:"id"`
} `json:"nullableNonBatch"`
} `json:"users"`
}
err := c.Post(`query { users { nullableBatch { id } nullableNonBatch { id } } }`, &resp)
requireErrorJSON(t, err, `[
{"message":"profile gqlerror path set at index 0","path":["custom",0]},
{"message":"profile gqlerror path set at index 0","path":["custom",0]}
]`)
require.JSONEq(
t,
`{"users":[{"nullableBatch":null,"nullableNonBatch":null},{"nullableBatch":{"id":"p2"},"nullableNonBatch":{"id":"p2"}}]}`,
marshalJSON(t, resp),
)
}
func TestBatchResolver_Parity_PartialResponseWithErrValue(t *testing.T) {
resolver := &Resolver{
users: []*User{{}, {}},
profiles: []*Profile{{ID: "p1"}, {ID: "p2"}},
profileErrWithValueIdxs: map[int]struct{}{0: {}},
profileErrIdx: -1,
}
c := newTestClient(resolver)
var resp struct {
Users []struct {
NullableBatch *struct {
ID string `json:"id"`
} `json:"nullableBatch"`
NullableNonBatch *struct {
ID string `json:"id"`
} `json:"nullableNonBatch"`
} `json:"users"`
}
err := c.Post(`query { users { nullableBatch { id } nullableNonBatch { id } } }`, &resp)
requireErrorJSON(t, err, `[
{"message":"profile error with value at index 0","path":["users",0,"nullableBatch"]},
{"message":"profile error with value at index 0","path":["users",0,"nullableNonBatch"]}
]`)
require.JSONEq(
t,
`{"users":[{"nullableBatch":null,"nullableNonBatch":null},{"nullableBatch":{"id":"p2"},"nullableNonBatch":{"id":"p2"}}]}`,
marshalJSON(t, resp),
)
}
func TestBatchResolver_Parity_NonNullPropagation(t *testing.T) {
resolver := &Resolver{
users: []*User{{}, {}},
profiles: []*Profile{{ID: "p1"}, {ID: "p2"}},
profileErrIdx: 0,
}
c := newTestClient(resolver)
var resp struct {
Users []struct {
NonNullableBatch *struct {
ID string `json:"id"`
} `json:"nonNullableBatch"`
NonNullableNonBatch *struct {
ID string `json:"id"`
} `json:"nonNullableNonBatch"`
} `json:"users"`
}
err := c.Post(`query { users { nonNullableBatch { id } nonNullableNonBatch { id } } }`, &resp)
requireErrorJSON(t, err, `[
{"message":"profile error at index 0","path":["users",0,"nonNullableBatch"]},
{"message":"profile error at index 0","path":["users",0,"nonNullableNonBatch"]}
]`)
require.JSONEq(
t,
`{"users":null}`,
marshalJSON(t, resp),
)
}
func TestBatchResolver_InvalidLen_AddsErrorPerParent(t *testing.T) {
resolver := &Resolver{
users: []*User{{}, {}},
profiles: []*Profile{{ID: "p1"}, {ID: "p2"}},
profileErrIdx: -1,
profileWrongLen: true,
}
c := newTestClient(resolver)
var resp struct {
Users []struct {
NullableBatch *struct {
ID string `json:"id"`
} `json:"nullableBatch"`
} `json:"users"`
}
err := c.Post(`query { users { nullableBatch { id } } }`, &resp)
requireErrorJSON(t, err, `[
{"message":"index 0: batch resolver User.nullableBatch returned 1 results for 2 parents","path":["users",0,"nullableBatch"]},
{"message":"index 1: batch resolver User.nullableBatch returned 1 results for 2 parents","path":["users",1,"nullableBatch"]}
]`)
require.JSONEq(
t,
`{"users":[{"nullableBatch":null},{"nullableBatch":null}]}`,
marshalJSON(t, resp),
)
}
func TestBatchResolver_BatchErrors_ErrLenMismatch_AddsErrorPerParent(t *testing.T) {
cases := []struct {
name string
errLen int
}{
{name: "len1", errLen: 1},
{name: "len0", errLen: 0},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
resolver := &Resolver{
users: []*User{{}, {}},
profiles: []*Profile{{ID: "p1"}, {ID: "p2"}},
profileErrIdx: -1,
batchErrsWrongLen: true,
batchErrsLen: tc.errLen,
}
c := newTestClient(resolver)
var resp struct {
Users []struct {
NullableBatch *struct {
ID string `json:"id"`
} `json:"nullableBatch"`
} `json:"users"`
}
err := c.Post(`query { users { nullableBatch { id } } }`, &resp)
requireErrorJSON(t, err, fmt.Sprintf(`[
{"message":"index 0: batch resolver User.nullableBatch returned %d errors for 2 parents","path":["users",0,"nullableBatch"]},
{"message":"index 1: batch resolver User.nullableBatch returned %d errors for 2 parents","path":["users",1,"nullableBatch"]}
]`, tc.errLen, tc.errLen))
require.JSONEq(
t,
`{"users":[{"nullableBatch":null},{"nullableBatch":null}]}`,
marshalJSON(t, resp),
)
})
}
}
func TestBatchResolver_BatchErrors_ResultLenMismatch_AddsErrorPerParent(t *testing.T) {
resolver := &Resolver{
users: []*User{{}, {}},
profiles: []*Profile{{ID: "p1"}, {ID: "p2"}},
profileErrIdx: -1,
batchResultsWrongLen: true,
batchResultsLen: 1,
}
c := newTestClient(resolver)
var resp struct {
Users []struct {
NullableBatch *struct {
ID string `json:"id"`
} `json:"nullableBatch"`
} `json:"users"`
}
err := c.Post(`query { users { nullableBatch { id } } }`, &resp)
requireErrorJSON(t, err, `[
{"message":"index 0: batch resolver User.nullableBatch returned 1 results for 2 parents","path":["users",0,"nullableBatch"]},
{"message":"index 1: batch resolver User.nullableBatch returned 1 results for 2 parents","path":["users",1,"nullableBatch"]}
]`)
require.JSONEq(
t,
`{"users":[{"nullableBatch":null},{"nullableBatch":null}]}`,
marshalJSON(t, resp),
)
}
func TestBatchDirectiveConfig(t *testing.T) {
cfg, err := config.LoadConfig("gqlgen.yml")
require.NoError(t, err)
require.NoError(t, cfg.Init())
userFields := cfg.Models["User"].Fields
// YAML-configured fields
require.True(t, userFields["nullableBatch"].Batch)
require.True(t, userFields["nullableBatchWithArg"].Batch)
require.True(t, userFields["nonNullableBatch"].Batch)
require.False(t, userFields["nullableNonBatch"].Batch)
require.False(t, userFields["nullableNonBatchWithArg"].Batch)
require.False(t, userFields["nonNullableNonBatch"].Batch)
// Directive-configured fields
require.True(t, userFields["directiveNullableBatch"].Batch)
require.True(t, userFields["directiveNullableBatchWithArg"].Batch)
require.True(t, userFields["directiveNonNullableBatch"].Batch)
require.False(t, userFields["directiveNullableNonBatch"].Batch)
require.False(t, userFields["directiveNullableNonBatchWithArg"].Batch)
require.False(t, userFields["directiveNonNullableNonBatch"].Batch)
}
func TestBatchResolver_BatchErrors_ListPerIndex_AddsMultipleErrors(t *testing.T) {
resolver := &Resolver{
users: []*User{{}, {}},
profiles: []*Profile{{ID: "p1"}, {ID: "p2"}},
profileErrIdx: -1,
batchErrListIdxs: map[int]struct{}{0: {}},
}
c := newTestClient(resolver)
var resp struct {
Users []struct {
NullableBatch *struct {
ID string `json:"id"`
} `json:"nullableBatch"`
} `json:"users"`
}
err := c.Post(`query { users { nullableBatch { id } } }`, &resp)
requireErrorJSON(t, err, `[
{"message":"batch list error 1 at index 0","path":["users",0,"nullableBatch"]},
{"message":"batch list error 2 at index 0","path":["users",0,"nullableBatch"]}
]`)
require.JSONEq(
t,
`{"users":[{"nullableBatch":null},{"nullableBatch":{"id":"p2"}}]}`,
marshalJSON(t, resp),
)
}
func TestBatchResolver_Nested_CallCount(t *testing.T) {
const n = 10
users := make([]*User, n)
profiles := make([]*Profile, n)
images := make([]*Image, n)
for i := 0; i < n; i++ {
users[i] = &User{}
profiles[i] = &Profile{ID: fmt.Sprintf("p%d", i)}
images[i] = &Image{URL: fmt.Sprintf("https://img/%d", i)}
}
resolver := &Resolver{
users: users,
profiles: profiles,
images: images,
profileErrIdx: -1,
}
client := newTestClient(resolver)
type graphqlResp struct {
Users []struct {
Profile *struct {
ID string `json:"id"`
Cover *struct {
URL string `json:"url"`
} `json:"cover"`
} `json:"profile"`
} `json:"users"`
}
assertData := func(t *testing.T, resp graphqlResp, label string) {
t.Helper()
require.Len(t, resp.Users, n)
for i, u := range resp.Users {
require.NotNil(t, u.Profile, "%s user %d profile nil", label, i)
require.Equal(t, fmt.Sprintf("p%d", i), u.Profile.ID)
require.NotNil(t, u.Profile.Cover, "%s user %d cover nil", label, i)
require.Equal(t, fmt.Sprintf("https://img/%d", i), u.Profile.Cover.URL)
}
}
// --- Batch path ---
var batchResp graphqlResp
err := client.Post(`query {
users {
profile: profileBatch {
id
cover: coverBatch {
url
}
}
}
}`, &batchResp)
require.NoError(t, err)
assertData(t, batchResp, "batch")
require.Equal(
t,
int32(1),
resolver.profileBatchCalls.Load(),
"profileBatch should be called once for all users",
)
// TODO: coverBatch is called once per profile (not batched) because profiles
// are resolved as individual values, not as a list. The batch parent context
// for "Profile" is only set when marshalling a [Profile] list field.
// Nested batching should propagate the batch parent context from batch
// resolver results so coverBatchCalls == 1 here.
require.Equal(
t,
int32(n),
resolver.coverBatchCalls.Load(),
"coverBatch called once per profile (no list parent context)",
)
// --- Non-batch path ---
var nonBatchResp graphqlResp
err = client.Post(`query {
users {
profile: profileNonBatch {
id
cover: coverNonBatch {
url
}
}
}
}`, &nonBatchResp)
require.NoError(t, err)
assertData(t, nonBatchResp, "non-batch")
require.Equal(
t,
int32(n),
resolver.profileNonBatchCalls.Load(),
"profileNonBatch should be called once per user",
)
require.Equal(
t,
int32(n),
resolver.coverNonBatchCalls.Load(),
"coverNonBatch should be called once per profile",
)
// --- Verify both paths produce identical data ---
require.Equal(
t,
marshalJSON(t, batchResp),
marshalJSON(t, nonBatchResp),
"batch and non-batch should return identical data",
)
}
func TestBatchResolver_Nested_Connection_CallCount(t *testing.T) {
const n = 10
users := make([]*User, n)
profiles := make([]*Profile, n)
images := make([]*Image, n)
for i := 0; i < n; i++ {
users[i] = &User{}
profiles[i] = &Profile{ID: fmt.Sprintf("p%d", i)}
images[i] = &Image{URL: fmt.Sprintf("https://img/%d", i)}
}
resolver := &Resolver{
users: users,
profiles: profiles,
images: images,
profileErrIdx: -1,
}
client := newTestClient(resolver)
type graphqlResp struct {
Users []struct {
Conn *struct {
Edges []struct {
Node *struct {
ID string `json:"id"`
Cover *struct {
URL string `json:"url"`
} `json:"cover"`
} `json:"node"`
} `json:"edges"`
} `json:"conn"`
} `json:"users"`
}
assertData := func(t *testing.T, resp graphqlResp, label string) {
t.Helper()
require.Len(t, resp.Users, n)
for i, u := range resp.Users {
require.NotNil(t, u.Conn, "%s user %d connection nil", label, i)
require.Len(t, u.Conn.Edges, 1, "%s user %d edges", label, i)
node := u.Conn.Edges[0].Node
require.NotNil(t, node, "%s user %d node nil", label, i)
require.Equal(t, fmt.Sprintf("p%d", i), node.ID)
require.NotNil(t, node.Cover, "%s user %d cover nil", label, i)
require.Equal(t, fmt.Sprintf("https://img/%d", i), node.Cover.URL)
}
}
// --- Batch path ---
var batchResp graphqlResp
err := client.Post(`query {
users {
conn: profileConnectionBatch {
edges {
node {
id
cover: coverBatch { url }
}
}
}
}
}`, &batchResp)
require.NoError(t, err)
assertData(t, batchResp, "batch")
require.Equal(
t,
int32(1),
resolver.profileConnectionBatchCalls.Load(),
"profileConnectionBatch should be called once for all users",
)
// TODO: coverBatch is not batched because the immediate parent (Profile)
// and its edge are not batched — only the connection is. This should be 1
// once nested batching propagates through non-batched intermediate types.
require.Equal(
t,
int32(n),
resolver.coverBatchCalls.Load(),
"coverBatch called once per profile (immediate parent not batched)",
)
// --- Non-batch path ---
var nonBatchResp graphqlResp
err = client.Post(`query {
users {
conn: profileConnectionNonBatch {
edges {
node {
id
cover: coverNonBatch { url }
}
}
}
}
}`, &nonBatchResp)
require.NoError(t, err)
assertData(t, nonBatchResp, "non-batch")
require.Equal(
t,
int32(n),
resolver.profileConnectionNonBatchCalls.Load(),
"profileConnectionNonBatch should be called once per user",
)
require.Equal(
t,
int32(n),
resolver.coverNonBatchCalls.Load(),
"coverNonBatch should be called once per profile",
)
// --- Verify both paths produce identical data ---
require.Equal(
t,
marshalJSON(t, batchResp),
marshalJSON(t, nonBatchResp),
"batch and non-batch should return identical data",
)
}
func BenchmarkBatchResolver_SingleLevel(b *testing.B) {
const n = 100
users := make([]*User, n)
profiles := make([]*Profile, n)
for i := 0; i < n; i++ {
users[i] = &User{}
profiles[i] = &Profile{ID: fmt.Sprintf("p%d", i)}
}
b.Run("batch", func(b *testing.B) {
resolver := &Resolver{
users: users,
profiles: profiles,
profileErrIdx: -1,
}
c := newTestClient(resolver)
var resp json.RawMessage
for b.Loop() {
_ = c.Post(`query { users { nullableBatch { id } } }`, &resp)
}
})
b.Run("non-batch", func(b *testing.B) {
resolver := &Resolver{
users: users,
profiles: profiles,
profileErrIdx: -1,
}
c := newTestClient(resolver)
var resp json.RawMessage
for b.Loop() {
_ = c.Post(`query { users { nullableNonBatch { id } } }`, &resp)
}
})
}
func BenchmarkBatchResolver_Nested(b *testing.B) {
const n = 100
users := make([]*User, n)
profiles := make([]*Profile, n)
images := make([]*Image, n)
for i := 0; i < n; i++ {
users[i] = &User{}
profiles[i] = &Profile{ID: fmt.Sprintf("p%d", i)}
images[i] = &Image{URL: fmt.Sprintf("https://img/%d", i)}
}
b.Run("batch", func(b *testing.B) {
resolver := &Resolver{
users: users,
profiles: profiles,
images: images,
profileErrIdx: -1,
}
c := newTestClient(resolver)
var resp json.RawMessage
for b.Loop() {
_ = c.Post(`query {
users {
profile: profileBatch {
id
cover: coverBatch { url }
}
}
}`, &resp)
}
})
b.Run("non-batch", func(b *testing.B) {
resolver := &Resolver{
users: users,
profiles: profiles,
images: images,
profileErrIdx: -1,
}
c := newTestClient(resolver)
var resp json.RawMessage
for b.Loop() {
_ = c.Post(`query {
users {
profile: profileNonBatch {
id
cover: coverNonBatch { url }
}
}
}`, &resp)
}
})
}
================================================
FILE: _examples/batchresolver/generate.go
================================================
//go:generate go run ../../testdata/gqlgen.go
package batchresolver
================================================
FILE: _examples/batchresolver/generated.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package batchresolver
import (
"bytes"
"context"
"embed"
"errors"
"fmt"
"strconv"
"sync/atomic"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/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{SchemaData: cfg.Schema, Resolvers: cfg.Resolvers, Directives: cfg.Directives, ComplexityRoot: cfg.Complexity}
}
type Config = graphql.Config[ResolverRoot, DirectiveRoot, ComplexityRoot]
type ResolverRoot interface {
Profile() ProfileResolver
Query() QueryResolver
User() UserResolver
}
type DirectiveRoot struct {
}
type ComplexityRoot struct {
Image struct {
URL func(childComplexity int) int
}
Profile struct {
CoverBatch func(childComplexity int) int
CoverNonBatch func(childComplexity int) int
ID func(childComplexity int) int
}
ProfileEdge struct {
Cursor func(childComplexity int) int
Node func(childComplexity int) int
}
ProfilesConnection struct {
Edges func(childComplexity int) int
TotalCount func(childComplexity int) int
}
Query struct {
Users func(childComplexity int) int
}
User struct {
DirectiveNonNullableBatch func(childComplexity int) int
DirectiveNonNullableNonBatch func(childComplexity int) int
DirectiveNullableBatch func(childComplexity int) int
DirectiveNullableBatchWithArg func(childComplexity int, offset int) int
DirectiveNullableNonBatch func(childComplexity int) int
DirectiveNullableNonBatchWithArg func(childComplexity int, offset int) int
NonNullableBatch func(childComplexity int) int
NonNullableNonBatch func(childComplexity int) int
NullableBatch func(childComplexity int) int
NullableBatchWithArg func(childComplexity int, offset int) int
NullableNonBatch func(childComplexity int) int
NullableNonBatchWithArg func(childComplexity int, offset int) int
ProfileBatch func(childComplexity int) int
ProfileConnectionBatch func(childComplexity int) int
ProfileConnectionNonBatch func(childComplexity int) int
ProfileNonBatch func(childComplexity int) int
}
}
type ProfileResolver interface {
CoverBatch(ctx context.Context, objs []*Profile) ([]*Image, error)
CoverNonBatch(ctx context.Context, obj *Profile) (*Image, error)
}
type QueryResolver interface {
Users(ctx context.Context) ([]*User, error)
}
type UserResolver interface {
NullableBatch(ctx context.Context, objs []*User) ([]*Profile, error)
NullableNonBatch(ctx context.Context, obj *User) (*Profile, error)
NullableBatchWithArg(ctx context.Context, objs []*User, offset int) ([]*Profile, error)
NullableNonBatchWithArg(ctx context.Context, obj *User, offset int) (*Profile, error)
NonNullableBatch(ctx context.Context, objs []*User) ([]*Profile, error)
NonNullableNonBatch(ctx context.Context, obj *User) (*Profile, error)
DirectiveNullableBatch(ctx context.Context, objs []*User) ([]*Profile, error)
DirectiveNullableNonBatch(ctx context.Context, obj *User) (*Profile, error)
DirectiveNullableBatchWithArg(ctx context.Context, objs []*User, offset int) ([]*Profile, error)
DirectiveNullableNonBatchWithArg(ctx context.Context, obj *User, offset int) (*Profile, error)
DirectiveNonNullableBatch(ctx context.Context, objs []*User) ([]*Profile, error)
DirectiveNonNullableNonBatch(ctx context.Context, obj *User) (*Profile, error)
ProfileBatch(ctx context.Context, objs []*User) ([]*Profile, error)
ProfileNonBatch(ctx context.Context, obj *User) (*Profile, error)
ProfileConnectionBatch(ctx context.Context, objs []*User) ([]*ProfilesConnection, error)
ProfileConnectionNonBatch(ctx context.Context, obj *User) (*ProfilesConnection, error)
}
type executableSchema graphql.ExecutableSchemaState[ResolverRoot, DirectiveRoot, ComplexityRoot]
func (e *executableSchema) Schema() *ast.Schema {
if e.SchemaData != nil {
return e.SchemaData
}
return parsedSchema
}
func (e *executableSchema) Complexity(ctx context.Context, typeName, field string, childComplexity int, rawArgs map[string]any) (int, bool) {
ec := newExecutionContext(nil, e, nil)
_ = ec
switch typeName + "." + field {
case "Image.url":
if e.ComplexityRoot.Image.URL == nil {
break
}
return e.ComplexityRoot.Image.URL(childComplexity), true
case "Profile.coverBatch":
if e.ComplexityRoot.Profile.CoverBatch == nil {
break
}
return e.ComplexityRoot.Profile.CoverBatch(childComplexity), true
case "Profile.coverNonBatch":
if e.ComplexityRoot.Profile.CoverNonBatch == nil {
break
}
return e.ComplexityRoot.Profile.CoverNonBatch(childComplexity), true
case "Profile.id":
if e.ComplexityRoot.Profile.ID == nil {
break
}
return e.ComplexityRoot.Profile.ID(childComplexity), true
case "ProfileEdge.cursor":
if e.ComplexityRoot.ProfileEdge.Cursor == nil {
break
}
return e.ComplexityRoot.ProfileEdge.Cursor(childComplexity), true
case "ProfileEdge.node":
if e.ComplexityRoot.ProfileEdge.Node == nil {
break
}
return e.ComplexityRoot.ProfileEdge.Node(childComplexity), true
case "ProfilesConnection.edges":
if e.ComplexityRoot.ProfilesConnection.Edges == nil {
break
}
return e.ComplexityRoot.ProfilesConnection.Edges(childComplexity), true
case "ProfilesConnection.totalCount":
if e.ComplexityRoot.ProfilesConnection.TotalCount == nil {
break
}
return e.ComplexityRoot.ProfilesConnection.TotalCount(childComplexity), true
case "Query.users":
if e.ComplexityRoot.Query.Users == nil {
break
}
return e.ComplexityRoot.Query.Users(childComplexity), true
case "User.directiveNonNullableBatch":
if e.ComplexityRoot.User.DirectiveNonNullableBatch == nil {
break
}
return e.ComplexityRoot.User.DirectiveNonNullableBatch(childComplexity), true
case "User.directiveNonNullableNonBatch":
if e.ComplexityRoot.User.DirectiveNonNullableNonBatch == nil {
break
}
return e.ComplexityRoot.User.DirectiveNonNullableNonBatch(childComplexity), true
case "User.directiveNullableBatch":
if e.ComplexityRoot.User.DirectiveNullableBatch == nil {
break
}
return e.ComplexityRoot.User.DirectiveNullableBatch(childComplexity), true
case "User.directiveNullableBatchWithArg":
if e.ComplexityRoot.User.DirectiveNullableBatchWithArg == nil {
break
}
args, err := ec.field_User_directiveNullableBatchWithArg_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.User.DirectiveNullableBatchWithArg(childComplexity, args["offset"].(int)), true
case "User.directiveNullableNonBatch":
if e.ComplexityRoot.User.DirectiveNullableNonBatch == nil {
break
}
return e.ComplexityRoot.User.DirectiveNullableNonBatch(childComplexity), true
case "User.directiveNullableNonBatchWithArg":
if e.ComplexityRoot.User.DirectiveNullableNonBatchWithArg == nil {
break
}
args, err := ec.field_User_directiveNullableNonBatchWithArg_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.User.DirectiveNullableNonBatchWithArg(childComplexity, args["offset"].(int)), true
case "User.nonNullableBatch":
if e.ComplexityRoot.User.NonNullableBatch == nil {
break
}
return e.ComplexityRoot.User.NonNullableBatch(childComplexity), true
case "User.nonNullableNonBatch":
if e.ComplexityRoot.User.NonNullableNonBatch == nil {
break
}
return e.ComplexityRoot.User.NonNullableNonBatch(childComplexity), true
case "User.nullableBatch":
if e.ComplexityRoot.User.NullableBatch == nil {
break
}
return e.ComplexityRoot.User.NullableBatch(childComplexity), true
case "User.nullableBatchWithArg":
if e.ComplexityRoot.User.NullableBatchWithArg == nil {
break
}
args, err := ec.field_User_nullableBatchWithArg_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.User.NullableBatchWithArg(childComplexity, args["offset"].(int)), true
case "User.nullableNonBatch":
if e.ComplexityRoot.User.NullableNonBatch == nil {
break
}
return e.ComplexityRoot.User.NullableNonBatch(childComplexity), true
case "User.nullableNonBatchWithArg":
if e.ComplexityRoot.User.NullableNonBatchWithArg == nil {
break
}
args, err := ec.field_User_nullableNonBatchWithArg_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.User.NullableNonBatchWithArg(childComplexity, args["offset"].(int)), true
case "User.profileBatch":
if e.ComplexityRoot.User.ProfileBatch == nil {
break
}
return e.ComplexityRoot.User.ProfileBatch(childComplexity), true
case "User.profileConnectionBatch":
if e.ComplexityRoot.User.ProfileConnectionBatch == nil {
break
}
return e.ComplexityRoot.User.ProfileConnectionBatch(childComplexity), true
case "User.profileConnectionNonBatch":
if e.ComplexityRoot.User.ProfileConnectionNonBatch == nil {
break
}
return e.ComplexityRoot.User.ProfileConnectionNonBatch(childComplexity), true
case "User.profileNonBatch":
if e.ComplexityRoot.User.ProfileNonBatch == nil {
break
}
return e.ComplexityRoot.User.ProfileNonBatch(childComplexity), true
}
return 0, false
}
func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
opCtx := graphql.GetOperationContext(ctx)
ec := newExecutionContext(opCtx, e, make(chan graphql.DeferredResult))
inputUnmarshalMap := graphql.BuildUnmarshalerMap()
first := true
switch opCtx.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, opCtx.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.ExecutionContextState[ResolverRoot, DirectiveRoot, ComplexityRoot]
}
func newExecutionContext(
opCtx *graphql.OperationContext,
execSchema *executableSchema,
deferredResults chan graphql.DeferredResult,
) executionContext {
return executionContext{
ExecutionContextState: graphql.NewExecutionContextState[ResolverRoot, DirectiveRoot, ComplexityRoot](
opCtx,
(*graphql.ExecutableSchemaState[ResolverRoot, DirectiveRoot, ComplexityRoot])(execSchema),
parsedSchema,
deferredResults,
),
}
}
//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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
if err != nil {
return nil, err
}
args["name"] = arg0
return args, nil
}
func (ec *executionContext) field_User_directiveNullableBatchWithArg_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "offset", ec.unmarshalNInt2int)
if err != nil {
return nil, err
}
args["offset"] = arg0
return args, nil
}
func (ec *executionContext) field_User_directiveNullableNonBatchWithArg_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "offset", ec.unmarshalNInt2int)
if err != nil {
return nil, err
}
args["offset"] = arg0
return args, nil
}
func (ec *executionContext) field_User_nullableBatchWithArg_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "offset", ec.unmarshalNInt2int)
if err != nil {
return nil, err
}
args["offset"] = arg0
return args, nil
}
func (ec *executionContext) field_User_nullableNonBatchWithArg_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "offset", ec.unmarshalNInt2int)
if err != nil {
return nil, err
}
args["offset"] = arg0
return args, nil
}
func (ec *executionContext) field___Directive_args_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2ᚖbool)
if err != nil {
return nil, err
}
args["includeDeprecated"] = arg0
return args, nil
}
func (ec *executionContext) field___Field_args_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2ᚖbool)
if err != nil {
return nil, err
}
args["includeDeprecated"] = arg0
return args, nil
}
func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2bool)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2bool)
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) _Image_url(ctx context.Context, field graphql.CollectedField, obj *Image) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Image_url,
func(ctx context.Context) (any, error) {
return obj.URL, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Image_url(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Image",
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) _Profile_id(ctx context.Context, field graphql.CollectedField, obj *Profile) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Profile_id,
func(ctx context.Context) (any, error) {
return obj.ID, nil
},
nil,
ec.marshalNID2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Profile_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Profile",
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) _Profile_coverBatch(ctx context.Context, field graphql.CollectedField, obj *Profile) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Profile_coverBatch,
func(ctx context.Context) (any, error) {
return ec.resolveBatch_Profile_coverBatch(ctx, field, obj)
},
nil,
ec.marshalOImage2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐImage,
true,
false,
)
}
func (ec *executionContext) fieldContext_Profile_coverBatch(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Profile",
Field: field,
IsMethod: true,
IsResolver: true,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
switch field.Name {
case "url":
return ec.fieldContext_Image_url(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Image", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) resolveBatch_Profile_coverBatch(ctx context.Context, field graphql.CollectedField, obj *Profile) (any, error) {
resolver := ec.Resolvers.Profile()
group := graphql.GetBatchParentGroup(ctx, "Profile")
if group != nil {
parents, ok := group.Parents.([]*Profile)
if ok {
idx, ok := graphql.BatchParentIndex(ctx)
if ok {
key := field.Alias
if key == "" {
key = field.Name
}
result := group.GetFieldResult(key, func() (any, error) {
return resolver.CoverBatch(ctx, parents)
})
return graphql.ResolveBatchGroupResult[*Image](
ctx,
idx,
len(parents),
result,
"Profile.coverBatch",
)
}
}
}
results, err := resolver.CoverBatch(ctx, []*Profile{obj})
return graphql.ResolveBatchSingleResult[*Image](
ctx,
results,
err,
"Profile.coverBatch",
)
}
func (ec *executionContext) _Profile_coverNonBatch(ctx context.Context, field graphql.CollectedField, obj *Profile) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Profile_coverNonBatch,
func(ctx context.Context) (any, error) {
return ec.Resolvers.Profile().CoverNonBatch(ctx, obj)
},
nil,
ec.marshalOImage2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐImage,
true,
false,
)
}
func (ec *executionContext) fieldContext_Profile_coverNonBatch(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Profile",
Field: field,
IsMethod: true,
IsResolver: true,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
switch field.Name {
case "url":
return ec.fieldContext_Image_url(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Image", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) _ProfileEdge_node(ctx context.Context, field graphql.CollectedField, obj *ProfileEdge) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_ProfileEdge_node,
func(ctx context.Context) (any, error) {
return obj.Node, nil
},
nil,
ec.marshalNProfile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐProfile,
true,
true,
)
}
func (ec *executionContext) fieldContext_ProfileEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "ProfileEdge",
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_Profile_id(ctx, field)
case "coverBatch":
return ec.fieldContext_Profile_coverBatch(ctx, field)
case "coverNonBatch":
return ec.fieldContext_Profile_coverNonBatch(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Profile", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) _ProfileEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ProfileEdge) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_ProfileEdge_cursor,
func(ctx context.Context) (any, error) {
return obj.Cursor, nil
},
nil,
ec.marshalNID2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_ProfileEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "ProfileEdge",
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) _ProfilesConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ProfilesConnection) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_ProfilesConnection_edges,
func(ctx context.Context) (any, error) {
return obj.Edges, nil
},
nil,
ec.marshalNProfileEdge2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐProfileEdgeᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext_ProfilesConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "ProfilesConnection",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
switch field.Name {
case "node":
return ec.fieldContext_ProfileEdge_node(ctx, field)
case "cursor":
return ec.fieldContext_ProfileEdge_cursor(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type ProfileEdge", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) _ProfilesConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ProfilesConnection) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_ProfilesConnection_totalCount,
func(ctx context.Context) (any, error) {
return obj.TotalCount, nil
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
func (ec *executionContext) fieldContext_ProfilesConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "ProfilesConnection",
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_users(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query_users,
func(ctx context.Context) (any, error) {
return ec.Resolvers.Query().Users(ctx)
},
nil,
ec.marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐUserᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext_Query_users(_ 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 "nullableBatch":
return ec.fieldContext_User_nullableBatch(ctx, field)
case "nullableNonBatch":
return ec.fieldContext_User_nullableNonBatch(ctx, field)
case "nullableBatchWithArg":
return ec.fieldContext_User_nullableBatchWithArg(ctx, field)
case "nullableNonBatchWithArg":
return ec.fieldContext_User_nullableNonBatchWithArg(ctx, field)
case "nonNullableBatch":
return ec.fieldContext_User_nonNullableBatch(ctx, field)
case "nonNullableNonBatch":
return ec.fieldContext_User_nonNullableNonBatch(ctx, field)
case "directiveNullableBatch":
return ec.fieldContext_User_directiveNullableBatch(ctx, field)
case "directiveNullableNonBatch":
return ec.fieldContext_User_directiveNullableNonBatch(ctx, field)
case "directiveNullableBatchWithArg":
return ec.fieldContext_User_directiveNullableBatchWithArg(ctx, field)
case "directiveNullableNonBatchWithArg":
return ec.fieldContext_User_directiveNullableNonBatchWithArg(ctx, field)
case "directiveNonNullableBatch":
return ec.fieldContext_User_directiveNonNullableBatch(ctx, field)
case "directiveNonNullableNonBatch":
return ec.fieldContext_User_directiveNonNullableNonBatch(ctx, field)
case "profileBatch":
return ec.fieldContext_User_profileBatch(ctx, field)
case "profileNonBatch":
return ec.fieldContext_User_profileNonBatch(ctx, field)
case "profileConnectionBatch":
return ec.fieldContext_User_profileConnectionBatch(ctx, field)
case "profileConnectionNonBatch":
return ec.fieldContext_User_profileConnectionNonBatch(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query___type,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.IntrospectType(fc.Args["name"].(string))
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query___schema,
func(ctx context.Context) (any, error) {
return ec.IntrospectSchema()
},
nil,
ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema,
true,
false,
)
}
func (ec *executionContext) fieldContext_Query___schema(_ 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_nullableBatch(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_User_nullableBatch,
func(ctx context.Context) (any, error) {
return ec.resolveBatch_User_nullableBatch(ctx, field, obj)
},
nil,
ec.marshalOProfile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐProfile,
true,
false,
)
}
func (ec *executionContext) fieldContext_User_nullableBatch(_ 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_Profile_id(ctx, field)
case "coverBatch":
return ec.fieldContext_Profile_coverBatch(ctx, field)
case "coverNonBatch":
return ec.fieldContext_Profile_coverNonBatch(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Profile", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) resolveBatch_User_nullableBatch(ctx context.Context, field graphql.CollectedField, obj *User) (any, error) {
resolver := ec.Resolvers.User()
group := graphql.GetBatchParentGroup(ctx, "User")
if group != nil {
parents, ok := group.Parents.([]*User)
if ok {
idx, ok := graphql.BatchParentIndex(ctx)
if ok {
key := field.Alias
if key == "" {
key = field.Name
}
result := group.GetFieldResult(key, func() (any, error) {
return resolver.NullableBatch(ctx, parents)
})
return graphql.ResolveBatchGroupResult[*Profile](
ctx,
idx,
len(parents),
result,
"User.nullableBatch",
)
}
}
}
results, err := resolver.NullableBatch(ctx, []*User{obj})
return graphql.ResolveBatchSingleResult[*Profile](
ctx,
results,
err,
"User.nullableBatch",
)
}
func (ec *executionContext) _User_nullableNonBatch(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_User_nullableNonBatch,
func(ctx context.Context) (any, error) {
return ec.Resolvers.User().NullableNonBatch(ctx, obj)
},
nil,
ec.marshalOProfile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐProfile,
true,
false,
)
}
func (ec *executionContext) fieldContext_User_nullableNonBatch(_ 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_Profile_id(ctx, field)
case "coverBatch":
return ec.fieldContext_Profile_coverBatch(ctx, field)
case "coverNonBatch":
return ec.fieldContext_Profile_coverNonBatch(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Profile", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) _User_nullableBatchWithArg(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_User_nullableBatchWithArg,
func(ctx context.Context) (any, error) {
return ec.resolveBatch_User_nullableBatchWithArg(ctx, field, obj)
},
nil,
ec.marshalOProfile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐProfile,
true,
false,
)
}
func (ec *executionContext) fieldContext_User_nullableBatchWithArg(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_Profile_id(ctx, field)
case "coverBatch":
return ec.fieldContext_Profile_coverBatch(ctx, field)
case "coverNonBatch":
return ec.fieldContext_Profile_coverNonBatch(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Profile", 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_nullableBatchWithArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) resolveBatch_User_nullableBatchWithArg(ctx context.Context, field graphql.CollectedField, obj *User) (any, error) {
resolver := ec.Resolvers.User()
fc := graphql.GetFieldContext(ctx)
group := graphql.GetBatchParentGroup(ctx, "User")
if group != nil {
parents, ok := group.Parents.([]*User)
if ok {
idx, ok := graphql.BatchParentIndex(ctx)
if ok {
key := field.Alias
if key == "" {
key = field.Name
}
result := group.GetFieldResult(key, func() (any, error) {
return resolver.NullableBatchWithArg(ctx, parents, fc.Args["offset"].(int))
})
return graphql.ResolveBatchGroupResult[*Profile](
ctx,
idx,
len(parents),
result,
"User.nullableBatchWithArg",
)
}
}
}
results, err := resolver.NullableBatchWithArg(ctx, []*User{obj}, fc.Args["offset"].(int))
return graphql.ResolveBatchSingleResult[*Profile](
ctx,
results,
err,
"User.nullableBatchWithArg",
)
}
func (ec *executionContext) _User_nullableNonBatchWithArg(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_User_nullableNonBatchWithArg,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.User().NullableNonBatchWithArg(ctx, obj, fc.Args["offset"].(int))
},
nil,
ec.marshalOProfile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐProfile,
true,
false,
)
}
func (ec *executionContext) fieldContext_User_nullableNonBatchWithArg(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_Profile_id(ctx, field)
case "coverBatch":
return ec.fieldContext_Profile_coverBatch(ctx, field)
case "coverNonBatch":
return ec.fieldContext_Profile_coverNonBatch(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Profile", 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_nullableNonBatchWithArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) _User_nonNullableBatch(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_User_nonNullableBatch,
func(ctx context.Context) (any, error) {
return ec.resolveBatch_User_nonNullableBatch(ctx, field, obj)
},
nil,
ec.marshalNProfile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐProfile,
true,
true,
)
}
func (ec *executionContext) fieldContext_User_nonNullableBatch(_ 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_Profile_id(ctx, field)
case "coverBatch":
return ec.fieldContext_Profile_coverBatch(ctx, field)
case "coverNonBatch":
return ec.fieldContext_Profile_coverNonBatch(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Profile", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) resolveBatch_User_nonNullableBatch(ctx context.Context, field graphql.CollectedField, obj *User) (any, error) {
resolver := ec.Resolvers.User()
group := graphql.GetBatchParentGroup(ctx, "User")
if group != nil {
parents, ok := group.Parents.([]*User)
if ok {
idx, ok := graphql.BatchParentIndex(ctx)
if ok {
key := field.Alias
if key == "" {
key = field.Name
}
result := group.GetFieldResult(key, func() (any, error) {
return resolver.NonNullableBatch(ctx, parents)
})
return graphql.ResolveBatchGroupResult[*Profile](
ctx,
idx,
len(parents),
result,
"User.nonNullableBatch",
)
}
}
}
results, err := resolver.NonNullableBatch(ctx, []*User{obj})
return graphql.ResolveBatchSingleResult[*Profile](
ctx,
results,
err,
"User.nonNullableBatch",
)
}
func (ec *executionContext) _User_nonNullableNonBatch(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_User_nonNullableNonBatch,
func(ctx context.Context) (any, error) {
return ec.Resolvers.User().NonNullableNonBatch(ctx, obj)
},
nil,
ec.marshalNProfile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐProfile,
true,
true,
)
}
func (ec *executionContext) fieldContext_User_nonNullableNonBatch(_ 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_Profile_id(ctx, field)
case "coverBatch":
return ec.fieldContext_Profile_coverBatch(ctx, field)
case "coverNonBatch":
return ec.fieldContext_Profile_coverNonBatch(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Profile", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) _User_directiveNullableBatch(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_User_directiveNullableBatch,
func(ctx context.Context) (any, error) {
return ec.resolveBatch_User_directiveNullableBatch(ctx, field, obj)
},
nil,
ec.marshalOProfile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐProfile,
true,
false,
)
}
func (ec *executionContext) fieldContext_User_directiveNullableBatch(_ 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_Profile_id(ctx, field)
case "coverBatch":
return ec.fieldContext_Profile_coverBatch(ctx, field)
case "coverNonBatch":
return ec.fieldContext_Profile_coverNonBatch(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Profile", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) resolveBatch_User_directiveNullableBatch(ctx context.Context, field graphql.CollectedField, obj *User) (any, error) {
resolver := ec.Resolvers.User()
group := graphql.GetBatchParentGroup(ctx, "User")
if group != nil {
parents, ok := group.Parents.([]*User)
if ok {
idx, ok := graphql.BatchParentIndex(ctx)
if ok {
key := field.Alias
if key == "" {
key = field.Name
}
result := group.GetFieldResult(key, func() (any, error) {
return resolver.DirectiveNullableBatch(ctx, parents)
})
return graphql.ResolveBatchGroupResult[*Profile](
ctx,
idx,
len(parents),
result,
"User.directiveNullableBatch",
)
}
}
}
results, err := resolver.DirectiveNullableBatch(ctx, []*User{obj})
return graphql.ResolveBatchSingleResult[*Profile](
ctx,
results,
err,
"User.directiveNullableBatch",
)
}
func (ec *executionContext) _User_directiveNullableNonBatch(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_User_directiveNullableNonBatch,
func(ctx context.Context) (any, error) {
return ec.Resolvers.User().DirectiveNullableNonBatch(ctx, obj)
},
nil,
ec.marshalOProfile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐProfile,
true,
false,
)
}
func (ec *executionContext) fieldContext_User_directiveNullableNonBatch(_ 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_Profile_id(ctx, field)
case "coverBatch":
return ec.fieldContext_Profile_coverBatch(ctx, field)
case "coverNonBatch":
return ec.fieldContext_Profile_coverNonBatch(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Profile", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) _User_directiveNullableBatchWithArg(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_User_directiveNullableBatchWithArg,
func(ctx context.Context) (any, error) {
return ec.resolveBatch_User_directiveNullableBatchWithArg(ctx, field, obj)
},
nil,
ec.marshalOProfile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐProfile,
true,
false,
)
}
func (ec *executionContext) fieldContext_User_directiveNullableBatchWithArg(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_Profile_id(ctx, field)
case "coverBatch":
return ec.fieldContext_Profile_coverBatch(ctx, field)
case "coverNonBatch":
return ec.fieldContext_Profile_coverNonBatch(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Profile", 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_directiveNullableBatchWithArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) resolveBatch_User_directiveNullableBatchWithArg(ctx context.Context, field graphql.CollectedField, obj *User) (any, error) {
resolver := ec.Resolvers.User()
fc := graphql.GetFieldContext(ctx)
group := graphql.GetBatchParentGroup(ctx, "User")
if group != nil {
parents, ok := group.Parents.([]*User)
if ok {
idx, ok := graphql.BatchParentIndex(ctx)
if ok {
key := field.Alias
if key == "" {
key = field.Name
}
result := group.GetFieldResult(key, func() (any, error) {
return resolver.DirectiveNullableBatchWithArg(ctx, parents, fc.Args["offset"].(int))
})
return graphql.ResolveBatchGroupResult[*Profile](
ctx,
idx,
len(parents),
result,
"User.directiveNullableBatchWithArg",
)
}
}
}
results, err := resolver.DirectiveNullableBatchWithArg(ctx, []*User{obj}, fc.Args["offset"].(int))
return graphql.ResolveBatchSingleResult[*Profile](
ctx,
results,
err,
"User.directiveNullableBatchWithArg",
)
}
func (ec *executionContext) _User_directiveNullableNonBatchWithArg(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_User_directiveNullableNonBatchWithArg,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.User().DirectiveNullableNonBatchWithArg(ctx, obj, fc.Args["offset"].(int))
},
nil,
ec.marshalOProfile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐProfile,
true,
false,
)
}
func (ec *executionContext) fieldContext_User_directiveNullableNonBatchWithArg(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_Profile_id(ctx, field)
case "coverBatch":
return ec.fieldContext_Profile_coverBatch(ctx, field)
case "coverNonBatch":
return ec.fieldContext_Profile_coverNonBatch(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Profile", 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_directiveNullableNonBatchWithArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) _User_directiveNonNullableBatch(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_User_directiveNonNullableBatch,
func(ctx context.Context) (any, error) {
return ec.resolveBatch_User_directiveNonNullableBatch(ctx, field, obj)
},
nil,
ec.marshalNProfile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐProfile,
true,
true,
)
}
func (ec *executionContext) fieldContext_User_directiveNonNullableBatch(_ 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_Profile_id(ctx, field)
case "coverBatch":
return ec.fieldContext_Profile_coverBatch(ctx, field)
case "coverNonBatch":
return ec.fieldContext_Profile_coverNonBatch(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Profile", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) resolveBatch_User_directiveNonNullableBatch(ctx context.Context, field graphql.CollectedField, obj *User) (any, error) {
resolver := ec.Resolvers.User()
group := graphql.GetBatchParentGroup(ctx, "User")
if group != nil {
parents, ok := group.Parents.([]*User)
if ok {
idx, ok := graphql.BatchParentIndex(ctx)
if ok {
key := field.Alias
if key == "" {
key = field.Name
}
result := group.GetFieldResult(key, func() (any, error) {
return resolver.DirectiveNonNullableBatch(ctx, parents)
})
return graphql.ResolveBatchGroupResult[*Profile](
ctx,
idx,
len(parents),
result,
"User.directiveNonNullableBatch",
)
}
}
}
results, err := resolver.DirectiveNonNullableBatch(ctx, []*User{obj})
return graphql.ResolveBatchSingleResult[*Profile](
ctx,
results,
err,
"User.directiveNonNullableBatch",
)
}
func (ec *executionContext) _User_directiveNonNullableNonBatch(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_User_directiveNonNullableNonBatch,
func(ctx context.Context) (any, error) {
return ec.Resolvers.User().DirectiveNonNullableNonBatch(ctx, obj)
},
nil,
ec.marshalNProfile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐProfile,
true,
true,
)
}
func (ec *executionContext) fieldContext_User_directiveNonNullableNonBatch(_ 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_Profile_id(ctx, field)
case "coverBatch":
return ec.fieldContext_Profile_coverBatch(ctx, field)
case "coverNonBatch":
return ec.fieldContext_Profile_coverNonBatch(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Profile", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) _User_profileBatch(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_User_profileBatch,
func(ctx context.Context) (any, error) {
return ec.resolveBatch_User_profileBatch(ctx, field, obj)
},
nil,
ec.marshalOProfile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐProfile,
true,
false,
)
}
func (ec *executionContext) fieldContext_User_profileBatch(_ 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_Profile_id(ctx, field)
case "coverBatch":
return ec.fieldContext_Profile_coverBatch(ctx, field)
case "coverNonBatch":
return ec.fieldContext_Profile_coverNonBatch(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Profile", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) resolveBatch_User_profileBatch(ctx context.Context, field graphql.CollectedField, obj *User) (any, error) {
resolver := ec.Resolvers.User()
group := graphql.GetBatchParentGroup(ctx, "User")
if group != nil {
parents, ok := group.Parents.([]*User)
if ok {
idx, ok := graphql.BatchParentIndex(ctx)
if ok {
key := field.Alias
if key == "" {
key = field.Name
}
result := group.GetFieldResult(key, func() (any, error) {
return resolver.ProfileBatch(ctx, parents)
})
return graphql.ResolveBatchGroupResult[*Profile](
ctx,
idx,
len(parents),
result,
"User.profileBatch",
)
}
}
}
results, err := resolver.ProfileBatch(ctx, []*User{obj})
return graphql.ResolveBatchSingleResult[*Profile](
ctx,
results,
err,
"User.profileBatch",
)
}
func (ec *executionContext) _User_profileNonBatch(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_User_profileNonBatch,
func(ctx context.Context) (any, error) {
return ec.Resolvers.User().ProfileNonBatch(ctx, obj)
},
nil,
ec.marshalOProfile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐProfile,
true,
false,
)
}
func (ec *executionContext) fieldContext_User_profileNonBatch(_ 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_Profile_id(ctx, field)
case "coverBatch":
return ec.fieldContext_Profile_coverBatch(ctx, field)
case "coverNonBatch":
return ec.fieldContext_Profile_coverNonBatch(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Profile", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) _User_profileConnectionBatch(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_User_profileConnectionBatch,
func(ctx context.Context) (any, error) {
return ec.resolveBatch_User_profileConnectionBatch(ctx, field, obj)
},
nil,
ec.marshalOProfilesConnection2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐProfilesConnection,
true,
false,
)
}
func (ec *executionContext) fieldContext_User_profileConnectionBatch(_ 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 "edges":
return ec.fieldContext_ProfilesConnection_edges(ctx, field)
case "totalCount":
return ec.fieldContext_ProfilesConnection_totalCount(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type ProfilesConnection", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) resolveBatch_User_profileConnectionBatch(ctx context.Context, field graphql.CollectedField, obj *User) (any, error) {
resolver := ec.Resolvers.User()
group := graphql.GetBatchParentGroup(ctx, "User")
if group != nil {
parents, ok := group.Parents.([]*User)
if ok {
idx, ok := graphql.BatchParentIndex(ctx)
if ok {
key := field.Alias
if key == "" {
key = field.Name
}
result := group.GetFieldResult(key, func() (any, error) {
return resolver.ProfileConnectionBatch(ctx, parents)
})
return graphql.ResolveBatchGroupResult[*ProfilesConnection](
ctx,
idx,
len(parents),
result,
"User.profileConnectionBatch",
)
}
}
}
results, err := resolver.ProfileConnectionBatch(ctx, []*User{obj})
return graphql.ResolveBatchSingleResult[*ProfilesConnection](
ctx,
results,
err,
"User.profileConnectionBatch",
)
}
func (ec *executionContext) _User_profileConnectionNonBatch(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_User_profileConnectionNonBatch,
func(ctx context.Context) (any, error) {
return ec.Resolvers.User().ProfileConnectionNonBatch(ctx, obj)
},
nil,
ec.marshalOProfilesConnection2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐProfilesConnection,
true,
false,
)
}
func (ec *executionContext) fieldContext_User_profileConnectionNonBatch(_ 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 "edges":
return ec.fieldContext_ProfilesConnection_edges(ctx, field)
case "totalCount":
return ec.fieldContext_ProfilesConnection_totalCount(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type ProfilesConnection", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Directive_description(_ 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_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_isRepeatable,
func(ctx context.Context) (any, error) {
return obj.IsRepeatable, nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_isRepeatable(_ 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) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_locations,
func(ctx context.Context) (any, error) {
return obj.Locations, nil
},
nil,
ec.marshalN__DirectiveLocation2ᚕstringᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_locations(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_args,
func(ctx context.Context) (any, error) {
return obj.Args, nil
},
nil,
ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
true,
)
}
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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __InputValue", 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___Directive_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___EnumValue_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___EnumValue_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___EnumValue_isDeprecated(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___EnumValue_deprecationReason(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Field_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_args,
func(ctx context.Context) (any, error) {
return obj.Args, nil
},
nil,
ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
true,
)
}
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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __InputValue", 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___Field_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_type,
func(ctx context.Context) (any, error) {
return obj.Type, nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_type(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_isDeprecated(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Field_deprecationReason(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_type,
func(ctx context.Context) (any, error) {
return obj.Type, nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_type(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_defaultValue,
func(ctx context.Context) (any, error) {
return obj.DefaultValue, nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_defaultValue(_ 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_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_isDeprecated(_ 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 Boolean does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) ___InputValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_deprecationReason(_ 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) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_types,
func(ctx context.Context) (any, error) {
return obj.Types(), nil
},
nil,
ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_types(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_queryType,
func(ctx context.Context) (any, error) {
return obj.QueryType(), nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_queryType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_mutationType,
func(ctx context.Context) (any, error) {
return obj.MutationType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_mutationType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_subscriptionType,
func(ctx context.Context) (any, error) {
return obj.SubscriptionType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_subscriptionType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_directives,
func(ctx context.Context) (any, error) {
return obj.Directives(), nil
},
nil,
ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_directives(_ 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 "isRepeatable":
return ec.fieldContext___Directive_isRepeatable(ctx, field)
case "locations":
return ec.fieldContext___Directive_locations(ctx, field)
case "args":
return ec.fieldContext___Directive_args(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_kind,
func(ctx context.Context) (any, error) {
return obj.Kind(), nil
},
nil,
ec.marshalN__TypeKind2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Type_kind(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_name,
func(ctx context.Context) (any, error) {
return obj.Name(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_description(_ 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_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_specifiedByURL,
func(ctx context.Context) (any, error) {
return obj.SpecifiedByURL(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_specifiedByURL(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_fields,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil
},
nil,
ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_interfaces,
func(ctx context.Context) (any, error) {
return obj.Interfaces(), nil
},
nil,
ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_interfaces(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_possibleTypes,
func(ctx context.Context) (any, error) {
return obj.PossibleTypes(), nil
},
nil,
ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_possibleTypes(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_enumValues,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil
},
nil,
ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_inputFields,
func(ctx context.Context) (any, error) {
return obj.InputFields(), nil
},
nil,
ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_inputFields(_ 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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_ofType,
func(ctx context.Context) (any, error) {
return obj.OfType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_ofType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) ___Type_isOneOf(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_isOneOf,
func(ctx context.Context) (any, error) {
return obj.IsOneOf(), nil
},
nil,
ec.marshalOBoolean2bool,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_isOneOf(_ 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 Boolean 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 imageImplementors = []string{"Image"}
func (ec *executionContext) _Image(ctx context.Context, sel ast.SelectionSet, obj *Image) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, imageImplementors)
out := graphql.NewFieldSet(fields)
deferred := make(map[string]*graphql.FieldSet)
for i, field := range fields {
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Image")
case "url":
out.Values[i] = ec._Image_url(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 profileImplementors = []string{"Profile"}
func (ec *executionContext) _Profile(ctx context.Context, sel ast.SelectionSet, obj *Profile) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, profileImplementors)
out := graphql.NewFieldSet(fields)
deferred := make(map[string]*graphql.FieldSet)
for i, field := range fields {
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Profile")
case "id":
out.Values[i] = ec._Profile_id(ctx, field, obj)
if out.Values[i] == graphql.Null {
atomic.AddUint32(&out.Invalids, 1)
}
case "coverBatch":
field := field
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._Profile_coverBatch(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 "coverNonBatch":
field := field
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._Profile_coverNonBatch(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 profileEdgeImplementors = []string{"ProfileEdge"}
func (ec *executionContext) _ProfileEdge(ctx context.Context, sel ast.SelectionSet, obj *ProfileEdge) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, profileEdgeImplementors)
out := graphql.NewFieldSet(fields)
deferred := make(map[string]*graphql.FieldSet)
for i, field := range fields {
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("ProfileEdge")
case "node":
out.Values[i] = ec._ProfileEdge_node(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "cursor":
out.Values[i] = ec._ProfileEdge_cursor(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 profilesConnectionImplementors = []string{"ProfilesConnection"}
func (ec *executionContext) _ProfilesConnection(ctx context.Context, sel ast.SelectionSet, obj *ProfilesConnection) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, profilesConnectionImplementors)
out := graphql.NewFieldSet(fields)
deferred := make(map[string]*graphql.FieldSet)
for i, field := range fields {
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("ProfilesConnection")
case "edges":
out.Values[i] = ec._ProfilesConnection_edges(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "totalCount":
out.Values[i] = ec._ProfilesConnection_totalCount(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 "users":
field := field
innerFunc := func(ctx 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_users(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 *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 "nullableBatch":
field := field
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._User_nullableBatch(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 "nullableNonBatch":
field := field
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._User_nullableNonBatch(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 "nullableBatchWithArg":
field := field
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._User_nullableBatchWithArg(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 "nullableNonBatchWithArg":
field := field
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._User_nullableNonBatchWithArg(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 "nonNullableBatch":
field := field
innerFunc := func(ctx 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_nonNullableBatch(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 "nonNullableNonBatch":
field := field
innerFunc := func(ctx 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_nonNullableNonBatch(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 "directiveNullableBatch":
field := field
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._User_directiveNullableBatch(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 "directiveNullableNonBatch":
field := field
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._User_directiveNullableNonBatch(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 "directiveNullableBatchWithArg":
field := field
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._User_directiveNullableBatchWithArg(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 "directiveNullableNonBatchWithArg":
field := field
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._User_directiveNullableNonBatchWithArg(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 "directiveNonNullableBatch":
field := field
innerFunc := func(ctx 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_directiveNonNullableBatch(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 "directiveNonNullableNonBatch":
field := field
innerFunc := func(ctx 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_directiveNonNullableNonBatch(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 "profileBatch":
field := field
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._User_profileBatch(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 "profileNonBatch":
field := field
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._User_profileNonBatch(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 "profileConnectionBatch":
field := field
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._User_profileConnectionBatch(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 "profileConnectionNonBatch":
field := field
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._User_profileConnectionNonBatch(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 __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 "isRepeatable":
out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
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++
}
default:
panic("unknown field " + strconv.Quote(field.Name))
}
}
out.Dispatch(ctx)
if out.Invalids > 0 {
return graphql.Null
}
atomic.AddInt32(&ec.Deferred, int32(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)
case "isDeprecated":
out.Values[i] = ec.___InputValue_isDeprecated(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "deprecationReason":
out.Values[i] = ec.___InputValue_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 __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 "specifiedByURL":
out.Values[i] = ec.___Type_specifiedByURL(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 "isOneOf":
out.Values[i] = ec.___Type_isOneOf(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 any) (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 {
_ = sel
res := graphql.MarshalBoolean(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalNID2string(ctx context.Context, v any) (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 {
_ = sel
res := graphql.MarshalID(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v any) (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 {
_ = sel
res := graphql.MarshalInt(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) marshalNProfile2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐProfile(ctx context.Context, sel ast.SelectionSet, v Profile) graphql.Marshaler {
return ec._Profile(ctx, sel, &v)
}
func (ec *executionContext) marshalNProfile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐProfile(ctx context.Context, sel ast.SelectionSet, v *Profile) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return ec._Profile(ctx, sel, v)
}
func (ec *executionContext) marshalNProfileEdge2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐProfileEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*ProfileEdge) graphql.Marshaler {
ctx = graphql.WithBatchParents(ctx, "ProfileEdge", v)
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalNProfileEdge2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐProfileEdge(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalNProfileEdge2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐProfileEdge(ctx context.Context, sel ast.SelectionSet, v *ProfileEdge) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return ec._ProfileEdge(ctx, sel, v)
}
func (ec *executionContext) unmarshalNString2string(ctx context.Context, v any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐUserᚄ(ctx context.Context, sel ast.SelectionSet, v []*User) graphql.Marshaler {
ctx = graphql.WithBatchParents(ctx, "User", v)
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐUser(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐUser(ctx context.Context, sel ast.SelectionSet, v *User) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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ᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler {
return ec.___Directive(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler {
ctx = graphql.WithBatchParents(ctx, "__Directive", v)
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v any) ([]string, error) {
var vSlice []any
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 := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__DirectiveLocation2string(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler {
return ec.___EnumValue(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler {
return ec.___Field(ctx, sel, &v)
}
func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler {
return ec.___InputValue(ctx, sel, &v)
}
func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
ctx = graphql.WithBatchParents(ctx, "__InputValue", v)
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler {
return ec.___Type(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
ctx = graphql.WithBatchParents(ctx, "__Type", v)
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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 any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v any) (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 {
_ = sel
_ = ctx
res := graphql.MarshalBoolean(v)
return res
}
func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v any) (*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
}
_ = sel
_ = ctx
res := graphql.MarshalBoolean(*v)
return res
}
func (ec *executionContext) marshalOImage2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐImage(ctx context.Context, sel ast.SelectionSet, v *Image) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._Image(ctx, sel, v)
}
func (ec *executionContext) marshalOProfile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐProfile(ctx context.Context, sel ast.SelectionSet, v *Profile) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._Profile(ctx, sel, v)
}
func (ec *executionContext) marshalOProfilesConnection2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋbatchresolverᚐProfilesConnection(ctx context.Context, sel ast.SelectionSet, v *ProfilesConnection) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._ProfilesConnection(ctx, sel, v)
}
func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v any) (*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
}
_ = sel
_ = ctx
res := graphql.MarshalString(*v)
return res
}
func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ctx = graphql.WithBatchParents(ctx, "__EnumValue", v)
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ctx = graphql.WithBatchParents(ctx, "__Field", v)
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ctx = graphql.WithBatchParents(ctx, "__InputValue", v)
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec.___Schema(ctx, sel, v)
}
func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ctx = graphql.WithBatchParents(ctx, "__Type", v)
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec.___Type(ctx, sel, v)
}
// endregion ***************************** type.gotpl *****************************
================================================
FILE: _examples/batchresolver/gqlgen.yml
================================================
schema:
- schema.graphql
exec:
filename: generated.go
package: batchresolver
model:
filename: models_gen.go
package: batchresolver
resolver:
dir: .
type: Resolver
layout: follow-schema
models:
User:
fields:
nullableBatch:
resolver: true
batch: true
nullableNonBatch:
resolver: true
nullableBatchWithArg:
resolver: true
batch: true
nullableNonBatchWithArg:
resolver: true
nonNullableBatch:
resolver: true
batch: true
nonNullableNonBatch:
resolver: true
profileBatch:
resolver: true
batch: true
profileNonBatch:
resolver: true
profileConnectionBatch:
resolver: true
batch: true
profileConnectionNonBatch:
resolver: true
Profile:
fields:
coverBatch:
resolver: true
batch: true
coverNonBatch:
resolver: true
================================================
FILE: _examples/batchresolver/models_gen.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package batchresolver
type Image struct {
URL string `json:"url"`
}
type Profile struct {
ID string `json:"id"`
CoverBatch *Image `json:"coverBatch,omitempty"`
CoverNonBatch *Image `json:"coverNonBatch,omitempty"`
}
type ProfileEdge struct {
Node *Profile `json:"node"`
Cursor string `json:"cursor"`
}
type ProfilesConnection struct {
Edges []*ProfileEdge `json:"edges"`
TotalCount int `json:"totalCount"`
}
type Query struct {
}
type User struct {
NullableBatch *Profile `json:"nullableBatch,omitempty"`
NullableNonBatch *Profile `json:"nullableNonBatch,omitempty"`
NullableBatchWithArg *Profile `json:"nullableBatchWithArg,omitempty"`
NullableNonBatchWithArg *Profile `json:"nullableNonBatchWithArg,omitempty"`
NonNullableBatch *Profile `json:"nonNullableBatch"`
NonNullableNonBatch *Profile `json:"nonNullableNonBatch"`
DirectiveNullableBatch *Profile `json:"directiveNullableBatch,omitempty"`
DirectiveNullableNonBatch *Profile `json:"directiveNullableNonBatch,omitempty"`
DirectiveNullableBatchWithArg *Profile `json:"directiveNullableBatchWithArg,omitempty"`
DirectiveNullableNonBatchWithArg *Profile `json:"directiveNullableNonBatchWithArg,omitempty"`
DirectiveNonNullableBatch *Profile `json:"directiveNonNullableBatch"`
DirectiveNonNullableNonBatch *Profile `json:"directiveNonNullableNonBatch"`
ProfileBatch *Profile `json:"profileBatch,omitempty"`
ProfileNonBatch *Profile `json:"profileNonBatch,omitempty"`
ProfileConnectionBatch *ProfilesConnection `json:"profileConnectionBatch,omitempty"`
ProfileConnectionNonBatch *ProfilesConnection `json:"profileConnectionNonBatch,omitempty"`
}
================================================
FILE: _examples/batchresolver/readme.md
================================================
# Batch Resolver Example
This example demonstrates **batch field resolvers** in gqlgen — resolvers that receive a slice of parent objects and return results for all of them in a single call, instead of being invoked once per parent.
## Schema
A `User` type has six `Profile` fields covering the key variations:
| Field | Nullable | Batch | Has Args |
|----------------------------|----------|-------|----------|
| `nullableBatch` | yes | yes | no |
| `nullableNonBatch` | yes | no | no |
| `nullableBatchWithArg` | yes | yes | yes |
| `nullableNonBatchWithArg` | yes | no | yes |
| `nonNullableBatch` | no | yes | no |
| `nonNullableNonBatch` | no | no | no |
## Configuration
In `gqlgen.yml`, batch resolvers are enabled per-field:
```yaml
models:
User:
fields:
nullableBatch:
resolver: true
batch: true
```
This changes the generated resolver signature from the standard single-object form:
```go
NullableNonBatch(ctx context.Context, obj *User) (*Profile, error)
```
to a batch form that receives all parents at once:
```go
NullableBatch(ctx context.Context, objs []*User) ([]*Profile, error)
```
## Per-Item Errors
Batch resolvers can return per-item errors using `graphql.BatchErrorList`:
```go
results := make([]*Profile, len(objs))
errs := make([]error, len(objs))
for i, obj := range objs {
results[i], errs[i] = resolve(obj)
}
return results, graphql.BatchErrorList(errs)
```
Each entry in the error slice corresponds to the parent at the same index. Individual errors can also be `gqlerror.List` to report multiple errors for a single item.
## Nested Batching
The schema also demonstrates **nested batch resolvers** through the path `User → Profile → Image`:
| Parent | Field | Batch | Target |
|-----------|-------------------|-------|---------|
| `User` | `profileBatch` | yes | Profile |
| `User` | `profileNonBatch` | no | Profile |
| `Profile` | `coverBatch` | yes | Image |
| `Profile` | `coverNonBatch` | no | Image |
With 10 users, the batch path resolves all profiles in **1 call** (vs 10 for non-batch). However, `coverBatch` is still called **once per profile** (10 calls) rather than once for all profiles. This happens because profiles returned by a batch resolver are marshalled as individual values, not as a list — the batch parent context for `Profile` is only set when marshalling a `[Profile]` list field. Ideally, nested batching should propagate the batch parent context from batch resolver results so that `coverBatch` is called only once for all 10 profiles. The `TestBatchResolver_Nested_CallCount` test documents these current call counts and confirms both paths return identical data.
## Tests
The tests verify **parity** between batch and non-batch resolvers — both must produce identical data and errors for the same inputs. Covered scenarios include:
- Successful resolution
- Arguments passed through correctly
- Errors at specific indices
- `gqlerror.List` expansion
- `gqlerror.Error` with and without a custom path
- Non-null field error propagation (parent nulled out)
- Wrong result/error slice lengths (produces per-parent error messages)
- Nested batch call count verification (`User → Profile → Image`)
## Benchmarks
`BenchmarkBatchResolver_SingleLevel` and `BenchmarkBatchResolver_Nested` compare batch vs non-batch execution time. Note that these benchmarks use in-memory resolvers with no I/O, so they only measure the framework overhead of batching. In a real-world scenario the main benefit of batching is reducing the number of round-trips to external services (databases, APIs, etc.), which these benchmarks do not capture.
================================================
FILE: _examples/batchresolver/resolver.go
================================================
package batchresolver
// This file will not be regenerated automatically.
//
// It serves as dependency injection for your app, add any dependencies you require
// here.
import "sync/atomic"
type Resolver struct {
users []*User
profiles []*Profile
images []*Image
profileErrIdx int
profileErrWithValueIdxs map[int]struct{}
profileErrListIdxs map[int]struct{}
profileGqlErrNoPathIdxs map[int]struct{}
profileGqlErrPathIdxs map[int]struct{}
profileWrongLen bool
batchErrsWrongLen bool
batchErrsLen int
batchResultsWrongLen bool
batchResultsLen int
batchErrListIdxs map[int]struct{}
// Call counters for the nested batch performance test (atomic for -race safety)
profileBatchCalls atomic.Int32
profileNonBatchCalls atomic.Int32
coverBatchCalls atomic.Int32
coverNonBatchCalls atomic.Int32
profileConnectionBatchCalls atomic.Int32
profileConnectionNonBatchCalls atomic.Int32
}
func (r *Resolver) userIndex(obj *User) int {
if obj == nil {
return -1
}
for i := range r.users {
if r.users[i] == obj {
return i
}
}
return -1
}
func (r *Resolver) profileIndex(obj *Profile) int {
if obj == nil {
return -1
}
for i := range r.profiles {
if r.profiles[i] == obj {
return i
}
}
return -1
}
================================================
FILE: _examples/batchresolver/resolver_helpers.go
================================================
package batchresolver
import (
"fmt"
"github.com/vektah/gqlparser/v2/ast"
"github.com/vektah/gqlparser/v2/gqlerror"
)
func resolveProfile(r *Resolver, idx int) (*Profile, error) {
if r.profileGqlErrPathIdxs != nil {
if _, ok := r.profileGqlErrPathIdxs[idx]; ok {
return nil, &gqlerror.Error{
Message: fmt.Sprintf("profile gqlerror path set at index %d", idx),
Path: ast.Path{ast.PathName("custom"), ast.PathIndex(idx)},
}
}
}
if r.profileGqlErrNoPathIdxs != nil {
if _, ok := r.profileGqlErrNoPathIdxs[idx]; ok {
return nil, gqlerror.Errorf("profile gqlerror path nil at index %d", idx)
}
}
if r.profileErrListIdxs != nil {
if _, ok := r.profileErrListIdxs[idx]; ok {
return nil, gqlerror.List{
gqlerror.Errorf("profile list error 1 at index %d", idx),
gqlerror.Errorf("profile list error 2 at index %d", idx),
}
}
}
if r.profileErrWithValueIdxs != nil {
if _, ok := r.profileErrWithValueIdxs[idx]; ok {
var value *Profile
if idx >= 0 && idx < len(r.profiles) {
value = r.profiles[idx]
}
return value, fmt.Errorf("profile error with value at index %d", idx)
}
}
if idx == r.profileErrIdx {
return nil, fmt.Errorf("profile error at index %d", idx)
}
if idx < 0 || idx >= len(r.profiles) {
return nil, fmt.Errorf("profile not set at index %d", idx)
}
return r.profiles[idx], nil
}
func resolveImage(r *Resolver, idx int) (*Image, error) {
if idx < 0 || idx >= len(r.images) {
return nil, fmt.Errorf("image not set at index %d", idx)
}
return r.images[idx], nil
}
================================================
FILE: _examples/batchresolver/schema.graphql
================================================
directive @goField(
forceResolver: Boolean
name: String
omittable: Boolean
batch: Boolean
) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION
type Query {
users: [User!]!
}
type User {
nullableBatch: Profile
nullableNonBatch: Profile
nullableBatchWithArg(offset: Int!): Profile
nullableNonBatchWithArg(offset: Int!): Profile
nonNullableBatch: Profile!
nonNullableNonBatch: Profile!
directiveNullableBatch: Profile @goField(batch: true)
directiveNullableNonBatch: Profile @goField(forceResolver: true)
directiveNullableBatchWithArg(offset: Int!): Profile @goField(batch: true)
directiveNullableNonBatchWithArg(offset: Int!): Profile @goField(forceResolver: true)
directiveNonNullableBatch: Profile! @goField(batch: true)
directiveNonNullableNonBatch: Profile! @goField(forceResolver: true)
profileBatch: Profile
profileNonBatch: Profile
profileConnectionBatch: ProfilesConnection
profileConnectionNonBatch: ProfilesConnection
}
type Profile {
id: ID!
coverBatch: Image
coverNonBatch: Image
}
type Image {
url: String!
}
type ProfilesConnection {
edges: [ProfileEdge!]!
totalCount: Int!
}
type ProfileEdge {
node: Profile!
cursor: ID!
}
================================================
FILE: _examples/batchresolver/schema.resolvers.go
================================================
package batchresolver
// 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/99designs/gqlgen version v0.17.88-dev
import (
"context"
"errors"
"fmt"
"github.com/99designs/gqlgen/graphql"
"github.com/vektah/gqlparser/v2/gqlerror"
)
// CoverBatch is the batch resolver for the coverBatch field.
func (r *profileResolver) CoverBatch(ctx context.Context, objs []*Profile) ([]*Image, error) {
r.coverBatchCalls.Add(1)
results := make([]*Image, len(objs))
for i, obj := range objs {
idx := r.profileIndex(obj)
results[i], _ = resolveImage(r.Resolver, idx)
}
return results, nil
}
// CoverNonBatch is the resolver for the coverNonBatch field.
func (r *profileResolver) CoverNonBatch(ctx context.Context, obj *Profile) (*Image, error) {
r.coverNonBatchCalls.Add(1)
idx := r.profileIndex(obj)
return resolveImage(r.Resolver, idx)
}
// Users is the resolver for the users field.
func (r *queryResolver) Users(ctx context.Context) ([]*User, error) {
if r.users == nil {
return nil, errors.New("users not set")
}
return r.users, nil
}
// NullableBatch is the batch resolver for the nullableBatch field.
func (r *userResolver) NullableBatch(ctx context.Context, objs []*User) ([]*Profile, error) {
if r.batchResultsWrongLen {
results := make([]*Profile, r.batchResultsLen)
errs := make([]error, len(objs))
return results, graphql.BatchErrorList(errs)
}
if r.batchErrsWrongLen {
results := make([]*Profile, len(objs))
errs := make([]error, r.batchErrsLen)
return results, graphql.BatchErrorList(errs)
}
if r.batchErrListIdxs != nil {
results := make([]*Profile, len(objs))
errs := make([]error, len(objs))
for i, obj := range objs {
idx := r.userIndex(obj)
if idx >= 0 && idx < len(r.profiles) {
results[i] = r.profiles[idx]
}
if _, ok := r.batchErrListIdxs[idx]; ok {
errs[i] = gqlerror.List{
gqlerror.Errorf("batch list error 1 at index %d", idx),
gqlerror.Errorf("batch list error 2 at index %d", idx),
}
}
}
return results, graphql.BatchErrorList(errs)
}
if r.profileWrongLen {
if len(objs) == 0 {
return nil, nil
}
idx := r.userIndex(objs[0])
value, _ := resolveProfile(r.Resolver, idx)
return []*Profile{value}, nil
}
results := make([]*Profile, len(objs))
errs := make([]error, len(objs))
hasErr := false
for i, obj := range objs {
idx := r.userIndex(obj)
value, err := resolveProfile(r.Resolver, idx)
results[i] = value
errs[i] = err
if err != nil {
hasErr = true
}
}
if hasErr {
return results, graphql.BatchErrorList(errs)
}
return results, nil
}
// NullableNonBatch is the resolver for the nullableNonBatch field.
func (r *userResolver) NullableNonBatch(ctx context.Context, obj *User) (*Profile, error) {
idx := r.userIndex(obj)
return resolveProfile(r.Resolver, idx)
}
// NullableBatchWithArg is the batch resolver for the nullableBatchWithArg field.
func (r *userResolver) NullableBatchWithArg(ctx context.Context, objs []*User, offset int) ([]*Profile, error) {
if r.profileWrongLen {
if len(objs) == 0 {
return nil, nil
}
idx := r.userIndex(objs[0]) + offset
value, _ := resolveProfile(r.Resolver, idx)
return []*Profile{value}, nil
}
results := make([]*Profile, len(objs))
errs := make([]error, len(objs))
hasErr := false
for i, obj := range objs {
idx := r.userIndex(obj) + offset
value, err := resolveProfile(r.Resolver, idx)
results[i] = value
errs[i] = err
if err != nil {
hasErr = true
}
}
if hasErr {
return results, graphql.BatchErrorList(errs)
}
return results, nil
}
// NullableNonBatchWithArg is the resolver for the nullableNonBatchWithArg field.
func (r *userResolver) NullableNonBatchWithArg(ctx context.Context, obj *User, offset int) (*Profile, error) {
idx := r.userIndex(obj) + offset
return resolveProfile(r.Resolver, idx)
}
// NonNullableBatch is the batch resolver for the nonNullableBatch field.
func (r *userResolver) NonNullableBatch(ctx context.Context, objs []*User) ([]*Profile, error) {
if r.profileWrongLen {
if len(objs) == 0 {
return nil, nil
}
idx := r.userIndex(objs[0])
value, _ := resolveProfile(r.Resolver, idx)
return []*Profile{value}, nil
}
results := make([]*Profile, len(objs))
errs := make([]error, len(objs))
hasErr := false
for i, obj := range objs {
idx := r.userIndex(obj)
value, err := resolveProfile(r.Resolver, idx)
results[i] = value
errs[i] = err
if err != nil {
hasErr = true
}
}
if hasErr {
return results, graphql.BatchErrorList(errs)
}
return results, nil
}
// NonNullableNonBatch is the resolver for the nonNullableNonBatch field.
func (r *userResolver) NonNullableNonBatch(ctx context.Context, obj *User) (*Profile, error) {
idx := r.userIndex(obj)
return resolveProfile(r.Resolver, idx)
}
// DirectiveNullableBatch is the batch resolver for the directiveNullableBatch field.
func (r *userResolver) DirectiveNullableBatch(ctx context.Context, objs []*User) ([]*Profile, error) {
return r.NullableBatch(ctx, objs)
}
// DirectiveNullableNonBatch is the resolver for the directiveNullableNonBatch field.
func (r *userResolver) DirectiveNullableNonBatch(ctx context.Context, obj *User) (*Profile, error) {
return r.NullableNonBatch(ctx, obj)
}
// DirectiveNullableBatchWithArg is the batch resolver for the directiveNullableBatchWithArg field.
func (r *userResolver) DirectiveNullableBatchWithArg(ctx context.Context, objs []*User, offset int) ([]*Profile, error) {
return r.NullableBatchWithArg(ctx, objs, offset)
}
// DirectiveNullableNonBatchWithArg is the resolver for the directiveNullableNonBatchWithArg field.
func (r *userResolver) DirectiveNullableNonBatchWithArg(ctx context.Context, obj *User, offset int) (*Profile, error) {
return r.NullableNonBatchWithArg(ctx, obj, offset)
}
// DirectiveNonNullableBatch is the batch resolver for the directiveNonNullableBatch field.
func (r *userResolver) DirectiveNonNullableBatch(ctx context.Context, objs []*User) ([]*Profile, error) {
return r.NonNullableBatch(ctx, objs)
}
// DirectiveNonNullableNonBatch is the resolver for the directiveNonNullableNonBatch field.
func (r *userResolver) DirectiveNonNullableNonBatch(ctx context.Context, obj *User) (*Profile, error) {
return r.NonNullableNonBatch(ctx, obj)
}
// ProfileBatch is the batch resolver for the profileBatch field.
func (r *userResolver) ProfileBatch(ctx context.Context, objs []*User) ([]*Profile, error) {
r.profileBatchCalls.Add(1)
results := make([]*Profile, len(objs))
for i, obj := range objs {
idx := r.userIndex(obj)
if idx >= 0 && idx < len(r.profiles) {
results[i] = r.profiles[idx]
}
}
return results, nil
}
// ProfileNonBatch is the resolver for the profileNonBatch field.
func (r *userResolver) ProfileNonBatch(ctx context.Context, obj *User) (*Profile, error) {
r.profileNonBatchCalls.Add(1)
idx := r.userIndex(obj)
if idx < 0 || idx >= len(r.profiles) {
return nil, fmt.Errorf("profile not set at index %d", idx)
}
return r.profiles[idx], nil
}
// ProfileConnectionBatch is the batch resolver for the profileConnectionBatch field.
func (r *userResolver) ProfileConnectionBatch(ctx context.Context, objs []*User) ([]*ProfilesConnection, error) {
r.profileConnectionBatchCalls.Add(1)
results := make([]*ProfilesConnection, len(objs))
for i, obj := range objs {
idx := r.userIndex(obj)
var profile *Profile
if idx >= 0 && idx < len(r.profiles) {
profile = r.profiles[idx]
}
results[i] = &ProfilesConnection{
Edges: []*ProfileEdge{{Node: profile, Cursor: fmt.Sprintf("cursor-%d", idx)}},
TotalCount: 1,
}
}
return results, nil
}
// ProfileConnectionNonBatch is the resolver for the profileConnectionNonBatch field.
func (r *userResolver) ProfileConnectionNonBatch(ctx context.Context, obj *User) (*ProfilesConnection, error) {
r.profileConnectionNonBatchCalls.Add(1)
idx := r.userIndex(obj)
var profile *Profile
if idx >= 0 && idx < len(r.profiles) {
profile = r.profiles[idx]
}
return &ProfilesConnection{
Edges: []*ProfileEdge{{Node: profile, Cursor: fmt.Sprintf("cursor-%d", idx)}},
TotalCount: 1,
}, nil
}
// Profile returns ProfileResolver implementation.
func (r *Resolver) Profile() ProfileResolver { return &profileResolver{r} }
// Query returns QueryResolver implementation.
func (r *Resolver) Query() QueryResolver { return &queryResolver{r} }
// User returns UserResolver implementation.
func (r *Resolver) User() UserResolver { return &userResolver{r} }
type profileResolver struct{ *Resolver }
type queryResolver struct{ *Resolver }
type userResolver struct{ *Resolver }
================================================
FILE: _examples/chat/.gitignore
================================================
# 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*
================================================
FILE: _examples/chat/.gqlgen.yml
================================================
models:
Chatroom:
model: github.com/99designs/gqlgen/_examples/chat.Chatroom
================================================
FILE: _examples/chat/chat_test.go
================================================
package chat
import (
"fmt"
"runtime"
"sync"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/99designs/gqlgen/client"
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/handler/transport"
)
func TestChatSubscriptions(t *testing.T) {
srv := handler.New(NewExecutableSchema(New()))
srv.AddTransport(transport.Websocket{
KeepAlivePingInterval: time.Second,
})
srv.AddTransport(transport.POST{})
c := client.New(srv)
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)
if !assert.NoError(t, msg.err, "sub.Next") {
return
}
assert.Equal(t, "You've joined the room", msg.resp.MessageAdded.Text)
assert.Equal(t, "system", msg.resp.MessageAdded.CreatedBy)
go func() {
var resp any
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)
if !assert.NoError(t, msg.err, "sub.Next") {
return
}
assert.Equal(t, "Hello!", msg.resp.MessageAdded.Text)
assert.Equal(t, "vektah", msg.resp.MessageAdded.CreatedBy)
msg.err = sub.Next(&msg.resp)
if !assert.NoError(t, msg.err, "sub.Next") {
return
}
assert.Equal(t, "Whats up?", msg.resp.MessageAdded.Text)
assert.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")
}
================================================
FILE: _examples/chat/generated.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package chat
import (
"bytes"
"context"
"embed"
"errors"
"fmt"
"strconv"
"sync/atomic"
"time"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/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{SchemaData: cfg.Schema, Resolvers: cfg.Resolvers, Directives: cfg.Directives, ComplexityRoot: cfg.Complexity}
}
type Config = graphql.Config[ResolverRoot, DirectiveRoot, ComplexityRoot]
type ResolverRoot interface {
Mutation() MutationResolver
Query() QueryResolver
Subscription() SubscriptionResolver
}
type DirectiveRoot struct {
User func(ctx context.Context, obj any, next graphql.Resolver, username string) (res any, 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 graphql.ExecutableSchemaState[ResolverRoot, DirectiveRoot, ComplexityRoot]
func (e *executableSchema) Schema() *ast.Schema {
if e.SchemaData != nil {
return e.SchemaData
}
return parsedSchema
}
func (e *executableSchema) Complexity(ctx context.Context, typeName, field string, childComplexity int, rawArgs map[string]any) (int, bool) {
ec := newExecutionContext(nil, e, nil)
_ = ec
switch typeName + "." + field {
case "Chatroom.messages":
if e.ComplexityRoot.Chatroom.Messages == nil {
break
}
return e.ComplexityRoot.Chatroom.Messages(childComplexity), true
case "Chatroom.name":
if e.ComplexityRoot.Chatroom.Name == nil {
break
}
return e.ComplexityRoot.Chatroom.Name(childComplexity), true
case "Chatroom.subscription":
if e.ComplexityRoot.Chatroom.Subscription == nil {
break
}
return e.ComplexityRoot.Chatroom.Subscription(childComplexity), true
case "Message.createdAt":
if e.ComplexityRoot.Message.CreatedAt == nil {
break
}
return e.ComplexityRoot.Message.CreatedAt(childComplexity), true
case "Message.createdBy":
if e.ComplexityRoot.Message.CreatedBy == nil {
break
}
return e.ComplexityRoot.Message.CreatedBy(childComplexity), true
case "Message.id":
if e.ComplexityRoot.Message.ID == nil {
break
}
return e.ComplexityRoot.Message.ID(childComplexity), true
case "Message.subscription":
if e.ComplexityRoot.Message.Subscription == nil {
break
}
return e.ComplexityRoot.Message.Subscription(childComplexity), true
case "Message.text":
if e.ComplexityRoot.Message.Text == nil {
break
}
return e.ComplexityRoot.Message.Text(childComplexity), true
case "Mutation.post":
if e.ComplexityRoot.Mutation.Post == nil {
break
}
args, err := ec.field_Mutation_post_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Mutation.Post(childComplexity, args["text"].(string), args["username"].(string), args["roomName"].(string)), true
case "Query.room":
if e.ComplexityRoot.Query.Room == nil {
break
}
args, err := ec.field_Query_room_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Query.Room(childComplexity, args["name"].(string)), true
case "Subscription.messageAdded":
if e.ComplexityRoot.Subscription.MessageAdded == nil {
break
}
args, err := ec.field_Subscription_messageAdded_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Subscription.MessageAdded(childComplexity, args["roomName"].(string)), true
}
return 0, false
}
func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
opCtx := graphql.GetOperationContext(ctx)
ec := newExecutionContext(opCtx, e, make(chan graphql.DeferredResult))
inputUnmarshalMap := graphql.BuildUnmarshalerMap()
first := true
switch opCtx.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, opCtx.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, opCtx.Operation.SelectionSet)
var buf bytes.Buffer
data.MarshalGQL(&buf)
return &graphql.Response{
Data: buf.Bytes(),
}
}
case ast.Subscription:
next := ec._subscriptionMiddleware(ctx, opCtx.Operation, func(ctx context.Context) (any, error) {
return ec._Subscription(ctx, opCtx.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.ExecutionContextState[ResolverRoot, DirectiveRoot, ComplexityRoot]
}
func newExecutionContext(
opCtx *graphql.OperationContext,
execSchema *executableSchema,
deferredResults chan graphql.DeferredResult,
) executionContext {
return executionContext{
ExecutionContextState: graphql.NewExecutionContextState[ResolverRoot, DirectiveRoot, ComplexityRoot](
opCtx,
(*graphql.ExecutableSchemaState[ResolverRoot, DirectiveRoot, ComplexityRoot])(execSchema),
parsedSchema,
deferredResults,
),
}
}
//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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "username", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "text", ec.unmarshalNString2string)
if err != nil {
return nil, err
}
args["text"] = arg0
arg1, err := graphql.ProcessArgField(ctx, rawArgs, "username", ec.unmarshalNString2string)
if err != nil {
return nil, err
}
args["username"] = arg1
arg2, err := graphql.ProcessArgField(ctx, rawArgs, "roomName", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "roomName", ec.unmarshalNString2string)
if err != nil {
return nil, err
}
args["roomName"] = arg0
return args, nil
}
func (ec *executionContext) field___Directive_args_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2ᚖbool)
if err != nil {
return nil, err
}
args["includeDeprecated"] = arg0
return args, nil
}
func (ec *executionContext) field___Field_args_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2ᚖbool)
if err != nil {
return nil, err
}
args["includeDeprecated"] = arg0
return args, nil
}
func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2bool)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2bool)
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) (any, 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) (any, 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
}
graphql.AddErrorf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Chatroom_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Chatroom_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Chatroom_messages,
func(ctx context.Context) (any, error) {
return obj.Messages, nil
},
nil,
ec.marshalNMessage2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋchatᚐMessageᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext_Chatroom_messages(_ 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ᚋ99designsᚋgqlgenᚋ_examplesᚋchatᚐSubscription(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Chatroom_subscription(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Message_id,
func(ctx context.Context) (any, error) {
return obj.ID, nil
},
nil,
ec.marshalNID2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Message_id(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Message_text,
func(ctx context.Context) (any, error) {
return obj.Text, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Message_text(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Message_createdBy,
func(ctx context.Context) (any, error) {
return obj.CreatedBy, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Message_createdBy(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Message_createdAt,
func(ctx context.Context) (any, error) {
return obj.CreatedAt, nil
},
nil,
ec.marshalNTime2timeᚐTime,
true,
true,
)
}
func (ec *executionContext) fieldContext_Message_createdAt(_ 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ᚋ99designsᚋgqlgenᚋ_examplesᚋchatᚐSubscription(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Message_subscription(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Mutation_post,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Mutation().Post(ctx, fc.Args["text"].(string), fc.Args["username"].(string), fc.Args["roomName"].(string))
},
nil,
ec.marshalNMessage2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋchatᚐMessage,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query_room,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Query().Room(ctx, fc.Args["name"].(string))
},
nil,
ec.marshalOChatroom2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋchatᚐChatroom,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query___type,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.IntrospectType(fc.Args["name"].(string))
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query___schema,
func(ctx context.Context) (any, error) {
return ec.IntrospectSchema()
},
nil,
ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema,
true,
false,
)
}
func (ec *executionContext) fieldContext_Query___schema(_ 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) {
return graphql.ResolveFieldStream(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Subscription_messageAdded,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Subscription().MessageAdded(ctx, fc.Args["roomName"].(string))
},
nil,
ec.marshalNMessage2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋchatᚐMessage,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Directive_description(_ 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_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_isRepeatable,
func(ctx context.Context) (any, error) {
return obj.IsRepeatable, nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_isRepeatable(_ 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) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_locations,
func(ctx context.Context) (any, error) {
return obj.Locations, nil
},
nil,
ec.marshalN__DirectiveLocation2ᚕstringᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_locations(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_args,
func(ctx context.Context) (any, error) {
return obj.Args, nil
},
nil,
ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
true,
)
}
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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __InputValue", 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___Directive_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___EnumValue_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___EnumValue_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___EnumValue_isDeprecated(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___EnumValue_deprecationReason(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Field_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_args,
func(ctx context.Context) (any, error) {
return obj.Args, nil
},
nil,
ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
true,
)
}
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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __InputValue", 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___Field_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_type,
func(ctx context.Context) (any, error) {
return obj.Type, nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_type(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_isDeprecated(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Field_deprecationReason(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_type,
func(ctx context.Context) (any, error) {
return obj.Type, nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_type(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_defaultValue,
func(ctx context.Context) (any, error) {
return obj.DefaultValue, nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_defaultValue(_ 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_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_isDeprecated(_ 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 Boolean does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) ___InputValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_deprecationReason(_ 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) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_types,
func(ctx context.Context) (any, error) {
return obj.Types(), nil
},
nil,
ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_types(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_queryType,
func(ctx context.Context) (any, error) {
return obj.QueryType(), nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_queryType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_mutationType,
func(ctx context.Context) (any, error) {
return obj.MutationType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_mutationType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_subscriptionType,
func(ctx context.Context) (any, error) {
return obj.SubscriptionType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_subscriptionType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_directives,
func(ctx context.Context) (any, error) {
return obj.Directives(), nil
},
nil,
ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_directives(_ 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 "isRepeatable":
return ec.fieldContext___Directive_isRepeatable(ctx, field)
case "locations":
return ec.fieldContext___Directive_locations(ctx, field)
case "args":
return ec.fieldContext___Directive_args(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_kind,
func(ctx context.Context) (any, error) {
return obj.Kind(), nil
},
nil,
ec.marshalN__TypeKind2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Type_kind(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_name,
func(ctx context.Context) (any, error) {
return obj.Name(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_description(_ 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_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_specifiedByURL,
func(ctx context.Context) (any, error) {
return obj.SpecifiedByURL(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_specifiedByURL(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_fields,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil
},
nil,
ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_interfaces,
func(ctx context.Context) (any, error) {
return obj.Interfaces(), nil
},
nil,
ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_interfaces(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_possibleTypes,
func(ctx context.Context) (any, error) {
return obj.PossibleTypes(), nil
},
nil,
ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_possibleTypes(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_enumValues,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil
},
nil,
ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_inputFields,
func(ctx context.Context) (any, error) {
return obj.InputFields(), nil
},
nil,
ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_inputFields(_ 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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_ofType,
func(ctx context.Context) (any, error) {
return obj.OfType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_ofType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) ___Type_isOneOf(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_isOneOf,
func(ctx context.Context) (any, error) {
return obj.IsOneOf(), nil
},
nil,
ec.marshalOBoolean2bool,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_isOneOf(_ 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 Boolean 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, _ *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 {
graphql.AddErrorf(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 "isRepeatable":
out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
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++
}
default:
panic("unknown field " + strconv.Quote(field.Name))
}
}
out.Dispatch(ctx)
if out.Invalids > 0 {
return graphql.Null
}
atomic.AddInt32(&ec.Deferred, int32(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)
case "isDeprecated":
out.Values[i] = ec.___InputValue_isDeprecated(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "deprecationReason":
out.Values[i] = ec.___InputValue_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 __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 "specifiedByURL":
out.Values[i] = ec.___Type_specifiedByURL(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 "isOneOf":
out.Values[i] = ec.___Type_isOneOf(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 any) (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 {
_ = sel
res := graphql.MarshalBoolean(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalNID2string(ctx context.Context, v any) (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 {
_ = sel
res := graphql.MarshalID(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) marshalNMessage2githubᚗcomᚋ99designsᚋ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ᚋ99designsᚋgqlgenᚋ_examplesᚋchatᚐMessageᚄ(ctx context.Context, sel ast.SelectionSet, v []Message) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalNMessage2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋchatᚐMessage(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalNMessage2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋchatᚐMessage(ctx context.Context, sel ast.SelectionSet, v *Message) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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 any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) marshalNSubscription2githubᚗcomᚋ99designsᚋ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ᚋ99designsᚋgqlgenᚋ_examplesᚋchatᚐSubscription(ctx context.Context, sel ast.SelectionSet, v *Subscription) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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 any) (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 {
_ = sel
res := graphql.MarshalTime(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler {
return ec.___Directive(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v any) ([]string, error) {
var vSlice []any
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 := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__DirectiveLocation2string(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler {
return ec.___EnumValue(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler {
return ec.___Field(ctx, sel, &v)
}
func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler {
return ec.___InputValue(ctx, sel, &v)
}
func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler {
return ec.___Type(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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 any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v any) (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 {
_ = sel
_ = ctx
res := graphql.MarshalBoolean(v)
return res
}
func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v any) (*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
}
_ = sel
_ = ctx
res := graphql.MarshalBoolean(*v)
return res
}
func (ec *executionContext) marshalOChatroom2ᚖgithubᚗcomᚋ99designsᚋ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 any) (*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
}
_ = sel
_ = ctx
res := graphql.MarshalString(*v)
return res
}
func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec.___Schema(ctx, sel, v)
}
func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec.___Type(ctx, sel, v)
}
// endregion ***************************** type.gotpl *****************************
================================================
FILE: _examples/chat/models_gen.go
================================================
// Code generated by github.com/99designs/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 {
}
================================================
FILE: _examples/chat/package.json
================================================
{
"name": "chat",
"version": "0.1.0",
"private": true,
"dependencies": {
"@apollo/client": "^4.0.0",
"apollo-utilities": "^1.0.26",
"graphql": "^16.8.1",
"graphql-sse": "^2.0.0",
"graphql-tag": "^2.10.0",
"graphql-ws": "^6.0.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-scripts": "^5.0.1",
"styled-components": "^6.1.8",
"subscriptions-transport-ws": "^0.11.0",
"typescript": "^5.3.3"
},
"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"
]
}
================================================
FILE: _examples/chat/public/index.html
================================================
React App
================================================
FILE: _examples/chat/readme.md
================================================
# 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
```
================================================
FILE: _examples/chat/resolvers.go
================================================
//go:generate go run ../../testdata/gqlgen.go
package chat
import (
"context"
"math/rand"
"sync"
"time"
"github.com/99designs/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 any, next graphql.Resolver, username string) (res any, 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, username, 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 any) 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)
}
================================================
FILE: _examples/chat/schema.graphql
================================================
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
================================================
FILE: _examples/chat/server/server.go
================================================
package main
import (
"log"
"net/http"
"time"
"github.com/gorilla/websocket"
"github.com/rs/cors"
"github.com/99designs/gqlgen/_examples/chat"
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/handler/extension"
"github.com/99designs/gqlgen/graphql/handler/transport"
"github.com/99designs/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))
}
================================================
FILE: _examples/chat/src/App.js
================================================
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)} />
>
);
};
================================================
FILE: _examples/chat/src/Room.js
================================================
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
{{ end }}
{{ end }}
================================================
FILE: docs/layouts/partials/sidebar.html
================================================
{{$currentVersion}}
{{ range $i, $version := $Versions }}
{{ if not (eq $currentVersion $version) }}
{{$version}}
{{ end }}
{{ end }}
================================================
FILE: docs/layouts/sitemap.xml
================================================
{{ 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 }}
================================================
FILE: docs/readme.md
================================================
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.
================================================
FILE: docs/static/main.css
================================================
: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;
}
================================================
FILE: docs/static/main.js
================================================
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);
}
}
};
================================================
FILE: docs/static/syntax.css
================================================
.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 */
================================================
FILE: go.mod
================================================
module github.com/99designs/gqlgen
go 1.25.0
require (
github.com/PuerkitoBio/goquery v1.11.0
github.com/go-viper/mapstructure/v2 v2.5.0
github.com/goccy/go-yaml v1.19.2
github.com/google/uuid v1.6.0
github.com/gorilla/websocket v1.5.0 // do not upgrade to v1.5.1 as it has serious bugs
github.com/hashicorp/golang-lru/v2 v2.0.7
github.com/logrusorgru/aurora/v4 v4.0.0
github.com/matryer/moq v0.6.0
github.com/mattn/go-colorable v0.1.14
github.com/mattn/go-isatty v0.0.20
github.com/sosodev/duration v1.4.0
github.com/stretchr/testify v1.11.1
github.com/urfave/cli/v3 v3.7.0
github.com/vektah/gqlparser/v2 v2.5.32
golang.org/x/text v0.34.0
golang.org/x/tools v0.42.0
google.golang.org/protobuf v1.36.11
)
require golang.org/x/sync v0.20.0
require (
github.com/agnivade/levenshtein v1.2.1 // indirect
github.com/andybalholm/cascadia v1.3.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/mod v0.33.0 // indirect
golang.org/x/net v0.51.0 // indirect
golang.org/x/sys v0.42.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
================================================
FILE: go.sum
================================================
github.com/PuerkitoBio/goquery v1.11.0 h1:jZ7pwMQXIITcUXNH83LLk+txlaEy6NVOfTuP43xxfqw=
github.com/PuerkitoBio/goquery v1.11.0/go.mod h1:wQHgxUOU3JGuj3oD/QFfxUdlzW6xPHfqyHre6VMY4DQ=
github.com/agnivade/levenshtein v1.2.1 h1:EHBY3UOn1gwdy/VbFwgo4cxecRznFk7fKWN1KOX7eoM=
github.com/agnivade/levenshtein v1.2.1/go.mod h1:QVVI16kDrtSuwcpd0p1+xMC6Z/VfhtCyDIjcwga4/DU=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kktS1LM=
github.com/andybalholm/cascadia v1.3.3/go.mod h1:xNd9bqTn98Ln4DwST8/nG+H0yuB8Hmgu1YHNnWw0GeA=
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/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgryski/trifles v0.0.0-20230903005119-f50d829f2e54 h1:SG7nF6SRlWhcT7cNTs5R6Hk4V2lcmLz2NsG2VnInyNo=
github.com/dgryski/trifles v0.0.0-20230903005119-f50d829f2e54/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA=
github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro=
github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM=
github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.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.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/logrusorgru/aurora/v4 v4.0.0 h1:sRjfPpun/63iADiSvGGjgA1cAYegEWMPCJdUpJYn9JA=
github.com/logrusorgru/aurora/v4 v4.0.0/go.mod h1:lP0iIa2nrnT/qoFXcOZSrZQpJ1o6n2CUf/hyHi2Q4ZQ=
github.com/matryer/moq v0.6.0 h1:FCccG09c3o4cg3gnrZ+7ty5Pa/sjmN24BMHp/0pwhjQ=
github.com/matryer/moq v0.6.0/go.mod h1:iEVhY/XBwFG/nbRyEf0oV+SqnTHZJ5wectzx7yT+y98=
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
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/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
github.com/sosodev/duration v1.4.0 h1:35ed0KiVFriGHHzZZJaZLgmTEEICIyt8Sx0RQfj9IjE=
github.com/sosodev/duration v1.4.0/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/urfave/cli/v3 v3.7.0 h1:AGSnbUyjtLiM+WJUb4dzXKldl/gL+F8OwmRDtVr6g2U=
github.com/urfave/cli/v3 v3.7.0/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso=
github.com/vektah/gqlparser/v2 v2.5.32 h1:k9QPJd4sEDTL+qB4ncPLflqTJ3MmjB9SrVzJrawpFSc=
github.com/vektah/gqlparser/v2 v2.5.32/go.mod h1:c1I28gSOVNzlfc4WuDlqU7voQnsqI6OG2amkBAFmgts=
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/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8=
golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w=
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-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/net v0.51.0 h1:94R/GTO7mt3/4wIKpcR5gkGmRLOuE/2hNGeWq/GBIFo=
golang.org/x/net v0.51.0/go.mod h1:aamm+2QF5ogm02fjy5Bb7CQ0WMt1/WVM7FtyaTLlA9Y=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/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.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
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-20210615035016-665e8c7367d1/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.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
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/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
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.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.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk=
golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA=
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.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/tools v0.42.0 h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k=
golang.org/x/tools v0.42.0/go.mod h1:Ma6lCIwGZvHK6XtgbswSoWroEkhugApmsXyrUmBhfr0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
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.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
================================================
FILE: gqlgen.schema.json
================================================
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "gqlgen Configuration",
"description": "Configuration file for gqlgen code generation",
"type": "object",
"properties": {
"schema": {
"description": "Where are all the schema files located? globs are supported",
"type": "array",
"items": {
"type": "string"
}
},
"exec": {
"description": "Where should the generated server code go?",
"type": "object",
"properties": {
"filename": {
"type": "string",
"description": "Path to the generated file (required for single-file layout)"
},
"package": {
"type": "string",
"description": "The go package name"
},
"layout": {
"type": "string",
"enum": ["single-file", "follow-schema"],
"default": "single-file"
},
"dir": {
"type": "string",
"description": "Directory for generated files (required for follow-schema layout)"
},
"filename_template": {
"type": "string",
"default": "{name}.generated.go",
"description": "Template for filenames (required for follow-schema layout)"
},
"worker_limit": {
"type": "integer",
"description": "Maximum number of goroutines in concurrency to use per child resolvers",
"default": 1000
}
}
},
"federation": {
"description": "Federation configuration",
"type": "object",
"properties": {
"filename": { "type": "string" },
"package": { "type": "string" },
"version": { "type": "integer" },
"options": {
"type": "object",
"properties": {
"explicit_requires": {
"type": "boolean",
"description": "Generate a function in the execution context to populate fields using the @requires directive into the entity. Cannot be used together with computed_requires.",
"default": false
},
"computed_requires": {
"type": "boolean",
"description": "Generate resolver functions to compute values for fields using the @requires directive. Requires federation version 2 and call_argument_directives_with_null to be true. Cannot be used together with explicit_requires.",
"default": false
},
"entity_resolver_multi": {
"type": "boolean",
"description": "Default engine for entityResolver generation. Can be overridden per entity with @entityResolver(multi: Boolean) directive.",
"default": false
}
}
},
"model_template": { "type": "string" }
}
},
"model": {
"description": "Where should any generated models go?",
"type": "object",
"properties": {
"filename": { "type": "string" },
"package": { "type": "string" },
"model_template": { "type": "string" },
"version": { "type": "integer" },
"options": {
"type": "object",
"additionalProperties": { "type": "boolean" }
}
}
},
"resolver": {
"description": "Where should the resolver implementations go?",
"type": "object",
"properties": {
"layout": {
"type": "string",
"enum": ["single-file", "follow-schema"],
"default": "follow-schema"
},
"package": { "type": "string" },
"dir": { "type": "string" },
"filename": { "type": "string" },
"filename_template": {
"type": "string",
"default": "{name}.resolvers.go"
},
"omit_template_comment": { "type": "boolean" },
"resolver_template": { "type": "string" },
"preserve_resolver": { "type": "boolean" },
"type": {
"type": "string",
"description": "The name of the resolver struct type",
"default": "Resolver"
}
}
},
"autobind": {
"description": "gqlgen will search for any type names in the schema in these go packages",
"type": "array",
"items": { "type": "string" }
},
"autobind_getter_haser": {
"description": "Enable getter/haser methods for autobind",
"type": "boolean",
"default": false
},
"models": {
"description": "Type mapping between the GraphQL and go type systems",
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"model": {
"type": "array",
"items": { "type": "string" }
},
"forceGenerate": {
"type": "boolean",
"description": "Force generation of this type even if it is mapped to a model"
},
"fields": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"type": {
"type": "string",
"description": "Go type for this field"
},
"resolver": { "type": "boolean" },
"fieldName": { "type": "string" },
"omittable": {
"type": "boolean",
"description": "Wrap this field with Omittable"
},
"autoBindGetterHaser": {
"type": "boolean",
"description": "Enable getter/haser auto-binding for this field"
},
"batch": {
"type": "boolean",
"description": "Enable batch resolver generation for this field to reduce N+1 queries"
},
"forceGenerate": {
"type": "boolean",
"description": "Force generate this field in the model even when OmitResolverFields is enabled"
}
}
}
},
"enum_values": {
"type": "object",
"description": "Custom enum value mappings",
"additionalProperties": {
"type": "object"
}
},
"extraFields": {
"type": "object",
"description": "Additional named fields to add to the generated model",
"additionalProperties": {
"type": "object",
"properties": {
"type": { "type": "string", "description": "Go type of the extra field" },
"overrideTags": { "type": "string", "description": "Override the Go struct tag" },
"description": { "type": "string", "description": "Go doc-comment for the field" }
}
}
},
"embedExtraFields": {
"type": "array",
"description": "Embeddable extra fields to add to the generated model",
"items": {
"type": "object",
"properties": {
"type": { "type": "string", "description": "Go type of the extra field" },
"overrideTags": { "type": "string", "description": "Override the Go struct tag" },
"description": { "type": "string", "description": "Go doc-comment for the field" }
}
}
}
}
}
},
"struct_tag": {
"description": "Tag to use for model fields (e.g. json)",
"type": "string",
"default": "json"
},
"embedded_structs_prefix": {
"description": "Prefix for embedded structs",
"type": "string",
"default": "Base"
},
"directives": {
"description": "Custom directive configuration",
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"skip_runtime": {
"type": "boolean",
"description": "Skip runtime directive hook generation"
},
"implementation": {
"type": "string",
"description": "Static implementation function for the directive"
}
}
}
},
"local_prefix": {
"description": "Local package prefix for import sorting",
"type": "string"
},
"omit_slice_element_pointers": {
"description": "Turn on to use []Thing instead of []*Thing",
"type": "boolean",
"default": false
},
"omit_getters": {
"description": "Turn on to omit getter methods on models",
"type": "boolean",
"default": false
},
"omit_interface_checks": {
"description": "Turn on to omit Is() methods to interface and unions",
"type": "boolean",
"default": true
},
"omit_complexity": {
"description": "Turn on to skip generation of ComplexityRoot struct content and Complexity function",
"type": "boolean",
"default": false
},
"omit_gqlgen_file_notice": {
"description": "Turn on to not generate any file notice comments in generated files",
"type": "boolean",
"default": false
},
"omit_gqlgen_version_in_file_notice": {
"description": "Turn on to exclude the gqlgen version in the generated file notice",
"type": "boolean",
"default": false
},
"omit_root_models": {
"description": "Turn on to exclude root models such as Query and Mutation from the generated models file",
"type": "boolean",
"default": false
},
"omit_resolver_fields": {
"description": "Turn on to exclude resolver fields from the generated models file",
"type": "boolean",
"default": false
},
"omit_panic_handler": {
"description": "Turn on to omit panic handler in the generated server",
"type": "boolean",
"default": false
},
"omit_enum_json_marshalers": {
"description": "Turn on to omit JSON marshaler/unmarshaler generation for enums",
"type": "boolean",
"default": false
},
"struct_fields_always_pointers": {
"description": "Turn off to make struct-type struct fields not use pointers",
"type": "boolean",
"default": true
},
"resolvers_always_return_pointers": {
"description": "Turn off to make resolvers return values instead of pointers for structs",
"type": "boolean",
"default": true
},
"return_pointers_in_unmarshalinput": {
"description": "Turn on to return pointers instead of values in unmarshalInput",
"type": "boolean",
"default": false
},
"nullable_input_omittable": {
"description": "Wrap nullable input fields with Omittable",
"type": "boolean",
"default": true
},
"enable_model_json_omitempty_tag": {
"description": "Enable adding omitempty to the json tag of generated model fields",
"type": "boolean",
"default": false
},
"enable_model_json_omitzero_tag": {
"description": "Enable adding omitzero to the json tag of generated model fields",
"type": "boolean",
"default": false
},
"skip_validation": {
"description": "Set to speed up generation time by not performing a final validation pass",
"type": "boolean",
"default": false
},
"skip_mod_tidy": {
"description": "Set to skip running 'go mod tidy' when generating server code",
"type": "boolean",
"default": false
},
"fast_validation": {
"description": "Use -gcflags=\"-N -l\" during validation to disable compiler optimizations for faster cold cache builds",
"type": "boolean",
"default": false
},
"skip_import_grouping": {
"description": "Use go/format.Source instead of imports.Process for formatting (faster but no import grouping)",
"type": "boolean",
"default": false
},
"use_light_mode_prefetch": {
"description": "Use light mode (NeedName|NeedFiles|NeedModule) for initial package loading instead of full NeedTypes",
"type": "boolean",
"default": false
},
"use_buffer_pooling": {
"description": "Reuse byte buffers via sync.Pool during code formatting to reduce GC pressure",
"type": "boolean",
"default": false
},
"call_argument_directives_with_null": {
"description": "Argument directives decorating a field with a null value will still be called",
"type": "boolean",
"default": true
},
"use_function_syntax_for_execution_context": {
"description": "Use function syntax for execution context instead of receiver methods",
"type": "boolean",
"default": false
},
"go_build_tags": {
"description": "Set build tags that will be used to load packages",
"type": "array",
"items": { "type": "string" }
},
"go_initialisms": {
"description": "Set to modify the initialisms regarded for Go names",
"type": "object",
"properties": {
"replace_defaults": { "type": "boolean" },
"initialisms": {
"type": "array",
"items": { "type": "string" }
}
}
}
}
}
================================================
FILE: graphql/any.go
================================================
package graphql
import (
"encoding/json"
"io"
)
func MarshalAny(v any) Marshaler {
return WriterFunc(func(w io.Writer) {
err := json.NewEncoder(w).Encode(v)
if err != nil {
panic(err)
}
})
}
func UnmarshalAny(v any) (any, error) {
return v, nil
}
================================================
FILE: graphql/args.go
================================================
package graphql
import (
"context"
)
// ProcessArgField Parses argument value without Execution Context
// This function is called from generated code
func ProcessArgField[T any](
ctx context.Context,
rawArgs map[string]any,
fieldName string,
valueMapperFn func(ctx context.Context, value any) (T, error),
) (T, error) {
value, exists := rawArgs[fieldName]
if !exists {
var zeroVal T
return zeroVal, nil
}
ctx = WithPathContext(ctx, NewPathWithField(fieldName))
return valueMapperFn(ctx, value)
}
// ProcessArgFieldWithEC Parses argument value with Execution Context
// This function is called from generated code
func ProcessArgFieldWithEC[T, EC any](
ctx context.Context,
ec EC,
rawArgs map[string]any,
fieldName string,
valueMapperFn func(ctx context.Context, ec EC, value any) (T, error),
) (T, error) {
value, exists := rawArgs[fieldName]
if !exists {
var zeroVal T
return zeroVal, nil
}
ctx = WithPathContext(ctx, NewPathWithField(fieldName))
return valueMapperFn(ctx, ec, value)
}
================================================
FILE: graphql/args_test.go
================================================
package graphql
import (
"context"
"errors"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/vektah/gqlparser/v2/ast"
)
func TestProcessArgField(t *testing.T) {
tests := []struct {
name string
rawArgs map[string]any
fieldName string
valueMapperFn func(ctx context.Context, value any) (any, error)
expected any
expectedErr string
}{
{
name: "field does not exist",
rawArgs: map[string]any{},
fieldName: "name",
valueMapperFn: func(ctx context.Context, value any) (any, error) {
return "", errors.New("should not be called")
},
},
{
name: "field exists",
rawArgs: map[string]any{"name": "test"},
fieldName: "name",
valueMapperFn: func(ctx context.Context, value any) (any, error) {
path := GetPath(ctx)
assert.Equal(t, ast.Path{ast.PathName("name")}, path)
return value.(string), nil
},
expected: "test",
},
{
name: "valueMapperFn returns an error",
rawArgs: map[string]any{"name": "test"},
fieldName: "name",
valueMapperFn: func(ctx context.Context, value any) (any, error) {
return nil, errors.New("mapper error")
},
expectedErr: "mapper error",
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
actual, err := ProcessArgField(
context.Background(),
test.rawArgs,
test.fieldName,
test.valueMapperFn,
)
if test.expectedErr != "" {
require.EqualError(t, err, test.expectedErr)
} else {
require.NoError(t, err)
assert.Equal(t, test.expected, actual)
}
})
}
}
func TestProcessArgFieldWithEC(t *testing.T) {
type executionContext struct {
someValue string
}
tests := []struct {
name string
ec *executionContext
rawArgs map[string]any
fieldName string
valueMapperFn func(ctx context.Context, ec *executionContext, value any) (any, error)
expected any
expectedErr string
}{
{
name: "field does not exist",
ec: &executionContext{someValue: "test1"},
rawArgs: map[string]any{},
fieldName: "name",
valueMapperFn: func(ctx context.Context, ec *executionContext, value any) (any, error) {
return "", errors.New("should not be called")
},
},
{
name: "field exists",
ec: &executionContext{someValue: "test2"},
rawArgs: map[string]any{"name": "test"},
fieldName: "name",
valueMapperFn: func(ctx context.Context, ec *executionContext, value any) (any, error) {
path := GetPath(ctx)
assert.Equal(t, "test2", ec.someValue)
assert.Equal(t, ast.Path{ast.PathName("name")}, path)
return value.(string), nil
},
expected: "test",
},
{
name: "valueMapperFn returns an error",
ec: &executionContext{someValue: "test3"},
rawArgs: map[string]any{"name": "test"},
fieldName: "name",
valueMapperFn: func(ctx context.Context, ec *executionContext, value any) (any, error) {
assert.Equal(t, "test3", ec.someValue)
return nil, errors.New("mapper error")
},
expectedErr: "mapper error",
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
actual, err := ProcessArgFieldWithEC(
context.Background(),
test.ec,
test.rawArgs,
test.fieldName,
test.valueMapperFn,
)
if test.expectedErr != "" {
require.EqualError(t, err, test.expectedErr)
} else {
require.NoError(t, err)
assert.Equal(t, test.expected, actual)
}
})
}
}
================================================
FILE: graphql/batch.go
================================================
package graphql
import (
"context"
"errors"
"fmt"
"maps"
"sync"
"github.com/vektah/gqlparser/v2/ast"
"github.com/vektah/gqlparser/v2/gqlerror"
)
// BatchErrors represents per-item errors from a batch resolver.
// The returned slice must be the same length as the results slice, with nils for successes.
type BatchErrors interface {
error
Errors() []error
}
// BatchErrorList is a simple BatchErrors implementation backed by a slice.
type BatchErrorList []error
func (e BatchErrorList) Error() string { return "batch resolver returned errors" }
func (e BatchErrorList) Errors() []error { return []error(e) }
func (e BatchErrorList) Unwrap() []error {
if len(e) == 0 {
return nil
}
out := make([]error, 0, len(e))
for _, err := range e {
if err != nil {
out = append(out, err)
}
}
if len(out) == 0 {
return nil
}
return out
}
type batchContextKey struct{}
// BatchParentState holds the batch parent groups for the current context.
type BatchParentState struct {
groups map[string]*BatchParentGroup
}
// BatchParentGroup represents a group of parent objects being resolved together.
type BatchParentGroup struct {
Parents any
fields sync.Map
}
// BatchFieldResult represents the cached result of a batch field resolution.
type BatchFieldResult struct {
once sync.Once
done chan struct{}
Results any
Err error
}
// WithBatchParents adds a batch parent group to the context.
func WithBatchParents(ctx context.Context, typeName string, parents any) context.Context {
prev, _ := ctx.Value(batchContextKey{}).(*BatchParentState)
var groups map[string]*BatchParentGroup
if prev != nil {
groups = make(map[string]*BatchParentGroup, len(prev.groups)+1)
maps.Copy(groups, prev.groups)
} else {
groups = make(map[string]*BatchParentGroup, 1)
}
groups[typeName] = &BatchParentGroup{Parents: parents}
return context.WithValue(ctx, batchContextKey{}, &BatchParentState{groups: groups})
}
// GetBatchParentGroup retrieves the batch parent group for a given type name from context.
func GetBatchParentGroup(ctx context.Context, typeName string) *BatchParentGroup {
state, _ := ctx.Value(batchContextKey{}).(*BatchParentState)
if state == nil {
return nil
}
return state.groups[typeName]
}
// GetFieldResult retrieves or computes the result for a batch field.
func (g *BatchParentGroup) GetFieldResult(
key string,
resolve func() (any, error),
) *BatchFieldResult {
if g == nil {
return nil
}
res, _ := g.fields.LoadOrStore(key, &BatchFieldResult{done: make(chan struct{})})
result := res.(*BatchFieldResult)
result.once.Do(func() {
defer close(result.done)
result.Results, result.Err = resolve()
})
<-result.done
return result
}
// BatchParentIndex returns the index of the current parent in the batch from the path.
func BatchParentIndex(ctx context.Context) (ast.PathIndex, bool) {
path := GetPath(ctx)
if len(path) < 2 {
return 0, false
}
if idx, ok := path[len(path)-2].(ast.PathIndex); ok {
return idx, true
}
return 0, false
}
// BatchPathWithIndex returns a copy of the current path with the parent index replaced.
func BatchPathWithIndex(ctx context.Context, index int) ast.Path {
path := GetPath(ctx)
if len(path) < 2 {
return path
}
if _, ok := path[len(path)-2].(ast.PathIndex); !ok {
return path
}
copied := make(ast.Path, len(path))
copy(copied, path)
copied[len(path)-2] = ast.PathIndex(index)
return copied
}
// AddBatchError adds an error for a specific index in a batch operation.
func AddBatchError(ctx context.Context, index int, err error) {
if err == nil {
return
}
path := BatchPathWithIndex(ctx, index)
if list, ok := err.(gqlerror.List); ok {
for _, item := range list {
if item == nil {
continue
}
if item.Path == nil {
cloned := *item
cloned.Path = path
AddError(ctx, &cloned)
continue
}
AddError(ctx, item)
}
return
}
var gqlErr *gqlerror.Error
if errors.As(err, &gqlErr) {
if gqlErr.Path == nil {
cloned := *gqlErr
cloned.Path = path
AddError(ctx, &cloned)
return
}
AddError(ctx, gqlErr)
return
}
AddError(ctx, gqlerror.WrapPath(path, err))
}
// ResolveBatchGroupResult handles batch resolver results for grouped parents.
func ResolveBatchGroupResult[T any](
ctx context.Context,
idx ast.PathIndex,
parentsLen int,
result *BatchFieldResult,
fieldName string,
) (any, error) {
idxInt := int(idx)
if result.Err != nil {
if batchErrs, ok := result.Err.(BatchErrors); ok {
results, ok := result.Results.([]T)
if !ok {
AddBatchError(ctx, idxInt, fmt.Errorf(
"batch resolver %s returned unexpected result type (index %d)",
fieldName,
idx,
))
return nil, nil
}
errs := batchErrs.Errors()
if len(results) != parentsLen {
AddBatchError(ctx, idxInt, fmt.Errorf(
"index %d: batch resolver %s returned %d results for %d parents",
idx,
fieldName,
len(results),
parentsLen,
))
return nil, nil
}
if len(errs) != parentsLen {
AddBatchError(ctx, idxInt, fmt.Errorf(
"index %d: batch resolver %s returned %d errors for %d parents",
idx,
fieldName,
len(errs),
parentsLen,
))
return nil, nil
}
if idxInt < 0 || idxInt >= len(results) {
AddBatchError(ctx, idxInt, fmt.Errorf(
"batch resolver %s could not resolve parent index %d",
fieldName,
idx,
))
return nil, nil
}
if err := errs[idxInt]; err != nil {
AddBatchError(ctx, idxInt, err)
return nil, nil
}
return results[idxInt], nil
}
AddBatchError(ctx, idxInt, result.Err)
return nil, nil
}
results, ok := result.Results.([]T)
if !ok {
AddBatchError(ctx, idxInt, fmt.Errorf(
"batch resolver %s returned unexpected result type (index %d)",
fieldName,
idx,
))
return nil, nil
}
if len(results) != parentsLen {
AddBatchError(ctx, idxInt, fmt.Errorf(
"index %d: batch resolver %s returned %d results for %d parents",
idx,
fieldName,
len(results),
parentsLen,
))
return nil, nil
}
if idxInt < 0 || idxInt >= len(results) {
AddBatchError(ctx, idxInt, fmt.Errorf(
"batch resolver %s could not resolve parent index %d",
fieldName,
idx,
))
return nil, nil
}
return results[idxInt], nil
}
// ResolveBatchSingleResult handles batch resolver results for a single parent.
func ResolveBatchSingleResult[T any](
ctx context.Context,
results []T,
err error,
fieldName string,
) (any, error) {
if err != nil {
if batchErrs, ok := err.(BatchErrors); ok {
errs := batchErrs.Errors()
if len(results) != 1 {
AddBatchError(ctx, 0, fmt.Errorf(
"batch resolver %s returned %d results for %d parents (index %d)",
fieldName,
len(results),
1,
0,
))
return nil, nil
}
if len(errs) != 1 {
AddBatchError(ctx, 0, fmt.Errorf(
"batch resolver %s returned %d errors for %d parents (index %d)",
fieldName,
len(errs),
1,
0,
))
return nil, nil
}
if errs[0] != nil {
AddBatchError(ctx, 0, errs[0])
return nil, nil
}
return results[0], nil
}
AddBatchError(ctx, 0, err)
return nil, nil
}
if len(results) != 1 {
AddBatchError(ctx, 0, fmt.Errorf(
"batch resolver %s returned %d results for %d parents (index %d)",
fieldName,
len(results),
1,
0,
))
return nil, nil
}
return results[0], nil
}
================================================
FILE: graphql/batch_test.go
================================================
package graphql
import (
"context"
"errors"
"testing"
"github.com/stretchr/testify/require"
"github.com/vektah/gqlparser/v2/ast"
)
func TestBatchErrorList_UnwrapFiltersNil(t *testing.T) {
sentinel := errors.New("sentinel")
list := BatchErrorList{nil, sentinel, nil}
type unwrapper interface {
Unwrap() []error
}
u, ok := any(list).(unwrapper)
require.True(t, ok)
got := u.Unwrap()
require.Len(t, got, 1)
require.Equal(t, sentinel, got[0])
}
func TestBatchErrorList_ErrorsIs(t *testing.T) {
sentinel := errors.New("sentinel")
other := errors.New("other")
list := BatchErrorList{nil, sentinel, other}
require.ErrorIs(t, list, sentinel)
require.ErrorIs(t, list, other)
require.NotErrorIs(t, list, errors.New("missing"))
}
func TestBatchErrorList_ErrorsIsWithAllNil(t *testing.T) {
list := BatchErrorList{nil, nil}
require.NotErrorIs(t, list, errors.New("missing"))
}
func newBatchTestContext() context.Context {
ctx := WithResponseContext(context.Background(), DefaultErrorPresenter, nil)
ctx = WithPathContext(ctx, NewPathWithField("users"))
ctx = WithPathContext(ctx, NewPathWithIndex(0))
ctx = WithPathContext(ctx, NewPathWithField("profile"))
return ctx
}
func TestResolveBatchGroupResult_Success(t *testing.T) {
ctx := newBatchTestContext()
result := &BatchFieldResult{
Results: []string{"a", "b"},
}
got, err := ResolveBatchGroupResult[string](
ctx,
ast.PathIndex(1),
2,
result,
"User.profile",
)
require.NoError(t, err)
require.Equal(t, "b", got)
require.Empty(t, GetErrors(ctx))
}
func TestResolveBatchGroupResult_ResultLenMismatch(t *testing.T) {
ctx := newBatchTestContext()
result := &BatchFieldResult{
Results: []string{"a"},
}
got, err := ResolveBatchGroupResult[string](
ctx,
ast.PathIndex(1),
2,
result,
"User.profile",
)
require.NoError(t, err)
require.Nil(t, got)
errs := GetErrors(ctx)
require.Len(t, errs, 1)
require.Equal(
t,
"index 1: batch resolver User.profile returned 1 results for 2 "+
"parents",
errs[0].Message,
)
require.Equal(
t,
ast.Path{
ast.PathName("users"),
ast.PathIndex(1),
ast.PathName("profile"),
},
errs[0].Path,
)
}
func TestResolveBatchSingleResult_BatchErrors(t *testing.T) {
ctx := newBatchTestContext()
got, err := ResolveBatchSingleResult[string](
ctx,
[]string{"a"},
BatchErrorList{errors.New("boom")},
"User.profile",
)
require.NoError(t, err)
require.Nil(t, got)
errs := GetErrors(ctx)
require.Len(t, errs, 1)
require.Equal(t, "boom", errs[0].Message)
}
func TestResolveBatchSingleResult_ErrorLenMismatch(t *testing.T) {
ctx := newBatchTestContext()
got, err := ResolveBatchSingleResult[string](
ctx,
[]string{"a"},
BatchErrorList{},
"User.profile",
)
require.NoError(t, err)
require.Nil(t, got)
errs := GetErrors(ctx)
require.Len(t, errs, 1)
require.Equal(
t,
"batch resolver User.profile returned 0 errors for 1 "+
"parents (index 0)",
errs[0].Message,
)
}
================================================
FILE: graphql/bool.go
================================================
package graphql
import (
"fmt"
"io"
"strconv"
"strings"
)
func MarshalBoolean(b bool) Marshaler {
str := strconv.FormatBool(b)
return WriterFunc(func(w io.Writer) { w.Write([]byte(str)) })
}
func UnmarshalBoolean(v any) (bool, error) {
switch v := v.(type) {
case string:
return strings.EqualFold(v, "true"), nil
case int:
return v != 0, nil
case bool:
return v, nil
case nil:
return false, nil
default:
return false, fmt.Errorf("%T is not a bool", v)
}
}
================================================
FILE: graphql/bool_test.go
================================================
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()
}
================================================
FILE: graphql/cache.go
================================================
package graphql
import "context"
// Cache is a shared store for APQ and query AST caching
type Cache[T any] interface {
// Get looks up a key's value from the cache.
Get(ctx context.Context, key string) (value T, ok bool)
// Add adds a value to the cache.
Add(ctx context.Context, key string, value T)
}
// MapCache is the simplest implementation of a cache, because it can not evict it should only be
// used in tests
type MapCache[T any] map[string]T
// Get looks up a key's value from the cache.
func (m MapCache[T]) Get(_ context.Context, key string) (value T, ok bool) {
v, ok := m[key]
return v, ok
}
// Add adds a value to the cache.
func (m MapCache[T]) Add(_ context.Context, key string, value T) { m[key] = value }
type NoCache[T any] struct{}
var _ Cache[string] = (*NoCache[string])(nil)
func (n NoCache[T]) Get(_ context.Context, _ string) (value T, ok bool) {
var val T
return val, false
}
func (n NoCache[T]) Add(_ context.Context, _ string, _ T) {}
================================================
FILE: graphql/cache_test.go
================================================
package graphql
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
)
func TestMapCache(t *testing.T) {
t.Run("Add and Get", func(t *testing.T) {
cache := MapCache[string]{}
ctx := context.Background()
key := "testKey"
value := "testValue"
// Test Add
cache.Add(ctx, key, value)
val, ok := cache[key]
assert.True(t, ok, "Key should exist in cache")
assert.Equal(t, value, val, "Cache should return the correct value for a key")
// Test Get
gotValue, ok := cache.Get(ctx, key)
assert.True(t, ok, "Get should find the key")
assert.Equal(t, value, gotValue, "Get should return the correct value")
})
}
func TestMapCacheMultipleEntries(t *testing.T) {
t.Run("Multiple Add and Get", func(t *testing.T) {
cache := MapCache[string]{}
ctx := context.Background()
// Define multiple key-value pairs
entries := map[string]string{
"key1": "value1",
"key2": "value2",
"key3": "value3",
}
// Test Add for multiple entries
for key, value := range entries {
cache.Add(ctx, key, value)
val, ok := cache[key]
assert.True(t, ok, "Key %s should exist in cache", key)
assert.Equal(t, value, val, "Cache should return the correct value for key %s", key)
}
// Test Get for multiple entries
for key, expectedValue := range entries {
gotValue, ok := cache.Get(ctx, key)
assert.True(t, ok, "Get should find the key %s", key)
assert.Equal(
t,
expectedValue,
gotValue,
"Get should return the correct value for key %s",
key,
)
}
})
}
func TestMapCacheEdgeCases(t *testing.T) {
type testCase struct {
name string
key string
value string
initialVal string // Initial value if needed (for overwrite tests)
wantValue string
wantOk bool
}
tests := []testCase{
{
name: "Empty Key",
key: "",
value: "valueForEmptyKey",
wantValue: "valueForEmptyKey",
wantOk: true,
},
{
name: "Very Long Key",
key: "key" + string(make([]rune, 10000)),
value: "valueForLongKey",
wantValue: "valueForLongKey",
wantOk: true,
},
{
name: "Overwrite Existing Key",
key: "testKey",
initialVal: "initialValue",
value: "newValue",
wantValue: "newValue",
wantOk: true,
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
cache := MapCache[string]{}
ctx := context.Background()
// Set initial value if needed
if tc.initialVal != "" {
cache.Add(ctx, tc.key, tc.initialVal)
}
// Add the main value
cache.Add(ctx, tc.key, tc.value)
// Test Get
gotValue, ok := cache.Get(ctx, tc.key)
assert.Equal(t, tc.wantOk, ok, "Expected ok to be %v", tc.wantOk)
assert.Equal(t, tc.wantValue, gotValue, "Expected value to be %v", tc.wantValue)
})
}
}
func TestNoCache(t *testing.T) {
t.Run("Add and Get", func(t *testing.T) {
cache := NoCache[*string]{}
ctx := context.Background()
key := "testKey"
value := "testValue"
// Test Add
cache.Add(ctx, key, &value) // Should do nothing
// Test Get
gotValue, ok := cache.Get(ctx, key)
assert.False(t, ok, "Get should not find the key")
assert.Nil(t, gotValue, "Get should return nil for any key")
})
}
func TestNoCacheMultipleEntries(t *testing.T) {
t.Run("Multiple Add and Get", func(t *testing.T) {
cache := NoCache[*string]{}
ctx := context.Background()
// Define multiple key-value pairs
entries := map[string]string{
"key1": "value1",
"key2": "value2",
"key3": "value3",
}
// Test Add for multiple entries
for key, value := range entries {
cache.Add(ctx, key, &value) // Should do nothing
}
// Test Get for multiple entries
for key := range entries {
gotValue, ok := cache.Get(ctx, key)
assert.False(t, ok, "Get should not find the key %s", key)
assert.Nil(t, gotValue, "Get should return nil for key %s", key)
}
})
}
func TestNoCacheEdgeCases(t *testing.T) {
type testCase struct {
name string
key string
value string
wantOk bool
wantValue *string
}
tests := []testCase{
{
name: "Get After Add",
key: "anyKey",
value: "anyValue",
wantOk: false,
wantValue: nil,
},
{
name: "Empty Key",
key: "",
value: "value",
wantOk: false,
wantValue: nil,
},
{
name: "Very Long Key",
key: "key" + string(make([]rune, 10000)),
value: "value",
wantOk: false,
wantValue: nil,
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
cache := NoCache[*string]{}
ctx := context.Background()
// Test Add
cache.Add(ctx, tc.key, &tc.value)
// Test Get
gotValue, ok := cache.Get(ctx, tc.key)
assert.Equal(t, tc.wantOk, ok, "Get should not find the key")
assert.Equal(t, tc.wantValue, gotValue, "Get should return nil for any key")
})
}
}
================================================
FILE: graphql/coercion.go
================================================
package graphql
import (
"encoding/json"
)
// CoerceList applies coercion from a single value to a list.
func CoerceList(v any) []any {
var vSlice []any
if v == nil {
return vSlice
}
switch v := v.(type) {
case []any:
// already a slice no coercion required
vSlice = v
case []string:
if len(v) > 0 {
vSlice = []any{v[0]}
}
case []json.Number:
if len(v) > 0 {
vSlice = []any{v[0]}
}
case []bool:
if len(v) > 0 {
vSlice = []any{v[0]}
}
case []map[string]any:
if len(v) > 0 {
vSlice = []any{v[0]}
}
case []float64:
if len(v) > 0 {
vSlice = []any{v[0]}
}
case []float32:
if len(v) > 0 {
vSlice = []any{v[0]}
}
case []int:
if len(v) > 0 {
vSlice = []any{v[0]}
}
case []int32:
if len(v) > 0 {
vSlice = []any{v[0]}
}
case []int64:
if len(v) > 0 {
vSlice = []any{v[0]}
}
default:
vSlice = []any{v}
}
return vSlice
}
================================================
FILE: graphql/coercion_test.go
================================================
package graphql
import (
"encoding/json"
"testing"
"github.com/stretchr/testify/assert"
)
func TestCoerceList(t *testing.T) {
mapInput := map[string]any{
"test": "value",
"nested": map[string]any{
"nested": true,
},
}
jsonNumber := json.Number("12")
assert.Equal(t, []any{"test", "values"}, CoerceList([]any{"test", "values"}))
assert.Equal(t, []any{"test"}, CoerceList("test"))
assert.Equal(t, []any{"test"}, CoerceList([]string{"test"}))
assert.Equal(t, []any{3}, CoerceList([]int{3}))
assert.Equal(t, []any{3}, CoerceList(3))
assert.Equal(t, []any{int32(3)}, CoerceList([]int32{3}))
assert.Equal(t, []any{int64(2)}, CoerceList([]int64{2}))
assert.Equal(t, []any{float32(3.14)}, CoerceList([]float32{3.14}))
assert.Equal(t, []any{3.14}, CoerceList([]float64{3.14}))
assert.Equal(t, []any{jsonNumber}, CoerceList([]json.Number{jsonNumber}))
assert.Equal(t, []any{jsonNumber}, CoerceList(jsonNumber))
assert.Equal(t, []any{true}, CoerceList([]bool{true}))
assert.Equal(t, []any{mapInput}, CoerceList(mapInput))
assert.Equal(t, []any{mapInput}, CoerceList([]any{mapInput}))
assert.Equal(t, []any{mapInput}, CoerceList([]map[string]any{mapInput}))
assert.Empty(t, CoerceList(nil))
}
================================================
FILE: graphql/collect_fields_cache_integration_test.go
================================================
package graphql
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/vektah/gqlparser/v2"
"github.com/vektah/gqlparser/v2/ast"
"github.com/vektah/gqlparser/v2/validator/rules"
)
const collectFieldsSchemaSDL = `
interface Node {
name: String!
email: String
}
type User implements Node {
name: String!
email: String
}
type Admin implements Node {
name: String!
email: String
secret: String
}
type Query {
search: [Node!]!
user: User!
}
`
var collectFieldsSchema = gqlparser.MustLoadSchema(&ast.Source{
Name: "collectFieldsCache",
Input: collectFieldsSchemaSDL,
})
func TestCollectFieldsCache_InterfaceResult(t *testing.T) {
const query = `
query {
search {
name
... on User {
email
}
... on Admin {
secret
}
}
}
`
doc := gqlparser.MustLoadQueryWithRules(collectFieldsSchema, query, rules.NewDefaultRules())
op := doc.Operations[0]
searchField := op.SelectionSet[0].(*ast.Field)
opCtx := &OperationContext{
RawQuery: query,
Variables: nil,
Doc: doc,
Operation: op,
}
userFields := CollectFields(opCtx, searchField.SelectionSet, []string{"User"})
adminFields := CollectFields(opCtx, searchField.SelectionSet, []string{"Admin"})
require.ElementsMatch(t, []string{"name", "email"}, fieldNames(userFields))
require.ElementsMatch(t, []string{"name", "secret"}, fieldNames(adminFields))
require.Equal(t, 2, opCtx.collectFieldsCache.Len())
}
func TestCollectFieldsCache_AliasResult(t *testing.T) {
const query = `
query {
user1: user { name }
user2: user { email }
}
`
doc := gqlparser.MustLoadQueryWithRules(collectFieldsSchema, query, rules.NewDefaultRules())
op := doc.Operations[0]
opCtx := &OperationContext{
RawQuery: query,
Variables: nil,
Doc: doc,
Operation: op,
}
fields := CollectFields(opCtx, op.SelectionSet, nil)
require.Equal(t, 1, opCtx.collectFieldsCache.Len())
require.Len(t, fields, 2)
expected := []struct {
alias string
expectedName string
}{
{alias: "user1", expectedName: "name"},
{alias: "user2", expectedName: "email"},
}
for _, check := range expected {
var matched bool
for _, f := range fields {
alias := f.Alias
if alias == "" {
alias = f.Name
}
if alias == check.alias {
require.Equal(t, []string{check.expectedName}, selectionNames(f.Selections))
matched = true
break
}
}
require.True(t, matched, "expected alias %q not found", check.alias)
}
}
func TestCollectFieldsCache_DirectiveResult(t *testing.T) {
const query = `
query Test($includeEmail: Boolean!, $skipName: Boolean!) {
search {
... on User {
name @skip(if: $skipName)
email @include(if: $includeEmail)
}
}
}
`
run := func(vars map[string]any) ([]CollectedField, int) {
doc := gqlparser.MustLoadQueryWithRules(collectFieldsSchema, query, rules.NewDefaultRules())
op := doc.Operations[0]
searchField := op.SelectionSet[0].(*ast.Field)
opCtx := &OperationContext{
RawQuery: query,
Variables: vars,
Doc: doc,
Operation: op,
}
first := CollectFields(opCtx, searchField.SelectionSet, []string{"User"})
second := CollectFields(opCtx, searchField.SelectionSet, []string{"User"})
require.Equal(t, first, second)
return first, opCtx.collectFieldsCache.Len()
}
fieldsA, cacheA := run(map[string]any{"includeEmail": false, "skipName": false})
require.Equal(t, 1, cacheA)
require.Equal(t, []string{"name"}, fieldNames(fieldsA))
fieldsB, cacheB := run(map[string]any{"includeEmail": true, "skipName": true})
require.Equal(t, 1, cacheB)
require.Equal(t, []string{"email"}, fieldNames(fieldsB))
fieldsC, cacheC := run(map[string]any{"includeEmail": false, "skipName": true})
require.Equal(t, 1, cacheC)
require.Empty(t, fieldsC)
fieldsD, cacheD := run(map[string]any{"includeEmail": true, "skipName": false})
require.Equal(t, 1, cacheD)
require.ElementsMatch(t, []string{"name", "email"}, fieldNames(fieldsD))
}
func fieldNames(fields []CollectedField) []string {
names := make([]string, 0, len(fields))
for _, f := range fields {
names = append(names, f.Name)
}
return names
}
func selectionNames(sel ast.SelectionSet) []string {
names := make([]string, 0, len(sel))
for _, s := range sel {
if f, ok := s.(*ast.Field); ok {
names = append(names, f.Name)
}
}
return names
}
================================================
FILE: graphql/collect_fields_cache_store.go
================================================
package graphql
import (
"hash/fnv"
"reflect"
"sync"
"github.com/vektah/gqlparser/v2/ast"
)
// collectFieldsCacheKey is the cache key for CollectFields results.
type collectFieldsCacheKey struct {
selectionPtr uintptr // Pointer to the underlying SelectionSet data
selectionLen int // Length of the selection set
satisfiesHash uint64 // Hash of the satisfies array
}
// collectFieldsCacheStore manages CollectFields cache entries safely.
type collectFieldsCacheStore struct {
mu sync.RWMutex
items map[collectFieldsCacheKey][]CollectedField
}
// Get returns the cached result for the key if present.
func (s *collectFieldsCacheStore) Get(key collectFieldsCacheKey) ([]CollectedField, bool) {
s.mu.RLock()
defer s.mu.RUnlock()
if s.items == nil {
return nil, false
}
val, ok := s.items[key]
return val, ok
}
// Add stores the value when absent and returns the cached value.
func (s *collectFieldsCacheStore) Add(
key collectFieldsCacheKey,
value []CollectedField,
) []CollectedField {
s.mu.Lock()
defer s.mu.Unlock()
if s.items == nil {
s.items = make(map[collectFieldsCacheKey][]CollectedField)
}
if existing, ok := s.items[key]; ok {
return existing
}
s.items[key] = value
return value
}
// Len returns the number of cached entries.
func (s *collectFieldsCacheStore) Len() int {
s.mu.RLock()
defer s.mu.RUnlock()
return len(s.items)
}
// makeCollectFieldsCacheKey generates a cache key for CollectFields.
func makeCollectFieldsCacheKey(selSet ast.SelectionSet, satisfies []string) collectFieldsCacheKey {
var selectionPtr uintptr
if selSet != nil {
selectionPtr = reflect.ValueOf(selSet).Pointer()
}
h := fnv.New64a()
for _, s := range satisfies {
h.Write([]byte(s))
h.Write([]byte{0})
}
return collectFieldsCacheKey{
selectionPtr: selectionPtr,
selectionLen: len(selSet),
satisfiesHash: h.Sum64(),
}
}
================================================
FILE: graphql/config.go
================================================
package graphql
import "github.com/vektah/gqlparser/v2/ast"
// Config holds dependencies for constructing an executable schema.
// R, D, C are generated types from the target schema package.
type Config[R any, D any, C any] struct {
Schema *ast.Schema
Resolvers R
Directives D
Complexity C
}
================================================
FILE: graphql/context_field.go
================================================
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]any
// The raw field
Field CollectedField
// The index of array in path.
Index *int
// The result object of resolver
Result any
// 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) (any, error) {
// fc := graphql.GetFieldContext(ctx)
// opCtx := 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.Printf("child context %q with args: %v\n", 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, b ast.Path) bool {
if len(a) != len(b) {
return false
}
for i := range a {
if a[i] != b[i] {
return false
}
}
return true
}
================================================
FILE: graphql/context_field_test.go
================================================
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
}
================================================
FILE: graphql/context_operation.go
================================================
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]any
OperationName string
Doc *ast.QueryDocument
Extensions map[string]any
Headers http.Header
Operation *ast.OperationDefinition
DisableIntrospection bool
RecoverFunc RecoverFunc
ResolverMiddleware FieldMiddleware
RootResolverMiddleware RootFieldMiddleware
Stats Stats
collectFieldsCache collectFieldsCacheStore
}
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]any)
}
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, opCtx *OperationContext) context.Context {
return context.WithValue(ctx, operationCtx, opCtx)
}
// 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
}
// CollectFieldsCtx 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 ...any) {
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 any) error {
return ErrorOnPath(ctx, c.RecoverFunc(ctx, err))
}
================================================
FILE: graphql/context_operation_test.go
================================================
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 any) any {
return t.opContext
}
func TestGetOperationContext(t *testing.T) {
opCtx := &OperationContext{}
t.Run("with operation context", func(t *testing.T) {
ctx := WithOperationContext(context.Background(), opCtx)
require.True(t, HasOperationContext(ctx))
require.Equal(t, opCtx, 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 TestCollectFields(t *testing.T) {
getNames := func(collected []CollectedField) []string {
names := make([]string, 0, len(collected))
for _, f := range collected {
names = append(names, f.Name)
}
return names
}
var (
trueVal = &ast.Value{Kind: ast.BooleanValue, Raw: "true"}
falseVal = &ast.Value{Kind: ast.BooleanValue, Raw: "false"}
skipTrue = &ast.Directive{
Name: "skip",
Arguments: ast.ArgumentList{{Name: "if", Value: trueVal}},
}
skipFalse = &ast.Directive{
Name: "skip",
Arguments: ast.ArgumentList{{Name: "if", Value: falseVal}},
}
includeTrue = &ast.Directive{
Name: "include",
Arguments: ast.ArgumentList{{Name: "if", Value: trueVal}},
}
includeFalse = &ast.Directive{
Name: "include",
Arguments: ast.ArgumentList{{Name: "if", Value: falseVal}},
}
)
t.Run("handles fields", func(t *testing.T) {
ctx := testContext(ast.SelectionSet{
&ast.Field{
Name: "field",
},
})
resCtx := GetFieldContext(ctx)
collected := CollectFields(GetOperationContext(ctx), resCtx.Field.Selections, nil)
require.Equal(t, []string{"field"}, getNames(collected))
})
t.Run("handles include and skip on fields", func(t *testing.T) {
ctx := testContext(ast.SelectionSet{
&ast.Field{
Name: "fieldA",
},
&ast.Field{
Name: "fieldB",
Directives: ast.DirectiveList{includeTrue},
},
&ast.Field{
Name: "fieldC",
Directives: ast.DirectiveList{includeFalse},
},
&ast.Field{
Name: "fieldD",
Directives: ast.DirectiveList{skipTrue},
},
&ast.Field{
Name: "fieldE",
Directives: ast.DirectiveList{skipFalse},
},
})
resCtx := GetFieldContext(ctx)
collected := CollectFields(GetOperationContext(ctx), resCtx.Field.Selections, nil)
require.Equal(t, []string{"fieldA", "fieldB", "fieldE"}, getNames(collected))
})
t.Run("handles inline fragments that apply", func(t *testing.T) {
ctx := testContext(ast.SelectionSet{
&ast.InlineFragment{
TypeCondition: "ExampleTypeA",
SelectionSet: ast.SelectionSet{
&ast.Field{
Name: "fieldA",
},
},
},
&ast.InlineFragment{
TypeCondition: "ExampleTypeB",
SelectionSet: ast.SelectionSet{
&ast.Field{
Name: "fieldB",
},
},
},
&ast.Field{
Name: "fieldC",
},
})
resCtx := GetFieldContext(ctx)
collected := CollectFields(
GetOperationContext(ctx),
resCtx.Field.Selections,
[]string{"ExampleTypeB"},
)
require.Equal(t, []string{"fieldB", "fieldC"}, getNames(collected))
})
t.Run("handles inline fragment when no type", func(t *testing.T) {
ctx := testContext(ast.SelectionSet{
&ast.InlineFragment{
TypeCondition: "",
SelectionSet: ast.SelectionSet{
&ast.Field{
Name: "fieldA",
},
},
},
&ast.InlineFragment{
TypeCondition: "ExampleTypeB",
SelectionSet: ast.SelectionSet{
&ast.Field{
Name: "fieldB",
},
},
},
&ast.Field{
Name: "fieldC",
},
})
resCtx := GetFieldContext(ctx)
collected := CollectFields(
GetOperationContext(ctx),
resCtx.Field.Selections,
[]string{"ExampleTypeB"},
)
require.Equal(t, []string{"fieldA", "fieldB", "fieldC"}, getNames(collected))
})
t.Run("handles inline fragments with include and skip", func(t *testing.T) {
ctx := testContext(ast.SelectionSet{
&ast.InlineFragment{
TypeCondition: "",
SelectionSet: ast.SelectionSet{
&ast.Field{
Name: "fieldA*",
},
},
Directives: ast.DirectiveList{includeFalse},
},
&ast.InlineFragment{
TypeCondition: "",
SelectionSet: ast.SelectionSet{
&ast.Field{
Name: "fieldA1",
},
&ast.Field{
Name: "fieldA2",
Directives: ast.DirectiveList{skipTrue},
},
},
Directives: ast.DirectiveList{includeTrue},
},
&ast.InlineFragment{
TypeCondition: "ExampleTypeB",
SelectionSet: ast.SelectionSet{
&ast.Field{
Name: "fieldB*",
},
},
Directives: ast.DirectiveList{skipTrue},
},
&ast.InlineFragment{
TypeCondition: "ExampleTypeB",
SelectionSet: ast.SelectionSet{
&ast.Field{
Name: "fieldB1",
},
&ast.Field{
Name: "fieldB2",
Directives: ast.DirectiveList{skipTrue},
},
},
Directives: ast.DirectiveList{skipFalse},
},
&ast.InlineFragment{
TypeCondition: "ExampleTypeC",
SelectionSet: ast.SelectionSet{
&ast.Field{
Name: "fieldC1",
Directives: ast.DirectiveList{includeTrue},
},
&ast.Field{
Name: "fieldC2",
Directives: ast.DirectiveList{includeFalse},
},
},
},
&ast.InlineFragment{
TypeCondition: "ExampleTypeD",
SelectionSet: ast.SelectionSet{
&ast.Field{
Name: "fieldD*",
},
},
Directives: ast.DirectiveList{includeTrue},
},
})
resCtx := GetFieldContext(ctx)
collected := CollectFields(
GetOperationContext(ctx),
resCtx.Field.Selections,
[]string{"ExampleTypeB", "ExampleTypeC"},
)
require.Equal(t, []string{"fieldA1", "fieldB1", "fieldC1"}, getNames(collected))
})
t.Run("collect inline 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,
[]string{"ExampleTypeA", "ExampleTypeB"},
)
require.Len(t, collected, 2)
require.NotEqual(t, collected[0], collected[1])
require.Equal(t, collected[0].Name, collected[1].Name)
})
t.Run("collect inline 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,
[]string{"ExampleTypeA", "ExampleTypeB"},
)
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)
})
t.Run("handles fragment spreads", func(t *testing.T) {
ctx := testContext(ast.SelectionSet{
&ast.FragmentSpread{
Name: "FragmentA",
},
&ast.FragmentSpread{
Name: "FragmentB",
},
&ast.Field{
Name: "fieldC",
},
})
resCtx := GetFieldContext(ctx)
reqCtx := GetOperationContext(ctx)
reqCtx.Doc = &ast.QueryDocument{
Fragments: []*ast.FragmentDefinition{
{
Name: "FragmentA",
TypeCondition: "ExampleTypeA",
SelectionSet: ast.SelectionSet{
&ast.Field{
Name: "fieldA",
},
},
},
{
Name: "FragmentB",
TypeCondition: "ExampleTypeB",
SelectionSet: ast.SelectionSet{
&ast.Field{
Name: "fieldB",
},
},
},
},
}
collected := CollectFields(reqCtx, resCtx.Field.Selections, []string{"ExampleTypeB"})
require.Equal(t, []string{"fieldB", "fieldC"}, getNames(collected))
})
t.Run("handles fragment spreads with directives", func(t *testing.T) {
ctx := testContext(ast.SelectionSet{
&ast.FragmentSpread{
Name: "FragmentA",
Directives: ast.DirectiveList{includeTrue},
},
&ast.FragmentSpread{
Name: "FragmentB",
Directives: ast.DirectiveList{includeFalse},
},
&ast.FragmentSpread{
Name: "FragmentC",
Directives: ast.DirectiveList{skipTrue},
},
&ast.FragmentSpread{
Name: "FragmentD",
Directives: ast.DirectiveList{skipFalse},
},
})
resCtx := GetFieldContext(ctx)
reqCtx := GetOperationContext(ctx)
reqCtx.Doc = &ast.QueryDocument{
Fragments: []*ast.FragmentDefinition{
{
Name: "FragmentA",
TypeCondition: "ExampleTypeA",
SelectionSet: ast.SelectionSet{
&ast.Field{
Name: "fieldA",
},
},
},
{
Name: "FragmentB",
TypeCondition: "ExampleTypeB",
SelectionSet: ast.SelectionSet{
&ast.Field{
Name: "fieldB",
},
},
},
{
Name: "FragmentC",
TypeCondition: "ExampleTypeA",
SelectionSet: ast.SelectionSet{
&ast.Field{
Name: "fieldC",
},
},
},
{
Name: "FragmentD",
TypeCondition: "ExampleTypeB",
SelectionSet: ast.SelectionSet{
&ast.Field{
Name: "fieldD",
},
},
},
},
}
collected := CollectFields(
reqCtx,
resCtx.Field.Selections,
[]string{"ExampleTypeA", "ExampleTypeB"},
)
require.Equal(t, []string{"fieldA", "fieldD"}, getNames(collected))
})
}
func TestCollectAllFields(t *testing.T) {
t.Run(
"collects all fields incl inline fragments and fragment spreads regardless of type",
func(t *testing.T) {
ctx := testContext(ast.SelectionSet{
&ast.Field{
Name: "fieldA",
},
&ast.InlineFragment{
SelectionSet: ast.SelectionSet{
&ast.Field{
Name: "fieldB",
},
},
Directives: ast.DirectiveList{
&ast.Directive{Name: "someDirective"},
},
},
&ast.InlineFragment{
TypeCondition: "ExampleTypeC",
SelectionSet: ast.SelectionSet{
&ast.Field{
Name: "fieldC",
},
},
ObjectDefinition: &ast.Definition{Name: "ExampleTypeC"},
},
&ast.FragmentSpread{
Name: "FragmentD",
},
})
reqCtx := GetOperationContext(ctx)
reqCtx.Doc = &ast.QueryDocument{
Fragments: []*ast.FragmentDefinition{
{
Name: "FragmentD",
TypeCondition: "ExampleTypeD",
SelectionSet: ast.SelectionSet{
&ast.Field{
Name: "fieldD",
},
},
},
},
}
ctx = WithOperationContext(ctx, reqCtx)
require.Equal(
t,
[]string{"fieldA", "fieldB", "fieldC", "fieldD"},
CollectAllFields(ctx),
)
},
)
t.Run("de-dupes aliased field names", func(t *testing.T) {
ctx := testContext(ast.SelectionSet{
&ast.Field{
Name: "field",
},
&ast.Field{
Name: "field",
Alias: "field alias",
},
})
require.Equal(t, []string{"field"}, CollectAllFields(ctx))
})
}
================================================
FILE: graphql/context_path.go
================================================
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
}
================================================
FILE: graphql/context_path_test.go
================================================
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)))
}
================================================
FILE: graphql/context_response.go
================================================
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]any
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 ...any) {
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) {
if err == nil {
return
}
c := getResponseContext(ctx)
presentedError := c.errorPresenter(ctx, ErrorOnPath(ctx, err))
if presentedError == nil {
return
}
c.errorsMu.Lock()
defer c.errorsMu.Unlock()
c.errors = append(c.errors, presentedError)
}
func Recover(ctx context.Context, err any) (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 any) {
c := getResponseContext(ctx)
c.extensionsMu.Lock()
defer c.extensionsMu.Unlock()
if c.extensions == nil {
c.extensions = make(map[string]any)
}
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]any {
ext := getResponseContext(ctx).extensions
if ext == nil {
return map[string]any{}
}
return ext
}
func GetExtension(ctx context.Context, name string) any {
ext := getResponseContext(ctx).extensions
if ext == nil {
return nil
}
return ext[name]
}
================================================
FILE: graphql/context_response_test.go
================================================
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 nilUserPresenter(ctx context.Context, err error) *gqlerror.Error {
return nil
}
var _ ErrorPresenterFunc = nilUserPresenter
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 TestAddError_NilUserPresenter(t *testing.T) {
ctx := WithResponseContext(context.Background(), nilUserPresenter, nil)
nilUserPresenterRoot := &FieldContext{
Field: CollectedField{
Field: &ast.Field{
Alias: "foo",
},
},
}
ctx = WithFieldContext(ctx, nilUserPresenterRoot)
AddError(ctx, errors.New("foo"))
AddError(ctx, errors.New("bar"))
errList := GetFieldErrors(ctx, nilUserPresenterRoot)
require.Empty(t, errList)
}
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.Empty(t, errs)
return DefaultErrorPresenter(ctx, err)
},
nil,
)
ctx = WithFieldContext(ctx, &FieldContext{})
AddError(ctx, errors.New("foo1"))
}
================================================
FILE: graphql/context_root_field.go
================================================
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)
}
================================================
FILE: graphql/context_root_field_test.go
================================================
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)))
}
================================================
FILE: graphql/deferred.go
================================================
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
}
================================================
FILE: graphql/duration.go
================================================
package graphql
import (
"errors"
"time"
dur "github.com/sosodev/duration"
)
// UnmarshalDuration returns the duration from a string in ISO8601 format
// PnDTnHnMn.nS with days considered to be exactly 24 hours.
// See https://en.wikipedia.org/wiki/ISO_8601#Durations
// P - Period
// D - D is the
// T - T is the time designator that precedes the time components
// H - H is the hour designator that follows the value for the number of hours.
// M - M is the minute designator that follows the value for the number of minutes.
// S - S is the second designator that follows the value for the number of seconds.
// "PT20.345S" -- parses as "20.345 seconds"
// "PT15M" -- parses as "15 minutes" (where a minute is 60 seconds)
// "PT10H" -- parses as "10 hours" (where an hour is 3600 seconds)
// "P2D" -- parses as "2 days" (where a day is 24 hours or 86400 seconds)
func UnmarshalDuration(v any) (time.Duration, error) {
input, ok := v.(string)
if !ok {
return 0, errors.New("input must be a string")
}
d2, err := dur.Parse(input)
if err != nil {
return 0, err
}
return d2.ToTimeDuration(), nil
}
// MarshalDuration returns the duration in ISO8601 format
// PnDTnHnMn.nS with days considered to be exactly 24 hours.
// See https://en.wikipedia.org/wiki/ISO_8601#Durations
// P - Period
// D - D is the
// T - T is the time designator that precedes the time components
// H - H is the hour designator that follows the value for the number of hours.
// M - M is the minute designator that follows the value for the number of minutes.
// S - S is the second designator that follows the value for the number of seconds.
// "PT20.345S" -- parses as "20.345 seconds"
// "PT15M" -- parses as "15 minutes" (where a minute is 60 seconds)
// "PT10H" -- parses as "10 hours" (where an hour is 3600 seconds)
// "P2D" -- parses as "2 days" (where a day is 24 hours or 86400 seconds)
func MarshalDuration(d time.Duration) Marshaler {
return MarshalString(dur.Format(d))
}
================================================
FILE: graphql/duration_test.go
================================================
package graphql
import (
"bytes"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestDurationMarshaling(t *testing.T) {
t.Run("UnmarshalDuration", func(t *testing.T) {
d, err := UnmarshalDuration("P2Y")
require.NoError(t, err)
assert.InEpsilon(t, float64(365*24*2), d.Hours(), 0.02)
})
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())
})
}
================================================
FILE: graphql/errcode/codes.go
================================================
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]any{}
}
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
}
================================================
FILE: graphql/error.go
================================================
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 {
if err == nil {
return nil
}
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)
}
================================================
FILE: graphql/executable_schema.go
================================================
//go:generate go run github.com/matryer/moq -out executable_schema_mock.go . ExecutableSchema
package graphql
import (
"context"
"fmt"
"slices"
"github.com/vektah/gqlparser/v2/ast"
)
type ExecutableSchema interface {
Schema() *ast.Schema
Complexity(
ctx context.Context,
typeName, fieldName string,
childComplexity int,
args map[string]any,
) (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 slice for
// satisfies will collect all fields regardless of fragment type conditions.
func CollectFields(
reqCtx *OperationContext,
selSet ast.SelectionSet,
satisfies []string,
) []CollectedField {
cacheKey := makeCollectFieldsCacheKey(selSet, satisfies)
if cached, ok := reqCtx.collectFieldsCache.Get(cacheKey); ok {
return cached
}
result := collectFields(reqCtx, selSet, satisfies, map[string]bool{})
return reqCtx.collectFieldsCache.Add(cacheKey, result)
}
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 !doesFragmentConditionMatch(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:
fragmentName := sel.Name
if _, seen := visited[fragmentName]; seen {
continue
}
if !shouldIncludeNode(sel.Directives, reqCtx.Variables) {
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 !doesFragmentConditionMatch(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 doesFragmentConditionMatch(typeCondition string, satisfies []string) bool {
// To allow simplified "collect all" types behavior, pass an empty list of types
// that the type condition must satisfy: we will apply the fragment regardless of
// type condition.
if len(satisfies) == 0 {
return true
}
// When the type condition is not set (... { field }) we will apply the fragment
// to any satisfying types.
if typeCondition == "" {
return true
}
// To handle abstract types we pass in a list of all known types that the current
// type will satisfy.
return slices.Contains(satisfies, typeCondition)
}
func getOrCreateAndAppendField(
c *[]CollectedField,
name, 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]
}
if slices.Contains(objectDefinition.Interfaces, cf.ObjectDefinition.Name) {
return &(*c)[i]
}
if slices.Contains(cf.ObjectDefinition.Interfaces, objectDefinition.Name) {
return &(*c)[i]
}
}
}
f := creator()
*c = append(*c, f)
return &(*c)[len(*c)-1]
}
func shouldIncludeNode(directives ast.DirectiveList, variables map[string]any) 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]any,
) (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]any) 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
}
================================================
FILE: graphql/executable_schema_mock.go
================================================
// 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(ctx context.Context, typeName string, fieldName string, childComplexity int, args map[string]any) (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(ctx context.Context, typeName string, fieldName string, childComplexity int, args map[string]any) (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 {
// Ctx is the ctx argument value.
Ctx context.Context
// 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]any
}
// 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(ctx context.Context, typeName string, fieldName string, childComplexity int, args map[string]any) (int, bool) {
if mock.ComplexityFunc == nil {
panic("ExecutableSchemaMock.ComplexityFunc: method is nil but ExecutableSchema.Complexity was just called")
}
callInfo := struct {
Ctx context.Context
TypeName string
FieldName string
ChildComplexity int
Args map[string]any
}{
Ctx: ctx,
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(ctx, 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 {
Ctx context.Context
TypeName string
FieldName string
ChildComplexity int
Args map[string]any
} {
var calls []struct {
Ctx context.Context
TypeName string
FieldName string
ChildComplexity int
Args map[string]any
}
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
}
================================================
FILE: graphql/executable_schema_state.go
================================================
package graphql
import "github.com/vektah/gqlparser/v2/ast"
// ExecutableSchemaState stores generated executable schema dependencies.
// Generated code defines its local executableSchema type from this one.
type ExecutableSchemaState[R any, D any, C any] struct {
SchemaData *ast.Schema
Resolvers R
Directives D
ComplexityRoot C
}
================================================
FILE: graphql/execution_context_state.go
================================================
package graphql
import (
"errors"
"sync/atomic"
"github.com/vektah/gqlparser/v2/ast"
"github.com/99designs/gqlgen/graphql/introspection"
)
// ExecutionContextState stores generated execution context dependencies and state.
// Generated code defines its local executionContext type from this one.
type ExecutionContextState[R any, D any, C any] struct {
*OperationContext
*ExecutableSchemaState[R, D, C]
ParsedSchema *ast.Schema
Deferred int32
PendingDeferred int32
DeferredResults chan DeferredResult
}
func NewExecutionContextState[R any, D any, C any](
operationContext *OperationContext,
executableSchemaState *ExecutableSchemaState[R, D, C],
parsedSchema *ast.Schema,
deferredResults chan DeferredResult,
) *ExecutionContextState[R, D, C] {
return &ExecutionContextState[R, D, C]{
OperationContext: operationContext,
ExecutableSchemaState: executableSchemaState,
ParsedSchema: parsedSchema,
DeferredResults: deferredResults,
}
}
func (ec *ExecutionContextState[R, D, C]) Schema() *ast.Schema {
if ec.SchemaData != nil {
return ec.SchemaData
}
return ec.ParsedSchema
}
func (ec *ExecutionContextState[R, D, C]) ProcessDeferredGroup(dg DeferredGroup) {
atomic.AddInt32(&ec.PendingDeferred, 1)
go func() {
ctx := WithFreshResponseContext(dg.Context)
dg.FieldSet.Dispatch(ctx)
ds := DeferredResult{
Path: dg.Path,
Label: dg.Label,
Result: dg.FieldSet,
Errors: GetErrors(ctx),
}
// null fields should bubble up
if dg.FieldSet.Invalids > 0 {
ds.Result = Null
}
ec.DeferredResults <- ds
}()
}
func (ec *ExecutionContextState[R, D, C]) IntrospectSchema() (*introspection.Schema, error) {
if ec.DisableIntrospection {
return nil, errors.New("introspection disabled")
}
return introspection.WrapSchema(ec.Schema()), nil
}
func (ec *ExecutionContextState[R, D, C]) 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
}
================================================
FILE: graphql/execution_context_state_test.go
================================================
package graphql
import (
"context"
"errors"
"sync/atomic"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/vektah/gqlparser/v2/ast"
)
type (
testResolverRoot struct{}
testDirectiveRoot struct{}
testComplexityRoot struct{}
)
func newTestExecutionContextState(
opCtx *OperationContext,
schemaData *ast.Schema,
parsedSchema *ast.Schema,
deferredResults chan DeferredResult,
) *ExecutionContextState[testResolverRoot, testDirectiveRoot, testComplexityRoot] {
if opCtx == nil {
opCtx = &OperationContext{}
}
if deferredResults == nil {
deferredResults = make(chan DeferredResult, 1)
}
return NewExecutionContextState[testResolverRoot, testDirectiveRoot, testComplexityRoot](
opCtx,
&ExecutableSchemaState[testResolverRoot, testDirectiveRoot, testComplexityRoot]{
SchemaData: schemaData,
},
parsedSchema,
deferredResults,
)
}
func receiveDeferredResult(t *testing.T, ch <-chan DeferredResult) DeferredResult {
t.Helper()
select {
case res := <-ch:
return res
case <-time.After(2 * time.Second):
t.Fatal("timed out waiting for deferred result")
return DeferredResult{}
}
}
func makeSchemaWithType(typeName string) *ast.Schema {
query := &ast.Definition{Name: "Query", Kind: ast.Object}
typ := &ast.Definition{Name: typeName, Kind: ast.Object}
return &ast.Schema{
Query: query,
Types: map[string]*ast.Definition{
"Query": query,
typeName: typ,
},
Directives: map[string]*ast.DirectiveDefinition{},
}
}
func TestExecutionContextState_Schema(t *testing.T) {
schemaData := makeSchemaWithType("SchemaDataType")
parsedSchema := makeSchemaWithType("ParsedType")
ec := newTestExecutionContextState(
&OperationContext{},
schemaData,
parsedSchema,
nil,
)
assert.Same(t, schemaData, ec.Schema())
}
func TestExecutionContextState_Schema_FallsBackToParsedSchema(t *testing.T) {
parsedSchema := makeSchemaWithType("ParsedType")
ec := newTestExecutionContextState(
&OperationContext{},
nil,
parsedSchema,
nil,
)
assert.Same(t, parsedSchema, ec.Schema())
}
func TestExecutionContextState_IntrospectionDisabled(t *testing.T) {
ec := newTestExecutionContextState(
&OperationContext{DisableIntrospection: true},
nil,
makeSchemaWithType("Foo"),
nil,
)
schema, schemaErr := ec.IntrospectSchema()
require.Error(t, schemaErr)
require.EqualError(t, schemaErr, "introspection disabled")
assert.Nil(t, schema)
typ, typeErr := ec.IntrospectType("Foo")
require.Error(t, typeErr)
require.EqualError(t, typeErr, "introspection disabled")
assert.Nil(t, typ)
}
func TestExecutionContextState_IntrospectType(t *testing.T) {
ec := newTestExecutionContextState(
&OperationContext{},
nil,
makeSchemaWithType("Foo"),
nil,
)
typ, err := ec.IntrospectType("Foo")
require.NoError(t, err)
require.NotNil(t, typ)
name := typ.Name()
require.NotNil(t, name)
assert.Equal(t, "Foo", *name)
missing, missingErr := ec.IntrospectType("Missing")
require.NoError(t, missingErr)
assert.Nil(t, missing)
}
func TestExecutionContextState_ProcessDeferredGroup_IncrementsPendingAndPropagates(t *testing.T) {
deferredResults := make(chan DeferredResult, 1)
ec := newTestExecutionContextState(
&OperationContext{},
nil,
makeSchemaWithType("Foo"),
deferredResults,
)
ctx := WithResponseContext(context.Background(), DefaultErrorPresenter, DefaultRecover)
fieldSet := NewFieldSet([]CollectedField{{Field: &ast.Field{Alias: "value"}}})
fieldSet.Concurrently(0, func(ctx context.Context) Marshaler {
return MarshalString("ok")
})
path := ast.Path{ast.PathName("query")}
label := "group-1"
ec.ProcessDeferredGroup(DeferredGroup{
Path: path,
Label: label,
FieldSet: fieldSet,
Context: ctx,
})
assert.Equal(t, int32(1), atomic.LoadInt32(&ec.PendingDeferred))
result := receiveDeferredResult(t, deferredResults)
assert.Equal(t, path, result.Path)
assert.Equal(t, label, result.Label)
assert.Same(t, fieldSet, result.Result)
assert.Nil(t, result.Errors)
}
func TestExecutionContextState_ProcessDeferredGroup_NullsOnInvalidAndIsolatesErrors(t *testing.T) {
deferredResults := make(chan DeferredResult, 1)
ec := newTestExecutionContextState(
&OperationContext{},
nil,
makeSchemaWithType("Foo"),
deferredResults,
)
ctx := WithResponseContext(context.Background(), DefaultErrorPresenter, DefaultRecover)
AddError(ctx, errors.New("parent error"))
fieldSet := NewFieldSet([]CollectedField{{Field: &ast.Field{Alias: "value"}}})
fieldSet.Concurrently(0, func(ctx context.Context) Marshaler {
AddError(ctx, errors.New("deferred error"))
atomic.AddUint32(&fieldSet.Invalids, 1)
return MarshalString("ignored")
})
ec.ProcessDeferredGroup(DeferredGroup{
Path: ast.Path{ast.PathName("query")},
Label: "group-2",
FieldSet: fieldSet,
Context: ctx,
})
result := receiveDeferredResult(t, deferredResults)
assert.Same(t, Null, result.Result)
require.Len(t, result.Errors, 1)
assert.Equal(t, "deferred error", result.Errors[0].Message)
parentErrors := GetErrors(ctx)
require.Len(t, parentErrors, 1)
assert.Equal(t, "parent error", parentErrors[0].Message)
}
================================================
FILE: graphql/executor/executor.go
================================================
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/vektah/gqlparser/v2/validator/rules"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/errcode"
)
const parserTokenNoLimit = 0
// 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[*ast.QueryDocument]
parserTokenLimit int
disableSuggestion bool
defaultRulesFn func() *rules.Rules
}
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[*ast.QueryDocument]{},
ext: processExtensions(nil),
parserTokenLimit: parserTokenNoLimit,
}
return e
}
// SetDefaultRulesFn is to customize the Default GraphQL Validation Rules
func (e *Executor) SetDefaultRulesFn(f func() *rules.Rules) {
e.defaultRulesFn = f
}
func (e *Executor) CreateOperationContext(
ctx context.Context,
params *graphql.RawParams,
) (*graphql.OperationContext, gqlerror.List) {
opCtx := &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, opCtx)
for _, p := range e.ext.operationParameterMutators {
if err := p.MutateOperationParameters(ctx, params); err != nil {
return opCtx, gqlerror.List{err}
}
}
opCtx.RawQuery = params.Query
opCtx.OperationName = params.OperationName
opCtx.Extensions = params.Extensions
opCtx.Headers = params.Headers
var listErr gqlerror.List
opCtx.Doc, listErr = e.parseQuery(ctx, &opCtx.Stats, params.Query)
if len(listErr) != 0 {
return opCtx, listErr
}
opCtx.Operation = opCtx.Doc.Operations.ForName(params.OperationName)
if opCtx.Operation == nil {
err := gqlerror.Errorf("operation %s not found", params.OperationName)
errcode.Set(err, errcode.ValidationFailed)
return opCtx, gqlerror.List{err}
}
var err error
opCtx.Variables, err = validator.VariableValues(
e.es.Schema(),
opCtx.Operation,
params.Variables,
)
if err != nil {
gqlErr, ok := err.(*gqlerror.Error)
if ok {
errcode.Set(gqlErr, errcode.ValidationFailed)
return opCtx, gqlerror.List{gqlErr}
}
}
opCtx.Stats.Validation.End = graphql.Now()
for _, p := range e.ext.operationContextMutators {
if err := p.MutateOperationContext(ctx, opCtx); err != nil {
return opCtx, gqlerror.List{err}
}
}
return opCtx, nil
}
func (e *Executor) DispatchOperation(
ctx context.Context,
opCtx *graphql.OperationContext,
) (graphql.ResponseHandler, context.Context) {
innerCtx := graphql.WithOperationContext(ctx, opCtx)
res := e.ext.operationMiddleware(innerCtx, 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 any) error {
return e.errorPresenter(ctx, e.recoverFunc(ctx, err))
}
func (e *Executor) SetQueryCache(cache graphql.Cache[*ast.QueryDocument]) {
e.queryCache = cache
}
func (e *Executor) SetErrorPresenter(f graphql.ErrorPresenterFunc) {
e.errorPresenter = f
}
func (e *Executor) SetRecoverFunc(f graphql.RecoverFunc) {
e.recoverFunc = f
}
func (e *Executor) SetParserTokenLimit(limit int) {
e.parserTokenLimit = limit
}
func (e *Executor) SetDisableSuggestion(value bool) {
e.disableSuggestion = value
}
// 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, nil
}
doc, err := parser.ParseQueryWithTokenLimit(&ast.Source{Input: query}, e.parserTokenLimit)
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 doc == nil || len(doc.Operations) == 0 {
err = gqlerror.Errorf("no operation provided")
gqlErr, _ := err.(*gqlerror.Error)
errcode.Set(err, errcode.ValidationFailed)
return nil, gqlerror.List{gqlErr}
}
var currentRules *rules.Rules
if e.defaultRulesFn == nil {
currentRules = rules.NewDefaultRules()
} else {
currentRules = e.defaultRulesFn()
}
// Customise rules as required
// TODO(steve): consider currentRules.RemoveRule(rules.MaxIntrospectionDepth.Name)
// swap out the FieldsOnCorrectType rule with one that doesn't provide suggestions
if e.disableSuggestion {
currentRules.RemoveRule("FieldsOnCorrectType")
rule := rules.FieldsOnCorrectTypeRuleWithoutSuggestions
currentRules.AddRule(rule.Name, rule.RuleFunc)
} else { // or vice versa
currentRules.RemoveRule("FieldsOnCorrectTypeWithoutSuggestions")
rule := rules.FieldsOnCorrectTypeRule
currentRules.AddRule(rule.Name, rule.RuleFunc)
}
listErr := validator.ValidateWithRules(e.es.Schema(), doc, currentRules)
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
}
================================================
FILE: graphql/executor/executor_test.go
================================================
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/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/errcode"
"github.com/99designs/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.JSONEq(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.Empty(t, string(resp.Data))
assert.Len(t, resp.Errors, 1)
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.Empty(t, string(resp.Data))
assert.Len(t, resp.Errors, 1)
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.JSONEq(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.JSONEq(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.JSONEq(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 any, err error) {
calls = append(calls, "first")
return next(ctx)
})
exec.AroundFields(func(ctx context.Context, next graphql.Resolver) (res any, err error) {
calls = append(calls, "second")
return next(ctx)
})
resp := query(exec, "", "{name}")
assert.JSONEq(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, opCtx *graphql.OperationContext) *gqlerror.Error {
calls = append(calls, "context")
return nil
},
})
resp := query(exec, "", "{name}")
assert.JSONEq(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.Empty(t, string(resp.Data))
assert.Len(t, resp.Errors, 1)
assert.Len(t, errors1, 1)
assert.Len(t, errors2, 1)
})
t.Run("query caching", func(t *testing.T) {
ctx := context.Background()
cache := &graphql.MapCache[*ast.QueryDocument]{}
exec.SetQueryCache(cache)
qry := `query Foo {name}`
t.Run("cache miss populates cache", func(t *testing.T) {
resp := query(exec, "Foo", qry)
assert.JSONEq(t, `{"name":"test"}`, string(resp.Data))
cacheDoc, ok := cache.Get(ctx, qry)
require.True(t, ok)
require.Equal(t, "Foo", cacheDoc.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.NoError(t, err)
cache.Add(ctx, qry, doc)
resp := query(exec, "Bar", qry)
assert.JSONEq(t, `{"name":"test"}`, string(resp.Data))
cacheDoc, ok := cache.Get(ctx, qry)
require.True(t, ok)
require.Equal(t, "Bar", cacheDoc.Operations[0].Name)
})
})
}
func TestExecutorDisableSuggestion(t *testing.T) {
t.Run("by default, the error message will include suggestions", func(t *testing.T) {
exec := testexecutor.New()
resp := query(exec, "", "{nam}")
assert.Empty(t, string(resp.Data))
assert.Equal(
t,
"input:1:2: Cannot query field \"nam\" on type \"Query\". Did you mean \"name\"?\n",
resp.Errors.Error(),
)
})
t.Run("disable suggestion, the error message will not include suggestions", func(t *testing.T) {
exec := testexecutor.New()
exec.SetDisableSuggestion(true)
resp := query(exec, "", "{nam}")
assert.Empty(t, string(resp.Data))
assert.Len(t, resp.Errors, 1)
assert.Equal(
t,
"input:1:2: Cannot query field \"nam\" on type \"Query\".\n",
resp.Errors.Error(),
)
// check if the error message is displayed correctly even if an error occurs multiple times
resp = query(exec, "", "{nam}")
assert.Empty(t, string(resp.Data))
assert.Len(t, resp.Errors, 1)
assert.Equal(
t,
"input:1:2: Cannot query field \"nam\" on type \"Query\".\n",
resp.Errors.Error(),
)
})
}
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,
opCtx *graphql.OperationContext,
) *gqlerror.Error {
return m.Mutate(ctx, opCtx)
}
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.Len(t, errors1, 1)
assert.Len(t, errors2, 1)
})
}
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)
}
================================================
FILE: graphql/executor/extensions.go
================================================
package executor
import (
"context"
"errors"
"fmt"
"github.com/99designs/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 any, 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 any, err error) {
return p.InterceptField(ctx, func(ctx context.Context) (res any, 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 errors.New("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 errors.New("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 any, err error)
func (f aroundFieldFunc) ExtensionName() string {
return "InlineFieldFunc"
}
func (f aroundFieldFunc) Validate(schema graphql.ExecutableSchema) error {
if f == nil {
return errors.New("FieldFunc can not be nil")
}
return nil
}
func (f aroundFieldFunc) InterceptField(
ctx context.Context,
next graphql.Resolver,
) (res any, 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 errors.New("RootFieldFunc can not be nil")
}
return nil
}
func (f aroundRootFieldFunc) InterceptRootField(
ctx context.Context,
next graphql.RootResolver,
) graphql.Marshaler {
return f(ctx, next)
}
================================================
FILE: graphql/executor/testexecutor/testexecutor.go
================================================
package testexecutor
import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"time"
"github.com/vektah/gqlparser/v2"
"github.com/vektah/gqlparser/v2/ast"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/executor"
)
type MockResponse struct {
Name string `json:"name"`
}
func (mr *MockResponse) UnmarshalGQL(v any) 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 {
opCtx := graphql.GetOperationContext(ctx)
switch opCtx.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) (any, 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(ctx context.Context, typeName string, fieldName string, childComplexity int, args map[string]any) (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 {
opCtx := graphql.GetOperationContext(ctx)
switch opCtx.Operation.Operation {
case ast.Query:
ran := false
return func(ctx context.Context) *graphql.Response {
if ran {
return nil
}
ran = true
graphql.AddError(ctx, errors.New("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(ctx context.Context, typeName string, fieldName string, childComplexity int, args map[string]any) (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
}
================================================
FILE: graphql/fieldset.go
================================================
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)
writtenFields := make(map[string]bool, len(m.fields))
for i, field := range m.fields {
if writtenFields[field.Alias] {
continue
}
if i != 0 {
writer.Write(comma)
}
writeQuotedString(writer, field.Alias)
writer.Write(colon)
m.Values[i].MarshalGQL(writer)
writtenFields[field.Alias] = true
}
writer.Write(closeBrace)
}
================================================
FILE: graphql/fieldset_test.go
================================================
package graphql
import (
"bytes"
"testing"
"github.com/stretchr/testify/assert"
"github.com/vektah/gqlparser/v2/ast"
)
func TestFieldSet_MarshalGQL(t *testing.T) {
t.Run("Should_Deduplicate_Keys", func(t *testing.T) {
fs := NewFieldSet([]CollectedField{
{Field: &ast.Field{Alias: "__typename"}},
{Field: &ast.Field{Alias: "__typename"}},
})
fs.Values[0] = MarshalString("A")
fs.Values[1] = MarshalString("A")
b := bytes.NewBuffer(nil)
fs.MarshalGQL(b)
assert.JSONEq(t, "{\"__typename\":\"A\"}", b.String())
})
}
================================================
FILE: graphql/float.go
================================================
package graphql
import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"math"
"strconv"
)
func MarshalFloat(f float64) Marshaler {
return WriterFunc(func(w io.Writer) {
fmt.Fprintf(w, "%g", f)
})
}
func UnmarshalFloat(v any) (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)
case nil:
return 0, nil
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 errors.New("cannot marshal infinite no NaN float values")
}
fmt.Fprintf(w, "%g", f)
return nil
})
}
func UnmarshalFloatContext(ctx context.Context, v any) (float64, error) {
return UnmarshalFloat(v)
}
================================================
FILE: graphql/float_test.go
================================================
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()
}
================================================
FILE: graphql/handler/apollofederatedtracingv1/generated/apollo_trace.pb.go
================================================
// 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 = []any{
(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 any, i int) any {
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 any, i int) any {
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 any, i int) any {
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 any, i int) any {
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 any, i int) any {
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 any, i int) any {
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 any, i int) any {
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 any, i int) any {
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 any, i int) any {
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 any, i int) any {
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 any, i int) any {
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 any, i int) any {
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 any, i int) any {
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 any, i int) any {
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 any, i int) any {
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 any, i int) any {
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 any, i int) any {
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 any, i int) any {
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 any, i int) any {
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 any, i int) any {
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 any, i int) any {
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 any, i int) any {
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 any, i int) any {
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 any, i int) any {
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 any, i int) any {
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 any, i int) any {
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 = []any{
(*Trace_Node_ResponseName)(nil),
(*Trace_Node_Index)(nil),
}
file_apollo_trace_proto_msgTypes[19].OneofWrappers = []any{
(*Trace_QueryPlanNode_Sequence)(nil),
(*Trace_QueryPlanNode_Parallel)(nil),
(*Trace_QueryPlanNode_Fetch)(nil),
(*Trace_QueryPlanNode_Flatten)(nil),
}
file_apollo_trace_proto_msgTypes[28].OneofWrappers = []any{
(*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
}
================================================
FILE: graphql/handler/apollofederatedtracingv1/generated/apollo_trace.proto
================================================
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;
}
================================================
FILE: graphql/handler/apollofederatedtracingv1/logger/logger.go
================================================
package logger
import "log"
// Logger is an interface that can be implemented to log errors that occur during the tracing
// process
// This can use the default Go logger or a custom logger (e.g. logrus or zap)
type Logger interface {
Print(args any)
Println(args any)
Printf(format string, args any)
}
func NewNoopLogger() *NoopLogger {
return &NoopLogger{
log.New(NullWriter(1), "", log.LstdFlags),
}
}
type NullWriter int
func (NullWriter) Write([]byte) (int, error) { return 0, nil }
type NoopLogger struct {
*log.Logger
}
func (l *NoopLogger) Print(args any) {}
func (l *NoopLogger) Printf(format string, args any) {}
func (l *NoopLogger) Println(v any) {}
================================================
FILE: graphql/handler/apollofederatedtracingv1/logger/logger_test.go
================================================
package logger_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/99designs/gqlgen/graphql/handler/apollofederatedtracingv1/logger"
)
func TestNoopLogger_Print(t *testing.T) {
l := logger.NewNoopLogger()
assert.NotPanics(t, func() {
l.Print("test")
})
}
func TestNoopLogger_Printf(t *testing.T) {
l := logger.NewNoopLogger()
assert.NotPanics(t, func() {
l.Printf("test %s", "formatted")
})
}
func TestNoopLogger_Println(t *testing.T) {
l := logger.NewNoopLogger()
assert.NotPanics(t, func() {
l.Println("test")
})
}
================================================
FILE: graphql/handler/apollofederatedtracingv1/tracing.go
================================================
package apollofederatedtracingv1
import (
"context"
"encoding/base64"
"fmt"
"github.com/vektah/gqlparser/v2/gqlerror"
"google.golang.org/protobuf/proto"
"github.com/99designs/gqlgen/graphql"
tracing_logger "github.com/99designs/gqlgen/graphql/handler/apollofederatedtracingv1/logger"
)
const (
ERROR_MASKED = "masked"
ERROR_UNMODIFIED = "all"
ERROR_TRANSFORM = "transform"
)
type (
Tracer struct {
ClientName string
Version string
Hostname string
ErrorOptions *ErrorOptions
// Logger is used to log errors that occur during the tracing process; if nil, no logging
// will occur
// This can use the default Go logger or a custom logger (e.g. logrus or zap)
Logger tracing_logger.Logger
}
treeBuilderKey string
)
type ErrorOptions struct {
// ErrorOptions is the option to handle errors in the trace, it can be one of the following:
// - "masked": masks all errors
// - "all": includes all errors
// - "transform": includes all errors but transforms them using TransformFunction, which can
// allow users to redact sensitive information
ErrorOption string
TransformFunction func(g *gqlerror.Error) *gqlerror.Error
}
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(t.ErrorOptions, t.Logger)))
}
// 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) (any, error) {
if !t.shouldTrace(ctx) {
return next(ctx)
}
if tb := t.getTreeBuilder(ctx); tb != nil {
stop := tb.WillResolveField(ctx)
if stop != nil {
defer stop()
}
}
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) {
errors := graphql.GetErrors(ctx)
if len(errors) > 0 {
tb.DidEncounterErrors(ctx, errors)
}
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
}
================================================
FILE: graphql/handler/apollofederatedtracingv1/tracing_test.go
================================================
package apollofederatedtracingv1_test
import (
"context"
"encoding/base64"
"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/gqlerror"
"google.golang.org/protobuf/proto"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/handler/apollofederatedtracingv1"
"github.com/99designs/gqlgen/graphql/handler/apollofederatedtracingv1/generated"
"github.com/99designs/gqlgen/graphql/handler/extension"
"github.com/99designs/gqlgen/graphql/handler/lru"
"github.com/99designs/gqlgen/graphql/handler/testserver"
"github.com/99designs/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.NoError(t, err)
ftv1 := &generated.Trace{}
err = proto.Unmarshal(pbuf, ftv1)
require.NoError(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)
t.Logf("%#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 range 2 {
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"`
}
err := json.Unmarshal(resp.Body.Bytes(), &respData)
if !assert.NoError(t, err) {
return
}
tracing := respData.Extensions.FTV1
pbuf, err := base64.StdEncoding.DecodeString(tracing)
if !assert.NoError(t, err) {
return
}
ftv1 := &generated.Trace{}
err = proto.Unmarshal(pbuf, ftv1)
if assert.NoError(t, err) {
assert.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[string](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()
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[string](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)
}
//nolint:unparam // expected to always get POST for GraphQL
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
}
================================================
FILE: graphql/handler/apollofederatedtracingv1/tree_builder.go
================================================
package apollofederatedtracingv1
import (
"context"
"encoding/json"
"errors"
"sync"
"time"
"github.com/vektah/gqlparser/v2/gqlerror"
"google.golang.org/protobuf/types/known/timestamppb"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/handler/apollofederatedtracingv1/generated"
tracing_logger "github.com/99designs/gqlgen/graphql/handler/apollofederatedtracingv1/logger"
)
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
errorOptions *ErrorOptions
logger tracing_logger.Logger
}
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(errorOptions *ErrorOptions, logger tracing_logger.Logger) *TreeBuilder {
if errorOptions == nil {
errorOptions = &ErrorOptions{
ErrorOption: ERROR_MASKED,
TransformFunction: defaultErrorTransform,
}
}
if logger == nil {
// defaults to a noop logger
logger = tracing_logger.NewNoopLogger()
}
switch errorOptions.ErrorOption {
case ERROR_MASKED:
errorOptions.TransformFunction = defaultErrorTransform
case ERROR_UNMODIFIED:
errorOptions.TransformFunction = nil
case ERROR_TRANSFORM:
if errorOptions.TransformFunction == nil {
errorOptions.TransformFunction = defaultErrorTransform
}
default:
errorOptions = &ErrorOptions{
ErrorOption: ERROR_MASKED,
TransformFunction: defaultErrorTransform,
}
}
tb := TreeBuilder{
rootNode: generated.Trace_Node{},
errorOptions: errorOptions,
logger: logger,
}
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 {
tb.logger.Println(errors.New("StartTimer called twice"))
}
if tb.stopped {
tb.logger.Println(errors.New("StartTimer called after StopTimer"))
}
opCtx := graphql.GetOperationContext(ctx)
start := opCtx.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) {
tb.logger.Print("StopTimer called")
if tb.startTime == nil {
tb.logger.Println(errors.New("StopTimer called before StartTimer"))
}
if tb.stopped {
tb.logger.Println(errors.New("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) func() {
if tb.startTime == nil {
tb.logger.Println(errors.New("WillResolveField called before StartTimer"))
return nil
}
if tb.stopped {
tb.logger.Println(errors.New("WillResolveField called after StopTimer"))
return nil
}
fc := graphql.GetFieldContext(ctx)
node := tb.newNode(fc)
node.StartTime = uint64(graphql.Now().Sub(*tb.startTime).Nanoseconds())
node.Type = fc.Field.Definition.Type.String()
node.ParentType = fc.Object
return func() {
node.EndTime = uint64(graphql.Now().Sub(*tb.startTime).Nanoseconds())
}
}
func (tb *TreeBuilder) DidEncounterErrors(ctx context.Context, gqlErrors gqlerror.List) {
if tb.startTime == nil {
tb.logger.Println(errors.New("DidEncounterErrors called before StartTimer"))
return
}
if tb.stopped {
tb.logger.Println(errors.New("DidEncounterErrors called after StopTimer"))
return
}
for _, err := range gqlErrors {
if err != nil {
tb.addProtobufError(err)
}
}
}
// 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)
}
func (tb *TreeBuilder) addProtobufError(
gqlError *gqlerror.Error,
) {
if tb.startTime == nil {
tb.logger.Println(errors.New("addProtobufError called before StartTimer"))
return
}
if tb.stopped {
tb.logger.Println(errors.New("addProtobufError called after StopTimer"))
return
}
tb.mu.Lock()
var nodeRef *generated.Trace_Node
if tb.nodes[gqlError.Path.String()].self != nil {
nodeRef = tb.nodes[gqlError.Path.String()].self
} else {
tb.logger.Println("Error: Path not found in node map")
tb.mu.Unlock()
return
}
if tb.errorOptions.ErrorOption != ERROR_UNMODIFIED && tb.errorOptions.TransformFunction != nil {
gqlError = tb.errorOptions.TransformFunction(gqlError)
}
errorLocations := make([]*generated.Trace_Location, len(gqlError.Locations))
for i, loc := range gqlError.Locations {
errorLocations[i] = &generated.Trace_Location{
Line: uint32(loc.Line),
Column: uint32(loc.Column),
}
}
gqlJson, err := json.Marshal(gqlError)
if err != nil {
tb.logger.Println(err)
tb.mu.Unlock()
return
}
nodeRef.Error = append(nodeRef.Error, &generated.Trace_Error{
Message: gqlError.Message,
Location: errorLocations,
Json: string(gqlJson),
})
tb.mu.Unlock()
}
func defaultErrorTransform(_ *gqlerror.Error) *gqlerror.Error {
return gqlerror.Errorf("")
}
================================================
FILE: graphql/handler/apollotracing/tracer.go
================================================
package apollotracing
import (
"context"
"sync"
"time"
"github.com/vektah/gqlparser/v2/ast"
"github.com/99designs/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) (any, error) {
td, ok := graphql.GetExtension(ctx, "tracing").(*TracingExtension)
if !ok {
return next(ctx)
}
start := graphql.Now()
defer func() {
end := graphql.Now()
opCtx := 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(opCtx.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)
}
opCtx := graphql.GetOperationContext(ctx)
start := opCtx.Stats.OperationStart
td := &TracingExtension{
Version: 1,
StartTime: start,
Parsing: Span{
StartOffset: opCtx.Stats.Parsing.Start.Sub(start),
Duration: opCtx.Stats.Parsing.End.Sub(opCtx.Stats.Parsing.Start),
},
Validation: Span{
StartOffset: opCtx.Stats.Validation.Start.Sub(start),
Duration: opCtx.Stats.Validation.End.Sub(opCtx.Stats.Validation.Start),
},
}
graphql.RegisterExtension(ctx, "tracing", td)
resp := next(ctx)
end := graphql.Now()
td.EndTime = end
td.Duration = end.Sub(start)
return resp
}
================================================
FILE: graphql/handler/apollotracing/tracer_test.go
================================================
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/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/handler/apollotracing"
"github.com/99designs/gqlgen/graphql/handler/extension"
"github.com/99designs/gqlgen/graphql/handler/lru"
"github.com/99designs/gqlgen/graphql/handler/testserver"
"github.com/99designs/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[string](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
}
================================================
FILE: graphql/handler/debug/tracer.go
================================================
package debug
import (
"context"
"encoding/json"
"fmt"
"io"
"os"
"strings"
"github.com/logrusorgru/aurora/v4"
"github.com/mattn/go-colorable"
"github.com/mattn/go-isatty"
"github.com/99designs/gqlgen/graphql"
)
type Tracer struct {
DisableColor bool
au *aurora.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 = aurora.New(aurora.WithColors(!a.DisableColor && isTTY))
a.out = colorable.NewColorableStdout()
return nil
}
func stringify(value any) 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 {
opCtx := graphql.GetOperationContext(ctx)
_, _ = fmt.Fprintln(a.out, "GraphQL Request {")
for line := range strings.SplitSeq(opCtx.RawQuery, "\n") {
_, _ = fmt.Fprintln(a.out, " ", aurora.Cyan(line))
}
for name, value := range opCtx.Variables {
_, _ = fmt.Fprintf(a.out, " var %s = %s\n", name, aurora.Yellow(stringify(value)))
}
resp := next(ctx)
_, _ = fmt.Fprintln(a.out, " resp:", aurora.Green(stringify(resp)))
if resp != nil {
for _, err := range resp.Errors {
_, _ = fmt.Fprintln(
a.out,
" error:",
aurora.Bold(err.Path.String()+":"),
aurora.Red(err.Message),
)
}
}
_, _ = fmt.Fprintln(a.out, "}")
_, _ = fmt.Fprintln(a.out)
return resp
}
================================================
FILE: graphql/handler/extension/apq.go
================================================
package extension
import (
"context"
"crypto/sha256"
"encoding/hex"
"errors"
"github.com/go-viper/mapstructure/v2"
"github.com/vektah/gqlparser/v2/gqlerror"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/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[string]
}
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 errors.New("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 == "" {
var ok bool
// client sent optimistic query hash without query string, get it from the cache
rawParams.Query, ok = a.Cache.Get(ctx, extension.Sha256)
if !ok {
err := gqlerror.Errorf(errPersistedQueryNotFound)
errcode.Set(err, errPersistedQueryNotFoundCode)
return err
}
} 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 {
opCtx := graphql.GetOperationContext(ctx)
if opCtx == nil {
return nil
}
s, _ := opCtx.Stats.GetExtension(apqExtension).(*ApqStats)
return s
}
func computeQueryHash(query string) string {
b := sha256.Sum256([]byte(query))
return hex.EncodeToString(b[:])
}
================================================
FILE: graphql/handler/extension/apq_test.go
================================================
package extension_test
import (
"context"
"net/http"
"testing"
"github.com/stretchr/testify/require"
"github.com/vektah/gqlparser/v2/gqlerror"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/handler/extension"
"github.com/99designs/gqlgen/graphql/handler/testserver"
"github.com/99designs/gqlgen/graphql/handler/transport"
)
func TestAPQIntegration(t *testing.T) {
h := testserver.New()
h.Use(&extension.AutomaticPersistedQuery{Cache: graphql.MapCache[string]{}})
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,
http.MethodPost,
"/graphql",
`{"query":"{ name }","extensions":{"persistedQuery":{"version":1,"sha256Hash":"30166fc3298853f22709fce1e4a00e98f1b6a3160eaaaf9cb3b7db6a16073b07"}}}`,
)
require.Equal(t, http.StatusOK, resp.Code, resp.Body.String())
require.JSONEq(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{
Cache: graphql.MapCache[string]{},
}.MutateOperationParameters(
ctx,
params,
)
require.Equal(t, (*gqlerror.Error)(nil), 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]any{
"persistedQuery": map[string]any{
"sha256Hash": hash,
"version": 1,
},
},
}
err := extension.AutomaticPersistedQuery{
Cache: graphql.MapCache[string]{},
}.MutateOperationParameters(
ctx,
params,
)
require.Equal(t, "PersistedQueryNotFound", err.Message)
})
t.Run("with hash miss and query", func(t *testing.T) {
ctx := newOC()
params := &graphql.RawParams{
Query: query,
Extensions: map[string]any{
"persistedQuery": map[string]any{
"sha256Hash": hash,
"version": 1,
},
},
}
cache := graphql.MapCache[string]{}
err := extension.AutomaticPersistedQuery{
Cache: cache,
}.MutateOperationParameters(
ctx,
params,
)
require.Equal(t, (*gqlerror.Error)(nil), 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]any{
"persistedQuery": map[string]any{
"sha256Hash": hash,
"version": 1,
},
},
}
cache := graphql.MapCache[string]{}
err := extension.AutomaticPersistedQuery{cache}.MutateOperationParameters(ctx, params)
require.Equal(t, (*gqlerror.Error)(nil), 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]any{
"persistedQuery": map[string]any{
"sha256Hash": hash,
"version": 1,
},
},
}
cache := graphql.MapCache[string]{
hash: query,
}
err := extension.AutomaticPersistedQuery{cache}.MutateOperationParameters(ctx, params)
require.Equal(t, (*gqlerror.Error)(nil), 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]any{
"persistedQuery": "asdf",
},
}
err := extension.AutomaticPersistedQuery{
graphql.MapCache[string]{},
}.MutateOperationParameters(
ctx,
params,
)
require.Equal(t, "invalid APQ extension data", err.Message)
})
t.Run("with invalid extension version", func(t *testing.T) {
ctx := newOC()
params := &graphql.RawParams{
Extensions: map[string]any{
"persistedQuery": map[string]any{
"version": 2,
},
},
}
err := extension.AutomaticPersistedQuery{
graphql.MapCache[string]{},
}.MutateOperationParameters(
ctx,
params,
)
require.Equal(t, "unsupported APQ version", err.Message)
})
t.Run("with hash mismatch", func(t *testing.T) {
ctx := newOC()
params := &graphql.RawParams{
Query: query,
Extensions: map[string]any{
"persistedQuery": map[string]any{
"sha256Hash": "badhash",
"version": 1,
},
},
}
err := extension.AutomaticPersistedQuery{
graphql.MapCache[string]{},
}.MutateOperationParameters(
ctx,
params,
)
require.Equal(t, "provided APQ hash does not match query", err.Message)
})
}
func newOC() context.Context {
oc := &graphql.OperationContext{}
return graphql.WithOperationContext(context.Background(), oc)
}
================================================
FILE: graphql/handler/extension/complexity.go
================================================
package extension
import (
"context"
"errors"
"github.com/vektah/gqlparser/v2/gqlerror"
"github.com/99designs/gqlgen/complexity"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/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, opCtx *graphql.OperationContext) int
es graphql.ExecutableSchema
opts []complexity.Option
}
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, opts ...complexity.Option) *ComplexityLimit {
return &ComplexityLimit{
Func: func(ctx context.Context, opCtx *graphql.OperationContext) int {
return limit
},
opts: opts,
}
}
func (c ComplexityLimit) ExtensionName() string {
return complexityExtension
}
func (c *ComplexityLimit) Validate(schema graphql.ExecutableSchema) error {
if c.Func == nil {
return errors.New("ComplexityLimit func can not be nil")
}
c.es = schema
return nil
}
func (c ComplexityLimit) MutateOperationContext(
ctx context.Context,
opCtx *graphql.OperationContext,
) *gqlerror.Error {
op := opCtx.Doc.Operations.ForName(opCtx.OperationName)
complexityCalcs := complexity.Calculate(ctx, c.es, op, opCtx.Variables, c.opts...)
limit := c.Func(ctx, opCtx)
opCtx.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 {
opCtx := graphql.GetOperationContext(ctx)
if opCtx == nil {
return nil
}
s, _ := opCtx.Stats.GetExtension(complexityExtension).(*ComplexityStats)
return s
}
================================================
FILE: graphql/handler/extension/complexity_test.go
================================================
package extension_test
import (
"context"
"net/http"
"net/http/httptest"
"strings"
"testing"
"github.com/stretchr/testify/require"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/handler/extension"
"github.com/99designs/gqlgen/graphql/handler/testserver"
"github.com/99designs/gqlgen/graphql/handler/transport"
)
func TestHandlerComplexity(t *testing.T) {
h := testserver.New()
h.Use(&extension.ComplexityLimit{
Func: func(ctx context.Context, opCtx *graphql.OperationContext) int {
if opCtx.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, http.MethodPost, "/graphql", `{"query":"{ name }"}`)
require.Equal(t, http.StatusOK, resp.Code, resp.Body.String())
require.JSONEq(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, http.MethodPost, "/graphql", `{"query":"{ name }"}`)
require.Equal(t, http.StatusOK, resp.Code, resp.Body.String())
require.JSONEq(
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, http.MethodPost, "/graphql", `{"query":"{ ok: name }"}`)
require.Equal(t, http.StatusOK, resp.Code, resp.Body.String())
require.JSONEq(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, http.MethodPost, "/graphql", `{"query":"{ name }"}`)
require.Equal(t, http.StatusOK, resp.Code, resp.Body.String())
require.JSONEq(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, http.MethodPost, "/graphql", `{"query":"{ name }"}`)
require.Equal(t, http.StatusOK, resp.Code, resp.Body.String())
require.JSONEq(
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,
http.MethodPost,
"/graphql",
`{ "operationName":"IntrospectionQuery", "query":"query IntrospectionQuery { __schema { queryType { name } mutationType { name }}}"}`,
)
require.Equal(t, http.StatusOK, resp.Code, resp.Body.String())
require.JSONEq(t, `{"data":{"name":"test"}}`, resp.Body.String())
require.Equal(t, 2, stats.ComplexityLimit)
require.Equal(t, 0, stats.Complexity)
})
}
//nolint:unparam // expected to always get POST for GraphQL
func doRequest(handler http.Handler, method, target, 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
}
================================================
FILE: graphql/handler/extension/introspection.go
================================================
package extension
import (
"context"
"github.com/vektah/gqlparser/v2/gqlerror"
"github.com/99designs/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,
opCtx *graphql.OperationContext,
) *gqlerror.Error {
opCtx.DisableIntrospection = false
return nil
}
================================================
FILE: graphql/handler/extension/introspection_test.go
================================================
package extension
import (
"context"
"testing"
"github.com/stretchr/testify/require"
"github.com/vektah/gqlparser/v2/gqlerror"
"github.com/99designs/gqlgen/graphql"
)
func TestIntrospection(t *testing.T) {
opCtx := &graphql.OperationContext{
DisableIntrospection: true,
}
err := Introspection{}.MutateOperationContext(context.Background(), opCtx)
require.Equal(t, (*gqlerror.Error)(nil), err)
require.False(t, opCtx.DisableIntrospection)
}
================================================
FILE: graphql/handler/lru/lru.go
================================================
package lru
import (
"context"
lru "github.com/hashicorp/golang-lru/v2"
"github.com/99designs/gqlgen/graphql"
)
type LRU[T any] struct {
lru *lru.Cache[string, T]
}
var _ graphql.Cache[any] = &LRU[any]{}
func New[T any](size int) *LRU[T] {
cache, err := lru.New[string, T](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[T]{cache}
}
func (l LRU[T]) Get(ctx context.Context, key string) (value T, ok bool) {
return l.lru.Get(key)
}
func (l LRU[T]) Add(ctx context.Context, key string, value T) {
l.lru.Add(key, value)
}
================================================
FILE: graphql/handler/server.go
================================================
package handler
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"time"
"github.com/vektah/gqlparser/v2/ast"
"github.com/vektah/gqlparser/v2/gqlerror"
"github.com/vektah/gqlparser/v2/validator/rules"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/executor"
"github.com/99designs/gqlgen/graphql/handler/extension"
"github.com/99designs/gqlgen/graphql/handler/lru"
"github.com/99designs/gqlgen/graphql/handler/transport"
)
type (
Server struct {
transports []graphql.Transport
exec *executor.Executor
}
)
// New returns a new Server for the given executable schema. The Server is not
// ready for use until the transports you require are added and configured with
// Server.AddTransport. See the implementation of [NewDefaultServer] for an
// example.
func New(es graphql.ExecutableSchema) *Server {
return &Server{
exec: executor.New(es),
}
}
// NewDefaultServer returns a Server for the given executable schema which is
// only suitable for use in examples.
//
// Deprecated:
// The Server returned by NewDefaultServer is not suitable for production use.
// Use [New] instead and add transports configured for your use case,
// appropriate caches, and introspection if required. See the implementation of
// NewDefaultServer for an example of starting point to construct a Server.
//
// SSE is not supported using this example. SSE when used over HTTP/1.1 (but not
// HTTP/2 or HTTP/3) suffers from a severe limitation to the maximum number of
// open connections of 6 per browser, see [Using server-sent events].
//
// [Using server-sent events]:
// https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#sect1
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[*ast.QueryDocument](1000))
srv.Use(extension.Introspection{})
srv.Use(extension.AutomaticPersistedQuery{
Cache: lru.New[string](100),
})
return srv
}
// AddTransport adds a transport to the Server. The server picks the first
// supported transport. Adding a transport which has already been added has no
// effect.
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[*ast.QueryDocument]) {
s.exec.SetQueryCache(cache)
}
func (s *Server) SetParserTokenLimit(limit int) {
s.exec.SetParserTokenLimit(limit)
}
func (s *Server) SetDisableSuggestion(value bool) {
s.exec.SetDisableSuggestion(value)
}
// Use adds the given extension middleware to the server. Extensions are run in
// order from first to last added.
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
}
// SetValidationRulesFn is to customize the Default GraphQL Validation Rules
func (s *Server) SetValidationRulesFn(f func() *rules.Rules) {
s.exec.SetDefaultRulesFn(f)
}
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 ...any) {
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 errors.New("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 errors.New("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 any, err error)
func (f FieldFunc) ExtensionName() string {
return "InlineFieldFunc"
}
func (f FieldFunc) Validate(schema graphql.ExecutableSchema) error {
if f == nil {
return errors.New("FieldFunc can not be nil")
}
return nil
}
func (f FieldFunc) InterceptField(ctx context.Context, next graphql.Resolver) (res any, err error) {
return f(ctx, next)
}
================================================
FILE: graphql/handler/server_test.go
================================================
package handler_test
import (
"context"
"errors"
"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/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/handler/testserver"
"github.com/99designs/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.JSONEq(
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.JSONEq(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.JSONEq(
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.JSONEq(
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 any, err error) {
calls = append(calls, "first")
return next(ctx)
})
srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res any, 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.Len(t, errors1, 1)
assert.Len(t, errors2, 1)
})
t.Run("query caching", func(t *testing.T) {
ctx := context.Background()
cache := &graphql.MapCache[*ast.QueryDocument]{}
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.JSONEq(t, `{"data":{"name":"test"}}`, resp.Body.String())
cacheDoc, ok := cache.Get(ctx, qry)
require.True(t, ok)
require.Equal(t, "Foo", cacheDoc.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.NoError(t, err)
cache.Add(ctx, qry, doc)
resp := get(srv, "/foo?query="+url.QueryEscape(qry))
assert.Equal(t, http.StatusOK, resp.Code)
assert.JSONEq(t, `{"data":{"name":"test"}}`, resp.Body.String())
cacheDoc, ok := cache.Get(ctx, qry)
require.True(t, ok)
require.Equal(t, "Bar", cacheDoc.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.Len(t, errors1, 1)
assert.Len(t, errors2, 1)
})
}
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(errors.New("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(http.MethodGet, target, http.NoBody)
w := httptest.NewRecorder()
handler.ServeHTTP(w, r)
return w
}
func post(handler http.Handler, target, contentType string) *httptest.ResponseRecorder {
r := httptest.NewRequest(http.MethodPost, target, http.NoBody)
r.Header.Set("Content-Type", contentType)
w := httptest.NewRecorder()
handler.ServeHTTP(w, r)
return w
}
================================================
FILE: graphql/handler/testserver/testserver.go
================================================
package testserver
import (
"context"
"errors"
"fmt"
"strings"
"time"
"github.com/vektah/gqlparser/v2"
"github.com/vektah/gqlparser/v2/ast"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/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 {
opCtx := graphql.GetOperationContext(ctx)
switch opCtx.Operation.Operation {
case ast.Query:
ran := false
// If the query contains @defer, we will mimic a deferred response.
if strings.Contains(opCtx.RawQuery, "@defer") {
initialResponse := true
return func(context context.Context) *graphql.Response {
select {
case <-ctx.Done():
return nil
case <-next:
if initialResponse {
initialResponse = false
hasNext := true
return &graphql.Response{
Data: []byte(`{"name":null}`),
HasNext: &hasNext,
}
}
hasNext := false
return &graphql.Response{
Data: []byte(`{"name":"test"}`),
HasNext: &hasNext,
}
case <-completeSubscription:
return nil
}
}
}
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) (any, 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(ctx context.Context, typeName string, fieldName string, childComplexity int, args map[string]any) (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 {
opCtx := graphql.GetOperationContext(ctx)
switch opCtx.Operation.Operation {
case ast.Query:
ran := false
return func(ctx context.Context) *graphql.Response {
if ran {
return nil
}
ran = true
graphql.AddError(ctx, errors.New("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(ctx context.Context, typeName string, fieldName string, childComplexity int, args map[string]any) (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
}
================================================
FILE: graphql/handler/transport/error.go
================================================
package transport
import (
"encoding/json"
"fmt"
"net/http"
"github.com/vektah/gqlparser/v2/gqlerror"
"github.com/99designs/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 ...any) {
SendError(w, code, &gqlerror.Error{Message: fmt.Sprintf(format, args...)})
}
================================================
FILE: graphql/handler/transport/headers.go
================================================
package transport
import (
"maps"
"mime"
"net/http"
"strings"
)
const (
acceptApplicationJson = "application/json"
acceptApplicationGraphqlResponseJson = "application/graphql-response+json"
)
func determineResponseContentType(
explicitHeaders map[string][]string,
r *http.Request,
useGrapQLResponseJsonByDefault bool,
) string {
for k, v := range explicitHeaders {
if strings.EqualFold(k, "Content-Type") {
return v[0]
}
}
accept := r.Header.Get("Accept")
if accept == "" {
if useGrapQLResponseJsonByDefault {
return acceptApplicationGraphqlResponseJson
}
return acceptApplicationJson
}
for acceptPart := range strings.SplitSeq(accept, ",") {
mediaType, _, err := mime.ParseMediaType(strings.TrimSpace(acceptPart))
if err != nil {
continue
}
switch mediaType {
case "*/*", "application/*":
if useGrapQLResponseJsonByDefault {
return acceptApplicationGraphqlResponseJson
}
return acceptApplicationJson
case "application/json":
return acceptApplicationJson
case "application/graphql-response+json":
return acceptApplicationGraphqlResponseJson
}
}
return acceptApplicationGraphqlResponseJson
}
func writeHeaders(w http.ResponseWriter, headers map[string][]string) {
if len(headers) == 0 {
headers = map[string][]string{
// Stay with application/json (not application/graphql-response+json)
// as it is not an actively supported protocol for now
"Content-Type": {"application/json"},
}
}
for key, values := range headers {
for _, value := range values {
w.Header().Add(key, value)
}
}
}
func mergeHeaders(baseHeaders, additionalHeaders map[string][]string) map[string][]string {
result := make(map[string][]string)
maps.Copy(result, baseHeaders)
maps.Copy(result, additionalHeaders)
return result
}
================================================
FILE: graphql/handler/transport/headers_test.go
================================================
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/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/handler/testserver"
"github.com/99designs/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,
http.MethodPost,
"/graphql",
`{"query":"{ name }"}`,
"",
"application/json",
)
assert.Equal(t, http.StatusOK, resp.Code)
assert.Len(t, resp.Header(), 1)
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,
http.MethodPost,
"/graphql",
`{"query":"{ name }"}`,
"",
"application/json",
)
assert.Equal(t, http.StatusOK, resp.Code)
assert.Len(t, resp.Header(), 2)
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.Len(t, resp.Header(), 1)
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.Len(t, resp.Header(), 2)
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, http.MethodPost, "/graphql", `{ name }`, "", "application/graphql")
assert.Equal(t, http.StatusOK, resp.Code)
assert.Len(t, resp.Header(), 1)
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, http.MethodPost, "/graphql", `{ name }`, "", "application/graphql")
assert.Equal(t, http.StatusOK, resp.Code)
assert.Len(t, resp.Header(), 2)
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,
http.MethodPost,
"/graphql",
`{ name }`,
"",
"application/x-www-form-urlencoded",
)
assert.Equal(t, http.StatusOK, resp.Code)
assert.Len(t, resp.Header(), 1)
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,
http.MethodPost,
"/graphql",
`{ name }`,
"",
"application/x-www-form-urlencoded",
)
assert.Equal(t, http.StatusOK, resp.Code)
assert.Len(t, resp.Header(), 2)
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.Len(t, resp.Header(), 1)
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.Len(t, resp.Header(), 2)
assert.Equal(t, "application/json; charset: utf8", resp.Header().Get("Content-Type"))
assert.Equal(t, "dummy-multipart", resp.Header().Get("Other-Header"))
})
}
================================================
FILE: graphql/handler/transport/http_form_multipart.go
================================================
package transport
import (
"encoding/json"
"io"
"mime"
"net/http"
"os"
"github.com/99designs/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 == http.MethodPost && 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))
}
================================================
FILE: graphql/handler/transport/http_form_multipart_test.go
================================================
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/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/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.Len(t, op.VariableDefinitions, 1)
require.Equal(t, "file", op.VariableDefinitions[0].Variable)
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.JSONEq(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.Len(t, op.VariableDefinitions, 1)
require.Equal(t, "req", op.VariableDefinitions[0].Variable)
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.JSONEq(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.Len(t, op.VariableDefinitions, 1)
require.Equal(t, "files", op.VariableDefinitions[0].Variable)
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.JSONEq(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.Len(t, op.VariableDefinitions, 1)
require.Equal(t, "req", op.VariableDefinitions[0].Variable)
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.JSONEq(
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.Len(t, op.VariableDefinitions, 1)
require.Equal(t, "req", op.VariableDefinitions[0].Variable)
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.JSONEq(
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: http.MethodPost,
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.JSONEq(
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.JSONEq(
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.JSONEq(
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.JSONEq(
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.JSONEq(
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.JSONEq(
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(http.MethodPost, "/graphql", bodyBuf)
require.NoError(t, err)
req.Header.Set("Content-Type", bodyWriter.FormDataContentType())
return req
}
================================================
FILE: graphql/handler/transport/http_form_urlencode_test.go
================================================
package transport_test
import (
"fmt"
"net/http"
"net/http/httptest"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/99designs/gqlgen/graphql/handler/testserver"
"github.com/99designs/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,
http.MethodPost,
"/graphql",
`{"query":"{ name }"}`,
"",
"application/x-www-form-urlencoded",
)
assert.Equal(t, http.StatusOK, resp.Code)
assert.JSONEq(t, `{"data":{"name":"test"}}`, resp.Body.String())
})
t.Run("success urlencoded", func(t *testing.T) {
resp := doRequest(
h,
http.MethodPost,
"/graphql",
`query=%7B%20name%20%7D`,
"",
"application/x-www-form-urlencoded",
)
assert.Equal(t, http.StatusOK, resp.Code)
assert.JSONEq(t, `{"data":{"name":"test"}}`, resp.Body.String())
})
t.Run("success plain", func(t *testing.T) {
resp := doRequest(
h,
http.MethodPost,
"/graphql",
`query={ name }`,
"",
"application/x-www-form-urlencoded",
)
assert.Equal(t, http.StatusOK, resp.Code)
assert.JSONEq(t, `{"data":{"name":"test"}}`, resp.Body.String())
})
t.Run("decode failure json", func(t *testing.T) {
resp := doRequest(
h,
http.MethodPost,
"/graphql",
"notjson",
"",
"application/x-www-form-urlencoded",
)
assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String())
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(
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,
http.MethodPost,
"/graphql",
"query=%7Bnot-good",
"",
"application/x-www-form-urlencoded",
)
assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String())
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(
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,
http.MethodPost,
"/graphql",
`{"query":{"wrong": "format"}}`,
"",
"application/x-www-form-urlencoded",
)
assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String())
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(
t,
`{"errors":[{"message":"could not cleanup body: json: cannot unmarshal object into Go struct field RawParams.query of type string"}],"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/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, http.MethodPost, "/graphql", `{"query":"{ name }"}`, contentType)
assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String())
assert.JSONEq(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, http.MethodPost, "/graphql", `{"query":"{ name }"}`, tc)
assert.Equal(t, http.StatusBadRequest, resp.Code, resp.Body.String())
assert.JSONEq(
t,
fmt.Sprintf(
`{"errors":[{"message":"%s"}],"data":null}`,
"transport not supported",
),
resp.Body.String(),
)
})
}
})
}
================================================
FILE: graphql/handler/transport/http_form_urlencoded.go
================================================
package transport
import (
"io"
"mime"
"net/http"
"net/url"
"strings"
"github.com/vektah/gqlparser/v2/gqlerror"
"github.com/99designs/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 == http.MethodPost && 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
}
================================================
FILE: graphql/handler/transport/http_get.go
================================================
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/99designs/gqlgen/graphql"
"github.com/99designs/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/graphql-response+json will be set.
ResponseHeaders map[string][]string
// UseGrapQLResponseJsonByDefault determines whether to use 'application/graphql-response+json'
// as the response content type
// when the Accept header is empty or 'application/*' or '*/*'.
UseGrapQLResponseJsonByDefault bool
}
var _ graphql.Transport = GET{}
func (h GET) Supports(r *http.Request) bool {
if r.Header.Get("Upgrade") != "" {
return false
}
return r.Method == http.MethodGet
}
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
}
contentType := determineResponseContentType(
h.ResponseHeaders,
r,
h.UseGrapQLResponseJsonByDefault,
)
responseHeaders := mergeHeaders(
map[string][]string{
"Content-Type": {contentType},
},
h.ResponseHeaders,
)
writeHeaders(w, 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()
opCtx, gqlError := exec.CreateOperationContext(r.Context(), raw)
if gqlError != nil {
if contentType == acceptApplicationGraphqlResponseJson {
w.WriteHeader(statusForGraphQLResponse(gqlError))
} else {
w.WriteHeader(statusFor(gqlError))
}
resp := exec.DispatchError(graphql.WithOperationContext(r.Context(), opCtx), gqlError)
writeJson(w, resp)
return
}
op := opCtx.Doc.Operations.ForName(opCtx.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(), opCtx)
writeJson(w, responses(ctx))
}
func jsonDecode(r io.Reader, val any) 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
}
}
func statusForGraphQLResponse(errs gqlerror.List) int {
// https://graphql.github.io/graphql-over-http/draft/#sec-application-graphql-response-json
switch errcode.GetErrorKind(errs) {
case errcode.KindProtocol:
return http.StatusBadRequest
default:
return http.StatusOK
}
}
================================================
FILE: graphql/handler/transport/http_get_test.go
================================================
package transport_test
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
"github.com/99designs/gqlgen/graphql/handler/testserver"
"github.com/99designs/gqlgen/graphql/handler/transport"
)
func TestGET(t *testing.T) {
h := testserver.New()
h.AddTransport(transport.GET{})
graphqlResponseH := testserver.New()
graphqlResponseH.AddTransport(transport.GET{UseGrapQLResponseJsonByDefault: true})
jsonH := testserver.New()
jsonH.AddTransport(transport.GET{
ResponseHeaders: map[string][]string{
"Content-Type": {"application/json"},
},
})
t.Run("success with accept application/json", func(t *testing.T) {
resp := doRequest(
h,
"GET",
"/graphql?query={name}",
``,
"application/json",
"application/json",
)
assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String())
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(t, `{"data":{"name":"test"}}`, resp.Body.String())
})
t.Run("success with accept is empty with enabling graphql response json", func(t *testing.T) {
resp := doRequest(
graphqlResponseH,
"GET",
"/graphql?query={name}",
``,
"",
"application/json",
)
assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String())
assert.Equal(t, "application/graphql-response+json", resp.Header().Get("Content-Type"))
assert.JSONEq(t, `{"data":{"name":"test"}}`, resp.Body.String())
})
t.Run(
"success with accept is empty without enabling graphql response json",
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, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(t, `{"data":{"name":"test"}}`, resp.Body.String())
},
)
t.Run("success with accept application/graphql-response+json", func(t *testing.T) {
resp := doRequest(
h,
"GET",
"/graphql?query={name}",
``,
"application/graphql-response+json",
"application/json",
)
assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String())
assert.Equal(t, "application/graphql-response+json", resp.Header().Get("Content-Type"))
assert.JSONEq(t, `{"data":{"name":"test"}}`, resp.Body.String())
})
t.Run(
"success with wildcard with enabling application/graphql-response+json",
func(t *testing.T) {
resp := doRequest(
graphqlResponseH,
"GET",
"/graphql?query={name}",
``,
"*/*",
"application/json",
)
assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String())
assert.Equal(t, "application/graphql-response+json", resp.Header().Get("Content-Type"))
assert.JSONEq(t, `{"data":{"name":"test"}}`, resp.Body.String())
},
)
t.Run(
"success with wildcard without enabling application/graphql-response+json",
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, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(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",
"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",
"application/json",
)
assert.Equal(t, http.StatusBadRequest, resp.Code, resp.Body.String())
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(
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, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(
t,
`{"errors":[{"message":"cannot use bool as Int","path":["variable","id"],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}],"data":null}`,
resp.Body.String(),
)
})
t.Run("invalid variable with json only", func(t *testing.T) {
resp := doRequest(
jsonH,
"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, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(
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, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(
t,
`{"errors":[{"message":"Unexpected !","locations":[{"line":1,"column":1}],"extensions":{"code":"GRAPHQL_PARSE_FAILED"}}],"data":null}`,
resp.Body.String(),
)
})
t.Run("parse failure with json only", func(t *testing.T) {
resp := doRequest(jsonH, "GET", "/graphql?query=!", "", "", "application/json")
assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String())
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(
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.JSONEq(
t,
`{"errors":[{"message":"GET requests only allow query operations"}],"data":null}`,
resp.Body.String(),
)
})
}
================================================
FILE: graphql/handler/transport/http_graphql.go
================================================
package transport
import (
"mime"
"net/http"
"net/url"
"strings"
"github.com/vektah/gqlparser/v2/gqlerror"
"github.com/99designs/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 == http.MethodPost && 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
}
================================================
FILE: graphql/handler/transport/http_graphql_test.go
================================================
package transport_test
import (
"fmt"
"net/http"
"net/http/httptest"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/99designs/gqlgen/graphql/handler/testserver"
"github.com/99designs/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, http.MethodPost, "/graphql", `{ name }`)
assert.Equal(t, http.StatusOK, resp.Code)
assert.JSONEq(t, `{"data":{"name":"test"}}`, resp.Body.String())
})
t.Run("success even if url encoded", func(t *testing.T) {
resp := doGraphqlRequest(h, http.MethodPost, "/graphql", `%7B%20name%20%7D`)
assert.Equal(t, http.StatusOK, resp.Code)
assert.JSONEq(t, `{"data":{"name":"test"}}`, resp.Body.String())
})
t.Run("parse failure", func(t *testing.T) {
resp := doGraphqlRequest(h, http.MethodPost, "/graphql", `{"!"}`)
assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String())
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(
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, http.MethodPost, "/graphql", `%7B%H7U6Z`)
assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String())
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(
t,
`{"errors":[{"message":"could not cleanup body: invalid URL escape \"%H7\""}],"data":null}`,
resp.Body.String(),
)
})
t.Run("validation failure", func(t *testing.T) {
resp := doGraphqlRequest(h, http.MethodPost, "/graphql", `{ title }`)
assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String())
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(
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, http.MethodPost, "/graphql", `mutation { name }`)
assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String())
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(
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, http.MethodPost, "/graphql", `{ name }`, contentType)
assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String())
assert.JSONEq(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, http.MethodPost, "/graphql", `{"query":"{ name }"}`, tc)
assert.Equal(t, http.StatusBadRequest, resp.Code, resp.Body.String())
assert.JSONEq(
t,
fmt.Sprintf(
`{"errors":[{"message":"%s"}],"data":null}`,
"transport not supported",
),
resp.Body.String(),
)
})
}
})
}
func doGraphqlRequest(
handler http.Handler,
method, target, body string, //nolint:unparam // expected to always get POST for GraphQL
) *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
}
================================================
FILE: graphql/handler/transport/http_multipart_mixed.go
================================================
package transport
import (
"encoding/json"
"fmt"
"io"
"log"
"mime"
"net/http"
"strings"
"sync"
"time"
"github.com/vektah/gqlparser/v2/gqlerror"
"github.com/99designs/gqlgen/graphql"
)
// MultipartMixed is a transport that supports the multipart/mixed spec
type MultipartMixed struct {
Boundary string
DeliveryTimeout time.Duration
}
var _ graphql.Transport = MultipartMixed{}
// Supports checks if the request supports the multipart/mixed spec
// Might be worth check the spec required, but Apollo Client mislabel the spec in the headers.
func (t MultipartMixed) Supports(r *http.Request) bool {
if !strings.Contains(r.Header.Get("Accept"), "multipart/mixed") {
return false
}
mediaType, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
if err != nil {
return false
}
return r.Method == http.MethodPost && mediaType == "application/json"
}
// Do implements the multipart/mixed spec as a multipart/mixed response
func (t MultipartMixed) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecutor) {
// Implements the multipart/mixed spec as a multipart/mixed response:
// *
// https://github.com/graphql/graphql-wg/blob/e4ef5f9d5997815d9de6681655c152b6b7838b4c/rfcs/DeferStream.md
// 2022/08/23 as implemented by gqlgen.
// *
// https://github.com/graphql/graphql-wg/blob/f22ea7748c6ebdf88fdbf770a8d9e41984ebd429/rfcs/DeferStream.md
// June 2023 Spec for the
// `incremental` field
// * https://github.com/graphql/graphql-over-http/blob/main/rfcs/IncrementalDelivery.md
// multipart specification
// Follows the format that is used in the Apollo Client tests:
// https://github.com/apollographql/apollo-client/blob/v3.11.8/src/link/http/__tests__/responseIterator.ts#L68
// Apollo Client, despite mentioning in its requests that they require the 2022 spec, it wants
// the `incremental` field to be an array of responses, not a single response. Theoretically we
// could
// batch responses in the `incremental` field, if we wanted to optimize this code.
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")
// This header will be replaced below, but it's required in case we return errors.
w.Header().Set("Content-Type", "application/json")
boundary := t.Boundary
if boundary == "" {
boundary = "-"
}
timeout := t.DeliveryTimeout
if timeout.Milliseconds() < 1 {
// If the timeout is less than 1ms, we'll set it to 1ms to avoid a busy loop
timeout = 1 * time.Millisecond
}
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)
if opErr != nil {
w.WriteHeader(statusFor(opErr))
resp := exec.DispatchError(ctx, opErr)
writeJson(w, resp)
return
}
// Example of the response format (note the new lines and boundaries are important!):
// https://github.com/graphql/graphql-over-http/blob/main/rfcs/IncrementalDelivery.md
// --graphql
// Content-Type: application/json
//
// {"data":{"apps":{"apps":[ .. ],"totalNumApps":161,"__typename":"AppsOutput"}},"hasNext":true}
// --graphql
// Content-Type: application/json
//
// {"incremental":[{"data":{"groupAccessCount":0},"label":"test","path":["apps","apps",7],"hasNext":true}],"hasNext":true}
// --graphql
// ...
// --graphql--
// Last boundary is a closing boundary with two dashes at the end.
w.Header().Set(
"Content-Type",
fmt.Sprintf(`multipart/mixed;boundary="%s";deferSpec=20220824`, boundary),
)
a := newMultipartResponseAggregator(w, boundary, timeout)
defer a.Done(w)
responses, ctx := exec.DispatchOperation(ctx, rc)
initialResponse := true
for {
response := responses(ctx)
if response == nil {
break
}
a.Add(response, initialResponse)
initialResponse = false
}
}
func writeIncrementalJson(w io.Writer, responses []*graphql.Response, hasNext bool) {
// TODO: Remove this wrapper on response once gqlgen supports the 2023 spec
b, err := json.Marshal(struct {
Incremental []*graphql.Response `json:"incremental"`
HasNext bool `json:"hasNext"`
}{
Incremental: responses,
HasNext: hasNext,
})
if err != nil {
panic(err)
}
w.Write(b)
}
func writeBoundary(w io.Writer, boundary string, finalResponse bool) {
if finalResponse {
fmt.Fprintf(w, "--%s--\r\n", boundary)
return
}
fmt.Fprintf(w, "--%s\r\n", boundary)
}
func writeContentTypeHeader(w io.Writer) {
fmt.Fprintf(w, "Content-Type: application/json\r\n\r\n")
}
// multipartResponseAggregator helps us reduce the number of responses sent to the frontend by
// batching all the
// incremental responses together.
type multipartResponseAggregator struct {
mu sync.Mutex
boundary string
initialResponse *graphql.Response
deferResponses []*graphql.Response
done chan bool
}
// newMultipartResponseAggregator creates a new multipartResponseAggregator
// The aggregator will flush responses to the client every `tickerDuration` (default 1ms) so that
// multiple incremental responses are batched together.
func newMultipartResponseAggregator(
w http.ResponseWriter,
boundary string,
tickerDuration time.Duration,
) *multipartResponseAggregator {
a := &multipartResponseAggregator{
boundary: boundary,
done: make(chan bool, 1),
}
go func() {
ticker := time.NewTicker(tickerDuration)
defer ticker.Stop()
for {
select {
case <-a.done:
return
case <-ticker.C:
a.flush(w)
}
}
}()
return a
}
// Done flushes the remaining responses
func (a *multipartResponseAggregator) Done(w http.ResponseWriter) {
a.done <- true
a.flush(w)
}
// Add accumulates the responses
func (a *multipartResponseAggregator) Add(resp *graphql.Response, initialResponse bool) {
a.mu.Lock()
defer a.mu.Unlock()
if initialResponse {
a.initialResponse = resp
return
}
a.deferResponses = append(a.deferResponses, resp)
}
// flush sends the accumulated responses to the client
func (a *multipartResponseAggregator) flush(w http.ResponseWriter) {
a.mu.Lock()
defer a.mu.Unlock()
// If we don't have any responses, we can return early
if a.initialResponse == nil && len(a.deferResponses) == 0 {
return
}
flusher, ok := w.(http.Flusher)
if !ok {
// This should never happen, as we check for this much earlier on
panic("response writer does not support flushing")
}
hasNext := false
if a.initialResponse != nil {
// Initial response will need to begin with the boundary
writeBoundary(w, a.boundary, false)
writeContentTypeHeader(w)
writeJson(w, a.initialResponse)
hasNext = a.initialResponse.HasNext != nil && *a.initialResponse.HasNext
// Handle when initial is aggregated with deferred responses.
if len(a.deferResponses) > 0 {
fmt.Fprintf(w, "\r\n")
writeBoundary(w, a.boundary, false)
}
// Reset the initial response so we don't send it again
a.initialResponse = nil
}
if len(a.deferResponses) > 0 {
writeContentTypeHeader(w)
// Note: while the 2023 spec that includes "incremental" does not
// explicitly list the fields that should be included as part of the
// incremental object, it shows hasNext only on the response payload
// (marking the status of the operation as a whole), and instead the
// response payload implements pending and complete fields to mark the
// status of the incrementally delivered data.
//
// TODO: use the "HasNext" status of deferResponses items to determine
// the operation status and pending / complete fields, but remove from
// the incremental (deferResponses) object.
hasNext = a.deferResponses[len(a.deferResponses)-1].HasNext != nil &&
*a.deferResponses[len(a.deferResponses)-1].HasNext
writeIncrementalJson(w, a.deferResponses, hasNext)
// Reset the deferResponses so we don't send them again
a.deferResponses = nil
}
// Make sure to put the delimiter after every request, so that Apollo Client knows that the
// current payload has been sent, and updates the UI. This is particular important for the first
// response and the last response, which may either hang or never get handled.
// Final response will have a closing boundary with two dashes at the end.
fmt.Fprintf(w, "\r\n")
writeBoundary(w, a.boundary, !hasNext)
flusher.Flush()
}
================================================
FILE: graphql/handler/transport/http_multipart_mixed_test.go
================================================
package transport_test
import (
"bufio"
"io"
"net/http"
"net/http/httptest"
"strings"
"sync"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/99designs/gqlgen/graphql/handler/testserver"
"github.com/99designs/gqlgen/graphql/handler/transport"
)
func TestMultipartMixed(t *testing.T) {
initialize := func() *testserver.TestServer {
h := testserver.New()
h.AddTransport(transport.MultipartMixed{
Boundary: "graphql",
})
return h
}
initializeWithServer := func() (*testserver.TestServer, *httptest.Server) {
h := initialize()
return h, httptest.NewServer(h)
}
createHTTPRequest := func(url string, query string) *http.Request {
req, err := http.NewRequest(http.MethodPost, url, strings.NewReader(query))
require.NoError(t, err, "Request threw error -> %s", err)
req.Header.Set("Accept", "multipart/mixed")
req.Header.Set("content-type", "application/json; charset=utf-8")
return req
}
doRequest := func(handler http.Handler, target, body string) *httptest.ResponseRecorder {
r := createHTTPRequest(target, body)
w := httptest.NewRecorder()
handler.ServeHTTP(w, r)
return w
}
t.Run("decode failure", func(t *testing.T) {
handler, srv := initializeWithServer()
resp := doRequest(handler, srv.URL, "notjson")
assert.Equal(t, http.StatusBadRequest, resp.Code, resp.Body.String())
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(
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) {
handler, srv := initializeWithServer()
resp := doRequest(handler, srv.URL, `{"query": "!"}`)
assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String())
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(
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) {
handler, srv := initializeWithServer()
resp := doRequest(handler, srv.URL, `{"query": "{ title }"}`)
assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String())
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(
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) {
handler, srv := initializeWithServer()
resp := doRequest(handler, srv.URL,
`{"query": "query($id:Int!){find(id:$id)}","variables":{"id":false}}`,
)
assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String())
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(
t,
`{"errors":[{"message":"cannot use bool as Int","path":["variable","id"],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}],"data":null}`,
resp.Body.String(),
)
})
readLine := func(br *bufio.Reader) string {
bs, err := br.ReadString('\n')
require.NoError(t, err)
return bs
}
t.Run("initial and incremental patches un-aggregated", func(t *testing.T) {
handler, srv := initializeWithServer()
defer srv.Close()
var wg sync.WaitGroup
wg.Go(func() {
handler.SendNextSubscriptionMessage()
})
client := &http.Client{}
req := createHTTPRequest(
srv.URL,
`{"query":"query { ... @defer { 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.Contains(t, res.Header.Get("Content-Type"), "multipart/mixed")
assert.Contains(t, res.Header.Get("Content-Type"), `boundary="graphql"`)
br := bufio.NewReader(res.Body)
assert.Equal(t, "--graphql\r\n", readLine(br))
assert.Equal(t, "Content-Type: application/json\r\n", readLine(br))
assert.Equal(t, "\r\n", readLine(br))
assert.JSONEq(t,
"{\"data\":{\"name\":null},\"hasNext\":true}\r\n",
readLine(br),
)
wg.Go(func() {
handler.SendNextSubscriptionMessage()
})
assert.Equal(t, "--graphql\r\n", readLine(br))
assert.Equal(t, "Content-Type: application/json\r\n", readLine(br))
assert.Equal(t, "\r\n", readLine(br))
assert.JSONEq(
t,
"{\"incremental\":[{\"data\":{\"name\":\"test\"},\"hasNext\":false}],\"hasNext\":false}\r\n",
readLine(br),
)
assert.Equal(t, "--graphql--\r\n", readLine(br))
wg.Go(func() {
handler.SendCompleteSubscriptionMessage()
})
_, err = br.ReadByte()
assert.Equal(t, err, io.EOF)
wg.Wait()
})
t.Run("initial and incremental patches aggregated", func(t *testing.T) {
handler := testserver.New()
handler.AddTransport(transport.MultipartMixed{
Boundary: "graphql",
DeliveryTimeout: time.Hour,
})
srv := httptest.NewServer(handler)
defer srv.Close()
var err error
var res *http.Response
var wg sync.WaitGroup
wg.Go(func() {
client := &http.Client{}
req := createHTTPRequest(
srv.URL,
`{"query":"query { ... @defer { name } }"}`,
)
res, err = client.Do(req) //nolint:bodyclose // false positive
})
handler.SendNextSubscriptionMessage()
handler.SendNextSubscriptionMessage()
handler.SendCompleteSubscriptionMessage()
wg.Wait()
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.Contains(t, res.Header.Get("Content-Type"), "multipart/mixed")
assert.Contains(t, res.Header.Get("Content-Type"), `boundary="graphql"`)
br := bufio.NewReader(res.Body)
assert.Equal(t, "--graphql\r\n", readLine(br))
assert.Equal(t, "Content-Type: application/json\r\n", readLine(br))
assert.Equal(t, "\r\n", readLine(br))
assert.JSONEq(t,
"{\"data\":{\"name\":null},\"hasNext\":true}\r\n",
readLine(br),
)
assert.Equal(t, "--graphql\r\n", readLine(br))
assert.Equal(t, "Content-Type: application/json\r\n", readLine(br))
assert.Equal(t, "\r\n", readLine(br))
assert.JSONEq(
t,
"{\"incremental\":[{\"data\":{\"name\":\"test\"},\"hasNext\":false}],\"hasNext\":false}\r\n",
readLine(br),
)
assert.Equal(t, "--graphql--\r\n", readLine(br))
_, err = br.ReadByte()
assert.Equal(t, err, io.EOF)
})
}
================================================
FILE: graphql/handler/transport/http_post.go
================================================
package transport
import (
"bytes"
"fmt"
"io"
"mime"
"net/http"
"sync"
"github.com/vektah/gqlparser/v2/gqlerror"
"github.com/99designs/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/graphql-response+json will be set.
ResponseHeaders map[string][]string
// UseGrapQLResponseJsonByDefault determines whether to use 'application/graphql-response+json'
// as the response content type
// when the Accept header is empty or 'application/*' or '*/*'.
UseGrapQLResponseJsonByDefault bool
}
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 == http.MethodPost && 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
}
var pool = sync.Pool{
New: func() any {
return &graphql.RawParams{}
},
}
func (h POST) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecutor) {
ctx := r.Context()
contentType := determineResponseContentType(
h.ResponseHeaders,
r,
h.UseGrapQLResponseJsonByDefault,
)
responseHeaders := mergeHeaders(
map[string][]string{
"Content-Type": {contentType},
},
h.ResponseHeaders,
)
writeHeaders(w, responseHeaders)
params := pool.Get().(*graphql.RawParams)
defer func() {
params.Headers = nil
params.ReadTime = graphql.TraceTiming{}
params.Extensions = nil
params.OperationName = ""
params.Query = ""
params.Variables = nil
pool.Put(params)
}()
params.Headers = r.Header
start := graphql.Now()
params.ReadTime = graphql.TraceTiming{
Start: start,
End: graphql.Now(),
}
bodyBytes, err := io.ReadAll(r.Body)
if err != nil {
gqlErr := gqlerror.Errorf("could not read request body: %+v", err)
resp := exec.DispatchError(ctx, gqlerror.List{gqlErr})
writeJson(w, resp)
return
}
bodyReader := bytes.NewReader(bodyBytes)
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,
string(bodyBytes),
)
resp := exec.DispatchError(ctx, gqlerror.List{gqlErr})
writeJson(w, resp)
return
}
rc, opErr := exec.CreateOperationContext(ctx, params)
if opErr != nil {
if contentType == acceptApplicationGraphqlResponseJson {
w.WriteHeader(statusForGraphQLResponse(opErr))
} else {
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))
}
================================================
FILE: graphql/handler/transport/http_post_test.go
================================================
package transport_test
import (
"fmt"
"net/http"
"net/http/httptest"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/99designs/gqlgen/graphql/handler/testserver"
"github.com/99designs/gqlgen/graphql/handler/transport"
)
func TestPOST(t *testing.T) {
h := testserver.New()
h.AddTransport(transport.POST{})
graphqlResponseH := testserver.New()
graphqlResponseH.AddTransport(transport.POST{UseGrapQLResponseJsonByDefault: true})
jsonH := testserver.New()
jsonH.AddTransport(transport.POST{
ResponseHeaders: map[string][]string{
"Content-Type": {"application/json"},
},
})
t.Run("success with accept application/json", func(t *testing.T) {
resp := doRequest(
h,
http.MethodPost,
"/graphql",
`{"query":"{ name }"}`,
"application/json",
"application/json",
)
assert.Equal(t, http.StatusOK, resp.Code)
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(t, `{"data":{"name":"test"}}`, resp.Body.String())
})
t.Run("success with accept application/graphql-response+json", func(t *testing.T) {
resp := doRequest(
h,
http.MethodPost,
"/graphql",
`{"query":"{ name }"}`,
"application/graphql-response+json; charset=utf-8",
"application/json",
)
assert.Equal(t, http.StatusOK, resp.Code)
assert.Equal(t, "application/graphql-response+json", resp.Header().Get("Content-Type"))
assert.JSONEq(t, `{"data":{"name":"test"}}`, resp.Body.String())
})
t.Run(
"success with accept wildcard with enabling application/graphql-response+json",
func(t *testing.T) {
resp := doRequest(
graphqlResponseH,
http.MethodPost,
"/graphql",
`{"query":"{ name }"}`,
"*/*",
"application/json",
)
assert.Equal(t, http.StatusOK, resp.Code)
assert.Equal(t, "application/graphql-response+json", resp.Header().Get("Content-Type"))
assert.JSONEq(t, `{"data":{"name":"test"}}`, resp.Body.String())
},
)
t.Run(
"success with accept wildcard without enabling application/graphql-response+json",
func(t *testing.T) {
resp := doRequest(
h,
http.MethodPost,
"/graphql",
`{"query":"{ name }"}`,
"*/*",
"application/json",
)
assert.Equal(t, http.StatusOK, resp.Code)
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(t, `{"data":{"name":"test"}}`, resp.Body.String())
},
)
t.Run("success with json only", func(t *testing.T) {
resp := doRequest(
jsonH,
http.MethodPost,
"/graphql",
`{"query":"{ name }"}`,
"",
"application/json",
)
assert.Equal(t, http.StatusOK, resp.Code)
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(t, `{"data":{"name":"test"}}`, resp.Body.String())
})
t.Run("decode failure", func(t *testing.T) {
resp := doRequest(
h,
http.MethodPost,
"/graphql",
"notjson",
"application/json",
"application/json",
)
assert.Equal(t, http.StatusBadRequest, resp.Code, resp.Body.String())
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(
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, http.MethodPost, "/graphql", `{"query": "!"}`, "", "application/json")
assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String())
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(
t,
`{"errors":[{"message":"Unexpected !","locations":[{"line":1,"column":1}],"extensions":{"code":"GRAPHQL_PARSE_FAILED"}}],"data":null}`,
resp.Body.String(),
)
})
t.Run("parse failure with json only", func(t *testing.T) {
resp := doRequest(
jsonH,
http.MethodPost,
"/graphql",
`{"query": "!"}`,
"",
"application/json",
)
assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String())
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(
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,
http.MethodPost,
"/graphql",
`{"query": "{ title }"}`,
"",
"application/json",
)
assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String())
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(
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("validation failure with json only", func(t *testing.T) {
resp := doRequest(
jsonH,
http.MethodPost,
"/graphql",
`{"query": "{ title }"}`,
"",
"application/json",
)
assert.Equal(t, http.StatusUnprocessableEntity, resp.Code, resp.Body.String())
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(
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,
http.MethodPost,
"/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, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(
t,
`{"errors":[{"message":"cannot use bool as Int","path":["variable","id"],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}],"data":null}`,
resp.Body.String(),
)
})
t.Run("invalid variable with json only", func(t *testing.T) {
resp := doRequest(
jsonH,
http.MethodPost,
"/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, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(
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,
http.MethodPost,
"/graphql",
`{"query": "mutation { name }"}`,
"",
"application/json",
)
assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String())
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(
t,
`{"errors":[{"message":"mutations are not supported"}],"data":null}`,
resp.Body.String(),
)
})
t.Run("execution failure with json only", func(t *testing.T) {
resp := doRequest(
jsonH,
http.MethodPost,
"/graphql",
`{"query": "mutation { name }"}`,
"",
"application/json",
)
assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String())
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
assert.JSONEq(
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, http.MethodPost, "/graphql", `{"query":"{ name }"}`, contentType)
assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String())
assert.JSONEq(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, http.MethodPost, "/graphql", `{"query":"{ name }"}`, tc)
assert.Equal(t, http.StatusBadRequest, resp.Code, resp.Body.String())
assert.JSONEq(
t,
fmt.Sprintf(
`{"errors":[{"message":"%s"}],"data":null}`,
"transport not supported",
),
resp.Body.String(),
)
})
}
})
t.Run("validate SSE", func(t *testing.T) {
doReq := func(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")
r.Header.Set("Accept", "text/event-stream")
w := httptest.NewRecorder()
handler.ServeHTTP(w, r)
return w
}
resp := doReq(h, http.MethodPost, "/graphql", `{"query":"{ name }"}`)
assert.Equal(t, http.StatusOK, resp.Code, resp.Body.String())
assert.JSONEq(t, `{"data":{"name":"test"}}`, resp.Body.String())
})
}
func doRequest(
handler http.Handler,
method, target, body, accept, contentType string,
) *httptest.ResponseRecorder {
r := httptest.NewRequest(method, target, strings.NewReader(body))
if accept != "" {
r.Header.Set("Accept", accept)
}
r.Header.Set("Content-Type", contentType)
w := httptest.NewRecorder()
handler.ServeHTTP(w, r)
return w
}
================================================
FILE: graphql/handler/transport/options.go
================================================
package transport
import (
"net/http"
"strings"
"github.com/99designs/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 == http.MethodHead || r.Method == http.MethodOptions
}
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, ", ")
}
================================================
FILE: graphql/handler/transport/options_test.go
================================================
package transport_test
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
"github.com/99designs/gqlgen/graphql/handler/testserver"
"github.com/99designs/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)
})
}
================================================
FILE: graphql/handler/transport/reader.go
================================================
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 n, err
}
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
}
================================================
FILE: graphql/handler/transport/reader_test.go
================================================
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 range 5 {
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.EqualError(t, err, "byte slice pointer is nil")
})
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))
})
}
================================================
FILE: graphql/handler/transport/sse.go
================================================
package transport
import (
"context"
"encoding/json"
"fmt"
"io"
"log"
"mime"
"net/http"
"strings"
"sync"
"time"
"github.com/vektah/gqlparser/v2/gqlerror"
"github.com/99designs/gqlgen/graphql"
)
type (
SSE struct {
KeepAlivePingInterval time.Duration
}
sseConnection struct {
ctx context.Context
mu sync.Mutex
f http.Flusher
keepAliveTicker *time.Ticker
}
)
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
}
c := &sseConnection{
ctx: ctx,
f: flusher,
}
defer c.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)
c.ctx = ctx
w.Header().Set("Content-Type", "text/event-stream")
fmt.Fprint(w, ":\n\n")
c.flush()
if t.KeepAlivePingInterval > 0 {
c.mu.Lock()
c.keepAliveTicker = time.NewTicker(t.KeepAlivePingInterval)
c.mu.Unlock()
go c.keepAlive(w)
}
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)
c.flush()
c.resetTicker(t.KeepAlivePingInterval)
}
}
fmt.Fprint(w, "event: complete\n\n")
}
func (c *sseConnection) resetTicker(interval time.Duration) {
if interval != 0 {
c.mu.Lock()
c.keepAliveTicker.Reset(interval)
c.mu.Unlock()
}
}
func (c *sseConnection) keepAlive(w io.Writer) {
for {
select {
case <-c.ctx.Done():
c.keepAliveTicker.Stop()
return
case <-c.keepAliveTicker.C:
fmt.Fprintf(w, ": ping\n\n")
c.flush()
}
}
}
func (c *sseConnection) flush() {
c.mu.Lock()
c.f.Flush()
c.mu.Unlock()
}
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)
}
================================================
FILE: graphql/handler/transport/sse_test.go
================================================
package transport_test
import (
"bufio"
"io"
"net/http"
"net/http/httptest"
"strings"
"sync"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/99designs/gqlgen/graphql/handler/testserver"
"github.com/99designs/gqlgen/graphql/handler/transport"
)
func TestSSE(t *testing.T) {
pingInterval := time.Second * 1
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)
}
initializeKeepAliveWithServer := func() (*testserver.TestServer, *httptest.Server) {
h := testserver.New()
h.AddTransport(transport.SSE{
KeepAlivePingInterval: pingInterval,
})
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(http.MethodPost, 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.JSONEq(
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.JSONEq(
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.Go(func() {
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.Go(func() {
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.Go(func() {
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()
})
t.Run("subscribe with keep alive", func(t *testing.T) {
handler, srv := initializeKeepAliveWithServer()
defer srv.Close()
var wg sync.WaitGroup
wg.Go(func() {
// Wait for ping interval to trigger
time.Sleep(pingInterval + time.Millisecond*100)
})
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, ": ping\n", readLine(br))
assert.Equal(t, "\n", readLine(br))
wg.Go(func() {
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()
})
}
================================================
FILE: graphql/handler/transport/util.go
================================================
package transport
import (
"encoding/json"
"fmt"
"io"
"github.com/vektah/gqlparser/v2/gqlerror"
"github.com/99designs/gqlgen/graphql"
)
func writeJson(w io.Writer, response *graphql.Response) {
b, err := json.Marshal(response)
if err != nil {
panic(fmt.Errorf("unable to marshal %s: %w", string(response.Data), 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 ...any) {
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})
}
================================================
FILE: graphql/handler/transport/websocket.go
================================================
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/99designs/gqlgen/graphql"
"github.com/99designs/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
headers http.Header
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,
headers: r.Header,
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
if c.InitFunc != nil {
var ctx context.Context
ctx, initAckPayload, err = c.InitFunc(c.ctx, c.initPayload)
if err != nil {
c.sendConnectionError("%s", 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()
}()
// 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("%s", 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(),
}
params.Headers = c.headers
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 ...any) {
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)
}
}
================================================
FILE: graphql/handler/transport/websocket_close_reason.go
================================================
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
}
================================================
FILE: graphql/handler/transport/websocket_graphql_transport_ws.go
================================================
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
}
================================================
FILE: graphql/handler/transport/websocket_graphqlws.go
================================================
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
}
================================================
FILE: graphql/handler/transport/websocket_init.go
================================================
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]any
// 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
}
================================================
FILE: graphql/handler/transport/websocket_resolver_error.go
================================================
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/99designs/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
}
================================================
FILE: graphql/handler/transport/websocket_subprotocol.go
================================================
package transport
import (
"encoding/json"
"errors"
"slices"
"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 (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 !slices.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
}
================================================
FILE: graphql/handler/transport/websocket_test.go
================================================
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/99designs/gqlgen/client"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/handler/testserver"
"github.com/99designs/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.JSONEq(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.JSONEq(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.JSONEq(
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.JSONEq(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.JSONEq(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 TestWebsocketWithPassedHeaders(t *testing.T) {
h := testserver.New()
h.AddTransport(transport.Websocket{
KeepAlivePingInterval: 100 * time.Millisecond,
})
h.AroundOperations(
func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler {
assert.NotNil(t, graphql.GetOperationContext(ctx).Headers)
return next(ctx)
},
)
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.JSONEq(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, connectionErrorMsg, m.Type)
assert.JSONEq(t, `{"message":"beep boop"}`, string(m.Payload))
},
)
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]any
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)
require.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 any, 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.EqualError(t, err, "websocket read: invalid message received")
require.ErrorAs(t, err, &transport.WebsocketError{IsReadError: true})
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 := wsConnectWithSubprotocol(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 := wsConnectWithSubprotocol(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.JSONEq(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.JSONEq(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 := wsConnectWithSubprotocol(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 := wsConnectWithSubprotocol(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 := wsConnectWithSubprotocol(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 being explicit for test clarity.
PingPongInterval: 5 * time.Millisecond,
CloseFunc: func(_ context.Context, _closeCode int) {
closeFuncCalled <- true
},
})
srv := httptest.NewServer(h)
defer srv.Close()
c := wsConnectWithSubprotocol(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 := wsConnectWithSubprotocol(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 := wsConnectWithSubprotocol(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.JSONEq(t, `{"data":{"name":"test"}}`, string(msg.Payload))
// keepalive
msg = readOp(c)
assert.Equal(t, graphqltransportwsPongMsg, msg.Type)
},
)
}
func wsConnect(url string) *websocket.Conn {
return wsConnectWithSubprotocol(url, "")
}
func wsConnectWithSubprotocol(url, subprotocol string) *websocket.Conn {
h := make(http.Header)
if subprotocol != "" {
h.Add("Sec-WebSocket-Protocol", subprotocol)
}
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"`
}
================================================
FILE: graphql/handler.go
================================================
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 any, err error)
FieldMiddleware func(ctx context.Context, next Resolver) (res any, 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]any `json:"variables"`
Extensions map[string]any `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,
opCtx *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, opCtx *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 any, 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 any = 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.([]any)[index] = upload
} else {
ptr = ptr.([]any)[index]
}
} else {
if last {
ptr.(map[string]any)[p] = upload
} else {
ptr = ptr.(map[string]any)[p]
}
}
}
return nil
}
================================================
FILE: graphql/handler_test.go
================================================
package graphql
import (
"os"
"testing"
"github.com/stretchr/testify/require"
"github.com/vektah/gqlparser/v2/gqlerror"
)
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.EqualError(
t,
err,
"input: path is missing \"variables.\" prefix, key: 0, path: variables.req.0.file",
)
})
t.Run("valid variable", func(t *testing.T) {
file, _ := os.Open("path/to/file")
request := &RawParams{
Variables: map[string]any{
"file": nil,
},
}
upload := Upload{
File: file,
Filename: "a.txt",
Size: int64(5),
ContentType: "text/plain",
}
expected := &RawParams{
Variables: map[string]any{
"file": upload,
},
}
path := "variables.file"
err := request.AddUpload(upload, key, path)
require.Equal(t, (*gqlerror.Error)(nil), err)
require.Equal(t, expected, request)
})
t.Run("valid nested variable", func(t *testing.T) {
file, _ := os.Open("path/to/file")
request := &RawParams{
Variables: map[string]any{
"req": []any{
map[string]any{
"file": nil,
},
},
},
}
upload := Upload{
File: file,
Filename: "a.txt",
Size: int64(5),
ContentType: "text/plain",
}
expected := &RawParams{
Variables: map[string]any{
"req": []any{
map[string]any{
"file": upload,
},
},
},
}
path := "variables.req.0.file"
err := request.AddUpload(upload, key, path)
require.Equal(t, (*gqlerror.Error)(nil), err)
require.Equal(t, expected, request)
})
}
================================================
FILE: graphql/id.go
================================================
package graphql
import (
"encoding/json"
"fmt"
"io"
"strconv"
)
func MarshalID(s string) Marshaler {
return MarshalString(s)
}
func UnmarshalID(v any) (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 strconv.FormatFloat(v, 'f', 6, 64), nil
case bool:
return strconv.FormatBool(v), 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 any) (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 MarshalUintID(i uint) Marshaler {
return WriterFunc(func(w io.Writer) {
writeQuotedString(w, strconv.FormatUint(uint64(i), 10))
})
}
func UnmarshalUintID(v any) (uint, error) {
switch v := v.(type) {
case string:
result, err := strconv.ParseUint(v, 10, 64)
return uint(result), err
case int:
return uint(v), nil
case int64:
return uint(v), nil
case int32:
return uint(v), nil
case uint32:
return uint(v), nil
case uint64:
return uint(v), nil
case json.Number:
result, err := strconv.ParseUint(string(v), 10, 64)
return uint(result), err
default:
return 0, fmt.Errorf("%T is not an uint", v)
}
}
================================================
FILE: graphql/id_test.go
================================================
package graphql
import (
"bytes"
"encoding/json"
"math"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
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 any
Expected string
ShouldError bool
}{
{
Name: "string",
Input: "str",
Expected: "str",
},
{
Name: "json.Number float64",
Input: json.Number("1.2"),
Expected: "1.2",
},
{
Name: "int64",
Input: int64(12),
Expected: "12",
},
{
Name: "int64 max",
Input: math.MaxInt64,
Expected: "9223372036854775807",
},
{
Name: "int64 min",
Input: math.MinInt64,
Expected: "-9223372036854775808",
},
{
Name: "bool true",
Input: true,
Expected: "true",
},
{
Name: "bool false",
Input: false,
Expected: "false",
},
{
Name: "nil",
Input: nil,
Expected: "null",
},
{
Name: "float64",
Input: 1.234567,
Expected: "1.234567",
},
{
Name: "float64 0",
Input: 0.0,
Expected: "0.000000",
},
{
Name: "float64 loss of precision",
Input: 0.0000005,
Expected: "0.000000",
},
{
Name: "float64 rounding up",
Input: 0.0000006,
Expected: "0.000001",
},
{
Name: "float64 negative",
Input: -1.234560,
Expected: "-1.234560",
},
{
Name: "float64 math.Inf(0)",
Input: math.Inf(0),
Expected: "+Inf",
},
{
Name: "float64 math.Inf(-1)",
Input: math.Inf(-1),
Expected: "-Inf",
},
{
Name: "float64 -math.Inf(0)",
Input: -math.Inf(0),
Expected: "-Inf",
},
{
Name: "not a string",
Input: struct{}{},
ShouldError: true,
},
}
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 {
require.NoError(t, err)
}
})
}
}
func TestMarshalUintID(t *testing.T) {
assert.Equal(t, `"12"`, m2s(MarshalUintID(12)))
}
func TestUnMarshalUintID(t *testing.T) {
result, err := UnmarshalUintID("12")
assert.Equal(t, uint(12), result)
require.NoError(t, err)
result, err = UnmarshalUintID(12)
assert.Equal(t, uint(12), result)
require.NoError(t, err)
result, err = UnmarshalUintID(int64(12))
assert.Equal(t, uint(12), result)
require.NoError(t, err)
result, err = UnmarshalUintID(int32(12))
assert.Equal(t, uint(12), result)
require.NoError(t, err)
result, err = UnmarshalUintID(int(12))
assert.Equal(t, uint(12), result)
require.NoError(t, err)
result, err = UnmarshalUintID(uint32(12))
assert.Equal(t, uint(12), result)
require.NoError(t, err)
result, err = UnmarshalUintID(uint64(12))
assert.Equal(t, uint(12), result)
require.NoError(t, err)
}
================================================
FILE: graphql/input.go
================================================
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 ...any) 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 any) 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")
}
================================================
FILE: graphql/int.go
================================================
package graphql
import (
"encoding/json"
"fmt"
"io"
"math"
"reflect"
"strconv"
)
func MarshalInt(i int) Marshaler {
return WriterFunc(func(w io.Writer) {
_, _ = io.WriteString(w, strconv.FormatInt(int64(i), 10))
})
}
func UnmarshalInt(v any) (int, error) {
return interfaceToSignedNumber[int](v)
}
func MarshalInt8(i int8) Marshaler {
return WriterFunc(func(w io.Writer) {
_, _ = io.WriteString(w, strconv.FormatInt(int64(i), 10))
})
}
func UnmarshalInt8(v any) (int8, error) {
return interfaceToSignedNumber[int8](v)
}
func MarshalInt16(i int16) Marshaler {
return WriterFunc(func(w io.Writer) {
_, _ = io.WriteString(w, strconv.FormatInt(int64(i), 10))
})
}
func UnmarshalInt16(v any) (int16, error) {
return interfaceToSignedNumber[int16](v)
}
func MarshalInt32(i int32) Marshaler {
return WriterFunc(func(w io.Writer) {
_, _ = io.WriteString(w, strconv.FormatInt(int64(i), 10))
})
}
func UnmarshalInt32(v any) (int32, error) {
return interfaceToSignedNumber[int32](v)
}
func MarshalInt64(i int64) Marshaler {
return WriterFunc(func(w io.Writer) {
_, _ = io.WriteString(w, strconv.FormatInt(i, 10))
})
}
func UnmarshalInt64(v any) (int64, error) {
return interfaceToSignedNumber[int64](v)
}
type number interface {
int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64
}
func interfaceToSignedNumber[N number](v any) (N, error) {
switch v := v.(type) {
case int, int8, int16, int32, int64:
return safeCastSignedNumber[N](reflect.ValueOf(v).Int())
case string:
iv, err := strconv.ParseInt(v, 10, 64)
if err != nil {
return 0, err
}
return safeCastSignedNumber[N](iv)
case json.Number:
iv, err := strconv.ParseInt(string(v), 10, 64)
if err != nil {
return 0, err
}
return safeCastSignedNumber[N](iv)
case nil:
return 0, nil
default:
return 0, fmt.Errorf("%T is not an %T", v, N(0))
}
}
// IntegerError is an error type that allows users to identify errors associated
// with receiving an integer value that is not valid for the specific integer
// type designated by the API. IntegerErrors designate otherwise valid unsigned
// or signed 64-bit integers that are invalid in a specific context: they do not
// designate integers that overflow 64-bit versions of the current type.
type IntegerError struct {
Message string
}
func (e IntegerError) Error() string {
return e.Message
}
type NumberOverflowError struct {
Value any
*IntegerError
}
type maxNumber interface {
int64 | uint64
}
func newNumberOverflowError[N maxNumber](i any, bitsize int) *NumberOverflowError {
switch v := i.(type) {
case int64:
return &NumberOverflowError{
Value: v,
IntegerError: &IntegerError{
Message: fmt.Sprintf("%d overflows signed %d-bit integer", i, bitsize),
},
}
default:
return &NumberOverflowError{
Value: v,
IntegerError: &IntegerError{
Message: fmt.Sprintf("%d overflows unsigned %d-bit integer", i, bitsize),
},
}
}
}
func (e *NumberOverflowError) Unwrap() error {
return e.IntegerError
}
// safeCastSignedNumber converts an int64 to a number of type N.
func safeCastSignedNumber[N number](val int64) (N, error) {
var zero N
switch any(zero).(type) {
case int8:
if val > math.MaxInt8 || val < math.MinInt8 {
return 0, newNumberOverflowError[int64](val, 8)
}
case int16:
if val > math.MaxInt16 || val < math.MinInt16 {
return 0, newNumberOverflowError[int64](val, 16)
}
case int32:
if val > math.MaxInt32 || val < math.MinInt32 {
return 0, newNumberOverflowError[int64](val, 32)
}
case int:
if strconv.IntSize == 32 && (val > math.MaxInt32 || val < math.MinInt32) {
return 0, newNumberOverflowError[int64](val, 32)
}
case int64:
default:
return 0, fmt.Errorf("invalid type %T", zero)
}
return N(val), nil
}
================================================
FILE: graphql/int_test.go
================================================
package graphql
import (
"encoding/json"
"fmt"
"math"
"math/rand/v2"
"strconv"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
const LENGTH = 1000
func TestInt8(t *testing.T) {
t.Run("marshal", func(t *testing.T) {
assert.Equal(t, "123", m2s(MarshalInt8(123)))
})
t.Run("unmarshal", func(t *testing.T) {
assert.Equal(t, int8(0), mustUnmarshalInt8(t, nil))
assert.Equal(t, int8(123), mustUnmarshalInt8(t, 123))
assert.Equal(t, int8(123), mustUnmarshalInt8(t, int64(123)))
assert.Equal(t, int8(123), mustUnmarshalInt8(t, json.Number("123")))
assert.Equal(t, int8(123), mustUnmarshalInt8(t, "123"))
assert.Equal(t, int8(0), mustUnmarshalInt8(t, nil))
})
t.Run("overflow", func(t *testing.T) {
cases := []struct {
name string
v any
err string
}{
{"positive int overflow", math.MaxInt8 + 1, "128 overflows signed 8-bit integer"},
{"negative int overflow", math.MinInt8 - 1, "-129 overflows signed 8-bit integer"},
{
"positive int64 overflow",
int64(math.MaxInt8 + 1),
"128 overflows signed 8-bit integer",
},
{
"negative int64 overflow",
int64(math.MinInt8 - 1),
"-129 overflows signed 8-bit integer",
},
{
"positive json.Number overflow",
json.Number("128"),
"128 overflows signed 8-bit integer",
},
{
"negative json.Number overflow",
json.Number("-129"),
"-129 overflows signed 8-bit integer",
},
{"positive string overflow", "128", "128 overflows signed 8-bit integer"},
{"negative string overflow", "-129", "-129 overflows signed 8-bit integer"},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
var numberOverflowErr *NumberOverflowError
var intErr *IntegerError
res, err := UnmarshalInt8(tc.v)
require.EqualError(
t,
err,
tc.err,
)
require.ErrorAs(
t,
err,
&numberOverflowErr,
)
require.ErrorAs(
t,
err,
&intErr,
)
assert.Equal(t, int8(0), res)
})
}
})
t.Run("invalid string numbers are not integer errors", func(t *testing.T) {
var intErr *IntegerError
res, err := UnmarshalInt8("-1.03")
require.EqualError(
t,
err,
"strconv.ParseInt: parsing \"-1.03\": invalid syntax",
)
assert.NotErrorAs(t, err, &intErr)
assert.Equal(t, int8(0), res)
res, err = UnmarshalInt8(json.Number(" 1"))
require.EqualError(
t,
err,
"strconv.ParseInt: parsing \" 1\": invalid syntax",
)
assert.NotErrorAs(t, err, &intErr)
assert.Equal(t, int8(0), res)
})
}
func mustUnmarshalInt8(t *testing.T, v any) int8 {
t.Helper()
res, err := UnmarshalInt8(v)
require.NoError(t, err)
return res
}
func TestInt16(t *testing.T) {
t.Run("marshal", func(t *testing.T) {
assert.Equal(t, "123", m2s(MarshalInt16(123)))
})
t.Run("unmarshal", func(t *testing.T) {
assert.Equal(t, int16(0), mustUnmarshalInt16(t, nil))
assert.Equal(t, int16(123), mustUnmarshalInt16(t, 123))
assert.Equal(t, int16(123), mustUnmarshalInt16(t, int64(123)))
assert.Equal(t, int16(123), mustUnmarshalInt16(t, json.Number("123")))
assert.Equal(t, int16(123), mustUnmarshalInt16(t, "123"))
assert.Equal(t, int16(0), mustUnmarshalInt16(t, nil))
})
t.Run("overflow", func(t *testing.T) {
cases := []struct {
name string
v any
err string
}{
{"positive int overflow", math.MaxInt16 + 1, "32768 overflows signed 16-bit integer"},
{"negative int overflow", math.MinInt16 - 1, "-32769 overflows signed 16-bit integer"},
{
"positive int64 overflow",
int64(math.MaxInt16 + 1),
"32768 overflows signed 16-bit integer",
},
{
"negative int64 overflow",
int64(math.MinInt16 - 1),
"-32769 overflows signed 16-bit integer",
},
{
"positive json.Number overflow",
json.Number("32768"),
"32768 overflows signed 16-bit integer",
},
{
"negative json.Number overflow",
json.Number("-32769"),
"-32769 overflows signed 16-bit integer",
},
{"positive string overflow", "32768", "32768 overflows signed 16-bit integer"},
{"negative string overflow", "-32769", "-32769 overflows signed 16-bit integer"},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
var numberOverflowErr *NumberOverflowError
var intErr *IntegerError
res, err := UnmarshalInt16(tc.v)
require.EqualError(
t,
err,
tc.err,
)
require.ErrorAs(
t,
err,
&numberOverflowErr,
)
require.ErrorAs(
t,
err,
&intErr,
)
assert.Equal(t, int16(0), res)
})
}
})
t.Run("invalid string numbers are not integer errors", func(t *testing.T) {
var intErr *IntegerError
res, err := UnmarshalInt16("-1.03")
require.EqualError(
t,
err,
"strconv.ParseInt: parsing \"-1.03\": invalid syntax",
)
assert.NotErrorAs(t, err, &intErr)
assert.Equal(t, int16(0), res)
res, err = UnmarshalInt16(json.Number(" 1"))
require.EqualError(
t,
err,
"strconv.ParseInt: parsing \" 1\": invalid syntax",
)
assert.NotErrorAs(t, err, &intErr)
assert.Equal(t, int16(0), res)
})
}
func mustUnmarshalInt16(t *testing.T, v any) int16 {
t.Helper()
res, err := UnmarshalInt16(v)
require.NoError(t, err)
return res
}
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, 0, mustUnmarshalInt(t, nil))
assert.Equal(t, 123, mustUnmarshalInt(t, 123))
assert.Equal(t, 123, mustUnmarshalInt(t, int64(123)))
assert.Equal(t, 123, mustUnmarshalInt(t, json.Number("123")))
assert.Equal(t, 123, mustUnmarshalInt(t, "123"))
assert.Equal(t, 0, mustUnmarshalInt(t, nil))
})
}
func mustUnmarshalInt(t *testing.T, v any) int {
t.Helper()
res, err := UnmarshalInt(v)
require.NoError(t, 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(0), mustUnmarshalInt32(t, nil))
assert.Equal(t, int32(123), mustUnmarshalInt32(t, 123))
assert.Equal(t, int32(123), mustUnmarshalInt32(t, int64(123)))
assert.Equal(t, int32(123), mustUnmarshalInt32(t, json.Number("123")))
assert.Equal(t, int32(123), mustUnmarshalInt32(t, "123"))
assert.Equal(t, int32(0), mustUnmarshalInt32(t, nil))
})
t.Run("overflow", func(t *testing.T) {
cases := []struct {
name string
v any
err string
}{
{
"positive int overflow",
math.MaxInt32 + 1,
"2147483648 overflows signed 32-bit integer",
},
{
"negative int overflow",
math.MinInt32 - 1,
"-2147483649 overflows signed 32-bit integer",
},
{
"positive int64 overflow",
int64(math.MaxInt32 + 1),
"2147483648 overflows signed 32-bit integer",
},
{
"negative int64 overflow",
int64(math.MinInt32 - 1),
"-2147483649 overflows signed 32-bit integer",
},
{
"positive json.Number overflow",
json.Number("2147483648"),
"2147483648 overflows signed 32-bit integer",
},
{
"negative json.Number overflow",
json.Number("-2147483649"),
"-2147483649 overflows signed 32-bit integer",
},
{
"positive string overflow",
"2147483648",
"2147483648 overflows signed 32-bit integer",
},
{
"negative string overflow",
"-2147483649",
"-2147483649 overflows signed 32-bit integer",
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
var numberOverflowErr *NumberOverflowError
var intErr *IntegerError
res, err := UnmarshalInt32(tc.v)
require.EqualError(
t,
err,
tc.err,
)
require.ErrorAs(
t,
err,
&numberOverflowErr,
)
require.ErrorAs(
t,
err,
&intErr,
)
assert.Equal(t, int32(0), res)
})
}
})
t.Run("invalid string numbers are not integer errors", func(t *testing.T) {
var intErr *IntegerError
res, err := UnmarshalInt32("-1.03")
require.EqualError(
t,
err,
"strconv.ParseInt: parsing \"-1.03\": invalid syntax",
)
assert.NotErrorAs(t, err, &intErr)
assert.Equal(t, int32(0), res)
res, err = UnmarshalInt32(json.Number(" 1"))
require.EqualError(
t,
err,
"strconv.ParseInt: parsing \" 1\": invalid syntax",
)
assert.NotErrorAs(t, err, &intErr)
assert.Equal(t, int32(0), res)
})
}
func mustUnmarshalInt32(t *testing.T, v any) int32 {
t.Helper()
res, err := UnmarshalInt32(v)
require.NoError(t, err)
return res
}
func TestInt64(t *testing.T) {
t.Run("marshal", func(t *testing.T) {
assert.Equal(t, "123", m2s(MarshalInt64(123)))
})
t.Run("unmarshal", func(t *testing.T) {
assert.Equal(t, int64(0), mustUnmarshalInt64(t, nil))
assert.Equal(t, int64(123), mustUnmarshalInt64(t, 123))
assert.Equal(t, int64(123), mustUnmarshalInt64(t, int64(123)))
assert.Equal(t, int64(123), mustUnmarshalInt64(t, json.Number("123")))
assert.Equal(t, int64(123), mustUnmarshalInt64(t, "123"))
assert.Equal(t, int64(0), mustUnmarshalInt64(t, nil))
})
}
func mustUnmarshalInt64(t *testing.T, v any) int64 {
t.Helper()
res, err := UnmarshalInt64(v)
require.NoError(t, err)
return res
}
func beforeUnmarshalInt(v any) (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))
case nil:
return 0, nil
default:
return 0, fmt.Errorf("%T is not an int", v)
}
}
func BenchmarkUnmarshalIntInitial(b *testing.B) {
numbers := makeRandomNumberSlice(true)
for b.Loop() {
for i := range numbers {
_, _ = beforeUnmarshalInt(numbers[i])
}
}
}
func BenchmarkUnmarshalIntNew(b *testing.B) {
numbers := makeRandomNumberSlice(true)
for b.Loop() {
for i := range numbers {
_, _ = UnmarshalInt(numbers[i])
}
}
}
func makeRandomNumberSlice(signed bool) []any {
numbers := make([]any, LENGTH)
for i := range numbers {
numbers[i] = randomNumber(signed)
}
return numbers
}
func randomNumber(signed bool) any {
switch rand.UintN(4) {
case 0:
switch signed {
case true:
return rand.Int()
case false:
return rand.Uint()
}
case 1:
switch signed {
case true:
return rand.Int64()
case false:
return rand.Uint64()
}
case 2:
switch signed {
case true:
return json.Number(strconv.FormatInt(rand.Int64(), 10))
case false:
return json.Number(strconv.FormatUint(rand.Uint64(), 10))
}
case 3:
switch signed {
case true:
return strconv.FormatInt(rand.Int64(), 10)
case false:
return strconv.FormatUint(rand.Uint64(), 10)
}
}
panic("unreachable")
}
================================================
FILE: graphql/introspection/introspection.go
================================================
// 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
deprecation *ast.Directive
}
)
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) IsDeprecated() bool {
return f.deprecation != nil
}
func (f *InputValue) 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 *InputValue) Description() *string {
if f.description == "" {
return nil
}
return &f.description
}
func (f *Directive) Description() *string {
if f.description == "" {
return nil
}
return &f.description
}
================================================
FILE: graphql/introspection/query.go
================================================
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
}
}
}
}
}
}
}
}
`
================================================
FILE: graphql/introspection/schema.go
================================================
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,
}
}
================================================
FILE: graphql/introspection/schema_test.go
================================================
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())
})
}
================================================
FILE: graphql/introspection/type.go
================================================
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),
deprecation: arg.Directives.ForName("deprecated"),
})
}
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),
deprecation: f.Directives.ForName("deprecated"),
})
}
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 && t.def.Kind != ast.Interface) {
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 {
if t.def == nil {
return nil
}
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
}
func (t *Type) IsOneOf() bool {
if t.def == nil {
return false
}
directive := t.def.Directives.ForName("oneOf")
if t.def.Kind != ast.InputObject || directive == nil {
return false
}
return true
}
================================================
FILE: graphql/introspection/type_test.go
================================================
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 includeDeprecated", 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)
})
}
================================================
FILE: graphql/jsonw.go
================================================
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 any) error
}
type ContextMarshaler interface {
MarshalGQLContext(ctx context.Context, w io.Writer) error
}
type ContextUnmarshaler interface {
UnmarshalGQLContext(ctx context.Context, v any) 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
}
================================================
FILE: graphql/jsonw_test.go
================================================
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.JSONEq(
t,
`{"test":10,"array":[1,"2",true,false,null,1.3,true],"emptyArray":[],"child":{"child":{"child":null}}}`,
b.String(),
)
}
================================================
FILE: graphql/map.go
================================================
package graphql
import (
"encoding/json"
"fmt"
"io"
)
func MarshalMap(val map[string]any) Marshaler {
return WriterFunc(func(w io.Writer) {
err := json.NewEncoder(w).Encode(val)
if err != nil {
panic(err)
}
})
}
func UnmarshalMap(v any) (map[string]any, error) {
if m, ok := v.(map[string]any); ok {
return m, nil
}
return nil, fmt.Errorf("%T is not a map", v)
}
================================================
FILE: graphql/omittable.go
================================================
package graphql
import (
"context"
"encoding/json"
"io"
)
// 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
}
// IsZero returns true then json.Marshal will omit this value.
// > The "omitzero" option specifies that the field should be omitted from the encoding if the field
// has a zero value, according to rules: > 1) If the field type has an "IsZero() bool" method, that
// will be used to determine whether the value is zero.
// > 2) Otherwise, the value is zero if it is the zero value for its type.
// https://pkg.go.dev/encoding/json#Marshal
func (o Omittable[T]) IsZero() bool {
return !o.set
}
func (o Omittable[T]) MarshalJSON() ([]byte, error) {
var value any = o.value
if !o.set {
var zero T
value = zero
}
return json.Marshal(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
}
func (o Omittable[T]) MarshalGQL(w io.Writer) {
var value any = o.value
if !o.set {
var zero T
value = zero
}
switch marshaler := value.(type) {
case Marshaler:
marshaler.MarshalGQL(w)
case ContextMarshaler:
_ = marshaler.MarshalGQLContext(context.Background(), w)
default:
b, _ := json.Marshal(value)
w.Write(b)
}
}
func (o *Omittable[T]) UnmarshalGQL(bytes []byte) error {
switch unmarshaler := any(o.value).(type) {
case Unmarshaler:
if err := unmarshaler.UnmarshalGQL(bytes); err != nil {
return err
}
o.set = true
case ContextUnmarshaler:
if err := unmarshaler.UnmarshalGQLContext(context.Background(), bytes); err != nil {
return err
}
o.set = true
default:
if err := json.Unmarshal(bytes, &o.value); err != nil {
return err
}
o.set = true
}
return nil
}
func (o Omittable[T]) MarshalGQLContext(ctx context.Context, w io.Writer) {
var value any = o.value
if !o.set {
var zero T
value = zero
}
switch marshaler := value.(type) {
case ContextMarshaler:
_ = marshaler.MarshalGQLContext(ctx, w)
case Marshaler:
marshaler.MarshalGQL(w)
default:
b, _ := json.Marshal(value)
w.Write(b)
}
}
func (o *Omittable[T]) UnmarshalGQLContext(ctx context.Context, bytes []byte) error {
switch unmarshaler := any(o.value).(type) {
case ContextUnmarshaler:
if err := unmarshaler.UnmarshalGQLContext(ctx, bytes); err != nil {
return err
}
o.set = true
case Unmarshaler:
if err := unmarshaler.UnmarshalGQL(bytes); err != nil {
return err
}
o.set = true
default:
if err := json.Unmarshal(bytes, &o.value); err != nil {
return err
}
o.set = true
}
return nil
}
================================================
FILE: graphql/omittable_go124_test.go
================================================
package graphql
import (
"encoding/json"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestOmittableIsZeroTrue_MarshalJSONGo124(t *testing.T) {
s := "test"
testCases := []struct {
name string
input any
expectedJSON string
}{
{
name: "simple string omitzero IsZero=true",
input: struct {
Value Omittable[string] `json:",omitzero"`
}{},
expectedJSON: `{}`,
},
{
name: "string pointer",
input: struct{ Value Omittable[*string] }{Value: OmittableOf(&s)},
expectedJSON: `{"Value":"test"}`,
},
{
name: "string pointer omitzero IsZero=true",
input: struct {
Value Omittable[*string] `json:",omitzero"`
}{},
expectedJSON: `{}`,
},
{
name: "omitted integer",
input: struct{ Value Omittable[int] }{},
expectedJSON: `{"Value":0}`,
},
{
name: "omitted integer omitzero IsZero=true",
input: struct {
Value Omittable[int] `json:",omitzero"`
}{},
expectedJSON: `{}`,
},
{
name: "omittable omittable omitzero IsZero=true", //nolint:dupword
input: struct {
Value Omittable[Omittable[uint64]] `json:",omitzero"`
}{},
expectedJSON: `{}`,
},
{
name: "omittable struct Value omitzero IsZero=true",
input: struct {
Value Omittable[struct {
Inner string
}] `json:",omitzero"`
}{},
expectedJSON: `{}`,
},
{
name: "omittable struct Inner omitzero IsZero=true",
input: struct {
Value Omittable[struct {
Inner Omittable[string] `json:",omitzero"`
}]
}{},
expectedJSON: `{"Value":{}}`,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
data, err := json.Marshal(tc.input)
require.NoError(t, err)
assert.Equal(t, tc.expectedJSON, string(data))
})
}
}
func TestOmittableIsZeroFalse_MarshalJSONGo124(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: "simple string omitzero IsZero=false",
input: struct {
Value Omittable[string] `json:",omitzero"`
}{
Value: OmittableOf(""),
},
expectedJSON: `{"Value":""}`,
},
{
name: "string pointer",
input: struct{ Value Omittable[*string] }{Value: OmittableOf(&s)},
expectedJSON: `{"Value":"test"}`,
},
{
name: "string pointer omitzero IsZero=false",
input: struct {
Value Omittable[*string] `json:",omitzero"`
}{
Value: OmittableOf[*string](nil),
},
expectedJSON: `{"Value":null}`,
},
{
name: "omitted integer",
input: struct{ Value Omittable[int] }{},
expectedJSON: `{"Value":0}`,
},
{
name: "omitted integer omitzero IsZero=false",
input: struct {
Value Omittable[int] `json:",omitzero"`
}{
Value: OmittableOf(0),
},
expectedJSON: `{"Value":0}`,
},
{
name: "omittable omittable", //nolint:dupword
input: struct{ Value Omittable[Omittable[uint64]] }{
Value: OmittableOf(OmittableOf(uint64(42))),
},
expectedJSON: `{"Value":42}`,
},
{
name: "omittable omittable omitzero IsZero=false", //nolint:dupword
input: struct {
Value Omittable[Omittable[uint64]] `json:",omitzero"`
}{
Value: OmittableOf(OmittableOf(uint64(0))),
},
expectedJSON: `{"Value":0}`,
},
{
name: "omittable struct",
input: struct {
Value Omittable[struct{ Inner string }]
}{Value: OmittableOf(struct{ Inner string }{})},
expectedJSON: `{"Value":{"Inner":""}}`,
},
{
name: "omittable struct Value omitzero IsZero=false",
input: struct {
Value Omittable[struct {
Inner string
}] `json:",omitzero"`
}{
Value: OmittableOf(struct {
Inner string
}{
Inner: "",
}),
},
expectedJSON: `{"Value":{"Inner":""}}`,
},
{
name: "omittable struct Inner omitzero IsZero=false",
input: struct {
Value Omittable[struct {
Inner Omittable[string] `json:",omitzero"`
}]
}{
Value: OmittableOf(struct {
Inner Omittable[string] `json:",omitzero"`
}{
Inner: OmittableOf(""),
}),
},
expectedJSON: `{"Value":{"Inner":""}}`,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
data, err := json.Marshal(tc.input)
require.NoError(t, err)
assert.Equal(t, tc.expectedJSON, string(data))
})
}
}
================================================
FILE: graphql/omittable_test.go
================================================
package graphql
import (
"encoding/json"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
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())
}
================================================
FILE: graphql/oneshot.go
================================================
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
}
}
================================================
FILE: graphql/playground/altair_playground.go
================================================
package playground
import (
"encoding/json"
"html/template"
"net/http"
)
var altairPage = template.Must(template.New("altair").Parse(`
{{.title}}
`))
// AltairHandler responsible for setting up the altair playground
func AltairHandler(title, endpoint string, options map[string]any) http.HandlerFunc {
jsonOptions, err := json.Marshal(options)
if err != nil {
jsonOptions = []byte("{}")
}
return func(w http.ResponseWriter, r *http.Request) {
err := altairPage.Execute(w, map[string]any{
"title": title,
"endpoint": endpoint,
"endpointIsAbsolute": endpointHasScheme(endpoint),
"subscriptionEndpoint": getSubscriptionEndpoint(endpoint),
"version": "8.1.3",
"cssSRI": "sha256-aYcodhWPcqIHh2lLDWeoq+irtg7qkWLLLK30gjQJZc8=",
"mainSRI": "sha256-bjpcMy7w3aaX8Cjuyv5hPE9FlkJRys0kxooPRtbGd8c=",
"polyfillsSRI": "sha256-+hQzPqfWEkAfOfKytrW7hLceq0mUR3pHXn+UzwhrWQ0=",
"runtimeSRI": "sha256-2SHK1nFbucnnM02VXrl4CAKDYQbJEF9HVZstRkVbkJM=",
"options": string(jsonOptions),
})
if err != nil {
panic(err)
}
}
}
================================================
FILE: graphql/playground/altair_playground_test.go
================================================
package playground
import (
"net/http"
"testing"
)
func TestAltairHandler_Integrity(t *testing.T) {
testResourceIntegrity(
t,
func(title, endpoint string) http.HandlerFunc { return AltairHandler(title, endpoint, nil) },
)
}
================================================
FILE: graphql/playground/apollo_sandbox_playground.go
================================================
package playground
import (
"encoding/json"
"fmt"
"html/template"
"net/http"
)
const (
apolloSandboxMainJs = "https://embeddable-sandbox.cdn.apollographql.com/02e2da0fccbe0240ef03d2396d6c98559bab5b06/embeddable-sandbox.umd.production.min.js"
apolloSandboxMainSri = "sha256-asj/scPAF8jmMGj1J+YwCHps3uI57AZ78cHs0bJkML4="
)
// 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 := &apolloSandboxHandlerOptions{
MainJs: apolloSandboxMainJs,
MainSri: apolloSandboxMainSri,
ApolloSandboxOption: &apolloSandboxOptions{
HideCookieToggle: true,
EndpointIsEditable: false,
InitialState: &apolloSandboxInitialState{
IncludeCookies: true,
PollForSchemaUpdates: false,
},
},
}
for _, opt := range opts {
opt(options)
}
optionsBytes, err := json.Marshal(options.ApolloSandboxOption)
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]any{
"title": title,
"endpoint": endpoint,
"endpointIsAbsolute": endpointHasScheme(endpoint),
"mainJs": options.MainJs,
"mainSRI": options.MainSri,
"options": string(optionsBytes),
})
if err != nil {
panic(err)
}
}
}
type apolloSandboxHandlerOptions struct {
MainJs string
MainSri string
ApolloSandboxOption *apolloSandboxOptions
}
// 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 *apolloSandboxHandlerOptions)
// 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 *apolloSandboxHandlerOptions) {
options.ApolloSandboxOption.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 *apolloSandboxHandlerOptions) {
options.ApolloSandboxOption.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 *apolloSandboxHandlerOptions) {
options.ApolloSandboxOption.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 *apolloSandboxHandlerOptions) {
options.ApolloSandboxOption.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 *apolloSandboxHandlerOptions) {
options.ApolloSandboxOption.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 *apolloSandboxHandlerOptions) {
options.ApolloSandboxOption.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 *apolloSandboxHandlerOptions) {
options.ApolloSandboxOption.InitialState.CollectionId = collectionId
options.ApolloSandboxOption.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 *apolloSandboxHandlerOptions) {
options.ApolloSandboxOption.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 *apolloSandboxHandlerOptions) {
options.ApolloSandboxOption.InitialState.SharedHeaders = sharedHeaders
}
}
// WithApolloSandboxJs The main javascript resource and its subresource integrity checksum
//
// You can change the version of apollo sandbox.
func WithApolloSandboxJs(mainJs, mainSri string) ApolloSandboxOption {
return func(options *apolloSandboxHandlerOptions) {
options.MainJs = mainJs
options.MainSri = mainSri
}
}
================================================
FILE: graphql/playground/apollo_sandbox_playground_test.go
================================================
package playground
import (
"net/http"
"testing"
)
func TestApolloSandboxHandler_Integrity(t *testing.T) {
testResourceIntegrity(t, func(title, endpoint string) http.HandlerFunc {
return ApolloSandboxHandler(title, endpoint)
})
}
================================================
FILE: graphql/playground/helper_test.go
================================================
package playground
import (
"crypto/sha256"
"encoding/base64"
"io"
"net/http"
"net/http/httptest"
"strings"
"testing"
"github.com/PuerkitoBio/goquery"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func testResourceIntegrity(t *testing.T, handler func(title, endpoint string) http.HandlerFunc) {
t.Helper()
recorder := httptest.NewRecorder()
request := httptest.NewRequest(http.MethodGet, "http://localhost:8080/", http.NoBody)
handler("example.org API", "/query").ServeHTTP(recorder, request)
res := recorder.Result()
defer require.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)
require.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, urlAttrKey, integrityAttrKey string,
) {
t.Helper()
selection := doc.Find(selector)
for _, node := range selection.Nodes {
var url string
var integrity string
for _, attribute := range node.Attr {
switch attribute.Key {
case urlAttrKey:
url = attribute.Val
case integrityAttrKey:
integrity = attribute.Val
}
}
if integrity != "" {
assert.NotEmpty(t, url)
}
if url != "" && integrity != "" {
resp, err := http.Get(baseUrl + url)
require.NoError(t, err)
hasher := sha256.New()
_, err = io.Copy(hasher, resp.Body)
require.NoError(t, err)
require.NoError(t, resp.Body.Close())
actual := "sha256-" + base64.StdEncoding.EncodeToString(hasher.Sum(nil))
assert.Equal(t, integrity, actual)
}
}
}
================================================
FILE: graphql/playground/playground.go
================================================
package playground
import (
"html/template"
"net/http"
"net/url"
)
var page = template.Must(template.New("graphiql").Parse(`
{{.Title}}
{{- if .EnablePluginExplorer}}
{{- end}}
Loading…
{{- if .EnablePluginExplorer}}
{{- end}}
`))
type GraphiqlConfig struct {
Title string
StoragePrefix string
Endpoint string
FetcherHeaders map[string]string
UiHeaders map[string]string
EndpointIsAbsolute bool
SubscriptionEndpoint string
JsUrl template.URL
JsSRI string
CssUrl template.URL
CssSRI string
ReactUrl template.URL
ReactSRI string
ReactDOMUrl template.URL
ReactDOMSRI string
EnablePluginExplorer bool
PluginExplorerJsUrl template.URL
PluginExplorerJsSRI string
PluginExplorerCssUrl template.URL
PluginExplorerCssSRI string
}
type GraphiqlConfigOption func(*GraphiqlConfig)
func WithGraphiqlFetcherHeaders(headers map[string]string) GraphiqlConfigOption {
return func(config *GraphiqlConfig) {
config.FetcherHeaders = headers
}
}
func WithGraphiqlUiHeaders(headers map[string]string) GraphiqlConfigOption {
return func(config *GraphiqlConfig) {
config.UiHeaders = headers
}
}
func WithGraphiqlVersion(jsUrl, cssUrl, jsSri, cssSri string) GraphiqlConfigOption {
return func(config *GraphiqlConfig) {
config.JsUrl = template.URL(jsUrl)
config.CssUrl = template.URL(cssUrl)
config.JsSRI = jsSri
config.CssSRI = cssSri
}
}
func WithGraphiqlReactVersion(
reactJsUrl, reactDomJsUrl, reactJsSri, reactDomJsSri string,
) GraphiqlConfigOption {
return func(config *GraphiqlConfig) {
config.ReactUrl = template.URL(reactJsUrl)
config.ReactDOMUrl = template.URL(reactDomJsUrl)
config.ReactSRI = reactJsSri
config.ReactDOMSRI = reactDomJsSri
}
}
func WithGraphiqlPluginExplorerVersion(jsUrl, cssUrl, jsSri, cssSri string) GraphiqlConfigOption {
return func(config *GraphiqlConfig) {
config.PluginExplorerJsUrl = template.URL(jsUrl)
config.PluginExplorerCssUrl = template.URL(cssUrl)
config.PluginExplorerJsSRI = jsSri
config.PluginExplorerCssSRI = cssSri
}
}
func WithGraphiqlEnablePluginExplorer(enable bool) GraphiqlConfigOption {
return func(config *GraphiqlConfig) {
config.EnablePluginExplorer = enable
}
}
func WithStoragePrefix(prefix string) GraphiqlConfigOption {
return func(config *GraphiqlConfig) {
config.StoragePrefix = prefix
}
}
// Handler responsible for setting up the playground
func Handler(title, endpoint string, opts ...GraphiqlConfigOption) http.HandlerFunc {
data := GraphiqlConfig{
Title: title,
Endpoint: endpoint,
EndpointIsAbsolute: endpointHasScheme(endpoint),
SubscriptionEndpoint: getSubscriptionEndpoint(endpoint),
// https://www.jsdelivr.com/package/npm/graphiql?tab=files
JsUrl: "https://cdn.jsdelivr.net/npm/graphiql@4.1.2/graphiql.min.js",
JsSRI: "sha256-hnImuor1znlJkD/FOTL3jayfS/xsyNoP04abi8bFJWs=",
CssUrl: "https://cdn.jsdelivr.net/npm/graphiql@4.1.2/graphiql.min.css",
CssSRI: "sha256-MEh+B2NdMSpj9kexQNN3QKc8UzMrCXW/Sx/phcpuyIU=",
// https://www.jsdelivr.com/package/npm/react?tab=files
ReactUrl: "https://cdn.jsdelivr.net/npm/react@18.2.0/umd/react.production.min.js",
ReactSRI: "sha256-S0lp+k7zWUMk2ixteM6HZvu8L9Eh//OVrt+ZfbCpmgY=",
// https://www.jsdelivr.com/package/npm/react-dom?tab=files
ReactDOMUrl: "https://cdn.jsdelivr.net/npm/react-dom@18.2.0/umd/react-dom.production.min.js",
ReactDOMSRI: "sha256-IXWO0ITNDjfnNXIu5POVfqlgYoop36bDzhodR6LW5Pc=",
// https://www.jsdelivr.com/package/npm/@graphiql/plugin-explorer?tab=files
PluginExplorerJsUrl: template.URL(
"https://cdn.jsdelivr.net/npm/@graphiql/plugin-explorer@4.0.6/dist/index.umd.js",
),
PluginExplorerJsSRI: "sha256-UM8sWOS0Xa9yLY85q6Clh0pF4qpxX+TOcJ41flECqBs=",
PluginExplorerCssUrl: template.URL(
"https://cdn.jsdelivr.net/npm/@graphiql/plugin-explorer@4.0.6/dist/style.min.css",
),
PluginExplorerCssSRI: "sha256-b0izygy8aEMY3fCLmtNkm9PKdE3kRD4Qjn6Q8gw5xKI=",
}
for _, opt := range opts {
opt(&data)
}
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Type", "text/html; charset=UTF-8")
if err := page.Execute(w, data); err != nil {
panic(err)
}
}
}
// 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, endpoint string,
fetcherHeaders, uiHeaders map[string]string,
) http.HandlerFunc {
return Handler(
title,
endpoint,
WithGraphiqlFetcherHeaders(fetcherHeaders),
WithGraphiqlUiHeaders(uiHeaders),
)
}
// 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()
}
================================================
FILE: graphql/playground/playground_test.go
================================================
package playground
import (
"html/template"
"io"
"net/http"
"net/http/httptest"
"regexp"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestHandler_createsAbsoluteURLs(t *testing.T) {
rec := httptest.NewRecorder()
req := httptest.NewRequest(http.MethodGet, "https://example.org/query", http.NoBody)
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 {
t.Fatalf("reading res.Body: %v", 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,}.*`,
) // element must be in and before
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", http.NoBody)
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 {
t.Fatalf("reading res.Body: %v", 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, func(title, endpoint string) http.HandlerFunc {
return Handler(title, endpoint, WithGraphiqlEnablePluginExplorer(true))
})
}
func TestWithGraphiqlFetcherHeaders(t *testing.T) {
t.Run("should set fetcher headers", func(t *testing.T) {
config := &GraphiqlConfig{}
headers := map[string]string{"Authorization": "Bearer token"}
WithGraphiqlFetcherHeaders(headers)(config)
assert.Equal(t, headers, config.FetcherHeaders)
})
}
func TestWithGraphiqlUiHeaders(t *testing.T) {
t.Run("should set ui headers", func(t *testing.T) {
config := &GraphiqlConfig{}
headers := map[string]string{"X-Custom-Header": "value"}
WithGraphiqlUiHeaders(headers)(config)
assert.Equal(t, headers, config.UiHeaders)
})
}
func TestWithGraphiqlVersion(t *testing.T) {
t.Run("should set graphiql version", func(t *testing.T) {
config := &GraphiqlConfig{}
jsURL := "https://example.com/graphiql.js"
cssURL := "https://example.com/graphiql.css"
jsSRI := "sha256-js"
cssSRI := "sha256-css"
WithGraphiqlVersion(jsURL, cssURL, jsSRI, cssSRI)(config)
assert.Equal(t, template.URL(jsURL), config.JsUrl)
assert.Equal(t, template.URL(cssURL), config.CssUrl)
assert.Equal(t, cssSRI, config.CssSRI)
assert.Equal(t, jsSRI, config.JsSRI)
})
}
func TestWithGraphiqlReactVersion(t *testing.T) {
t.Run("should set react version", func(t *testing.T) {
config := &GraphiqlConfig{}
reactJSURL := "https://example.com/react.js"
reactDomJSURL := "https://example.com/react-dom.js"
reactJSSRI := "sha256-react"
reactDomJSSRI := "sha256-react-dom"
WithGraphiqlReactVersion(reactJSURL, reactDomJSURL, reactJSSRI, reactDomJSSRI)(config)
assert.Equal(t, template.URL(reactJSURL), config.ReactUrl)
assert.Equal(t, template.URL(reactDomJSURL), config.ReactDOMUrl)
assert.Equal(t, reactJSSRI, config.ReactSRI)
assert.Equal(t, reactDomJSSRI, config.ReactDOMSRI)
})
}
func TestWithGraphiqlPluginExplorerVersion(t *testing.T) {
t.Run("should set plugin explorer version", func(t *testing.T) {
config := &GraphiqlConfig{}
jsURL := "https://example.com/plugin-explorer.js"
cssURL := "https://example.com/plugin-explorer.css"
jsSRI := "sha256-plugin-js"
cssSRI := "sha256-plugin-css"
WithGraphiqlPluginExplorerVersion(jsURL, cssURL, jsSRI, cssSRI)(config)
assert.Equal(t, template.URL(jsURL), config.PluginExplorerJsUrl)
assert.Equal(t, template.URL(cssURL), config.PluginExplorerCssUrl)
assert.Equal(t, cssSRI, config.PluginExplorerCssSRI)
assert.Equal(t, jsSRI, config.PluginExplorerJsSRI)
})
}
func TestWithGraphiqlEnablePluginExplorer(t *testing.T) {
tests := []struct {
name string
enable bool
expected bool
}{
{
name: "should enable plugin explorer",
enable: true,
expected: true,
},
{
name: "should disable plugin explorer",
enable: false,
expected: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
config := &GraphiqlConfig{}
WithGraphiqlEnablePluginExplorer(tt.enable)(config)
assert.Equal(t, tt.expected, config.EnablePluginExplorer)
})
}
}
func TestWithStoragePrefix(t *testing.T) {
t.Run("should set storage prefix", func(t *testing.T) {
config := &GraphiqlConfig{}
prefix := "my-prefix"
WithStoragePrefix(prefix)(config)
assert.Equal(t, prefix, config.StoragePrefix)
})
}
func TestHandler_WithOptions(t *testing.T) {
tests := []struct {
name string
options []GraphiqlConfigOption
assert func(t *testing.T, body string)
}{
{
name: "WithGraphiqlFetcherHeaders",
options: []GraphiqlConfigOption{
WithGraphiqlFetcherHeaders(map[string]string{"Authorization": "Bearer token"}),
},
assert: func(t *testing.T, body string) {
assert.True(
t,
strings.Contains(
body,
`const fetcherHeaders = {"Authorization":"Bearer token"};`,
),
)
},
},
{
name: "WithGraphiqlUiHeaders",
options: []GraphiqlConfigOption{
WithGraphiqlUiHeaders(map[string]string{"X-Custom-Header": "value"}),
},
assert: func(t *testing.T, body string) {
assert.True(
t,
strings.Contains(body, `const uiHeaders = {"X-Custom-Header":"value"};`),
)
},
},
{
name: "WithGraphiqlVersion",
options: []GraphiqlConfigOption{
WithGraphiqlVersion(
"https://example.com/graphiql.js",
"https://example.com/graphiql.css",
"sha256-js",
"sha256-css",
),
},
assert: func(t *testing.T, body string) {
assert.True(t, strings.Contains(body, `src="https://example.com/graphiql.js"`))
assert.True(t, strings.Contains(body, `href="https://example.com/graphiql.css"`))
assert.True(t, strings.Contains(body, `integrity="sha256-js"`))
assert.True(t, strings.Contains(body, `integrity="sha256-css"`))
},
},
{
name: "WithGraphiqlReactVersion",
options: []GraphiqlConfigOption{
WithGraphiqlReactVersion(
"https://example.com/react.js",
"https://example.com/react-dom.js",
"sha256-react",
"sha256-react-dom",
),
},
assert: func(t *testing.T, body string) {
assert.True(t, strings.Contains(body, `src="https://example.com/react.js"`))
assert.True(t, strings.Contains(body, `src="https://example.com/react-dom.js"`))
assert.True(t, strings.Contains(body, `integrity="sha256-react"`))
assert.True(t, strings.Contains(body, `integrity="sha256-react-dom"`))
},
},
{
name: "WithGraphiqlPluginExplorerVersion",
options: []GraphiqlConfigOption{
WithGraphiqlEnablePluginExplorer(true),
WithGraphiqlPluginExplorerVersion(
"https://example.com/plugin-explorer.js",
"https://example.com/plugin-explorer.css",
"sha256-plugin-js",
"sha256-plugin-css",
),
},
assert: func(t *testing.T, body string) {
assert.True(
t,
strings.Contains(body, `src="https://example.com/plugin-explorer.js"`),
)
assert.True(
t,
strings.Contains(body, `href="https://example.com/plugin-explorer.css"`),
)
assert.True(t, strings.Contains(body, `integrity="sha256-plugin-js"`))
assert.True(t, strings.Contains(body, `integrity="sha256-plugin-css"`))
},
},
{
name: "WithGraphiqlEnablePluginExplorer",
options: []GraphiqlConfigOption{
WithGraphiqlEnablePluginExplorer(true),
},
assert: func(t *testing.T, body string) {
assert.True(t, strings.Contains(body, `GraphiQLPluginExplorer.explorerPlugin()`))
},
},
{
name: "WithStoragePrefix",
options: []GraphiqlConfigOption{
WithStoragePrefix("my-prefix"),
},
assert: func(t *testing.T, body string) {
assert.True(t, strings.Contains(body, `new PrefixedStorage('my-prefix')`))
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
recorder := httptest.NewRecorder()
request := httptest.NewRequest(http.MethodGet, "/", http.NoBody)
h := Handler("test", "/query", tt.options...)
h.ServeHTTP(recorder, request)
result := recorder.Result()
defer result.Body.Close()
body, err := io.ReadAll(result.Body)
require.NoError(t, err)
tt.assert(t, string(body))
})
}
}
================================================
FILE: graphql/recovery.go
================================================
package graphql
import (
"context"
"fmt"
"os"
"runtime/debug"
"github.com/vektah/gqlparser/v2/gqlerror"
)
type RecoverFunc func(ctx context.Context, err any) (userMessage error)
func DefaultRecover(ctx context.Context, err any) error {
fmt.Fprintln(os.Stderr, err)
fmt.Fprintln(os.Stderr)
debug.PrintStack()
return gqlerror.Errorf("internal system error")
}
================================================
FILE: graphql/resolve_field.go
================================================
package graphql
import (
"context"
"io"
"github.com/vektah/gqlparser/v2/ast"
)
func ResolveField[T any](
ctx context.Context,
oc *OperationContext,
field CollectedField,
initializeFieldContext func(ctx context.Context, field CollectedField) (*FieldContext, error),
fieldResolver func(ctx context.Context) (any, error),
middlewareChain func(ctx context.Context, next Resolver) Resolver,
marshal func(ctx context.Context, sel ast.SelectionSet, v T) Marshaler,
recoverFromPanic bool,
nonNull bool,
) Marshaler {
return resolveField[T, Marshaler](
ctx,
oc,
field,
initializeFieldContext,
fieldResolver,
middlewareChain,
recoverFromPanic,
nonNull,
Null,
func(ctx context.Context, res T) Marshaler {
return marshal(ctx, field.Selections, res)
},
)
}
func ResolveFieldStream[T any](
ctx context.Context,
oc *OperationContext,
field CollectedField,
initializeFieldContext func(ctx context.Context, field CollectedField) (*FieldContext, error),
fieldResolver func(context.Context) (any, error),
middlewareChain func(ctx context.Context, next Resolver) Resolver,
marshal func(ctx context.Context, sel ast.SelectionSet, v T) Marshaler,
recoverFromPanic bool,
nonNull bool,
) func(context.Context) Marshaler {
return resolveField(
ctx,
oc,
field,
initializeFieldContext,
fieldResolver,
middlewareChain,
recoverFromPanic,
nonNull,
nil,
func(ctx context.Context, res <-chan T) func(context.Context) Marshaler {
return func(ctx context.Context) Marshaler {
select {
case v, ok := <-res:
if !ok {
return nil
}
return WriterFunc(func(w io.Writer) {
w.Write([]byte{'{'})
MarshalString(field.Alias).MarshalGQL(w)
w.Write([]byte{':'})
marshal(ctx, field.Selections, v).MarshalGQL(w)
w.Write([]byte{'}'})
})
case <-ctx.Done():
return nil
}
}
},
)
}
func resolveField[T, R any](
ctx context.Context,
oc *OperationContext,
field CollectedField,
initializeFieldContext func(ctx context.Context, field CollectedField) (*FieldContext, error),
fieldResolver func(ctx context.Context) (any, error),
middlewareChain func(ctx context.Context, next Resolver) Resolver,
recoverFromPanic bool,
nonNull bool,
defaultResult R,
result func(ctx context.Context, res T) R,
) (ret R) {
fc, err := initializeFieldContext(ctx, field)
if err != nil {
return defaultResult
}
ctx = WithFieldContext(ctx, fc)
if recoverFromPanic {
defer func() {
if r := recover(); r != nil {
oc.Error(ctx, oc.Recover(ctx, r))
ret = defaultResult
}
}()
}
next := func(rctx context.Context) (any, error) {
ctx = rctx // use context from middleware stack in children
return fieldResolver(rctx)
}
if middlewareChain != nil {
next = middlewareChain(ctx, next)
}
resTmp, err := oc.ResolverMiddleware(ctx, next)
if err != nil {
oc.Error(ctx, err)
return defaultResult
}
if resTmp == nil {
if nonNull {
if !HasFieldError(ctx, fc) {
oc.Errorf(ctx, "must not be null")
}
}
return defaultResult
}
if res, ok := resTmp.(T); ok {
fc.Result = res
return result(ctx, res)
}
if res, ok := resTmp.(R); ok {
fc.Result = res
return res
}
var t T
oc.Errorf(
ctx,
`unexpected type %T from middleware/directive chain, should be %T`,
resTmp,
t,
)
return defaultResult
}
================================================
FILE: graphql/resolve_field_test.go
================================================
package graphql
import (
"context"
"errors"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/vektah/gqlparser/v2/ast"
)
type ResolveFieldTest struct {
name string
recoverFromPanic bool
nonNull bool
initializeFieldContextErr error
panicMiddlewareChain string
panicResolverMiddleware string
panicFieldResolver string
fieldResolverValue any
fieldResolverErr error
marshalCalls []int
expected string
expectedPanic string
expectedErr string
expectedCalls int
}
var commonResolveFieldTests = []ResolveFieldTest{
{
name: "should handle nullable field when field resolver returns nil value",
fieldResolverValue: nil,
expected: "null",
expectedCalls: 4,
},
{
name: "should fail non nullable field when field resolver returns nil value",
nonNull: true,
fieldResolverValue: nil,
expected: "null",
expectedErr: "input: testField must not be null\n",
expectedCalls: 4,
},
{
name: "should fail when initialize field context returns an error",
initializeFieldContextErr: errors.New("test initialize field context error"),
expected: "null",
expectedCalls: 1,
},
{
name: "should not recover from panic when middleware chain panics",
panicMiddlewareChain: "test middleware chain panic",
expectedPanic: "test middleware chain panic",
expectedCalls: 2,
},
{
name: "should recover from panic when middleware chain panics with recover from panic",
recoverFromPanic: true,
panicMiddlewareChain: "test middleware chain panic",
expected: "null",
expectedPanic: "test middleware chain panic",
expectedCalls: 3,
},
{
name: "should not recover from panic when resolver middleware panics",
panicResolverMiddleware: "test resolver middleware panic",
expectedPanic: "test resolver middleware panic",
expectedCalls: 3,
},
{
name: "should recover from panic when resolver middleware panics with recover from panic",
recoverFromPanic: true,
panicResolverMiddleware: "test resolver middleware panic",
expected: "null",
expectedPanic: "test resolver middleware panic",
expectedCalls: 4,
},
{
name: "should not recover from panic when field resolver panics",
panicFieldResolver: "test field resolver panic",
expectedPanic: "test field resolver panic",
expectedCalls: 4,
},
{
name: "should recover from panic when field resolver panics with recover from panic",
recoverFromPanic: true,
panicFieldResolver: "test field resolver panic",
expected: "null",
expectedPanic: "test field resolver panic",
expectedCalls: 5,
},
{
name: "should fail when field resolver returns an error",
fieldResolverErr: errors.New("test field resolver error"),
expected: "null",
expectedErr: "input: testField test field resolver error\n",
expectedCalls: 4,
},
}
func TestResolveField(t *testing.T) {
tests := append(
[]ResolveFieldTest{
{
name: "should resolve field",
fieldResolverValue: "test value",
marshalCalls: []int{5},
expected: `"test value"`,
expectedCalls: 5,
},
{
name: "should fail when field resolver returns invalid type",
nonNull: true,
// the tests are using string so int should fail
fieldResolverValue: 123,
expected: "null",
expectedErr: "input: testField unexpected type int from middleware/directive chain, should be string\n",
expectedCalls: 4,
},
},
commonResolveFieldTests...,
)
testResolveField(
t,
tests,
ResolveField,
false,
func(t *testing.T, test ResolveFieldTest, result Marshaler) {
t.Helper()
var sb strings.Builder
if result != nil {
result.MarshalGQL(&sb)
}
assert.Equal(t, test.expected, sb.String())
},
)
}
func TestResolveFieldStream(t *testing.T) {
resultChan := make(chan string, 3)
resultChan <- "test one"
resultChan <- "test two"
resultChan <- "test three"
close(resultChan)
tests := append(
[]ResolveFieldTest{
{
name: "should resolve field",
fieldResolverValue: (<-chan string)(resultChan),
marshalCalls: []int{5, 6, 7},
expected: `{"testField":"test one"}{"testField":"test two"}{"testField":"test three"}`,
expectedCalls: 7,
},
{
name: "should fail when field resolver returns invalid type",
nonNull: true,
// the tests are using <-chan string so int should fail
fieldResolverValue: 123,
expected: "null",
expectedErr: "input: testField unexpected type int from middleware/directive chain, should be <-chan string\n",
expectedCalls: 4,
},
},
commonResolveFieldTests...,
)
for i, test := range tests {
// the stream tests output empty string where the non stream tests output null
if test.expected == "null" {
tests[i].expected = ""
}
}
testResolveField(
t,
tests,
ResolveFieldStream,
true,
func(t *testing.T, test ResolveFieldTest, result func(ctx context.Context) Marshaler) {
var sb strings.Builder
if result != nil {
for range 3 {
result(context.Background()).MarshalGQL(&sb)
}
}
assert.Equal(t, test.expected, sb.String())
},
)
}
type resolveFieldFunc[T, R any] func(
ctx context.Context,
oc *OperationContext,
field CollectedField,
initializeFieldContext func(ctx context.Context, field CollectedField) (*FieldContext, error),
fieldResolver func(context.Context) (any, error),
middlewareChain func(ctx context.Context, next Resolver) Resolver,
marshal func(ctx context.Context, sel ast.SelectionSet, v T) Marshaler,
recoverFromPanic bool,
nonNull bool,
) R
type resolveFieldTestKey string
func testResolveField[R any](
t *testing.T,
tests []ResolveFieldTest,
resolveField resolveFieldFunc[string, R],
stream bool,
assertResult func(t *testing.T, test ResolveFieldTest, result R),
) {
t.Helper()
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
calls := 0
assertCall := func(call int) {
calls++
assert.Equal(t, call, calls)
}
marshalCalled := 0
ctx := WithResponseContext(context.Background(), DefaultErrorPresenter, nil)
oc := &OperationContext{
RecoverFunc: func(ctx context.Context, err any) (userMessage error) {
assertCall(test.expectedCalls)
if test.expectedPanic != "" {
assert.Equal(t, test.expectedPanic, err)
} else {
t.Errorf("should not panic but recover func called with: %v", err)
}
return nil
},
ResolverMiddleware: func(ctx context.Context, next Resolver) (res any, err error) {
assertCall(3)
ctx = context.WithValue(
ctx,
resolveFieldTestKey("middlewareResolver"),
"test middleware resolver",
)
if test.panicResolverMiddleware != "" {
panic(test.panicResolverMiddleware)
}
return next(ctx)
},
}
field := CollectedField{
Field: &ast.Field{
Alias: "testField",
},
}
var result R
run := func() {
result = resolveField(
ctx,
oc,
field,
func(ctx context.Context, field CollectedField) (*FieldContext, error) {
assertCall(1)
return &FieldContext{
Object: "Test",
Field: field,
}, test.initializeFieldContextErr
},
func(ctx context.Context) (any, error) {
assertCall(4)
assert.Equal(
t,
"test middleware resolver",
ctx.Value(resolveFieldTestKey("middlewareResolver")),
"should propagate value from resolver middleware",
)
if test.panicFieldResolver != "" {
panic(test.panicFieldResolver)
}
return test.fieldResolverValue, test.fieldResolverErr
},
func(ctx context.Context, next Resolver) Resolver {
assertCall(2)
if test.panicMiddlewareChain != "" {
panic(test.panicMiddlewareChain)
}
return func(ctx context.Context) (res any, err error) {
ctx = context.WithValue(
ctx,
resolveFieldTestKey("middlewareChain"),
"test middleware chain",
)
return next(ctx)
}
},
func(ctx context.Context, sel ast.SelectionSet, v string) Marshaler {
assertCall(test.marshalCalls[marshalCalled])
marshalCalled++
if !stream {
assert.Equal(
t,
"test middleware chain",
ctx.Value(resolveFieldTestKey("middlewareChain")),
"should propagate value from middleware chain",
)
}
return MarshalString(v)
},
test.recoverFromPanic,
test.nonNull,
)
}
if test.expectedPanic == "" || test.recoverFromPanic {
run()
} else {
assert.PanicsWithValue(t, test.expectedPanic, run)
}
require.EqualError(t, GetErrors(ctx), test.expectedErr)
assertResult(t, test, result)
assert.Equal(t, test.expectedCalls, calls)
})
}
}
func TestResolveFieldMiddlewareReturningMarshaler(t *testing.T) {
t.Run(
"should not call field resolver when field resolver returns a Marshaler",
func(t *testing.T) {
oc := &OperationContext{
ResolverMiddleware: func(ctx context.Context, next Resolver) (res any, err error) {
return next(ctx)
},
}
field := CollectedField{
Field: &ast.Field{
Alias: "testField",
},
}
result := ResolveField(
context.Background(),
oc,
field,
func(ctx context.Context, field CollectedField) (*FieldContext, error) {
return &FieldContext{
Object: "Test",
Field: field,
}, nil
},
func(ctx context.Context) (any, error) {
t.Error("should not call field resolver")
return nil, nil
},
func(ctx context.Context, next Resolver) Resolver {
return func(ctx context.Context) (res any, err error) {
return MarshalString("test value"), nil
}
},
func(ctx context.Context, sel ast.SelectionSet, v string) Marshaler {
t.Error("should not call marshal")
return nil
},
false,
false,
)
var sb strings.Builder
result.MarshalGQL(&sb)
assert.Equal(t, `"test value"`, sb.String())
},
)
}
================================================
FILE: graphql/response.go
================================================
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]any `json:"extensions,omitempty"`
}
func ErrorResponse(ctx context.Context, messagef string, args ...any) *Response {
return &Response{
Errors: gqlerror.List{{Message: fmt.Sprintf(messagef, args...)}},
}
}
================================================
FILE: graphql/root.go
================================================
package graphql
type Query struct{}
type Mutation struct{}
type Subscription struct{}
================================================
FILE: graphql/slice.go
================================================
package graphql
import (
"context"
"sync"
"sync/atomic"
"golang.org/x/sync/semaphore"
)
// MarshalSliceConcurrently marshals a slice of elements concurrently, writing
// each result into the returned Array.
//
// The marshalElement callback is called for each index and receives a context
// that already has a FieldContext with Index set. The callback should set
// FieldContext.Result and perform the actual marshaling.
//
// workerLimit of 0 means unlimited concurrency.
func MarshalSliceConcurrently(
ctx context.Context,
length int,
workerLimit int64,
omitPanicHandler bool,
marshalElement func(ctx context.Context, i int) Marshaler,
) Array {
ret := make(Array, length)
if length == 0 {
return ret
}
isLen1 := length == 1
if isLen1 {
i := 0
fc := &FieldContext{
Index: &i,
}
childCtx := WithFieldContext(ctx, fc)
if omitPanicHandler {
ret[0] = marshalElement(childCtx, 0)
} else {
func() {
defer func() {
if r := recover(); r != nil {
AddError(childCtx, Recover(childCtx, r))
ret = nil
}
}()
ret[0] = marshalElement(childCtx, 0)
}()
}
return ret
}
// Multiple elements: use goroutines.
var wg sync.WaitGroup
var sm *semaphore.Weighted
if workerLimit > 0 {
sm = semaphore.NewWeighted(workerLimit)
}
// retNilFlag is used to signal from any goroutine that the result should
// be nil (e.g. on panic). We use atomic to avoid data races.
var retNilFlag atomic.Bool
for i := range length {
fc := &FieldContext{
Index: &i,
}
childCtx := WithFieldContext(ctx, fc)
f := func(i int) {
defer wg.Done()
if sm != nil {
defer sm.Release(1)
}
if !omitPanicHandler {
defer func() {
if r := recover(); r != nil {
AddError(childCtx, Recover(childCtx, r))
retNilFlag.Store(true)
}
}()
}
ret[i] = marshalElement(childCtx, i)
}
if sm != nil {
if err := sm.Acquire(ctx, 1); err != nil {
AddError(childCtx, ctx.Err())
retNilFlag.Store(true)
break
}
}
wg.Add(1)
go f(i)
}
wg.Wait()
if retNilFlag.Load() {
return nil
}
return ret
}
================================================
FILE: graphql/slice_test.go
================================================
package graphql
import (
"bytes"
"context"
"fmt"
"sync/atomic"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/vektah/gqlparser/v2/gqlerror"
)
// withTestResponseContext sets up a minimal response context for testing.
func withTestResponseContext(ctx context.Context) context.Context {
return WithResponseContext(ctx, func(ctx context.Context, err error) *gqlerror.Error {
return &gqlerror.Error{Message: err.Error()}
}, DefaultRecover)
}
func TestMarshalSliceConcurrently(t *testing.T) {
t.Run("empty slice", func(t *testing.T) {
ctx := withTestResponseContext(context.Background())
ret := MarshalSliceConcurrently(
ctx,
0,
0,
false,
func(ctx context.Context, i int) Marshaler {
t.Fatal("should not be called")
return Null
},
)
assert.Empty(t, ret)
})
t.Run("single element runs synchronously", func(t *testing.T) {
ctx := withTestResponseContext(context.Background())
var called bool
ret := MarshalSliceConcurrently(
ctx,
1,
0,
false,
func(ctx context.Context, i int) Marshaler {
called = true
assert.Equal(t, 0, i)
fc := GetFieldContext(ctx)
require.NotNil(t, fc)
assert.Equal(t, 0, *fc.Index)
return MarshalString("hello")
},
)
assert.True(t, called)
require.Len(t, ret, 1)
var buf bytes.Buffer
ret[0].MarshalGQL(&buf)
assert.Equal(t, `"hello"`, buf.String())
})
t.Run("multiple elements run concurrently", func(t *testing.T) {
ctx := withTestResponseContext(context.Background())
n := 10
var callCount atomic.Int32
ret := MarshalSliceConcurrently(
ctx,
n,
0,
false,
func(ctx context.Context, i int) Marshaler {
callCount.Add(1)
fc := GetFieldContext(ctx)
require.NotNil(t, fc)
assert.Equal(t, i, *fc.Index)
return MarshalString(fmt.Sprintf("item-%d", i))
},
)
assert.Equal(t, int32(n), callCount.Load())
require.Len(t, ret, n)
for i := range n {
var buf bytes.Buffer
ret[i].MarshalGQL(&buf)
assert.Equal(t, fmt.Sprintf(`"item-%d"`, i), buf.String())
}
})
t.Run("worker limit bounds concurrency", func(t *testing.T) {
ctx := withTestResponseContext(context.Background())
n := 20
var workerLimit int64 = 3
var concurrent atomic.Int32
var maxConcurrent atomic.Int32
ret := MarshalSliceConcurrently(
ctx,
n,
workerLimit,
false,
func(ctx context.Context, i int) Marshaler {
cur := concurrent.Add(1)
defer concurrent.Add(-1)
// Track the maximum observed concurrency
for {
old := maxConcurrent.Load()
if cur <= old || maxConcurrent.CompareAndSwap(old, cur) {
break
}
}
// Small sleep to allow concurrency to build up
time.Sleep(time.Millisecond)
return MarshalString(fmt.Sprintf("item-%d", i))
},
)
require.Len(t, ret, n)
assert.LessOrEqual(t, maxConcurrent.Load(), int32(workerLimit))
})
t.Run("panic recovery sets result to nil", func(t *testing.T) {
ctx := withTestResponseContext(context.Background())
ret := MarshalSliceConcurrently(
ctx,
1,
0,
false,
func(ctx context.Context, i int) Marshaler {
panic("test panic")
},
)
assert.Nil(t, ret)
})
t.Run("panic recovery in concurrent mode sets result to nil", func(t *testing.T) {
ctx := withTestResponseContext(context.Background())
ret := MarshalSliceConcurrently(
ctx,
3,
0,
false,
func(ctx context.Context, i int) Marshaler {
if i == 1 {
panic("test panic")
}
return MarshalString("ok")
},
)
assert.Nil(t, ret)
})
t.Run("omit panic handler does not recover", func(t *testing.T) {
ctx := withTestResponseContext(context.Background())
assert.Panics(t, func() {
MarshalSliceConcurrently(ctx, 1, 0, true, func(ctx context.Context, i int) Marshaler {
panic("test panic")
})
})
})
t.Run("context cancellation with worker limit does not deadlock", func(t *testing.T) {
ctx := withTestResponseContext(context.Background())
ctx, cancel := context.WithCancel(ctx)
done := make(chan Array, 1)
go func() {
ret := MarshalSliceConcurrently(
ctx,
100,
1,
false,
func(ctx context.Context, i int) Marshaler {
if i == 2 {
// Cancel context mid-flight to trigger the deadlock scenario
cancel()
// Small delay to let cancellation propagate
time.Sleep(10 * time.Millisecond)
}
return MarshalString(fmt.Sprintf("item-%d", i))
},
)
done <- ret
}()
select {
case ret := <-done:
// Should return nil because remaining elements were skipped
// after context cancellation caused semaphore Acquire to fail.
assert.Nil(t, ret)
case <-time.After(5 * time.Second):
t.Fatal("deadlock detected: MarshalSliceConcurrently did not return within timeout")
}
cancel() // cleanup
})
t.Run("context already cancelled with worker limit", func(t *testing.T) {
ctx := withTestResponseContext(context.Background())
ctx, cancel := context.WithCancel(ctx)
cancel() // Cancel before calling
done := make(chan Array, 1)
go func() {
done <- MarshalSliceConcurrently(ctx, 10, 1, false, func(ctx context.Context, i int) Marshaler {
return MarshalString("should not reach")
})
}()
select {
case ret := <-done:
// Should return nil without deadlock since the context was
// already cancelled and no elements could be marshaled.
assert.Nil(t, ret)
case <-time.After(5 * time.Second):
t.Fatal("deadlock detected with pre-cancelled context")
}
})
t.Run("cancelled context does not panic on MarshalGQL", func(t *testing.T) {
ctx := withTestResponseContext(context.Background())
ctx, cancel := context.WithCancel(ctx)
cancel()
ret := MarshalSliceConcurrently(
ctx,
3,
1,
false,
func(ctx context.Context, i int) Marshaler {
return MarshalString("ok")
},
)
assert.Nil(t, ret)
assert.NotPanics(t, func() {
var buf bytes.Buffer
ret.MarshalGQL(&buf)
})
})
t.Run("no worker limit with cancelled context still works", func(t *testing.T) {
// Without worker limit, there's no semaphore, so context cancellation
// doesn't cause issues (all goroutines launch immediately).
ctx := withTestResponseContext(context.Background())
ctx, cancel := context.WithCancel(ctx)
cancel()
ret := MarshalSliceConcurrently(
ctx,
5,
0,
false,
func(ctx context.Context, i int) Marshaler {
return MarshalString("ok")
},
)
require.Len(t, ret, 5)
})
}
================================================
FILE: graphql/stats.go
================================================
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]any
}
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 any) {
if c.extension == nil {
c.extension = map[string]any{}
}
c.extension[name] = data
}
func (c *Stats) GetExtension(name string) any {
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
================================================
FILE: graphql/string.go
================================================
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 any) (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:
return strconv.FormatBool(v), nil
case nil:
return "", nil
default:
return "", fmt.Errorf("%T is not a string", v)
}
}
================================================
FILE: graphql/string_test.go
================================================
package graphql
import (
"encoding/json"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
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(t, "123"))
assert.Equal(t, "123", mustUnmarshalString(t, 123))
assert.Equal(t, "123", mustUnmarshalString(t, int64(123)))
assert.Equal(t, "123", mustUnmarshalString(t, float64(123)))
assert.Equal(t, "123", mustUnmarshalString(t, json.Number("123")))
assert.Equal(t, "true", mustUnmarshalString(t, true))
assert.Equal(t, "false", mustUnmarshalString(t, false))
assert.Empty(t, mustUnmarshalString(t, nil))
})
}
func mustUnmarshalString(t *testing.T, v any) string {
t.Helper()
res, err := UnmarshalString(v)
require.NoError(t, err)
return res
}
================================================
FILE: graphql/time.go
================================================
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 any) (time.Time, error) {
if v == nil {
return time.Time{}, nil
}
if tmpStr, ok := v.(string); ok {
if tmpStr == "" {
return time.Time{}, nil
}
t, err := time.Parse(time.RFC3339Nano, tmpStr)
if err == nil {
return t, nil
}
t, err = time.Parse(time.RFC3339, tmpStr)
if err == nil {
return t, nil
}
t, err = time.Parse(time.DateTime, tmpStr)
if err == nil {
return t, nil
}
}
return time.Time{}, errors.New("time should be RFC3339Nano formatted string")
}
func MarshalDate(t time.Time) Marshaler {
if t.IsZero() {
return Null
}
return WriterFunc(func(w io.Writer) {
io.WriteString(w, strconv.Quote(t.Format(time.DateOnly)))
})
}
func UnmarshalDate(v any) (time.Time, error) {
if v == nil {
return time.Time{}, nil
}
if tmpStr, ok := v.(string); ok {
if tmpStr == "" {
return time.Time{}, nil
}
t, err := time.Parse(time.DateOnly, tmpStr)
if err == nil {
return t, nil
}
}
return time.Time{}, errors.New("time should be DateOnly formatted string")
}
================================================
FILE: graphql/time_test.go
================================================
package graphql
import (
"bytes"
"strconv"
"testing"
"time"
"github.com/stretchr/testify/assert"
"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.NoError(t, err)
newTime, err := UnmarshalTime(str)
require.NoError(t, err)
require.True(
t,
initialTime.Equal(newTime),
"expected times %v and %v to equal",
initialTime,
newTime,
)
})
}
func TestMarshalTime(t *testing.T) {
tests := []struct {
name string
input time.Time
expected string
}{
{
name: "normal time with nanoseconds",
input: time.Date(2023, 10, 15, 14, 30, 45, 123456789, time.UTC),
expected: `"2023-10-15T14:30:45.123456789Z"`,
},
{
name: "normal time without nanoseconds",
input: time.Date(2023, 10, 15, 14, 30, 45, 0, time.UTC),
expected: `"2023-10-15T14:30:45Z"`,
},
{
name: "time with timezone offset",
input: time.Date(2023, 10, 15, 14, 30, 45, 0, time.FixedZone("EST", -5*60*60)),
expected: `"2023-10-15T14:30:45-05:00"`,
},
{
name: "epoch time",
input: time.Unix(0, 0).UTC(),
expected: `"1970-01-01T00:00:00Z"`,
},
{
name: "time at start of day",
input: time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC),
expected: `"2023-01-01T00:00:00Z"`,
},
{
name: "time at end of day",
input: time.Date(2023, 12, 31, 23, 59, 59, 999999999, time.UTC),
expected: `"2023-12-31T23:59:59.999999999Z"`,
},
{
name: "leap year february 29",
input: time.Date(2024, 2, 29, 12, 0, 0, 0, time.UTC),
expected: `"2024-02-29T12:00:00Z"`,
},
{
name: "far future date",
input: time.Date(2999, 12, 31, 23, 59, 59, 0, time.UTC),
expected: `"2999-12-31T23:59:59Z"`,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
buf := &bytes.Buffer{}
marshaler := MarshalTime(tt.input)
marshaler.MarshalGQL(buf)
assert.Equal(t, tt.expected, buf.String())
})
}
t.Run("zero time returns null", func(t *testing.T) {
zeroTime := time.Time{}
marshaler := MarshalTime(zeroTime)
assert.Equal(t, Null, marshaler, "zero time should return Null marshaler")
})
t.Run("zero time writes null to buffer", func(t *testing.T) {
buf := &bytes.Buffer{}
MarshalTime(time.Time{}).MarshalGQL(buf)
assert.Equal(t, "null", buf.String())
})
}
func TestUnmarshalTime(t *testing.T) {
t.Run("RFC3339Nano format", func(t *testing.T) {
tests := []struct {
name string
input string
expected time.Time
}{
{
name: "with nanoseconds",
input: "2023-10-15T14:30:45.123456789Z",
expected: time.Date(2023, 10, 15, 14, 30, 45, 123456789, time.UTC),
},
{
name: "without nanoseconds",
input: "2023-10-15T14:30:45Z",
expected: time.Date(2023, 10, 15, 14, 30, 45, 0, time.UTC),
},
{
name: "with milliseconds",
input: "2023-10-15T14:30:45.123Z",
expected: time.Date(2023, 10, 15, 14, 30, 45, 123000000, time.UTC),
},
{
name: "with microseconds",
input: "2023-10-15T14:30:45.123456Z",
expected: time.Date(2023, 10, 15, 14, 30, 45, 123456000, time.UTC),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result, err := UnmarshalTime(tt.input)
require.NoError(t, err)
assert.True(
t,
tt.expected.Equal(result),
"expected %v, got %v",
tt.expected,
result,
)
})
}
})
t.Run("RFC3339 format", func(t *testing.T) {
tests := []struct {
name string
input string
expected time.Time
}{
{
name: "with timezone offset positive",
input: "2023-10-15T14:30:45+05:00",
expected: time.Date(2023, 10, 15, 14, 30, 45, 0, time.FixedZone("", 5*60*60)),
},
{
name: "with timezone offset negative",
input: "2023-10-15T14:30:45-08:00",
expected: time.Date(2023, 10, 15, 14, 30, 45, 0, time.FixedZone("", -8*60*60)),
},
{
name: "UTC with Z suffix",
input: "2023-10-15T14:30:45Z",
expected: time.Date(2023, 10, 15, 14, 30, 45, 0, time.UTC),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result, err := UnmarshalTime(tt.input)
require.NoError(t, err)
assert.True(
t,
tt.expected.Equal(result),
"expected %v, got %v",
tt.expected,
result,
)
})
}
})
t.Run("DateTime format", func(t *testing.T) {
tests := []struct {
name string
input string
expected time.Time
}{
{
name: "standard datetime",
input: "2023-10-15 14:30:45",
expected: time.Date(2023, 10, 15, 14, 30, 45, 0, time.UTC),
},
{
name: "datetime with single digit day",
input: "2023-01-05 09:30:45",
expected: time.Date(2023, 1, 5, 9, 30, 45, 0, time.UTC),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result, err := UnmarshalTime(tt.input)
require.NoError(t, err)
assert.True(
t,
tt.expected.Equal(result),
"expected %v, got %v",
tt.expected,
result,
)
})
}
})
t.Run("null and empty values", func(t *testing.T) {
tests := []struct {
name string
input any
expected time.Time
wantErr bool
}{
{
name: "nil value",
input: nil,
expected: time.Time{},
wantErr: false,
},
{
name: "empty string",
input: "",
expected: time.Time{},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result, err := UnmarshalTime(tt.input)
if tt.wantErr {
assert.Error(t, err)
} else {
require.NoError(t, err)
assert.True(t, tt.expected.IsZero())
assert.True(t, result.IsZero())
}
})
}
})
t.Run("error cases", func(t *testing.T) {
tests := []struct {
name string
input any
wantErr string
}{
{
name: "invalid format",
input: "not a time",
wantErr: "time should be RFC3339Nano formatted string",
},
{
name: "wrong type - int",
input: 12345,
wantErr: "time should be RFC3339Nano formatted string",
},
{
name: "wrong type - bool",
input: true,
wantErr: "time should be RFC3339Nano formatted string",
},
{
name: "wrong type - struct",
input: struct{ Value string }{Value: "test"},
wantErr: "time should be RFC3339Nano formatted string",
},
{
name: "invalid date",
input: "2023-13-45T14:30:45Z",
wantErr: "time should be RFC3339Nano formatted string",
},
{
name: "invalid time",
input: "2023-10-15T25:70:90Z",
wantErr: "time should be RFC3339Nano formatted string",
},
{
name: "malformed RFC3339",
input: "2023-10-15 14:30:45Z",
wantErr: "time should be RFC3339Nano formatted string",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := UnmarshalTime(tt.input)
require.Error(t, err)
assert.Contains(t, err.Error(), tt.wantErr)
})
}
})
t.Run("round trip consistency", func(t *testing.T) {
testTimes := []time.Time{
time.Date(2023, 10, 15, 14, 30, 45, 123456789, time.UTC),
time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC),
time.Date(2023, 12, 31, 23, 59, 59, 999999999, time.UTC),
time.Unix(0, 0).UTC(),
time.Now().UTC(),
}
for i, originalTime := range testTimes {
t.Run(strconv.Itoa(i), func(t *testing.T) {
// Marshal
buf := &bytes.Buffer{}
MarshalTime(originalTime).MarshalGQL(buf)
// Unquote
str, err := strconv.Unquote(buf.String())
require.NoError(t, err)
// Unmarshal
parsedTime, err := UnmarshalTime(str)
require.NoError(t, err)
// Compare
assert.True(t, originalTime.Equal(parsedTime),
"round trip failed: original=%v, parsed=%v", originalTime, parsedTime)
})
}
})
}
func TestMarshalTime_EdgeCases(t *testing.T) {
t.Run("time with different locations same instant", func(t *testing.T) {
utcTime := time.Date(2023, 10, 15, 14, 30, 45, 0, time.UTC)
estTime := utcTime.In(time.FixedZone("EST", -5*60*60))
utcBuf := &bytes.Buffer{}
MarshalTime(utcTime).MarshalGQL(utcBuf)
estBuf := &bytes.Buffer{}
MarshalTime(estTime).MarshalGQL(estBuf)
// Should produce different string representations
assert.NotEqual(t, utcBuf.String(), estBuf.String())
// But should unmarshal to the same instant
utcStr, _ := strconv.Unquote(utcBuf.String())
estStr, _ := strconv.Unquote(estBuf.String())
utcParsed, err := UnmarshalTime(utcStr)
require.NoError(t, err)
estParsed, err := UnmarshalTime(estStr)
require.NoError(t, err)
assert.True(t, utcParsed.Equal(estParsed))
})
t.Run("precision preservation", func(t *testing.T) {
// Test that nanosecond precision is preserved
timeWithNanos := time.Date(2023, 10, 15, 14, 30, 45, 123456789, time.UTC)
buf := &bytes.Buffer{}
MarshalTime(timeWithNanos).MarshalGQL(buf)
str, err := strconv.Unquote(buf.String())
require.NoError(t, err)
parsed, err := UnmarshalTime(str)
require.NoError(t, err)
assert.Equal(t, timeWithNanos.Nanosecond(), parsed.Nanosecond())
assert.True(t, timeWithNanos.Equal(parsed))
})
}
func TestMarshalDate(t *testing.T) {
tests := []struct {
name string
input time.Time
expected string
}{
{
name: "normal time with nanoseconds",
input: time.Date(2023, 10, 15, 14, 30, 45, 123456789, time.UTC),
expected: `"2023-10-15"`,
},
{
name: "normal time without nanoseconds",
input: time.Date(2023, 10, 15, 14, 30, 45, 0, time.UTC),
expected: `"2023-10-15"`,
},
{
name: "time with timezone offset",
input: time.Date(2023, 10, 15, 14, 30, 45, 0, time.FixedZone("EST", -5*60*60)),
expected: `"2023-10-15"`,
},
{
name: "epoch time",
input: time.Unix(0, 0).UTC(),
expected: `"1970-01-01"`,
},
{
name: "time at start of day",
input: time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC),
expected: `"2023-01-01"`,
},
{
name: "time at end of day",
input: time.Date(2023, 12, 31, 23, 59, 59, 999999999, time.UTC),
expected: `"2023-12-31"`,
},
{
name: "leap year february 29",
input: time.Date(2024, 2, 29, 12, 0, 0, 0, time.UTC),
expected: `"2024-02-29"`,
},
{
name: "far future date",
input: time.Date(2999, 12, 31, 23, 59, 59, 0, time.UTC),
expected: `"2999-12-31"`,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
buf := &bytes.Buffer{}
marshaler := MarshalDate(tt.input)
marshaler.MarshalGQL(buf)
assert.Equal(t, tt.expected, buf.String())
})
}
t.Run("zero time returns null", func(t *testing.T) {
zeroTime := time.Time{}
marshaler := MarshalDate(zeroTime)
assert.Equal(t, Null, marshaler, "zero time should return Null marshaler")
})
t.Run("zero time writes null to buffer", func(t *testing.T) {
buf := &bytes.Buffer{}
MarshalDate(time.Time{}).MarshalGQL(buf)
assert.Equal(t, "null", buf.String())
})
}
func TestUnmarshalDate(t *testing.T) {
t.Run("DateOnly format", func(t *testing.T) {
tests := []struct {
name string
input string
expected time.Time
}{
{
name: "standard date",
input: "2023-10-15",
expected: time.Date(2023, 10, 15, 0, 0, 0, 0, time.UTC),
},
{
name: "january first",
input: "2023-01-01",
expected: time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC),
},
{
name: "december last",
input: "2023-12-31",
expected: time.Date(2023, 12, 31, 0, 0, 0, 0, time.UTC),
},
{
name: "leap year february 29",
input: "2024-02-29",
expected: time.Date(2024, 2, 29, 0, 0, 0, 0, time.UTC),
},
{
name: "single digit month and day",
input: "2023-01-05",
expected: time.Date(2023, 1, 5, 0, 0, 0, 0, time.UTC),
},
{
name: "epoch date",
input: "1970-01-01",
expected: time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result, err := UnmarshalDate(tt.input)
require.NoError(t, err)
assert.True(
t,
tt.expected.Equal(result),
"expected %v, got %v",
tt.expected,
result,
)
})
}
})
t.Run("null and empty values", func(t *testing.T) {
tests := []struct {
name string
input any
expected time.Time
wantErr bool
}{
{
name: "nil value",
input: nil,
expected: time.Time{},
wantErr: false,
},
{
name: "empty string",
input: "",
expected: time.Time{},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result, err := UnmarshalDate(tt.input)
if tt.wantErr {
assert.Error(t, err)
} else {
require.NoError(t, err)
assert.True(t, tt.expected.IsZero())
assert.True(t, result.IsZero())
}
})
}
})
t.Run("error cases", func(t *testing.T) {
tests := []struct {
name string
input any
wantErr string
}{
{
name: "invalid format",
input: "not a date",
wantErr: "DateOnly",
},
{
name: "wrong type - int",
input: 12345,
wantErr: "DateOnly formatted string",
},
{
name: "wrong type - bool",
input: true,
wantErr: "DateOnly formatted string",
},
{
name: "wrong type - struct",
input: struct{ Value string }{Value: "test"},
wantErr: "DateOnly formatted string",
},
{
name: "invalid date - month out of range",
input: "2023-13-15",
wantErr: "time should be DateOnly formatted string",
},
{
name: "invalid date - day out of range",
input: "2023-10-45",
wantErr: "time should be DateOnly formatted string",
},
{
name: "RFC3339 format not accepted",
input: "2023-10-15T14:30:45Z",
wantErr: "time should be DateOnly formatted string",
},
{
name: "DateTime format not accepted",
input: "2023-10-15 14:30:45",
wantErr: "time should be DateOnly formatted string",
},
{
name: "incomplete date",
input: "2023-10",
wantErr: "time should be DateOnly formatted string",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := UnmarshalDate(tt.input)
require.Error(t, err)
assert.Contains(t, err.Error(), tt.wantErr)
})
}
})
t.Run("round trip consistency", func(t *testing.T) {
testTimes := []time.Time{
time.Date(2023, 10, 15, 14, 30, 45, 123456789, time.UTC),
time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC),
time.Date(2023, 12, 31, 23, 59, 59, 999999999, time.UTC),
time.Unix(0, 0).UTC(),
time.Now().UTC(),
}
for i, originalTime := range testTimes {
t.Run(strconv.Itoa(i), func(t *testing.T) {
// Marshal
buf := &bytes.Buffer{}
MarshalDate(originalTime).MarshalGQL(buf)
// Unquote
str, err := strconv.Unquote(buf.String())
require.NoError(t, err)
// Unmarshal
parsedTime, err := UnmarshalDate(str)
require.NoError(t, err)
// Compare - dates should match (time components are dropped)
expectedDate := time.Date(
originalTime.Year(),
originalTime.Month(),
originalTime.Day(),
0,
0,
0,
0,
time.UTC,
)
assert.True(t, expectedDate.Equal(parsedTime),
"round trip failed: expected=%v, parsed=%v", expectedDate, parsedTime)
})
}
})
}
func TestMarshalDate_EdgeCases(t *testing.T) {
t.Run("time components are ignored", func(t *testing.T) {
time1 := time.Date(2023, 10, 15, 0, 0, 0, 0, time.UTC)
time2 := time.Date(2023, 10, 15, 14, 30, 45, 123456789, time.UTC)
buf1 := &bytes.Buffer{}
MarshalDate(time1).MarshalGQL(buf1)
buf2 := &bytes.Buffer{}
MarshalDate(time2).MarshalGQL(buf2)
// Both should produce the same date string
assert.Equal(t, buf1.String(), buf2.String())
assert.Equal(t, `"2023-10-15"`, buf1.String())
})
t.Run("timezone is preserved in format but only date is shown", func(t *testing.T) {
utcTime := time.Date(2023, 10, 15, 14, 30, 45, 0, time.UTC)
estTime := time.Date(2023, 10, 15, 14, 30, 45, 0, time.FixedZone("EST", -5*60*60))
utcBuf := &bytes.Buffer{}
MarshalDate(utcTime).MarshalGQL(utcBuf)
estBuf := &bytes.Buffer{}
MarshalDate(estTime).MarshalGQL(estBuf)
// Both should produce date strings
assert.Equal(t, `"2023-10-15"`, utcBuf.String())
assert.Equal(t, `"2023-10-15"`, estBuf.String())
})
}
================================================
FILE: graphql/uint.go
================================================
package graphql
import (
"encoding/json"
"errors"
"fmt"
"io"
"math"
"reflect"
"strconv"
)
func MarshalUint(i uint) Marshaler {
return WriterFunc(func(w io.Writer) {
_, _ = io.WriteString(w, strconv.FormatUint(uint64(i), 10))
})
}
func UnmarshalUint(v any) (uint, error) {
return interfaceToUnsignedNumber[uint](v)
}
func MarshalUint8(i uint8) Marshaler {
return WriterFunc(func(w io.Writer) {
_, _ = io.WriteString(w, strconv.FormatUint(uint64(i), 10))
})
}
func UnmarshalUint8(v any) (uint8, error) {
return interfaceToUnsignedNumber[uint8](v)
}
func MarshalUint16(i uint16) Marshaler {
return WriterFunc(func(w io.Writer) {
_, _ = io.WriteString(w, strconv.FormatUint(uint64(i), 10))
})
}
func UnmarshalUint16(v any) (uint16, error) {
return interfaceToUnsignedNumber[uint16](v)
}
func MarshalUint32(i uint32) Marshaler {
return WriterFunc(func(w io.Writer) {
_, _ = io.WriteString(w, strconv.FormatUint(uint64(i), 10))
})
}
func UnmarshalUint32(v any) (uint32, error) {
return interfaceToUnsignedNumber[uint32](v)
}
func MarshalUint64(i uint64) Marshaler {
return WriterFunc(func(w io.Writer) {
_, _ = io.WriteString(w, strconv.FormatUint(i, 10))
})
}
func UnmarshalUint64(v any) (uint64, error) {
return interfaceToUnsignedNumber[uint64](v)
}
func interfaceToUnsignedNumber[N number](v any) (N, error) {
switch v := v.(type) {
case int, int64:
if reflect.ValueOf(v).Int() < 0 {
return 0, newUintSignError(strconv.FormatInt(reflect.ValueOf(v).Int(), 10))
}
return safeCastUnsignedNumber[N](uint64(reflect.ValueOf(v).Int()))
case uint, uint8, uint16, uint32, uint64:
return safeCastUnsignedNumber[N](reflect.ValueOf(v).Uint())
case string:
uv, err := strconv.ParseUint(v, 10, 64)
if err != nil {
var strconvErr *strconv.NumError
if errors.As(err, &strconvErr) && isSignedInteger(v) {
return 0, newUintSignError(v)
}
return 0, err
}
return safeCastUnsignedNumber[N](uv)
case json.Number:
uv, err := strconv.ParseUint(string(v), 10, 64)
if err != nil {
var strconvErr *strconv.NumError
if errors.As(err, &strconvErr) && isSignedInteger(string(v)) {
return 0, newUintSignError(string(v))
}
return 0, err
}
return safeCastUnsignedNumber[N](uv)
case nil:
return 0, nil
default:
return 0, fmt.Errorf("%T is not an %T", v, N(0))
}
}
type UintSignError struct {
*IntegerError
}
func newUintSignError(v string) *UintSignError {
return &UintSignError{
IntegerError: &IntegerError{
Message: fmt.Sprintf("%v is an invalid unsigned integer: includes sign", v),
},
}
}
func (e *UintSignError) Unwrap() error {
return e.IntegerError
}
// safeCastUnsignedNumber converts an uint64 to a number of type N.
func safeCastUnsignedNumber[N number](val uint64) (N, error) {
var zero N
switch any(zero).(type) {
case uint8:
if val > math.MaxUint8 {
return 0, newNumberOverflowError[uint64](val, 8)
}
case uint16:
if val > math.MaxUint16 {
return 0, newNumberOverflowError[uint64](val, 16)
}
case uint32:
if val > math.MaxUint32 {
return 0, newNumberOverflowError[uint64](val, 32)
}
case uint64, uint, int:
default:
return 0, fmt.Errorf("invalid type %T", zero)
}
return N(val), nil
}
func isSignedInteger(v string) bool {
if v == "" {
return false
}
if v[0] != '-' && v[0] != '+' {
return false
}
if _, err := strconv.ParseUint(v[1:], 10, 64); err == nil {
return true
}
return false
}
================================================
FILE: graphql/uint_test.go
================================================
package graphql
import (
"encoding/json"
"errors"
"fmt"
"math"
"strconv"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
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(0), mustUnmarshalUint(nil))
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"))
})
t.Run("can't unmarshal negative numbers", func(t *testing.T) {
cases := []struct {
name string
v any
err string
}{
{"negative int", -1, "-1 is an invalid unsigned integer: includes sign"},
{"negative int64", int64(-1), "-1 is an invalid unsigned integer: includes sign"},
{
"negative json.Number",
json.Number("-1"),
"-1 is an invalid unsigned integer: includes sign",
},
{"negative string", "-1", "-1 is an invalid unsigned integer: includes sign"},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
var uintSignErr *UintSignError
var intErr *IntegerError
res, err := UnmarshalUint(tc.v)
require.EqualError(
t,
err,
tc.err,
)
require.ErrorAs(
t,
err,
&uintSignErr,
)
require.ErrorAs(
t,
err,
&intErr,
)
assert.Equal(t, uint(0), res)
})
}
})
t.Run("invalid string numbers are not integer errors", func(t *testing.T) {
cases := []struct {
name string
v any
err string
}{
{"empty", "", `strconv.ParseUint: parsing "": invalid syntax`},
{"string", "-1.03", `strconv.ParseUint: parsing "-1.03": invalid syntax`},
{"json number", json.Number(" 1"), `strconv.ParseUint: parsing " 1": invalid syntax`},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
var uintSignErr *UintSignError
var intErr *IntegerError
res, err := UnmarshalUint(tc.v)
require.EqualError(
t,
err,
tc.err,
)
assert.NotErrorAs(t, err, &uintSignErr)
assert.NotErrorAs(t, err, &intErr)
assert.Equal(t, uint(0), res)
})
}
})
}
func mustUnmarshalUint(v any) uint {
res, err := UnmarshalUint(v)
if err != nil {
panic(err)
}
return res
}
func TestUint8(t *testing.T) {
t.Run("marshal", func(t *testing.T) {
assert.Equal(t, "123", m2s(MarshalUint8(123)))
assert.Equal(t, "255", m2s(MarshalUint8(math.MaxUint8)))
})
t.Run("unmarshal", func(t *testing.T) {
assert.Equal(t, uint8(0), mustUnmarshalUint8(nil))
assert.Equal(t, uint8(123), mustUnmarshalUint8(123))
assert.Equal(t, uint8(123), mustUnmarshalUint8(int64(123)))
assert.Equal(t, uint8(123), mustUnmarshalUint8(json.Number("123")))
assert.Equal(t, uint8(123), mustUnmarshalUint8("123"))
assert.Equal(t, uint8(255), mustUnmarshalUint8("255"))
})
t.Run("can't unmarshal negative numbers", func(t *testing.T) {
cases := []struct {
name string
v any
err string
}{
{"negative int", -1, "-1 is an invalid unsigned integer: includes sign"},
{"negative int64", int64(-1), "-1 is an invalid unsigned integer: includes sign"},
{
"negative json.Number",
json.Number("-1"),
"-1 is an invalid unsigned integer: includes sign",
},
{"negative string", "-1", "-1 is an invalid unsigned integer: includes sign"},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
var uintSignErr *UintSignError
var intErr *IntegerError
res, err := UnmarshalUint8(tc.v)
require.EqualError(
t,
err,
tc.err,
)
require.ErrorAs(
t,
err,
&uintSignErr,
)
require.ErrorAs(
t,
err,
&intErr,
)
assert.Equal(t, uint8(0), res)
})
}
})
t.Run("invalid string numbers are not integer errors", func(t *testing.T) {
var uintSignErr *UintSignError
var intErr *IntegerError
res, err := UnmarshalUint8("-1.03")
require.EqualError(
t,
err,
"strconv.ParseUint: parsing \"-1.03\": invalid syntax",
)
assert.NotErrorAs(t, err, &uintSignErr)
assert.NotErrorAs(t, err, &intErr)
assert.Equal(t, uint8(0), res)
res, err = UnmarshalUint8(json.Number(" 1"))
require.EqualError(
t,
err,
"strconv.ParseUint: parsing \" 1\": invalid syntax",
)
assert.NotErrorAs(t, err, &uintSignErr)
assert.NotErrorAs(t, err, &intErr)
assert.Equal(t, uint8(0), res)
})
t.Run("overflow", func(t *testing.T) {
cases := []struct {
name string
v any
err string
}{
{"int overflow", math.MaxUint8 + 1, "256 overflows unsigned 8-bit integer"},
{"int64 overflow", int64(math.MaxUint8 + 1), "256 overflows unsigned 8-bit integer"},
{"json.Number overflow", json.Number("256"), "256 overflows unsigned 8-bit integer"},
{"string overflow", "256", "256 overflows unsigned 8-bit integer"},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
var numberOverflowErr *NumberOverflowError
var intErr *IntegerError
res, err := UnmarshalUint8(tc.v)
require.EqualError(
t,
err,
tc.err,
)
require.ErrorAs(
t,
err,
&numberOverflowErr,
)
require.ErrorAs(
t,
err,
&intErr,
)
assert.Equal(t, uint8(0), res)
})
}
})
}
func mustUnmarshalUint8(v any) uint8 {
res, err := UnmarshalUint8(v)
if err != nil {
panic(err)
}
return res
}
func TestUint16(t *testing.T) {
t.Run("marshal", func(t *testing.T) {
assert.Equal(t, "123", m2s(MarshalUint16(123)))
assert.Equal(t, "65535", m2s(MarshalUint16(math.MaxUint16)))
})
t.Run("unmarshal", func(t *testing.T) {
assert.Equal(t, uint16(0), mustUnmarshalUint16(nil))
assert.Equal(t, uint16(123), mustUnmarshalUint16(123))
assert.Equal(t, uint16(123), mustUnmarshalUint16(int64(123)))
assert.Equal(t, uint16(123), mustUnmarshalUint16(json.Number("123")))
assert.Equal(t, uint16(123), mustUnmarshalUint16("123"))
assert.Equal(t, uint16(65535), mustUnmarshalUint16("65535"))
})
t.Run("can't unmarshal negative numbers", func(t *testing.T) {
cases := []struct {
name string
v any
err string
}{
{"negative int", -1, "-1 is an invalid unsigned integer: includes sign"},
{"negative int64", int64(-1), "-1 is an invalid unsigned integer: includes sign"},
{
"negative json.Number",
json.Number("-1"),
"-1 is an invalid unsigned integer: includes sign",
},
{"negative string", "-1", "-1 is an invalid unsigned integer: includes sign"},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
var uintSignErr *UintSignError
var intErr *IntegerError
res, err := UnmarshalUint16(tc.v)
require.EqualError(
t,
err,
tc.err,
)
require.ErrorAs(
t,
err,
&uintSignErr,
)
require.ErrorAs(
t,
err,
&intErr,
)
assert.Equal(t, uint16(0), res)
})
}
})
t.Run("invalid string numbers are not integer errors", func(t *testing.T) {
var uintSignErr *UintSignError
var intErr *IntegerError
res, err := UnmarshalUint16("-1.03")
require.EqualError(
t,
err,
"strconv.ParseUint: parsing \"-1.03\": invalid syntax",
)
assert.NotErrorAs(t, err, &uintSignErr)
assert.NotErrorAs(t, err, &intErr)
assert.Equal(t, uint16(0), res)
res, err = UnmarshalUint16(json.Number(" 1"))
require.EqualError(
t,
err,
"strconv.ParseUint: parsing \" 1\": invalid syntax",
)
assert.NotErrorAs(t, err, &uintSignErr)
assert.NotErrorAs(t, err, &intErr)
assert.Equal(t, uint16(0), res)
})
t.Run("overflow", func(t *testing.T) {
cases := []struct {
name string
v any
err string
}{
{"int overflow", math.MaxUint16 + 1, "65536 overflows unsigned 16-bit integer"},
{
"int64 overflow",
int64(math.MaxUint16 + 1),
"65536 overflows unsigned 16-bit integer",
},
{
"json.Number overflow",
json.Number("65536"),
"65536 overflows unsigned 16-bit integer",
},
{"string overflow", "65536", "65536 overflows unsigned 16-bit integer"},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
var numberOverflowErr *NumberOverflowError
var intErr *IntegerError
res, err := UnmarshalUint16(tc.v)
require.EqualError(
t,
err,
tc.err,
)
require.ErrorAs(
t,
err,
&numberOverflowErr,
)
require.ErrorAs(
t,
err,
&intErr,
)
assert.Equal(t, uint16(0), res)
})
}
})
}
func mustUnmarshalUint16(v any) uint16 {
res, err := UnmarshalUint16(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(0), mustUnmarshalUint32(nil))
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"))
})
t.Run("can't unmarshal negative numbers", func(t *testing.T) {
cases := []struct {
name string
v any
err string
}{
{"negative int", -1, "-1 is an invalid unsigned integer: includes sign"},
{"negative int64", int64(-1), "-1 is an invalid unsigned integer: includes sign"},
{
"negative json.Number",
json.Number("-1"),
"-1 is an invalid unsigned integer: includes sign",
},
{"negative string", "-1", "-1 is an invalid unsigned integer: includes sign"},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
var uintSignErr *UintSignError
var intErr *IntegerError
res, err := UnmarshalUint32(tc.v)
require.EqualError(
t,
err,
tc.err,
)
require.ErrorAs(
t,
err,
&uintSignErr,
)
require.ErrorAs(
t,
err,
&intErr,
)
assert.Equal(t, uint32(0), res)
})
}
})
t.Run("invalid string numbers are not integer errors", func(t *testing.T) {
var uintSignErr *UintSignError
var intErr *IntegerError
res, err := UnmarshalUint32("-1.03")
require.EqualError(
t,
err,
"strconv.ParseUint: parsing \"-1.03\": invalid syntax",
)
assert.NotErrorAs(t, err, &uintSignErr)
assert.NotErrorAs(t, err, &intErr)
assert.Equal(t, uint32(0), res)
res, err = UnmarshalUint32(json.Number(" 1"))
require.EqualError(
t,
err,
"strconv.ParseUint: parsing \" 1\": invalid syntax",
)
assert.NotErrorAs(t, err, &uintSignErr)
assert.NotErrorAs(t, err, &intErr)
assert.Equal(t, uint32(0), res)
})
t.Run("overflow", func(t *testing.T) {
cases := []struct {
name string
v any
err string
}{
{"int overflow", math.MaxUint32 + 1, "4294967296 overflows unsigned 32-bit integer"},
{
"int64 overflow",
int64(math.MaxUint32 + 1),
"4294967296 overflows unsigned 32-bit integer",
},
{
"json.Number overflow",
json.Number("4294967296"),
"4294967296 overflows unsigned 32-bit integer",
},
{"string overflow", "4294967296", "4294967296 overflows unsigned 32-bit integer"},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
var numberOverflowErr *NumberOverflowError
var intErr *IntegerError
res, err := UnmarshalUint32(tc.v)
require.EqualError(
t,
err,
tc.err,
)
require.ErrorAs(
t,
err,
&numberOverflowErr,
)
require.ErrorAs(
t,
err,
&intErr,
)
assert.Equal(t, uint32(0), res)
})
}
})
}
func mustUnmarshalUint32(v any) 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(0), mustUnmarshalUint64(nil))
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"))
})
t.Run("can't unmarshal negative numbers", func(t *testing.T) {
cases := []struct {
name string
v any
err string
}{
{"negative int", -1, "-1 is an invalid unsigned integer: includes sign"},
{"negative int64", int64(-1), "-1 is an invalid unsigned integer: includes sign"},
{
"negative json.Number",
json.Number("-1"),
"-1 is an invalid unsigned integer: includes sign",
},
{"negative string", "-1", "-1 is an invalid unsigned integer: includes sign"},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
var uintSignErr *UintSignError
var intErr *IntegerError
res, err := UnmarshalUint64(tc.v)
require.EqualError(
t,
err,
tc.err,
)
require.ErrorAs(
t,
err,
&uintSignErr,
)
require.ErrorAs(
t,
err,
&intErr,
)
assert.Equal(t, uint64(0), res)
})
}
})
t.Run("invalid string numbers are not integer errors", func(t *testing.T) {
var uintSignErr *UintSignError
var intErr *IntegerError
res, err := UnmarshalUint64("-1.03")
require.EqualError(
t,
err,
"strconv.ParseUint: parsing \"-1.03\": invalid syntax",
)
assert.NotErrorAs(t, err, &uintSignErr)
assert.NotErrorAs(t, err, &intErr)
assert.Equal(t, uint64(0), res)
res, err = UnmarshalUint64(json.Number(" 1"))
require.EqualError(
t,
err,
"strconv.ParseUint: parsing \" 1\": invalid syntax",
)
assert.NotErrorAs(t, err, &uintSignErr)
assert.NotErrorAs(t, err, &intErr)
assert.Equal(t, uint64(0), res)
})
}
func mustUnmarshalUint64(v any) uint64 {
res, err := UnmarshalUint64(v)
if err != nil {
panic(err)
}
return res
}
func beforeUnmarshalUint(v any) (uint, error) {
switch v := v.(type) {
case string:
u64, err := strconv.ParseUint(v, 10, 64)
if err != nil {
var strconvErr *strconv.NumError
if errors.As(err, &strconvErr) && isSignedInteger(v) {
return 0, newUintSignError(v)
}
return 0, err
}
return uint(u64), err
case int:
if v < 0 {
return 0, newUintSignError(strconv.FormatInt(int64(v), 10))
}
return uint(v), nil
case int64:
if v < 0 {
return 0, newUintSignError(strconv.FormatInt(v, 10))
}
return uint(v), nil
case json.Number:
u64, err := strconv.ParseUint(string(v), 10, 64)
if err != nil {
var strconvErr *strconv.NumError
if errors.As(err, &strconvErr) && isSignedInteger(string(v)) {
return 0, newUintSignError(string(v))
}
return 0, err
}
return uint(u64), err
case nil:
return 0, nil
default:
return 0, fmt.Errorf("%T is not an uint", v)
}
}
func BenchmarkUnmarshalUintInitial(b *testing.B) {
numbers := makeRandomNumberSlice(false)
for b.Loop() {
for i := range numbers {
_, _ = beforeUnmarshalUint(numbers[i])
}
}
}
func BenchmarkUnmarshalUintNew(b *testing.B) {
numbers := makeRandomNumberSlice(false)
for b.Loop() {
for i := range numbers {
_, _ = UnmarshalUint(numbers[i])
}
}
}
================================================
FILE: graphql/upload.go
================================================
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 any) (Upload, error) {
upload, ok := v.(Upload)
if !ok {
return Upload{}, fmt.Errorf("%T is not an Upload", v)
}
return upload, nil
}
================================================
FILE: graphql/uuid.go
================================================
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)
}
}
================================================
FILE: graphql/uuid_test.go
================================================
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) {
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) {
values := []any{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) {
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)
}
})
}
================================================
FILE: graphql/version.go
================================================
package graphql
const Version = "v0.17.88-dev"
================================================
FILE: handler/handler.go
================================================
package handler
import (
"context"
"net/http"
"time"
"github.com/gorilla/websocket"
"github.com/vektah/gqlparser/v2/ast"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/handler/extension"
"github.com/99designs/gqlgen/graphql/handler/lru"
"github.com/99designs/gqlgen/graphql/handler/transport"
"github.com/99designs/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[*ast.QueryDocument](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, opCtx *graphql.OperationContext) int {
return cfg.complexityLimitFunc(graphql.WithOperationContext(ctx, opCtx))
},
})
}
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(recoverFn graphql.RecoverFunc) Option {
return func(cfg *Config) {
cfg.recover = recoverFn
}
}
// 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 string, ok bool) {
return a.PersistedQueryCache.Get(ctx, key)
}
func (a apqAdapter) Add(ctx context.Context, key, value string) {
a.PersistedQueryCache.Add(ctx, key, value)
}
type PersistedQueryCache interface {
Add(ctx context.Context, hash, query string)
Get(ctx context.Context, hash string) (string, bool)
}
// Deprecated: use playground.Handler instead
func Playground(title, endpoint string) http.HandlerFunc {
return playground.Handler(title, endpoint)
}
// Deprecated: use transport.InitPayload instead
type InitPayload = transport.InitPayload
================================================
FILE: init-templates/gqlgen.yml.gotmpl
================================================
# Where are all the schema files located? globs are supported eg src/**/*.graphqls
schema:
- graph/*.graphqls
# Where should the generated server code go?
exec:
package: graph
layout: single-file # Only other option is "follow-schema," ie multi-file.
# Only for single-file layout:
filename: graph/generated.go
# Only for follow-schema layout:
# dir: graph
# filename_template: "{name}.generated.go"
# Optional: Maximum number of goroutines in concurrency to use per child resolvers(default: unlimited)
# worker_limit: 1000
# Uncomment to enable federation
# federation:
# filename: graph/federation.go
# package: graph
# version: 2
# options:
# # Generate a function to populate @requires fields (cannot be used with computed_requires)
# explicit_requires: false
# # Generate resolver functions to compute @requires field values (requires version 2 and call_argument_directives_with_null: true)
# computed_requires: false
# # Default engine for entityResolver generation, can be overridden per entity with @entityResolver(multi: Boolean)
# entity_resolver_multi: false
# 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:
package: graph
layout: follow-schema # Only other option is "single-file."
# Only for single-file layout:
# filename: graph/resolver.go
# Only for follow-schema layout:
dir: 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 to avoid rewriting existing resolver(s) when generating
# preserve_resolver: false
# Optional: the name of the resolver struct type (default: Resolver)
# type: Resolver
# Optional: turn on use ` + "`" + `gqlgen:"fieldName"` + "`" + ` tags in your models
# struct_tag: json
# Optional: prefix for embedded structs (default: "Base")
# embedded_structs_prefix: Base
# Optional: custom directive configuration
# directives:
# hasRole:
# skip_runtime: false
# Optional: local package prefix for import sorting
# local_prefix: ""
# Optional: turn on to use []Thing instead of []*Thing
# omit_slice_element_pointers: false
# Optional: turn on to omit getter methods on models
# omit_getters: 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 on to exclude resolver fields from the generated models file.
# omit_resolver_fields: false
# Optional: turn on to omit panic handler in the generated server
# omit_panic_handler: false
# Optional: turn on to omit JSON marshaler/unmarshaler generation for enums
# omit_enum_json_marshalers: 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: enable adding omitempty to the json tag of generated model fields
# enable_model_json_omitempty_tag: false
# Optional: enable adding omitzero to the json tag of generated model fields
# enable_model_json_omitzero_tag: 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: if this is set to true, argument directives that
# decorate a field with a null value will still be called.
#
# This enables argumment directives to not just mutate
# argument values but to set them even if they're null.
call_argument_directives_with_null: true
# This enables gql server to use function syntax for execution context
# instead of generating receiver methods of the execution context.
# use_function_syntax_for_execution_context: 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'
# Optional: enable getter/haser methods for autobind
# autobind_getter_haser: false
# 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/99designs/gqlgen/graphql.ID
- github.com/99designs/gqlgen/graphql.Int
- github.com/99designs/gqlgen/graphql.Int64
- github.com/99designs/gqlgen/graphql.Int32
# gqlgen provides a default GraphQL UUID convenience wrapper for github.com/google/uuid
# but you can override this to provide your own GraphQL UUID implementation
UUID:
model:
- github.com/99designs/gqlgen/graphql.UUID
# The GraphQL spec explicitly states that the Int type is a signed 32-bit
# integer. Using Go int or int64 to represent it can lead to unexpected
# behavior, and some GraphQL tools like Apollo Router will fail when
# communicating numbers that overflow 32-bits.
#
# You may choose to use the custom, built-in Int64 scalar to represent 64-bit
# integers, or ignore the spec and bind Int to graphql.Int / graphql.Int64
# (the default behavior of gqlgen). This is fine in simple use cases when you
# do not need to worry about interoperability and only expect small numbers.
Int:
model:
- github.com/99designs/gqlgen/graphql.Int32
Int64:
model:
- github.com/99designs/gqlgen/graphql.Int
- github.com/99designs/gqlgen/graphql.Int64
================================================
FILE: init-templates/schema.graphqls
================================================
# 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!
}
================================================
FILE: integration/.gitignore
================================================
# 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?
================================================
FILE: integration/README.md
================================================
# 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
```
================================================
FILE: integration/codegen.ts
================================================
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;
================================================
FILE: integration/graphql.config.yml
================================================
name: Schema
schema: src/generated/schema-expected.graphql
extensions:
endpoints:
dev:
url: http://localhost:8080/query
introspect: true
================================================
FILE: integration/package.json
================================================
{
"name": "integration",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"test": "vitest",
"gen": "graphql-codegen --config codegen.ts"
},
"devDependencies": {
"@apollo/client": "^4.1.6",
"@graphql-codegen/cli": "^6.2.1",
"@graphql-codegen/client-preset": "^5.2.4",
"@graphql-codegen/introspection": "^5.0.1",
"@graphql-codegen/schema-ast": "^5.0.1",
"graphql": "^16.13.1",
"graphql-sse": "^2.6.0",
"graphql-ws": "^6.0.7",
"typescript": "^5.9.3",
"urql": "^5.0.1",
"vitest": "^4.0.18"
}
}
================================================
FILE: integration/server/cmd/integration/server.go
================================================
package main
import (
"context"
"errors"
"log"
"net/http"
"os"
"time"
"github.com/vektah/gqlparser/v2/ast"
"github.com/vektah/gqlparser/v2/gqlerror"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/handler/extension"
"github.com/99designs/gqlgen/graphql/handler/lru"
"github.com/99designs/gqlgen/graphql/handler/transport"
"github.com/99designs/gqlgen/graphql/playground"
"github.com/99designs/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[*ast.QueryDocument](1000))
srv.Use(extension.Introspection{})
srv.Use(extension.AutomaticPersistedQuery{
Cache: lru.New[string](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))
}
================================================
FILE: integration/server/generated.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package server
import (
"bytes"
"context"
"embed"
"errors"
"fmt"
"strconv"
"sync/atomic"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/introspection"
models "github.com/99designs/gqlgen/integration/server/models-go"
"github.com/99designs/gqlgen/integration/server/remote_api"
"github.com/99designs/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{SchemaData: cfg.Schema, Resolvers: cfg.Resolvers, Directives: cfg.Directives, ComplexityRoot: cfg.Complexity}
}
type Config = graphql.Config[ResolverRoot, DirectiveRoot, ComplexityRoot]
type ResolverRoot interface {
Element() ElementResolver
Query() QueryResolver
User() UserResolver
}
type DirectiveRoot struct {
Magic func(ctx context.Context, obj any, next graphql.Resolver, kind *int) (res any, 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 graphql.ExecutableSchemaState[ResolverRoot, DirectiveRoot, ComplexityRoot]
func (e *executableSchema) Schema() *ast.Schema {
if e.SchemaData != nil {
return e.SchemaData
}
return parsedSchema
}
func (e *executableSchema) Complexity(ctx context.Context, typeName, field string, childComplexity int, rawArgs map[string]any) (int, bool) {
ec := newExecutionContext(nil, e, nil)
_ = ec
switch typeName + "." + field {
case "Element.child":
if e.ComplexityRoot.Element.Child == nil {
break
}
return e.ComplexityRoot.Element.Child(childComplexity), true
case "Element.error":
if e.ComplexityRoot.Element.Error == nil {
break
}
return e.ComplexityRoot.Element.Error(childComplexity), true
case "Element.mismatched":
if e.ComplexityRoot.Element.Mismatched == nil {
break
}
return e.ComplexityRoot.Element.Mismatched(childComplexity), true
case "Query.coercion":
if e.ComplexityRoot.Query.Coercion == nil {
break
}
args, err := ec.field_Query_coercion_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Query.Coercion(childComplexity, args["value"].([]*models.ListCoercion)), true
case "Query.complexity":
if e.ComplexityRoot.Query.Complexity == nil {
break
}
args, err := ec.field_Query_complexity_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Query.Complexity(childComplexity, args["value"].(int)), true
case "Query.date":
if e.ComplexityRoot.Query.Date == nil {
break
}
args, err := ec.field_Query_date_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Query.Date(childComplexity, args["filter"].(models.DateFilter)), true
case "Query.error":
if e.ComplexityRoot.Query.Error == nil {
break
}
args, err := ec.field_Query_error_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Query.Error(childComplexity, args["type"].(*models.ErrorType)), true
case "Query.jsonEncoding":
if e.ComplexityRoot.Query.JSONEncoding == nil {
break
}
return e.ComplexityRoot.Query.JSONEncoding(childComplexity), true
case "Query.path":
if e.ComplexityRoot.Query.Path == nil {
break
}
return e.ComplexityRoot.Query.Path(childComplexity), true
case "Query.viewer":
if e.ComplexityRoot.Query.Viewer == nil {
break
}
return e.ComplexityRoot.Query.Viewer(childComplexity), true
case "RemoteModelWithOmitempty.newDesc":
if e.ComplexityRoot.RemoteModelWithOmitempty.Description == nil {
break
}
return e.ComplexityRoot.RemoteModelWithOmitempty.Description(childComplexity), true
case "User.likes":
if e.ComplexityRoot.User.Likes == nil {
break
}
return e.ComplexityRoot.User.Likes(childComplexity), true
case "User.name":
if e.ComplexityRoot.User.Name == nil {
break
}
return e.ComplexityRoot.User.Name(childComplexity), true
case "User.phoneNumber":
if e.ComplexityRoot.User.PhoneNumber == nil {
break
}
return e.ComplexityRoot.User.PhoneNumber(childComplexity), true
case "User.query":
if e.ComplexityRoot.User.Query == nil {
break
}
return e.ComplexityRoot.User.Query(childComplexity), true
case "Viewer.user":
if e.ComplexityRoot.Viewer.User == nil {
break
}
return e.ComplexityRoot.Viewer.User(childComplexity), true
}
return 0, false
}
func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
opCtx := graphql.GetOperationContext(ctx)
ec := newExecutionContext(opCtx, e, make(chan graphql.DeferredResult))
inputUnmarshalMap := graphql.BuildUnmarshalerMap(
ec.unmarshalInputDateFilter,
ec.unmarshalInputListCoercion,
)
first := true
switch opCtx.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, opCtx.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.ExecutionContextState[ResolverRoot, DirectiveRoot, ComplexityRoot]
}
func newExecutionContext(
opCtx *graphql.OperationContext,
execSchema *executableSchema,
deferredResults chan graphql.DeferredResult,
) executionContext {
return executionContext{
ExecutionContextState: graphql.NewExecutionContextState[ResolverRoot, DirectiveRoot, ComplexityRoot](
opCtx,
(*graphql.ExecutableSchemaState[ResolverRoot, DirectiveRoot, ComplexityRoot])(execSchema),
parsedSchema,
deferredResults,
),
}
}
//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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "kind", ec.unmarshalOInt2ᚖint)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "value", ec.unmarshalOListCoercion2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐListCoercionᚄ)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "value", ec.unmarshalNInt2int)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "filter", ec.unmarshalNDateFilter2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐDateFilter)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "type", ec.unmarshalOErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐErrorType)
if err != nil {
return nil, err
}
args["type"] = arg0
return args, nil
}
func (ec *executionContext) field___Directive_args_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2ᚖbool)
if err != nil {
return nil, err
}
args["includeDeprecated"] = arg0
return args, nil
}
func (ec *executionContext) field___Field_args_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2ᚖbool)
if err != nil {
return nil, err
}
args["includeDeprecated"] = arg0
return args, nil
}
func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2bool)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2bool)
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Element_child,
func(ctx context.Context) (any, error) {
return ec.Resolvers.Element().Child(ctx, obj)
},
nil,
ec.marshalNElement2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐElement,
true,
true,
)
}
func (ec *executionContext) fieldContext_Element_child(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Element_error,
func(ctx context.Context) (any, error) {
return ec.Resolvers.Element().Error(ctx, obj)
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext_Element_error(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Element_mismatched,
func(ctx context.Context) (any, error) {
return ec.Resolvers.Element().Mismatched(ctx, obj)
},
nil,
ec.marshalOBoolean2ᚕboolᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext_Element_mismatched(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query_path,
func(ctx context.Context) (any, error) {
return ec.Resolvers.Query().Path(ctx)
},
nil,
ec.marshalOElement2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐElement,
true,
false,
)
}
func (ec *executionContext) fieldContext_Query_path(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query_date,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Query().Date(ctx, fc.Args["filter"].(models.DateFilter))
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query_viewer,
func(ctx context.Context) (any, error) {
return ec.Resolvers.Query().Viewer(ctx)
},
nil,
ec.marshalOViewer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐViewer,
true,
false,
)
}
func (ec *executionContext) fieldContext_Query_viewer(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query_jsonEncoding,
func(ctx context.Context) (any, error) {
return ec.Resolvers.Query().JSONEncoding(ctx)
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Query_jsonEncoding(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query_error,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Query().Error(ctx, fc.Args["type"].(*models.ErrorType))
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query_complexity,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Query().Complexity(ctx, fc.Args["value"].(int))
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query_coercion,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Query().Coercion(ctx, fc.Args["value"].([]*models.ListCoercion))
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query___type,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.IntrospectType(fc.Args["name"].(string))
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query___schema,
func(ctx context.Context) (any, error) {
return ec.IntrospectSchema()
},
nil,
ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema,
true,
false,
)
}
func (ec *executionContext) fieldContext_Query___schema(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_RemoteModelWithOmitempty_newDesc,
func(ctx context.Context) (any, error) {
return obj.Description, nil
},
nil,
ec.marshalOString2string,
true,
false,
)
}
func (ec *executionContext) fieldContext_RemoteModelWithOmitempty_newDesc(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_User_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_User_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_User_likes,
func(ctx context.Context) (any, error) {
return ec.Resolvers.User().Likes(ctx, obj)
},
nil,
ec.marshalNString2ᚕstringᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext_User_likes(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_User_phoneNumber,
func(ctx context.Context) (any, error) {
return obj.PhoneNumber, nil
},
nil,
ec.marshalOString2string,
true,
false,
)
}
func (ec *executionContext) fieldContext_User_phoneNumber(_ 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ᚋ99designsᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐQuery(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_User_query(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Viewer_user,
func(ctx context.Context) (any, error) {
return obj.User, nil
},
nil,
ec.marshalOUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋserverᚋremote_apiᚐUser,
true,
false,
)
}
func (ec *executionContext) fieldContext_Viewer_user(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Directive_description(_ 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_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_isRepeatable,
func(ctx context.Context) (any, error) {
return obj.IsRepeatable, nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_isRepeatable(_ 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) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_locations,
func(ctx context.Context) (any, error) {
return obj.Locations, nil
},
nil,
ec.marshalN__DirectiveLocation2ᚕstringᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_locations(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_args,
func(ctx context.Context) (any, error) {
return obj.Args, nil
},
nil,
ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
true,
)
}
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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __InputValue", 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___Directive_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___EnumValue_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___EnumValue_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___EnumValue_isDeprecated(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___EnumValue_deprecationReason(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Field_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_args,
func(ctx context.Context) (any, error) {
return obj.Args, nil
},
nil,
ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
true,
)
}
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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __InputValue", 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___Field_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_type,
func(ctx context.Context) (any, error) {
return obj.Type, nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_type(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_isDeprecated(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Field_deprecationReason(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_type,
func(ctx context.Context) (any, error) {
return obj.Type, nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_type(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_defaultValue,
func(ctx context.Context) (any, error) {
return obj.DefaultValue, nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_defaultValue(_ 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_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_isDeprecated(_ 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 Boolean does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) ___InputValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_deprecationReason(_ 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) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_types,
func(ctx context.Context) (any, error) {
return obj.Types(), nil
},
nil,
ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_types(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_queryType,
func(ctx context.Context) (any, error) {
return obj.QueryType(), nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_queryType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_mutationType,
func(ctx context.Context) (any, error) {
return obj.MutationType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_mutationType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_subscriptionType,
func(ctx context.Context) (any, error) {
return obj.SubscriptionType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_subscriptionType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_directives,
func(ctx context.Context) (any, error) {
return obj.Directives(), nil
},
nil,
ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_directives(_ 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 "isRepeatable":
return ec.fieldContext___Directive_isRepeatable(ctx, field)
case "locations":
return ec.fieldContext___Directive_locations(ctx, field)
case "args":
return ec.fieldContext___Directive_args(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_kind,
func(ctx context.Context) (any, error) {
return obj.Kind(), nil
},
nil,
ec.marshalN__TypeKind2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Type_kind(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_name,
func(ctx context.Context) (any, error) {
return obj.Name(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_description(_ 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_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_specifiedByURL,
func(ctx context.Context) (any, error) {
return obj.SpecifiedByURL(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_specifiedByURL(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_fields,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil
},
nil,
ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_interfaces,
func(ctx context.Context) (any, error) {
return obj.Interfaces(), nil
},
nil,
ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_interfaces(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_possibleTypes,
func(ctx context.Context) (any, error) {
return obj.PossibleTypes(), nil
},
nil,
ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_possibleTypes(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_enumValues,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil
},
nil,
ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_inputFields,
func(ctx context.Context) (any, error) {
return obj.InputFields(), nil
},
nil,
ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_inputFields(_ 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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_ofType,
func(ctx context.Context) (any, error) {
return obj.OfType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_ofType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) ___Type_isOneOf(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_isOneOf,
func(ctx context.Context) (any, error) {
return obj.IsOneOf(), nil
},
nil,
ec.marshalOBoolean2bool,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_isOneOf(_ 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 Boolean does not have child fields")
},
}
return fc, nil
}
// endregion **************************** field.gotpl *****************************
// region **************************** input.gotpl *****************************
func (ec *executionContext) unmarshalInputDateFilter(ctx context.Context, obj any) (models.DateFilter, error) {
var it models.DateFilter
if obj == nil {
return it, nil
}
asMap := map[string]any{}
for k, v := range obj.(map[string]any) {
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ᚋ99designsᚋ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 any) (models.ListCoercion, error) {
var it models.ListCoercion
if obj == nil {
return it, nil
}
asMap := map[string]any{}
for k, v := range obj.(map[string]any) {
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ᚋ99designsᚋ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, _ *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, _ *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, _ *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 "isRepeatable":
out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
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++
}
default:
panic("unknown field " + strconv.Quote(field.Name))
}
}
out.Dispatch(ctx)
if out.Invalids > 0 {
return graphql.Null
}
atomic.AddInt32(&ec.Deferred, int32(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)
case "isDeprecated":
out.Values[i] = ec.___InputValue_isDeprecated(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "deprecationReason":
out.Values[i] = ec.___InputValue_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 __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 "specifiedByURL":
out.Values[i] = ec.___Type_specifiedByURL(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 "isOneOf":
out.Values[i] = ec.___Type_isOneOf(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 any) (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 {
_ = sel
res := graphql.MarshalBoolean(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalNDateFilter2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐDateFilter(ctx context.Context, v any) (models.DateFilter, error) {
res, err := ec.unmarshalInputDateFilter(ctx, v)
return res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalNElement2githubᚗcomᚋ99designsᚋ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ᚋ99designsᚋ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)) {
graphql.AddErrorf(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 any) (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 {
_ = sel
res := graphql.MarshalInt(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalNListCoercion2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐListCoercion(ctx context.Context, v any) (*models.ListCoercion, error) {
res, err := ec.unmarshalInputListCoercion(ctx, v)
return &res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalNQuery2githubᚗcomᚋ99designsᚋ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 any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalNString2ᚕstringᚄ(ctx context.Context, v any) ([]string, error) {
var vSlice []any
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ᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler {
return ec.___Directive(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v any) ([]string, error) {
var vSlice []any
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 := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__DirectiveLocation2string(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler {
return ec.___EnumValue(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler {
return ec.___Field(ctx, sel, &v)
}
func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler {
return ec.___InputValue(ctx, sel, &v)
}
func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler {
return ec.___Type(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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 any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v any) (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 {
_ = sel
_ = ctx
res := graphql.MarshalBoolean(v)
return res
}
func (ec *executionContext) unmarshalOBoolean2ᚕboolᚄ(ctx context.Context, v any) ([]bool, error) {
if v == nil {
return nil, nil
}
var vSlice []any
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 any) (*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
}
_ = sel
_ = ctx
res := graphql.MarshalBoolean(*v)
return res
}
func (ec *executionContext) unmarshalODATE_FILTER_OP2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐDateFilterOp(ctx context.Context, v any) (*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ᚋ99designsᚋ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ᚋ99designsᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐElement(ctx context.Context, sel ast.SelectionSet, v []*models.Element) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalOElement2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐElement(ctx, sel, v[i])
})
return ret
}
func (ec *executionContext) marshalOElement2ᚖgithubᚗcomᚋ99designsᚋ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ᚋ99designsᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐErrorType(ctx context.Context, v any) ([]*models.ErrorType, error) {
if v == nil {
return nil, nil
}
var vSlice []any
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ᚋ99designsᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐErrorType(ctx, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil
}
func (ec *executionContext) marshalOErrorType2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐErrorType(ctx context.Context, sel ast.SelectionSet, v []*models.ErrorType) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalOErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐErrorType(ctx, sel, v[i])
})
return ret
}
func (ec *executionContext) unmarshalOErrorType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐErrorType(ctx context.Context, v any) (*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ᚋ99designsᚋ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 any) ([]*int, error) {
if v == nil {
return nil, nil
}
var vSlice []any
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 any) (*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
}
_ = sel
_ = ctx
res := graphql.MarshalInt(*v)
return res
}
func (ec *executionContext) unmarshalOListCoercion2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐListCoercionᚄ(ctx context.Context, v any) ([]*models.ListCoercion, error) {
if v == nil {
return nil, nil
}
var vSlice []any
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ᚋ99designsᚋ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 any) (map[string]any, 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]any) graphql.Marshaler {
if v == nil {
return graphql.Null
}
_ = sel
_ = ctx
res := graphql.MarshalMap(v)
return res
}
func (ec *executionContext) unmarshalOMap2ᚕmap(ctx context.Context, v any) ([]map[string]any, error) {
if v == nil {
return nil, nil
}
var vSlice []any
vSlice = graphql.CoerceList(v)
var err error
res := make([]map[string]any, 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]any) 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 any) (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 {
_ = sel
_ = ctx
res := graphql.MarshalString(v)
return res
}
func (ec *executionContext) unmarshalOString2ᚕᚖstring(ctx context.Context, v any) ([]*string, error) {
if v == nil {
return nil, nil
}
var vSlice []any
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 any) (*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
}
_ = sel
_ = ctx
res := graphql.MarshalString(*v)
return res
}
func (ec *executionContext) marshalOUser2ᚖgithubᚗcomᚋ99designsᚋ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ᚋ99designsᚋ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ᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec.___Schema(ctx, sel, v)
}
func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec.___Type(ctx, sel, v)
}
// endregion ***************************** type.gotpl *****************************
================================================
FILE: integration/server/gqlgen.yml
================================================
schema:
- schema/**/*.graphql
exec:
filename: generated.go
model:
filename: models-go/generated.go
struct_tag: json
autobind:
- "github.com/99designs/gqlgen/integration/server/testomitempty"
models:
Element:
model: github.com/99designs/gqlgen/integration/server/models-go.Element
Viewer:
model: github.com/99designs/gqlgen/integration/server/models-go.Viewer
User:
model: github.com/99designs/gqlgen/integration/server/remote_api.User
fields:
likes:
resolver: true
================================================
FILE: integration/server/models-go/element.go
================================================
package models
type Element struct {
ID int
}
func (e *Element) Mismatched() []Element {
return []Element{*e}
}
================================================
FILE: integration/server/models-go/generated.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package models
import (
"bytes"
"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]any `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 any) 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()))
}
func (e *DateFilterOp) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e DateFilterOp) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
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 any) 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()))
}
func (e *ErrorType) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e ErrorType) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
================================================
FILE: integration/server/models-go/viewer.go
================================================
package models
import "github.com/99designs/gqlgen/integration/server/remote_api"
type Viewer struct {
User *remote_api.User
}
================================================
FILE: integration/server/remote_api/user.go
================================================
package remote_api
type User struct {
Name string
Likes []string
PhoneNumber string
}
================================================
FILE: integration/server/resolver.go
================================================
//go:generate go run ../../testdata/gqlgen.go
package server
import (
"context"
"errors"
"fmt"
"time"
models "github.com/99designs/gqlgen/integration/server/models-go"
"github.com/99designs/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, errors.New("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, errors.New("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, errors.New("value must be asdf")
}
if *filter.Timezone != "UTC" {
return false, errors.New("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
}
================================================
FILE: integration/server/schema/schema.graphql
================================================
"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`
================================================
FILE: integration/server/schema/testomitempty.graphql
================================================
type RemoteModelWithOmitempty {
newDesc: String
}
================================================
FILE: integration/server/schema/user.graphql
================================================
type User {
name: String!
likes: [String!]!
phoneNumber: String @deprecated
query: Query!
}
================================================
FILE: integration/server/testomitempty/testmodel.go
================================================
package testomitempty
type RemoteModelWithOmitempty struct {
Description string `json:"newDesc,omitempty"`
}
================================================
FILE: integration/src/__test__/integration.spec.ts
================================================
import {afterAll, describe, expect, it} from "vitest";
import {
ApolloClient,
ApolloLink,
CombinedGraphQLErrors,
HttpLink,
InMemoryCache,
Observable,
} 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,
subscriptionExchange,
} from "urql";
import {isFragmentReady, useFragment} from "../generated";
import {readFileSync} from "node:fs";
import {join} from "node:path";
const uri = process.env.VITE_SERVER_URL || "http://localhost:8080/query";
function test(client: ApolloClient) {
describe("Json", () => {
it("should follow json escaping rules", async () => {
const res = await client.query({
query: JsonEncodingDocument,
});
expect(res.data?.jsonEncoding).toBe("");
expect(res.error).toBeUndefined();
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).toBeTruthy();
expect(res.error).toBeUndefined();
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.error).toBeDefined();
expect(res.error?.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).toBeTruthy();
expect(res.error).toBeUndefined();
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).toBeTruthy();
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).toBeTruthy();
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).toBeTruthy();
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).toBeTruthy();
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).toBeTruthy();
return null;
});
});
describe("Errors", () => {
it("should respond with correct paths", async () => {
const res = await client.query({
query: PathDocument,
});
expect(res.error).toBeDefined();
expect(CombinedGraphQLErrors.is(res.error)).toBeTruthy()
if (res.error instanceof CombinedGraphQLErrors) {
expect(res.error.errors[0].path).toEqual(["path", 0, "cc", "error"]);
expect(res.error.errors[1].path).toEqual(["path", 1, "cc", "error"]);
expect(res.error.errors[2].path).toEqual(["path", 2, "cc", "error"]);
expect(res.error.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.error).toBeDefined();
expect(res.error?.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.error).toBeDefined();
expect(res.error?.message).toEqual("normal error");
return null;
});
});
}
describe("HTTP client", () => {
const client = new ApolloClient({
link: new HttpLink({uri}),
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).toBeTruthy();
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: ApolloLink.Operation): Observable {
return new Observable((sink) => {
return this.client.subscribe(
{...operation, query: print(operation.query)},
{
next: (data) => sink.next?.(data as ApolloLink.Result),
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: [
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).toBeUndefined();
expect(res.data).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;
});
});
});
================================================
FILE: integration/src/generated/.gitignore
================================================
schema-fetched.graphql
schema-introspection.json
================================================
FILE: integration/src/generated/fragment-masking.ts
================================================
/* eslint-disable */
import { ResultOf, DocumentTypeDecoration, TypedDocumentNode } from '@graphql-typed-document-node/core';
import { FragmentDefinitionNode } from 'graphql';
import { Incremental } from './graphql';
export type FragmentType> = 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(
_documentNode: DocumentTypeDecoration,
fragmentType: FragmentType>
): TType;
// return nullable if `fragmentType` is undefined
export function useFragment(
_documentNode: DocumentTypeDecoration,
fragmentType: FragmentType> | undefined
): TType | undefined;
// return nullable if `fragmentType` is nullable
export function useFragment(
_documentNode: DocumentTypeDecoration,
fragmentType: FragmentType> | null
): TType | null;
// return nullable if `fragmentType` is nullable or undefined
export function useFragment(
_documentNode: DocumentTypeDecoration,
fragmentType: FragmentType> | null | undefined
): TType | null | undefined;
// return array of non-nullable if `fragmentType` is array of non-nullable
export function useFragment(
_documentNode: DocumentTypeDecoration,
fragmentType: Array>>
): Array;
// return array of nullable if `fragmentType` is array of nullable
export function useFragment(
_documentNode: DocumentTypeDecoration,
fragmentType: Array>> | null | undefined
): Array | null | undefined;
// return readonly array of non-nullable if `fragmentType` is array of non-nullable
export function useFragment(
_documentNode: DocumentTypeDecoration,
fragmentType: ReadonlyArray>>
): ReadonlyArray;
// return readonly array of nullable if `fragmentType` is array of nullable
export function useFragment(
_documentNode: DocumentTypeDecoration,
fragmentType: ReadonlyArray>> | null | undefined
): ReadonlyArray | null | undefined;
export function useFragment(
_documentNode: DocumentTypeDecoration,
fragmentType: FragmentType> | Array>> | ReadonlyArray>> | null | undefined
): TType | Array | ReadonlyArray | null | undefined {
return fragmentType as any;
}
export function makeFragmentData<
F extends DocumentTypeDecoration,
FT extends ResultOf
>(data: FT, _fragment: F): FragmentType {
return data as FragmentType;
}
export function isFragmentReady(
queryNode: DocumentTypeDecoration,
fragmentNode: TypedDocumentNode,
data: FragmentType, any>> | null | undefined
): data is FragmentType {
const deferredFields = (queryNode as { __meta__?: { deferredFields: Record } }).__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);
}
================================================
FILE: integration/src/generated/gql.ts
================================================
/* 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.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
type Documents = {
"query coercion($value: [ListCoercion!]) {\n coercion(value: $value)\n}": typeof types.CoercionDocument,
"query complexity($value: Int!) {\n complexity(value: $value)\n}": typeof types.ComplexityDocument,
"query date($filter: DateFilter!) {\n date(filter: $filter)\n}": typeof types.DateDocument,
"query error($type: ErrorType) {\n error(type: $type)\n}": typeof types.ErrorDocument,
"query jsonEncoding {\n jsonEncoding\n}": typeof types.JsonEncodingDocument,
"query path {\n path {\n cc: child {\n error\n }\n }\n}": typeof 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}": typeof types.ViewerDocument,
};
const documents: 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< infer TType, any> ? TType : never;
================================================
FILE: integration/src/generated/graphql.ts
================================================
/* eslint-disable */
import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
export type Maybe = T | null;
export type InputMaybe = T | null | undefined;
export type Exact = { [K in keyof T]: T[K] };
export type MakeOptional = Omit & { [SubKey in K]?: Maybe };
export type MakeMaybe = Omit & { [SubKey in K]: Maybe };
export type MakeEmpty = { [_ in K]?: never };
export type Incremental = 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; 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;
timezone?: InputMaybe;
value: Scalars['String']['input'];
};
export type Element = {
__typename?: 'Element';
child: Element;
error: Scalars['Boolean']['output'];
mismatched?: Maybe>;
};
export enum ErrorType {
Custom = 'CUSTOM',
Normal = 'NORMAL'
}
export type ListCoercion = {
enumVal?: InputMaybe>>;
intVal?: InputMaybe>>;
scalarVal?: InputMaybe>>;
strVal?: InputMaybe>>;
};
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>>;
viewer?: Maybe;
};
export type QueryCoercionArgs = {
value?: InputMaybe>;
};
export type QueryComplexityArgs = {
value: Scalars['Int']['input'];
};
export type QueryDateArgs = {
filter: DateFilter;
};
export type QueryErrorArgs = {
type?: InputMaybe;
};
export type RemoteModelWithOmitempty = {
__typename?: 'RemoteModelWithOmitempty';
newDesc?: Maybe;
};
export type User = {
__typename?: 'User';
likes: Array;
name: Scalars['String']['output'];
/** @deprecated No longer supported */
phoneNumber?: Maybe;
query: Query;
};
export type Viewer = {
__typename?: 'Viewer';
user?: Maybe;
};
export type CoercionQueryVariables = Exact<{
value?: InputMaybe | 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;
}>;
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 } }
) | null } | null };
export type UserFragmentFragment = { __typename?: 'User', likes: Array } & { ' $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;
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;
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;
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;
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;
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;
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;
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;
================================================
FILE: integration/src/generated/index.ts
================================================
export * from "./fragment-masking";
export * from "./gql";
================================================
FILE: integration/src/generated/schema-expected.graphql
================================================
"""
Directs the executor to defer this fragment when the `if` argument is true or undefined.
"""
directive @defer(
"""Deferred when true or undefined."""
if: Boolean = true
"""Unique name"""
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
}
================================================
FILE: integration/src/queries/coercion.graphql
================================================
query coercion($value: [ListCoercion!]){
coercion(value: $value )
}
================================================
FILE: integration/src/queries/complexity.graphql
================================================
query complexity($value: Int!) {
complexity(value: $value)
}
================================================
FILE: integration/src/queries/date.graphql
================================================
query date($filter: DateFilter!) {
date(filter: $filter)
}
================================================
FILE: integration/src/queries/error.graphql
================================================
query error($type: ErrorType) {
error(type: $type)
}
================================================
FILE: integration/src/queries/jsonEncoding.graphql
================================================
query jsonEncoding {
jsonEncoding
}
================================================
FILE: integration/src/queries/path.graphql
================================================
query path {
path {
cc:child {
error
}
}
}
================================================
FILE: integration/src/queries/viewer.graphql
================================================
query viewer {
viewer {
user {
name
phoneNumber
query {
jsonEncoding
}
...userFragment @defer
}
}
}
fragment userFragment on User {
likes
}
================================================
FILE: integration/tsconfig.json
================================================
{
"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"]
}
================================================
FILE: internal/code/alias.go
================================================
package code
import (
"go/types"
"strings"
)
// Unalias unwraps an alias type
func Unalias(t types.Type) types.Type {
if alias, ok := t.(*types.Alias); ok {
// If the type is an alias type, it must first check if the non-alias
// type is in an internal package. Only the last type in the alias
// chain is provided as the RHS.
if isAliasInternal(t.String(), unalias(t).String()) {
return types.NewNamed(alias.Obj(), alias.Underlying(), nil)
}
}
return unalias(t)
}
func unalias(t types.Type) types.Type {
if p, ok := t.(*types.Pointer); ok {
// If the type come from auto-binding,
// it will be a pointer to an alias type.
// (e.g: `type Cursor = entgql.Cursor[int]`)
// *ent.Cursor is the type we got from auto-binding.
return types.NewPointer(Unalias(p.Elem()))
}
return types.Unalias(t)
}
// isAliasInternal checks if an alias type path is declared for a type within
// an internal package. A best-effort attempt is made to mirror the Go internal
// visibility rules by finding the root for the rhs, and checking to ensure
// that the types both share the same root.
func isAliasInternal(lhs, rhs string) bool {
idx := strings.LastIndex(lhs, "internal")
if idx != -1 {
// If the alias type contains an internal package, there is no reason
// to continue.
return false
}
idx = strings.LastIndex(rhs, "internal")
if idx < 0 {
return false
}
root := rhs[:idx]
switch {
// The alias type path is checked against the root of the non-alias type to
// ensure the types being aliased share the same root.
case strings.HasPrefix(lhs, root):
return true
default:
return false
}
}
================================================
FILE: internal/code/alias_test.go
================================================
package code
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestIsAliasInternal(t *testing.T) {
isInternal := []struct {
name string
lhs string
rhs string
}{
{
name: "same root internal alias",
lhs: "github.com/org/repo/graph/model",
rhs: "github.com/org/repo/internal/store/example",
},
{
name: "same root internal alias, path begins with internal",
lhs: "graph/model",
rhs: "internal/store/example",
},
}
for _, tc := range isInternal {
t.Run(tc.name, func(t *testing.T) {
require.True(t, isAliasInternal(tc.lhs, tc.rhs))
})
}
isNotInternal := []struct {
name string
lhs string
rhs string
}{
{
name: "same root not internal alias",
lhs: "github.com/org/repo/graph/model",
rhs: "github.com/org/repo/store/example",
},
{
name: "same root both internal",
lhs: "github.com/org/repo/internal/model",
rhs: "github.com/org/repo/internal/store/example",
},
{
name: "diff root not internal alias",
lhs: "github.com/org/repo/graph/model",
rhs: "github.com/org/repoB/store/example",
},
{
name: "diff root internal alias",
lhs: "github.com/org/repo/graph/model",
rhs: "github.com/org/repoB/internal/store/example",
},
}
for _, tc := range isNotInternal {
t.Run(tc.name, func(t *testing.T) {
require.False(t, isAliasInternal(tc.lhs, tc.rhs))
})
}
}
================================================
FILE: internal/code/compare.go
================================================
package code
import (
"errors"
"fmt"
"go/types"
)
// CompatibleTypes isnt a strict comparison, it allows for pointer differences
func CompatibleTypes(expected, actual types.Type) error {
// Unwrap any aliases
expected, actual = Unalias(expected), Unalias(actual)
// 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 errors.New("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 errors.New("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)
}
================================================
FILE: internal/code/compare_test.go
================================================
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]any", "map[string]any"},
{"map[string]string", "map[string]string"},
{"Bar", "Bar"},
{"any", "any"},
{"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]any", "map[string]string"},
{"map[string]string", "[]string"},
{"interface{Foo() bool}", "any"},
{"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()
}
================================================
FILE: internal/code/imports.go
================================================
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 {
relPath, err := filepath.Rel(result.goModPath, d)
if err != nil {
panic(err)
}
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*)`)
================================================
FILE: internal/code/imports_test.go
================================================
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/99designs/gqlgen", extractModuleName(content))
}
func TestImportPathForDir(t *testing.T) {
wd, err := os.Getwd()
require.NoError(t, err)
assert.Equal(t, "github.com/99designs/gqlgen/internal/code", ImportPathForDir(wd))
assert.Equal(t, "github.com/99designs/gqlgen/internal/code", ImportPathForDir(wd))
assert.Equal(
t,
"github.com/99designs/gqlgen/api",
ImportPathForDir(filepath.Join(wd, "..", "..", "api")),
)
// doesnt contain go code, but should still give a valid import path
assert.Equal(
t,
"github.com/99designs/gqlgen/docs",
ImportPathForDir(filepath.Join(wd, "..", "..", "docs")),
)
// directory does not exist
assert.Equal(
t,
"github.com/99designs/gqlgen/dos",
ImportPathForDir(filepath.Join(wd, "..", "..", "dos")),
)
// out of module
assert.Empty(t, ImportPathForDir(filepath.Join(wd, "..", "..", "..")))
if runtime.GOOS == "windows" {
assert.Empty(t, ImportPathForDir("C:/doesnotexist"))
} else {
assert.Empty(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+"/../.."))
}
================================================
FILE: internal/code/packages.go
================================================
package code
import (
"bytes"
"errors"
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
"golang.org/x/tools/go/packages"
)
// lightMode is used for operations that don't need full type info (fast)
var lightMode = packages.NeedName |
packages.NeedFiles |
packages.NeedModule
// fullMode is used when type information is required (slow - triggers compilation)
var fullMode = packages.NeedName |
packages.NeedFiles |
packages.NeedTypes |
packages.NeedSyntax |
packages.NeedTypesInfo |
packages.NeedModule
// mode is the default mode for backwards compatibility
var mode = fullMode
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
packagesToCachePrefix string
useLightModePrefetch bool // Use lightMode instead of fullMode for LoadAll
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 option for NewPackages 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, ","))
}
}
func WithPreloadNames(importPaths ...string) func(p *Packages) {
return func(p *Packages) {
p.LoadAllNames(importPaths...)
}
}
// PackagePrefixToCache option for NewPackages
// will not reset gqlgen packages in packages.Load call
func PackagePrefixToCache(prefixPath string) func(p *Packages) {
return func(p *Packages) {
p.packagesToCachePrefix = prefixPath
}
}
// WithLightModePrefetch option for NewPackages uses lightMode (NeedName|NeedFiles|NeedModule)
// instead of fullMode for LoadAll, avoiding compilation until types are needed.
func WithLightModePrefetch(enabled bool) func(p *Packages) {
return func(p *Packages) {
p.useLightModePrefetch = enabled
}
}
// 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{
useLightModePrefetch: false, // Default to full mode for backwards compatibility
}
for _, opt := range opts {
opt(p)
}
return p
}
func dedupPackages(packages []string) []string {
packageMap := make(map[string]struct{})
dedupedPackages := make([]string, 0, len(packageMap))
for _, p := range packages {
if _, ok := packageMap[p]; ok {
continue
}
packageMap[p] = struct{}{}
dedupedPackages = append(dedupedPackages, p)
}
return dedupedPackages
}
func (p *Packages) CleanupUserPackages() {
if p.packagesToCachePrefix == "" {
// Cleanup all packages if we don't know which ones to keep
p.packages = nil
} else {
// Don't clean up github.com/99designs/gqlgen prefixed packages,
// they haven't changed and do not need to be reloaded
// if you are using a fork, then you need to have customized
// the prefix using PackagePrefixToCache
var toRemove []string
for k := range p.packages {
if !strings.HasPrefix(k, p.packagesToCachePrefix) {
toRemove = append(toRemove, k)
}
}
for _, k := range toRemove {
delete(p.packages, k)
}
}
}
// 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.
// If useLightModePrefetch is true, uses lightMode (faster, no type info).
// Otherwise uses fullMode (slower but includes type information).
func (p *Packages) LoadAll(importPaths ...string) []*packages.Package {
if p.useLightModePrefetch {
return p.loadAllWithMode(lightMode, importPaths...)
}
return p.loadAllWithMode(fullMode, importPaths...)
}
// LoadAllLight loads packages with minimal info (no type checking).
// This is ~200x faster than LoadAll because it doesn't trigger compilation.
// Use this when you only need package names/files, not type information.
func (p *Packages) LoadAllLight(importPaths ...string) []*packages.Package {
return p.loadAllWithMode(lightMode, importPaths...)
}
// loadAllWithMode is the internal implementation that supports different modes.
func (p *Packages) loadAllWithMode(
loadMode packages.LoadMode,
importPaths ...string,
) []*packages.Package {
if p.packages == nil {
p.packages = map[string]*packages.Package{}
}
needsTypes := loadMode&packages.NeedTypes != 0
missing := make([]string, 0, len(importPaths))
for _, path := range importPaths {
cached, ok := p.packages[path]
if !ok {
missing = append(missing, path)
continue
}
// If we need types but cached package doesn't have them, reload
if needsTypes && cached.Types == nil {
missing = append(missing, path)
}
}
if len(missing) > 0 {
p.numLoadCalls++
pkgs, err := packages.Load(&packages.Config{
Mode: loadMode,
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 {
pkg, ok := p.loadFromCache(path)
if ok {
res = append(res, pkg)
}
}
return res
}
func (p *Packages) addToCache(pkg *packages.Package) {
imp := NormalizeVendor(pkg.PkgPath)
p.packages[imp] = pkg
p.packages[pkg.Dir] = pkg // also cache by dir for relative path bindings
}
func (p *Packages) loadFromCache(importPath string) (*packages.Package, bool) {
pkg, ok := p.packages[importPath]
if ok {
return pkg, true
}
pkg, ok = p.packages[NormalizeVendor(importPath)]
if ok {
return pkg, true
}
// Special case relative paths. For example "./mypkg" or "../otherpkg"
if strings.HasPrefix(importPath, "./") || strings.HasPrefix(importPath, "../") {
wd, err := os.Getwd()
if err != nil {
p.loadErrors = append(p.loadErrors,
fmt.Errorf("unable to get working directory: %w", err))
return nil, false
}
if pkg, ok := p.packages[filepath.Clean(filepath.Join(wd, importPath))]; ok {
return pkg, true
}
}
return nil, false
}
// Load works the same as LoadAll, except a single package at a time.
func (p *Packages) Load(importPath string) *packages.Package {
pkg, ok := p.loadFromCache(importPath)
if 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
}
// LoadAllNames will call packages.Load with the NeedName mode only and will store the package name
// in a cache. it does not return any package data, but after calling this you can call
// NameForPackage to get the package name without loading the full package data.
func (p *Packages) LoadAllNames(importPaths ...string) {
importPaths = dedupPackages(importPaths)
missing := make([]string, 0, len(importPaths))
for _, importPath := range importPaths {
if importPath == "" {
panic(errors.New("import path can not be empty"))
}
if p.importToName == nil {
p.importToName = map[string]string{}
}
importPath = NormalizeVendor(importPath)
// if it's in the name cache use it
if name := p.importToName[importPath]; name != "" {
continue
}
// otherwise we might have already loaded the full package data for it cached
pkg := p.packages[importPath]
if pkg != nil {
if _, ok := p.importToName[importPath]; !ok {
p.importToName[importPath] = pkg.Name
}
continue
}
missing = append(missing, importPath)
}
if len(missing) > 0 {
pkgs, err := packages.Load(&packages.Config{
Mode: packages.NeedName,
BuildFlags: p.buildFlags,
}, missing...)
if err != nil {
p.loadErrors = append(p.loadErrors, err)
}
for _, pkg := range pkgs {
if pkg.Name == "" {
pkg.Name = SanitizePackageName(filepath.Base(pkg.PkgPath))
}
p.importToName[pkg.PkgPath] = pkg.Name
}
}
}
// 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 {
p.numNameCalls++
p.LoadAllNames(importPath)
importPath = NormalizeVendor(importPath)
return p.importToName[importPath]
}
// Evict removes a given package import path from the cache. Further calls to Load will fetch it
// from disk.
func (p *Packages) Evict(importPath string) {
pkg, ok := p.packages[importPath]
if !ok {
return
}
delete(p.packages, importPath)
delete(p.packages, pkg.Dir)
}
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
}
// disableOptimizationsFlag is passed to go build to skip compiler optimizations.
// This makes cold cache builds ~2x faster since we only need error checking.
const disableOptimizationsFlag = "-gcflags=-N -l"
// ValidateWithBuild validates packages by running `go build` instead of loading
// with NeedTypes. This is more efficient because:
// 1. It reuses the existing build cache
// 2. The user will likely run `go build` anyway after generation
// 3. It avoids double-loading type information
//
// If fastValidation is true, disables compiler optimizations for faster builds.
func ValidateWithBuild(fastValidation bool, importPaths ...string) error {
args := []string{"build"}
if fastValidation {
args = append(args, disableOptimizationsFlag)
}
args = append(args, importPaths...)
cmd := exec.Command("go", args...)
output, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("validation failed: %w\n%s", err, string(output))
}
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 {
res := append([]error{}, 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()
}
================================================
FILE: internal/code/packages_test.go
================================================
package code
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/tools/go/packages"
)
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/99designs/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/99designs/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/99designs/gqlgen/internal/code/testdata/b")
require.Equal(t, "a", p.Load("github.com/99designs/gqlgen/internal/code/testdata/a").Name)
require.Equal(t, 1, p.numLoadCalls)
require.Equal(t, "b", p.Load("github.com/99designs/gqlgen/internal/code/testdata/b").Name)
require.Equal(t, 2, 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/99designs/gqlgen/internal/code/testdata/a")
require.Equal(t, "a", p.Load("github.com/99designs/gqlgen/internal/code/testdata/a").Name)
require.Equal(t, 2, p.numLoadCalls)
require.Equal(t, "p", p.Load("github.com/99designs/gqlgen/internal/code/testdata/p").Name)
require.Equal(t, 3, p.numLoadCalls)
})
t.Run("able to load packages by relative path", func(t *testing.T) {
p := initialState(t)
require.Equal(t, "a", p.Load("./testdata/a").Name)
require.Equal(t, 1, p.numLoadCalls)
require.Equal(t, "b", p.Load("./testdata/b").Name)
require.Equal(t, 1, p.numLoadCalls)
})
t.Run("able to load relative package again after evict", func(t *testing.T) {
p := initialState(t)
p.Evict("github.com/99designs/gqlgen/internal/code/testdata/b")
require.Equal(t, "a", p.Load("./testdata/a").Name)
require.Equal(t, 1, p.numLoadCalls)
require.Equal(t, "b", p.Load("./testdata/b").Name)
require.Equal(t, 2, p.numLoadCalls)
})
}
func TestPackagesErrors(t *testing.T) {
loadFirstErr := errors.New("first")
loadSecondErr := errors.New("second")
packageErr := packages.Error{Msg: "package"}
p := &Packages{
loadErrors: []error{loadFirstErr, loadSecondErr},
packages: map[string]*packages.Package{
"github.com/99designs/gqlgen/internal/code/testdata/a": {
Errors: []packages.Error{packageErr},
},
},
}
errs := p.Errors()
assert.Equal(t, PkgErrors([]error{loadFirstErr, loadSecondErr, packageErr}), errs)
}
func TestNameForPackage(t *testing.T) {
var p Packages
assert.Equal(t, "api", p.NameForPackage("github.com/99designs/gqlgen/api"))
// does not contain go code, should still give a valid name
assert.Equal(t, "docs", p.NameForPackage("github.com/99designs/gqlgen/docs"))
assert.Equal(t, "github_com", p.NameForPackage("github.com"))
}
func TestLoadAllNames(t *testing.T) {
var p Packages
p.LoadAllNames(
"github.com/99designs/gqlgen/api",
"github.com/99designs/gqlgen/docs",
"github.com",
)
// should now be cached
assert.Equal(t, 0, p.numNameCalls)
assert.Equal(t, "api", p.importToName["github.com/99designs/gqlgen/api"])
assert.Equal(t, "docs", p.importToName["github.com/99designs/gqlgen/docs"])
assert.Equal(t, "github_com", p.importToName["github.com"])
}
func TestWithLightModePrefetch(t *testing.T) {
t.Run("default is false", func(t *testing.T) {
p := NewPackages()
require.False(t, p.useLightModePrefetch)
})
t.Run("can be enabled", func(t *testing.T) {
p := NewPackages(WithLightModePrefetch(true))
require.True(t, p.useLightModePrefetch)
})
t.Run("can be disabled", func(t *testing.T) {
p := NewPackages(WithLightModePrefetch(false))
require.False(t, p.useLightModePrefetch)
})
t.Run("LoadAll uses full mode when disabled", func(t *testing.T) {
p := NewPackages(WithLightModePrefetch(false))
pkgs := p.LoadAll("github.com/99designs/gqlgen/internal/code/testdata/a")
require.NotEmpty(t, pkgs)
// Full mode includes type info
require.NotNil(t, pkgs[0].Types)
})
t.Run("LoadAll uses light mode when enabled", func(t *testing.T) {
p := NewPackages(WithLightModePrefetch(true))
pkgs := p.LoadAll("github.com/99designs/gqlgen/internal/code/testdata/a")
require.NotEmpty(t, pkgs)
// Light mode does not include type info
require.Nil(t, pkgs[0].Types)
})
}
func initialState(t *testing.T, opts ...Option) *Packages {
t.Helper()
p := NewPackages(opts...)
pkgs := p.LoadAll(
"github.com/99designs/gqlgen/internal/code/testdata/a",
"github.com/99designs/gqlgen/internal/code/testdata/b",
"./testdata/a",
"./testdata/b",
)
require.Empty(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
}
================================================
FILE: internal/code/testdata/a/a.go
================================================
package a
var A = "A"
================================================
FILE: internal/code/testdata/b/b.go
================================================
package b
import "github.com/99designs/gqlgen/internal/code/testdata/a"
var B = a.A + " B"
================================================
FILE: internal/code/testdata/c/c.go
================================================
package c
import (
"github.com/99designs/gqlgen/internal/code/testdata/b"
)
var C = b.B + " C"
================================================
FILE: internal/code/testdata/p/p.go
================================================
//go: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/99designs/gqlgen/internal/code/testdata/b"
)
var P = b.C + " P"
================================================
FILE: internal/code/util.go
================================================
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/99designs/gqlgen/graphql becomes
// github.com/99designs/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/99designs/gqlgen/graphql becomes
// github.com/foo/vendor/github.com/99designs/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), "_")
}
================================================
FILE: internal/code/util_test.go
================================================
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"))
}
================================================
FILE: internal/imports/prune.go
================================================
// Wrapper around x/tools/imports that only removes imports, never adds new ones.
package imports
import (
"bytes"
"go/ast"
"go/format"
"go/parser"
"go/printer"
"go/token"
"strings"
"sync"
"golang.org/x/tools/go/ast/astutil"
"golang.org/x/tools/imports"
"github.com/99designs/gqlgen/internal/code"
)
// bufPool reuses buffers across Prune calls to reduce allocations.
var bufPool = sync.Pool{
New: func() any {
return new(bytes.Buffer)
},
}
// getBuffer returns a buffer and a release function.
// If usePool is true, the buffer is obtained from the pool and release returns it.
// If usePool is false, a new buffer is allocated and release is a no-op.
func getBuffer(usePool bool) (*bytes.Buffer, func()) {
if usePool {
buf := bufPool.Get().(*bytes.Buffer)
buf.Reset()
return buf, func() { bufPool.Put(buf) }
}
return new(bytes.Buffer), func() {}
}
// defaultTabWidth is the standard Go tab width used by gofmt.
const defaultTabWidth = 8
type visitFn func(node ast.Node)
func (fn visitFn) Visit(node ast.Node) ast.Visitor {
fn(node)
return fn
}
// PruneOptions configures the behavior of the Prune function.
type PruneOptions struct {
// SkipImportGrouping uses format.Source instead of imports.Process.
// Faster but doesn't group imports by stdlib/external/internal.
SkipImportGrouping bool
// UseBufferPooling reuses buffers via sync.Pool to reduce GC pressure.
UseBufferPooling bool
}
// Prune removes any unused imports from Go source code.
func Prune(
filename string,
src []byte,
packages *code.Packages,
opts PruneOptions,
) ([]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)
}
buf, release := getBuffer(opts.UseBufferPooling)
defer release()
printConfig := &printer.Config{Mode: printer.TabIndent, Tabwidth: defaultTabWidth}
if err := printConfig.Fprint(buf, fset, file); err != nil {
return nil, err
}
if opts.SkipImportGrouping {
return formatSourceFast(buf.Bytes())
}
return formatSourceWithGrouping(filename, buf.Bytes())
}
// formatSourceFast formats source code using go/format.Source.
// This is fast but doesn't group imports by category.
func formatSourceFast(src []byte) ([]byte, error) {
return format.Source(src)
}
// formatSourceWithGrouping formats source code using imports.Process.
// This groups imports by stdlib/external/internal but is slower.
func formatSourceWithGrouping(filename string, src []byte) ([]byte, error) {
opts := &imports.Options{
FormatOnly: true,
Comments: true,
TabIndent: true,
TabWidth: defaultTabWidth,
}
return imports.Process(filename, src, opts)
}
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
}
================================================
FILE: internal/imports/prune_test.go
================================================
package imports
import (
"os"
"strings"
"testing"
"github.com/stretchr/testify/require"
"github.com/99designs/gqlgen/internal/code"
)
func TestPrune(t *testing.T) {
testFile := "testdata/unused.go"
expectedFile := "testdata/unused.expected.go"
t.Run("default behavior (imports.Process)", func(t *testing.T) {
b, err := Prune(testFile, mustReadFile(testFile), code.NewPackages(), PruneOptions{})
require.NoError(t, err)
require.Equal(
t,
strings.ReplaceAll(string(mustReadFile(expectedFile)), "\r\n", "\n"),
string(b),
)
})
t.Run("with skip_import_grouping", func(t *testing.T) {
b, err := Prune(testFile, mustReadFile(testFile), code.NewPackages(), PruneOptions{
SkipImportGrouping: true,
})
require.NoError(t, err)
require.Contains(t, string(b), "package testdata")
})
t.Run("with buffer_pooling only", func(t *testing.T) {
b, err := Prune(testFile, mustReadFile(testFile), code.NewPackages(), PruneOptions{
UseBufferPooling: true,
})
require.NoError(t, err)
require.Equal(
t,
strings.ReplaceAll(string(mustReadFile(expectedFile)), "\r\n", "\n"),
string(b),
)
})
t.Run("with both options", func(t *testing.T) {
b, err := Prune(testFile, mustReadFile(testFile), code.NewPackages(), PruneOptions{
SkipImportGrouping: true,
UseBufferPooling: true,
})
require.NoError(t, err)
require.Contains(t, string(b), "package testdata")
})
}
func mustReadFile(filename string) []byte {
b, err := os.ReadFile(filename)
if err != nil {
panic(err)
}
return b
}
================================================
FILE: internal/imports/testdata/unused.expected.go
================================================
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"`
}
================================================
FILE: internal/imports/testdata/unused.go
================================================
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"`
}
================================================
FILE: internal/rewrite/rewriter.go
================================================
package rewrite
import (
"bytes"
"fmt"
"go/ast"
"go/token"
"os"
"path/filepath"
"strconv"
"strings"
"golang.org/x/tools/go/packages"
"github.com/99designs/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 && d.Doc != nil {
comments := make([]string, len(d.Doc.List))
for i := range d.Doc.List {
c := d.Doc.List[i].Text
switch c[1] {
case '/':
//-style comment (no newline at the end)
c = c[2:]
case '*':
/*-style comment */
c = c[2 : len(c)-2]
}
comments[i] = c
}
return strings.Join(comments, "\n")
}
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
}
================================================
FILE: internal/rewrite/rewriter_test.go
================================================
package rewrite
import (
"go/ast"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/tools/go/packages"
)
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)
})
}
func TestRewriter_GetMethodComment(t *testing.T) {
type fields struct {
pkg *packages.Package
files map[string]string
copied map[ast.Decl]bool
}
type args struct {
structname string
methodname string
}
tests := []struct {
name string
fields fields
args args
want string
}{
{
name: "comments",
fields: fields{
pkg: &packages.Package{
Syntax: []*ast.File{
{
Decls: []ast.Decl{
&ast.FuncDecl{
Name: &ast.Ident{Name: "Method"},
Doc: &ast.CommentGroup{
List: []*ast.Comment{
{
Text: "// comment",
},
{
Text: "// comment",
},
},
},
Recv: &ast.FieldList{
List: []*ast.Field{
{
Type: &ast.Ident{Name: "Foo"},
},
},
},
},
},
},
},
},
copied: map[ast.Decl]bool{},
},
args: args{
structname: "Foo",
methodname: "Method",
},
want: " comment\n comment", //nolint: dupword // this is for the test
},
{
name: "directive in comment",
fields: fields{
pkg: &packages.Package{
Syntax: []*ast.File{
{
Decls: []ast.Decl{
&ast.FuncDecl{
Name: &ast.Ident{Name: "Method"},
Doc: &ast.CommentGroup{
List: []*ast.Comment{
{
Text: "// comment",
},
{
Text: "//nolint:test // test",
},
},
},
Recv: &ast.FieldList{
List: []*ast.Field{
{
Type: &ast.Ident{Name: "Foo"},
},
},
},
},
},
},
},
},
copied: map[ast.Decl]bool{},
},
args: args{
structname: "Foo",
methodname: "Method",
},
want: " comment\nnolint:test // test",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := &Rewriter{
pkg: tt.fields.pkg,
files: tt.fields.files,
copied: tt.fields.copied,
}
assert.Equalf(
t,
tt.want,
r.GetMethodComment(tt.args.structname, tt.args.methodname),
"GetMethodComment(%v, %v)",
tt.args.structname,
tt.args.methodname,
)
})
}
}
================================================
FILE: internal/rewrite/testdata/example.go
================================================
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()
}
================================================
FILE: internal/tools.go
================================================
//go:build tools
package main
import (
_ "github.com/matryer/moq"
)
================================================
FILE: main.go
================================================
package main
//go:generate sh -c "cd _examples && go generate ./..."
import (
"bytes"
"context"
_ "embed"
"errors"
"fmt"
"html/template"
"io"
"io/fs"
"log"
"os"
"path/filepath"
"github.com/urfave/cli/v3"
"github.com/99designs/gqlgen/api"
"github.com/99designs/gqlgen/codegen/config"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/internal/code"
"github.com/99designs/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", filename, err)
}
if err := os.WriteFile(filename, []byte(contents), 0o644); err != nil {
return fmt.Errorf("unable to write file '%s': %w", 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 context.Context, c *cli.Command) error {
configFilename := c.String("config")
serverFilename := c.String("server")
schemaFilename := c.String("schema")
cwd, err := os.Getwd()
if err != nil {
return fmt.Errorf("unable to determine current directory: %w", err)
}
pkgName := code.ImportPathForDir(cwd)
if pkgName == "" {
return errors.New(
"unable to determine import path for current directory, you probably need to run 'go mod init' first",
)
}
modRoot := findModuleRoot(cwd)
if modRoot == "" {
return cli.Exit("go.mod is missing. Please, do 'go mod init' first\n", 1)
}
// 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 cli.Exit("gqlgen.yml already exists in a parent directory\n", 1)
}
// create config
fmt.Println("Creating", configFilename)
if err := initFile(configFilename, getConfigFileContent(pkgName)); err != nil {
return cli.Exit(err.Error()+"\n", 1)
}
// create schema
fmt.Println("Creating", schemaFilename)
if err := initFile(schemaFilename, schemaFileContent); err != nil {
return cli.Exit(err.Error()+"\n", 1)
}
// 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 cli.Exit(err.Error()+"\n", 1)
}
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 context.Context, c *cli.Command) error {
var cfg *config.Config
var err error
if configFilename := c.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
}
}
return api.Generate(cfg)
},
}
var versionCmd = &cli.Command{
Name: "version",
Usage: "print the version string",
Action: func(ctx context.Context, c *cli.Command) error {
fmt.Println(graphql.Version)
return nil
},
}
func main() {
app := &cli.Command{}
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(ctx context.Context, c *cli.Command) (context.Context, error) {
if c.Bool("verbose") {
log.SetFlags(0)
} else {
log.SetOutput(io.Discard)
}
return ctx, nil
}
app.Action = generateCmd.Action
app.Commands = []*cli.Command{
generateCmd,
initCmd,
versionCmd,
}
if err := app.Run(context.Background(), os.Args); err != nil {
fmt.Fprint(os.Stderr, err.Error()+"\n")
os.Exit(1)
}
}
================================================
FILE: plugin/federation/constants.go
================================================
package federation
import (
"github.com/vektah/gqlparser/v2/ast"
"github.com/99designs/gqlgen/codegen/config"
)
// The name of the field argument that is injected into the resolver to support @requires.
const fieldArgRequires = "_federationRequires"
// The name of the scalar type used in the injected field argument to support @requires.
const mapTypeName = "_RequiresMap"
// The @key directive that defines the key fields for an entity.
const dirNameKey = "key"
// The @requires directive that defines the required fields for an entity to be resolved.
const dirNameRequires = "requires"
// The @entityResolver directive allows users to specify entity resolvers as batch lookups
const dirNameEntityResolver = "entityResolver"
const dirNamePopulateFromRepresentations = "populateFromRepresentations"
var populateFromRepresentationsImplementation = `func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) {
fc := graphql.GetFieldContext(ctx)
// We get the Federation representations argument from the _entities resolver
representations, ok := fc.Parent.Parent.Args["representations"].([]map[string]any)
if !ok {
return nil, errors.New("must be called from within _entities")
}
// Get the index of the current entity in the representations list. This is
// set by the execution context after the _entities resolver is called.
index := fc.Parent.Index
if index == nil {
return nil, errors.New("couldn't find input index for entity")
}
if len(representations) < *index {
return nil, errors.New("representation not found")
}
return representations[*index], nil
}`
const DirNameEntityReference = "entityReference"
// The fields arguments must be provided to both key and requires directives.
const DirArgFields = "fields"
// Tells the code generator what type the directive is referencing
const DirArgType = "type"
// The file name for Federation directives
const dirGraphQLQFile = "federation/directives.graphql"
// The file name for Federation entities
const entityGraphQLQFile = "federation/entity.graphql"
const federationVersion1Schema = `
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
`
const federationVersion2Schema = `
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!, label: String) on FIELD_DEFINITION
directive @policy(policies: [[federation__Policy!]!]!) on
| FIELD_DEFINITION
| OBJECT
| INTERFACE
| SCALAR
| ENUM
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__Policy
scalar federation__Scope
`
var builtins = config.TypeMap{
"_Service": {
Model: config.StringList{
"github.com/99designs/gqlgen/plugin/federation/fedruntime.Service",
},
},
"_Entity": {
Model: config.StringList{
"github.com/99designs/gqlgen/plugin/federation/fedruntime.Entity",
},
},
"Entity": {
Model: config.StringList{
"github.com/99designs/gqlgen/plugin/federation/fedruntime.Entity",
},
},
"_Any": {
Model: config.StringList{"github.com/99designs/gqlgen/graphql.Map"},
},
"federation__Scope": {
Model: config.StringList{"github.com/99designs/gqlgen/graphql.String"},
},
"federation__Policy": {
Model: config.StringList{"github.com/99designs/gqlgen/graphql.String"},
},
}
var dirPopulateFromRepresentations = &ast.DirectiveDefinition{
Name: dirNamePopulateFromRepresentations,
IsRepeatable: false,
Description: `This is a runtime directive used to implement @requires. It's automatically placed
on the generated _federationRequires argument, and the implementation of it extracts the
correct value from the input representations list.`,
Locations: []ast.DirectiveLocation{ast.LocationArgumentDefinition},
Position: &ast.Position{Src: &ast.Source{
Name: dirGraphQLQFile,
}},
}
var dirEntityReference = &ast.DirectiveDefinition{
Name: DirNameEntityReference,
IsRepeatable: false,
Description: `This is a compile-time directive used to implement @requires.
It tells the code generator how to generate the model for the scalar.`,
Locations: []ast.DirectiveLocation{ast.LocationScalar},
Arguments: ast.ArgumentDefinitionList{
{
Name: DirArgType,
Type: ast.NonNullNamedType("String", nil),
Description: `The name of the entity that the fields selection
set should be validated against.`,
},
{
Name: DirArgFields,
Type: ast.NonNullNamedType("FieldSet", nil),
Description: "The selection that the scalar should generate into.",
},
},
Position: &ast.Position{Src: &ast.Source{
Name: dirGraphQLQFile,
}},
}
================================================
FILE: plugin/federation/entity.go
================================================
package federation
import (
"go/types"
"slices"
"github.com/vektah/gqlparser/v2/ast"
"github.com/99designs/gqlgen/codegen"
"github.com/99designs/gqlgen/codegen/config"
"github.com/99designs/gqlgen/codegen/templates"
"github.com/99designs/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 types.Type
// ImplDirectives are the resolved non-federation OBJECT-level directives
// with full type information, populated in GenerateCode for use in the
// federation template to wrap entity resolver calls.
ImplDirectives []*codegen.Directive
}
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
ReturnType types.Type // The Go generated return type for the entity
ReturnTypeName string
}
func (e *EntityResolver) LookupInputType() string {
return templates.CurrentImports.LookupType(e.InputType)
}
func (e *EntityResolver) LookupReturnType() string {
return templates.CurrentImports.LookupType(e.ReturnType)
}
// IsPointerReturnType returns true if the resolver's return type is a pointer
func (e *EntityResolver) IsPointerReturnType() bool {
if e.ReturnType == nil {
return false
}
lookupType := templates.CurrentImports.LookupType(e.ReturnType)
return lookupType != "" && lookupType[0] == '*'
}
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 _Entity 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(dirNameKey)
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 {
return slices.Contains(e.keyFields(), field.Name)
}
// Get the key fields for this entity.
func (e *Entity) keyFields() []string {
key := e.Def.Directives.ForName(dirNameKey)
if key == nil {
return []string{}
}
fields := key.Arguments.ForName(DirArgFields)
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
}
// GetTypeInfo - get the imported package & type name combo. package.TypeName
func (e Entity) GetTypeInfo() string {
return templates.CurrentImports.LookupType(e.Type)
}
================================================
FILE: plugin/federation/entity_directives.go
================================================
package federation
import (
"github.com/vektah/gqlparser/v2/ast"
)
// federationDirectiveNames lists directives that are internal to Apollo
// Federation or gqlgen and must NOT be applied as user-facing runtime
// middleware when resolving entities via the _entities query.
var federationDirectiveNames = map[string]bool{
// Federation v1
"key": true,
"requires": true,
"provides": true,
"external": true,
"extends": true,
// Federation v2
"tag": true,
"inaccessible": true,
"shareable": true,
"interfaceObject": true,
"override": true,
"composeDirective": true,
"link": true,
// Federation v2.5+
"authenticated": true,
"requiresScopes": true,
"policy": true,
// gqlgen-specific
"entityResolver": true,
"goModel": true,
"goField": true,
"goTag": true,
}
// HasObjectDirectives reports whether this entity's type definition carries
// any non-federation user-defined directives that should be applied at
// runtime when the entity is resolved through the _entities query.
func (e *Entity) HasObjectDirectives() bool {
return len(e.ImplDirectives) > 0
}
// NonFederationDirectives returns the AST directives applied to this entity,
// excluding federation-internal and gqlgen-internal directives.
func (e *Entity) NonFederationDirectives() ast.DirectiveList {
if e.Def == nil {
return nil
}
var result ast.DirectiveList
for _, d := range e.Def.Directives {
if !federationDirectiveNames[d.Name] {
result = append(result, d)
}
}
return result
}
================================================
FILE: plugin/federation/entity_directives_test.go
================================================
package federation
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/vektah/gqlparser/v2/ast"
"github.com/99designs/gqlgen/codegen"
)
func TestEntity_HasObjectDirectives(t *testing.T) {
assert.False(t, (&Entity{}).HasObjectDirectives())
assert.False(t, (&Entity{ImplDirectives: nil}).HasObjectDirectives())
assert.True(
t,
(&Entity{ImplDirectives: []*codegen.Directive{{Name: "guard"}}}).HasObjectDirectives(),
)
}
func TestEntity_NonFederationDirectives(t *testing.T) {
tests := []struct {
name string
entity *Entity
wantNames []string
}{
{
name: "nil Def",
entity: &Entity{Def: nil},
wantNames: nil,
},
{
name: "filters all federation directives",
entity: &Entity{Def: &ast.Definition{
Directives: ast.DirectiveList{
{Name: "key"},
{Name: "requires"},
{Name: "provides"},
{Name: "external"},
{Name: "extends"},
{Name: "tag"},
{Name: "inaccessible"},
{Name: "shareable"},
{Name: "interfaceObject"},
{Name: "override"},
{Name: "composeDirective"},
{Name: "link"},
{Name: "authenticated"},
{Name: "requiresScopes"},
{Name: "policy"},
{Name: "entityResolver"},
{Name: "goModel"},
{Name: "goField"},
{Name: "goTag"},
},
}},
wantNames: nil,
},
{
name: "keeps user directives in order",
entity: &Entity{Def: &ast.Definition{
Directives: ast.DirectiveList{
{Name: "key"},
{Name: "guard"},
{Name: "shareable"},
{Name: "hasRole"},
},
}},
wantNames: []string{"guard", "hasRole"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := tt.entity.NonFederationDirectives()
if tt.wantNames == nil {
assert.Nil(t, got)
return
}
require.Len(t, got, len(tt.wantNames))
for i, d := range got {
assert.Equal(t, tt.wantNames[i], d.Name)
}
})
}
}
func TestFederationDirectiveNames_Completeness(t *testing.T) {
for _, name := range []string{
"key", "requires", "provides", "external", "extends",
"tag", "inaccessible", "shareable", "interfaceObject",
"override", "composeDirective", "link",
"authenticated", "requiresScopes", "policy",
"entityResolver", "goModel", "goField", "goTag",
} {
assert.True(t, federationDirectiveNames[name], "%q missing", name)
}
}
// TestEntity_NonFederationDirectives_Filtering validates that user-defined
// directives are preserved while federation directives are filtered.
func TestEntity_NonFederationDirectives_Filtering(t *testing.T) {
tests := []struct {
name string
entity *Entity
wantNames []string
desc string
}{
{
name: "user directive preserved",
entity: &Entity{Def: &ast.Definition{
Directives: ast.DirectiveList{
{Name: "key"},
{Name: "guard"},
},
}},
wantNames: []string{"guard"},
desc: "User-defined @guard directive should be preserved while @key is filtered",
},
{
name: "multiple user directives",
entity: &Entity{Def: &ast.Definition{
Directives: ast.DirectiveList{
{Name: "shareable"},
{Name: "auth"},
{Name: "guard"},
{Name: "key"},
},
}},
wantNames: []string{"auth", "guard"},
desc: "Multiple user directives should be preserved in order",
},
{
name: "only federation directives",
entity: &Entity{Def: &ast.Definition{
Directives: ast.DirectiveList{
{Name: "key"},
{Name: "shareable"},
{Name: "tag"},
},
}},
wantNames: nil,
desc: "Only federation directives should result in empty list",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := tt.entity.NonFederationDirectives()
if tt.wantNames == nil {
assert.Nil(t, got, tt.desc)
return
}
require.Len(t, got, len(tt.wantNames), tt.desc)
for i, d := range got {
assert.Equal(t, tt.wantNames[i], d.Name)
}
})
}
}
================================================
FILE: plugin/federation/federation.go
================================================
package federation
import (
_ "embed"
"errors"
"fmt"
"go/types"
"sort"
"strings"
"github.com/vektah/gqlparser/v2/ast"
"github.com/99designs/gqlgen/codegen"
"github.com/99designs/gqlgen/codegen/config"
"github.com/99designs/gqlgen/codegen/templates"
"github.com/99designs/gqlgen/internal/rewrite"
"github.com/99designs/gqlgen/plugin/federation/fieldset"
)
//go:embed federation.gotpl
var federationTemplate string
//go:embed requires.gotpl
var explicitRequiresTemplate string
type Federation struct {
Entities []*Entity
RequiresEntities map[string]*Entity
PackageOptions PackageOptions
version int
// true if @requires is used in the schema
usesRequires bool
}
type PackageOptions struct {
// ExplicitRequires will generate a function in the execution context
// to populate fields using the @required directive into the entity.
//
// You can only set one of ExplicitRequires or ComputedRequires to true.
ExplicitRequires bool
// ComputedRequires generates resolver functions to compute values for
// fields using the @required directive.
ComputedRequires bool
// EntityResolverMulti is default engine for entityResolver generation.
// This can be overriding by @entityResolver(multi: Boolean) directive.
// false by default.
EntityResolverMulti bool
}
// New returns a federation plugin that injects
// federated directives and types into the schema
func New(version int, cfg *config.Config) (*Federation, error) {
if version == 0 {
version = 1
}
options, err := buildPackageOptions(cfg)
if err != nil {
return nil, fmt.Errorf("invalid federation package options: %w", err)
}
return &Federation{
version: version,
PackageOptions: options,
}, nil
}
func buildPackageOptions(cfg *config.Config) (PackageOptions, error) {
packageOptions := cfg.Federation.Options
const (
optionExplicitRequires = "explicit_requires"
optionComputedRequires = "computed_requires"
optionEntityResolverMulti = "entity_resolver_multi"
)
var explicitRequires,
computedRequires,
entityResolverMulti bool
for k, v := range packageOptions {
switch k {
case optionExplicitRequires:
explicitRequires = v
case optionComputedRequires:
computedRequires = v
case optionEntityResolverMulti:
entityResolverMulti = v
default:
return PackageOptions{}, fmt.Errorf("unknown package option: %s", k)
}
}
if explicitRequires && computedRequires {
return PackageOptions{}, fmt.Errorf(
"only one of %s or %s can be set to true",
optionExplicitRequires,
optionComputedRequires,
)
}
if computedRequires {
if cfg.Federation.Version != 2 {
return PackageOptions{}, fmt.Errorf(
"when using federation.options.%s you must be using Federation 2",
optionComputedRequires,
)
}
// We rely on injecting a null argument with a directives for fields with @requires, so we
// need to ensure
// our directive is always called.
if !cfg.CallArgumentDirectivesWithNull {
return PackageOptions{}, fmt.Errorf(
"when using federation.options.%s, call_argument_directives_with_null must be set to true",
optionComputedRequires,
)
}
}
// We rely on injecting a null argument with a directives for fields with @requires, so we need
// to ensure
// our directive is always called.
return PackageOptions{
ExplicitRequires: explicitRequires,
ComputedRequires: computedRequires,
EntityResolverMulti: entityResolverMulti,
}, nil
}
// Name returns the plugin name
func (f *Federation) Name() string {
return "federation"
}
// MutateConfig mutates the configuration
func (f *Federation) MutateConfig(cfg *config.Config) error {
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[dirNameRequires] = config.DirectiveConfig{SkipRuntime: true}
cfg.Directives["provides"] = config.DirectiveConfig{SkipRuntime: true}
cfg.Directives[dirNameKey] = config.DirectiveConfig{SkipRuntime: true}
cfg.Directives["extends"] = config.DirectiveConfig{SkipRuntime: true}
cfg.Directives[dirNameEntityResolver] = 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["policy"] = config.DirectiveConfig{SkipRuntime: true}
cfg.Directives["interfaceObject"] = config.DirectiveConfig{SkipRuntime: true}
cfg.Directives["composeDirective"] = config.DirectiveConfig{SkipRuntime: true}
}
if f.usesRequires && f.PackageOptions.ComputedRequires {
cfg.Schema.Directives[dirPopulateFromRepresentations.Name] = dirPopulateFromRepresentations
cfg.Directives[dirPopulateFromRepresentations.Name] = config.DirectiveConfig{
Implementation: &populateFromRepresentationsImplementation,
}
cfg.Schema.Directives[dirEntityReference.Name] = dirEntityReference
cfg.Directives[dirEntityReference.Name] = config.DirectiveConfig{SkipRuntime: true}
f.addMapType(cfg)
f.mutateSchemaForRequires(cfg.Schema, cfg)
}
return nil
}
func (f *Federation) InjectSourcesEarly() ([]*ast.Source, error) {
input := ``
// add version-specific changes on key directive, as well as adding the new directives for
// federation 2
switch f.version {
case 1:
input += federationVersion1Schema
case 2:
input += federationVersion2Schema
}
return []*ast.Source{{
Name: dirGraphQLQFile,
Input: input,
BuiltIn: true,
}}, nil
}
// InjectSourcesLate creates a GraphQL Entity type with all
// the fields that had the @key directive
func (f *Federation) InjectSourcesLate(schema *ast.Schema) ([]*ast.Source, error) {
f.Entities = f.buildEntities(schema, f.version)
entities := make([]string, 0)
resolvers := make([]string, 0)
entityResolverInputDefinitions := make([]string, 0)
for _, e := range f.Entities {
if e.Def.Kind != ast.Interface {
entities = append(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 {
resolverSDL, entityResolverInputSDL := buildResolverSDL(r, e.Multi)
resolvers = append(resolvers, resolverSDL)
if entityResolverInputSDL != "" {
entityResolverInputDefinitions = append(
entityResolverInputDefinitions,
entityResolverInputSDL,
)
}
}
}
var blocks []string
if len(entities) > 0 {
entitiesSDL := `# a union of all types that use the @key directive
union _Entity = ` + strings.Join(entities, " | ")
blocks = append(blocks, entitiesSDL)
}
// resolvers can be empty if a service defines only "empty
// extend" types. This should be rare.
if len(resolvers) > 0 {
if len(entityResolverInputDefinitions) > 0 {
inputSDL := strings.Join(entityResolverInputDefinitions, "\n\n")
blocks = append(blocks, inputSDL)
}
resolversSDL := `# fake type to build resolver interfaces for users to implement
type Entity {
` + strings.Join(resolvers, "\n") + `
}`
blocks = append(blocks, resolversSDL)
}
_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: entityGraphQLQFile,
BuiltIn: true,
Input: "\n" + strings.Join(blocks, "\n\n") + "\n",
}}, nil
}
func (f *Federation) GenerateCode(data *codegen.Data) error {
// requires imports
requiresImports := make(map[string]bool, 0)
requiresImports["context"] = true
requiresImports["fmt"] = true
requiresEntities := make(map[string]*Entity, 0)
// Save package options on f for template use
packageOptions, err := buildPackageOptions(data.Config)
if err != nil {
return fmt.Errorf("invalid federation package options: %w", err)
}
f.PackageOptions = packageOptions
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 {
populateKeyFieldTypes(r, obj, data.Objects, e.Def.Name)
}
// 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
}
// keep track of which entities have requires
requiresEntities[e.Def.Name] = e
// make a proper import path
typeString := strings.Split(obj.Type.String(), ".")
requiresImports[strings.Join(typeString[:len(typeString)-1], ".")] = true
if containsUnionField(reqField) {
continue
}
cgField := reqField.Field.TypeReference(obj, data.Objects)
reqField.Type = cgField.TypeReference
}
// add type info to entity
e.Type = obj.Type
}
}
// 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
}
}
// fill in return types for all entity resolvers
// Entity resolvers always return pointers in Federation
for _, entity := range f.Entities {
for _, resolver := range entity.Resolvers {
// Ensure the return type is a pointer
if ptr, ok := entity.Type.(*types.Pointer); ok {
// Already a pointer
resolver.ReturnType = ptr
} else {
// Make it a pointer
resolver.ReturnType = types.NewPointer(entity.Type)
}
}
}
if f.PackageOptions.ExplicitRequires && len(requiresEntities) > 0 {
err := f.generateExplicitRequires(
data,
requiresEntities,
requiresImports,
)
if err != nil {
return err
}
}
f.RequiresEntities = requiresEntities
// Populate ImplDirectives on each entity by extracting the resolved
// OBJECT-level directives from the corresponding codegen.Object.
// These are the user-defined directives (e.g. @guard, @auth) that
// should wrap entity resolver calls — federation-internal directives
// are excluded.
for _, e := range f.Entities {
obj := data.Objects.ByName(e.Def.Name)
if obj == nil || len(obj.Fields) == 0 {
continue
}
// OBJECT-level directives are propagated to every field during
// codegen. Pick them from the first field's directive list.
for _, d := range obj.Fields[0].Directives {
if d.SkipRuntime {
continue
}
if d.IsLocation(ast.LocationObject) && !federationDirectiveNames[d.Name] {
e.ImplDirectives = append(e.ImplDirectives, d)
}
}
}
return templates.Render(templates.Options{
PackageName: data.Config.Federation.Package,
Filename: data.Config.Federation.Filename,
Data: struct {
Federation
UsePointers bool
UseFunctionSyntaxForExecutionContext bool
}{*f, data.Config.ResolversAlwaysReturnPointers, data.Config.UseFunctionSyntaxForExecutionContext},
GeneratedHeader: true,
Packages: data.Config.Packages,
Template: federationTemplate,
PruneOptions: data.Config.GetPruneOptions(),
})
}
func containsUnionField(reqField *Requires) bool {
for _, requireFields := range reqField.Field {
if strings.HasPrefix(requireFields, "... on") {
return true
}
}
return false
}
// Fill in types for key fields
func populateKeyFieldTypes(
resolver *EntityResolver,
obj *codegen.Object,
allObjects codegen.Objects,
name string,
) {
for _, keyField := range resolver.KeyFields {
if len(keyField.Field) == 0 {
fmt.Println(
"skipping @key field " + keyField.Definition.Name + " in " + resolver.ResolverName + " in " + name,
)
continue
}
cgField := keyField.Field.TypeReference(obj, allObjects)
keyField.Type = cgField.TypeReference
}
}
func (f *Federation) buildEntities(schema *ast.Schema, version int) []*Entity {
entities := make([]*Entity, 0)
for _, schemaType := range schema.Types {
entity := f.buildEntity(schemaType, schema, version)
if entity != nil {
entities = append(entities, entity)
}
}
// make sure order remains stable across multiple builds
sort.Slice(entities, func(i, j int) bool {
return entities[i].Name < entities[j].Name
})
return entities
}
func (f *Federation) buildEntity(
schemaType *ast.Definition,
schema *ast.Schema,
version int,
) *Entity {
keys, ok := isFederatedEntity(schemaType)
if !ok {
return nil
}
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,
)
return nil
}
entity := &Entity{
Name: schemaType.Name,
Def: schemaType,
Resolvers: nil,
Requires: nil,
Multi: f.isMultiEntity(schemaType),
}
// 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 entity.allFieldsAreExternal(version) {
return entity
}
entity.Resolvers = buildResolvers(schemaType, schema, keys, entity.Multi)
entity.Requires = buildRequires(schemaType)
if len(entity.Requires) > 0 {
f.usesRequires = true
}
return entity
}
// isMultiEntity returns @entityResolver(multi) value, if directive is not defined,
// then global configuration parameter will be used.
func (f *Federation) isMultiEntity(schemaType *ast.Definition) bool {
dir := schemaType.Directives.ForName(dirNameEntityResolver)
if dir == nil {
return f.PackageOptions.EntityResolverMulti
}
if dirArg := dir.Arguments.ForName("multi"); dirArg != nil {
if dirVal, err := dirArg.Value.Value(nil); err == nil {
return dirVal.(bool)
}
}
return f.PackageOptions.EntityResolverMulti
}
func buildResolvers(
schemaType *ast.Definition,
schema *ast.Schema,
keys []*ast.Directive,
multi bool,
) []*EntityResolver {
resolvers := make([]*EntityResolver, 0)
for _, dir := range keys {
if len(dir.Arguments) > 2 {
panic("More than two arguments provided for @key declaration.")
}
keyFields, resolverFields := buildKeyFields(
schemaType,
schema,
dir,
)
resolverFieldsToGo := schemaType.Name + "By" + strings.Join(resolverFields, "And")
var resolverName string
if multi {
resolverFieldsToGo += "s" // Pluralize for better API readability
resolverName = fmt.Sprintf("findMany%s", resolverFieldsToGo)
} else {
resolverName = fmt.Sprintf("find%s", resolverFieldsToGo)
}
resolvers = append(resolvers, &EntityResolver{
ResolverName: resolverName,
KeyFields: keyFields,
InputTypeName: resolverFieldsToGo + "Input",
ReturnTypeName: schemaType.Name,
})
}
return resolvers
}
func extractFields(
dir *ast.Directive,
) (string, error) {
var arg *ast.Argument
// since directives 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 == DirArgFields {
if arg != nil {
return "", errors.New("more than one \"fields\" argument provided for declaration")
}
arg = a
}
}
return arg.Value.Raw, nil
}
func buildKeyFields(
schemaType *ast.Definition,
schema *ast.Schema,
dir *ast.Directive,
) ([]*KeyField, []string) {
fieldsRaw, err := extractFields(dir)
if err != nil {
panic("More than one `fields` argument provided for declaration.")
}
keyFieldSet := fieldset.New(fieldsRaw, 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())
}
return keyFields, resolverFields
}
func buildRequires(schemaType *ast.Definition) []*Requires {
requires := make([]*Requires, 0)
for _, f := range schemaType.Fields {
dir := f.Directives.ForName(dirNameRequires)
if dir == nil {
continue
}
fieldsRaw, err := extractFields(dir)
if err != nil {
panic("Exactly one `fields` argument needed for @requires declaration.")
}
requiresFieldSet := fieldset.New(fieldsRaw, nil)
for _, field := range requiresFieldSet {
requires = append(requires, &Requires{
Name: field.ToGoPrivate(),
Field: field,
})
}
}
return requires
}
func isFederatedEntity(schemaType *ast.Definition) ([]*ast.Directive, bool) {
switch schemaType.Kind {
case ast.Object:
keys := schemaType.Directives.ForNames(dirNameKey)
if len(keys) > 0 {
return keys, true
}
case ast.Interface:
keys := schemaType.Directives.ForNames(dirNameKey)
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
}
func (f *Federation) generateExplicitRequires(
data *codegen.Data,
requiresEntities map[string]*Entity,
requiresImports map[string]bool,
) error {
// check for existing requires functions
type Populator struct {
FuncName string
Exists bool
Comment string
Implementation string
Entity *Entity
}
populators := make([]Populator, 0)
rewriter, err := rewrite.New(data.Config.Federation.Dir())
if err != nil {
return err
}
for name, entity := range requiresEntities {
populator := Populator{
FuncName: fmt.Sprintf("Populate%sRequires", name),
Entity: entity,
}
populator.Comment = strings.TrimSpace(
strings.TrimLeft(
rewriter.GetMethodComment("executionContext", populator.FuncName),
`\`,
),
)
populator.Implementation = strings.TrimSpace(
rewriter.GetMethodBody("executionContext", populator.FuncName),
)
if populator.Implementation == "" {
populator.Exists = false
populator.Implementation = fmt.Sprintf(
"panic(fmt.Errorf(\"not implemented: %v\"))",
populator.FuncName,
)
}
populators = append(populators, populator)
}
sort.Slice(populators, func(i, j int) bool {
return populators[i].FuncName < populators[j].FuncName
})
requiresFile := data.Config.Federation.Dir() + "/federation.requires.go"
existingImports := rewriter.ExistingImports(requiresFile)
for _, imp := range existingImports {
if imp.Alias == "" {
// import exists in both places, remove
delete(requiresImports, imp.ImportPath)
}
}
for k := range requiresImports {
existingImports = append(existingImports, rewrite.Import{ImportPath: k})
}
// render requires populators
return templates.Render(templates.Options{
PackageName: data.Config.Federation.Package,
Filename: requiresFile,
Data: struct {
Federation
ExistingImports []rewrite.Import
Populators []Populator
OriginalSource string
}{*f, existingImports, populators, ""},
GeneratedHeader: false,
Packages: data.Config.Packages,
Template: explicitRequiresTemplate,
PruneOptions: data.Config.GetPruneOptions(),
})
}
func buildResolverSDL(
resolver *EntityResolver,
multi bool,
) (resolverSDL, entityResolverInputSDL string) {
if multi {
entityResolverInputSDL = buildEntityResolverInputDefinitionSDL(resolver)
resolverSDL := fmt.Sprintf(
"\t%s(reps: [%s]!): [%s]",
resolver.ResolverName,
resolver.InputTypeName,
resolver.ReturnTypeName,
)
return resolverSDL, entityResolverInputSDL
}
resolverArgs := ""
var resolverArgsSb705 strings.Builder
for _, keyField := range resolver.KeyFields {
fmt.Fprintf(
&resolverArgsSb705,
"%s: %s,",
keyField.Field.ToGoPrivate(),
keyField.Definition.Type.String(),
)
}
resolverArgs += resolverArgsSb705.String()
resolverSDL = fmt.Sprintf(
"\t%s(%s): %s!",
resolver.ResolverName,
resolverArgs,
resolver.ReturnTypeName,
)
return resolverSDL, ""
}
func buildEntityResolverInputDefinitionSDL(resolver *EntityResolver) string {
entityResolverInputDefinition := "input " + resolver.InputTypeName + " {\n"
var entityResolverInputDefinitionSb714 strings.Builder
for _, keyField := range resolver.KeyFields {
fmt.Fprintf(&entityResolverInputDefinitionSb714,
"\t%s: %s\n",
keyField.Field.ToGo(),
keyField.Definition.Type.String(),
)
}
entityResolverInputDefinition += entityResolverInputDefinitionSb714.String()
return entityResolverInputDefinition + "}"
}
func (f *Federation) addMapType(cfg *config.Config) {
cfg.Models[mapTypeName] = config.TypeMapEntry{
Model: config.StringList{"github.com/99designs/gqlgen/graphql.Map"},
}
cfg.Schema.Types[mapTypeName] = &ast.Definition{
Kind: ast.Scalar,
Name: mapTypeName,
Description: "Maps an arbitrary GraphQL value to a map[string]any Go type.",
}
}
func (f *Federation) mutateSchemaForRequires(
schema *ast.Schema,
cfg *config.Config,
) {
for _, schemaType := range schema.Types {
for _, field := range schemaType.Fields {
if dir := field.Directives.ForName(dirNameRequires); dir != nil {
// ensure we always generate a resolver for any @requires field
model := cfg.Models[schemaType.Name]
fieldConfig := model.Fields[field.Name]
fieldConfig.Resolver = true
if model.Fields == nil {
model.Fields = make(map[string]config.TypeMapField)
}
model.Fields[field.Name] = fieldConfig
cfg.Models[schemaType.Name] = model
requiresArgument := &ast.ArgumentDefinition{
Name: fieldArgRequires,
Type: ast.NamedType(mapTypeName, nil),
Directives: ast.DirectiveList{
{
Name: dirNamePopulateFromRepresentations,
Definition: dirPopulateFromRepresentations,
},
},
}
field.Arguments = append(field.Arguments, requiresArgument)
}
}
}
}
================================================
FILE: plugin/federation/federation.gotpl
================================================
{{ reserveImport "context" }}
{{ reserveImport "errors" }}
{{ reserveImport "fmt" }}
{{ reserveImport "strings" }}
{{ reserveImport "sync" }}
{{ reserveImport "github.com/99designs/gqlgen/plugin/federation/fedruntime" }}
{{ $options := .PackageOptions }}
{{ $usePointers := .UsePointers }}
{{ $useFunctionSyntaxForExecutionContext := .UseFunctionSyntaxForExecutionContext }}
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]any) []fedruntime.Entity {
list := make([]fedruntime.Entity, len(representations))
repsMap := ec.buildRepresentationGroups(ctx, representations)
switch len(repsMap) {
case 0:
return list
case 1:
for typeName, reps := range repsMap {
ec.resolveEntityGroup(ctx, typeName, reps, list)
}
return list
default:
var g sync.WaitGroup
g.Add(len(repsMap))
for typeName, reps := range repsMap {
go func(typeName string, reps []EntityWithIndex) {
ec.resolveEntityGroup(ctx, typeName, reps, list)
g.Done()
}(typeName, reps)
}
g.Wait()
return list
}
}
type EntityWithIndex struct {
// The index in the original representation array
index int
entity EntityRepresentation
}
// EntityRepresentation is the JSON representation of an entity sent by the Router
// used as the inputs for us to resolve.
//
// We make it a map because we know the top level JSON is always an object.
type EntityRepresentation map[string]any
// We group entities by typename so that we can parallelize their resolution.
// This is particularly helpful when there are entity groups in multi mode.
func (ec *executionContext) buildRepresentationGroups(
ctx context.Context,
representations []map[string]any,
) map[string][]EntityWithIndex {
repsMap := make(map[string][]EntityWithIndex)
for i, rep := range representations {
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
}
repsMap[typeName] = append(repsMap[typeName], EntityWithIndex{
index: i,
entity: rep,
})
}
return repsMap
}
func (ec *executionContext) resolveEntityGroup(
ctx context.Context,
typeName string,
reps []EntityWithIndex,
list []fedruntime.Entity,
) {
if isMulti(typeName) {
err := ec.resolveManyEntities(ctx, typeName, reps, list)
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 EntityWithIndex) {
entity, err := ec.resolveEntity(ctx, typeName, rep.entity)
if err != nil {
ec.Error(ctx, err)
} else {
list[rep.index] = entity
}
e.Done()
}(i, rep)
}
e.Wait()
}
}
func isMulti(typeName string) bool {
switch typeName {
{{- range .Entities -}}
{{- if .Resolvers -}}
{{- if .Multi -}}
case "{{.Def.Name}}":
return true
{{ end }}
{{- end -}}
{{- end -}}
default:
return false
}
}
func (ec *executionContext) resolveEntity(
ctx context.Context,
typeName string,
rep EntityRepresentation,
) (e fedruntime.Entity, 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 nil, fmt.Errorf(`finding resolver for Entity "{{.Def.Name}}": %w`, err)
}
switch resolverName {
{{ range $i, $resolver := .Resolvers }}
case "{{.ResolverName}}":
{{- range $j, $keyField := .KeyFields }}
{{ if $useFunctionSyntaxForExecutionContext -}}
id{{$j}}, err := {{.Type.UnmarshalFunc}}(ctx, ec, rep["{{.Field.Join `"].(map[string]any)["`}}"])
{{- else -}}
id{{$j}}, err := ec.{{.Type.UnmarshalFunc}}(ctx, rep["{{.Field.Join `"].(map[string]any)["`}}"])
{{- end }}
if err != nil {
return nil, 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 nil, fmt.Errorf(`resolving Entity "{{$entity.Def.Name}}": %w`, err)
}
{{- if $options.ComputedRequires }}
{{/* We don't do anything in this case, computed requires are handled by standard resolvers */}}
{{- else if and $options.ExplicitRequires $entity.Requires }}
err = ec.Populate{{$entity.Def.Name}}Requires(ctx, {{- if (not $usePointers) -}}&{{- end -}}entity, rep)
if err != nil {
return nil, fmt.Errorf(`populating requires for Entity "{{$entity.Def.Name}}": %w`, err)
}
{{- else }}
{{ range $entity.Requires }}
{{ if $useFunctionSyntaxForExecutionContext -}}
entity.{{.Field.JoinGo `.`}}, err = {{.Type.UnmarshalFunc}}(ctx, ec, rep["{{.Field.Join `"].(map[string]any)["`}}"])
{{- else -}}
entity.{{.Field.JoinGo `.`}}, err = ec.{{.Type.UnmarshalFunc}}(ctx, rep["{{.Field.Join `"].(map[string]any)["`}}"])
{{- end }}
if err != nil {
return nil, err
}
{{- end }}
{{- end }}
return entity, nil
{{- end }}
}
{{ end }}
{{- end }}
}
return nil, fmt.Errorf("%w: %s", ErrUnknownType, typeName)
}
func (ec *executionContext) resolveManyEntities(
ctx context.Context,
typeName string,
reps []EntityWithIndex,
list []fedruntime.Entity,
) (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].entity)
if err != nil {
return fmt.Errorf(`finding resolver for Entity "{{.Def.Name}}": %w`, err)
}
switch resolverName {
{{ range $i, $resolver := .Resolvers }}
case "{{.ResolverName}}":
typedReps := make([]*{{.LookupInputType}}, len(reps))
for i, rep := range reps {
{{ range $i, $keyField := .KeyFields -}}
{{ if $useFunctionSyntaxForExecutionContext -}}
id{{$i}}, err := {{.Type.UnmarshalFunc}}(ctx, ec, rep.entity["{{.Field.Join `"].(map[string]any)["`}}"])
{{- else -}}
id{{$i}}, err := ec.{{.Type.UnmarshalFunc}}(ctx, rep.entity["{{.Field.Join `"].(map[string]any)["`}}"])
{{- end }}
if err != nil {
return errors.New(fmt.Sprintf("Field %s undefined in schema.", "{{.Definition.Name}}"))
}
{{end}}
typedReps[i] = &{{.LookupInputType}} {
{{ range $i, $keyField := .KeyFields -}}
{{$keyField.Field.ToGo}}: id{{$i}},
{{end}}
}
}
entities, err := ec.Resolvers.Entity().{{.ResolverName | go}}(ctx, typedReps)
if err != nil {
return err
}
for i, entity := range entities {
{{- if and $.PackageOptions.ExplicitRequires (index $.RequiresEntities $entity.Def.Name) }}
err = ec.Populate{{$entity.Def.Name}}Requires(ctx, {{- if not $usePointers -}}&{{- end -}}entity, reps[i].entity)
if err != nil {
return fmt.Errorf(`populating requires for Entity "{{$entity.Def.Name}}": %w`, err)
}
{{- end }}
{{- range $entity.Requires }}
{{- if $options.ComputedRequires }}
{{/* We don't do anything in this case, computed requires are handled by standard resolvers */}}
{{- else if $.PackageOptions.ExplicitRequires }}
{{/* already handled above */}}
{{- else }}
{{ if $useFunctionSyntaxForExecutionContext -}}
entity.{{.Field.JoinGo `.`}}, err = {{.Type.UnmarshalFunc}}(ctx, ec, reps[i].entity["{{.Field.Join `"].(map[string]any)["`}}"])
{{- else -}}
entity.{{.Field.JoinGo `.`}}, err = ec.{{.Type.UnmarshalFunc}}(ctx, reps[i].entity["{{.Field.Join `"].(map[string]any)["`}}"])
{{- end }}
if err != nil {
return err
}
{{- end}}
{{- end}}
list[reps[i].index] = entity
}
return nil
{{ end }}
default:
return fmt.Errorf("unknown resolver: %s", resolverName)
}
{{ end }}
{{- end }}
default:
return errors.New("unknown type: "+typeName)
}
}
{{- /* 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 EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
{{- range .Resolvers }}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
{{- range $_, $keyField := .KeyFields }}
m = rep
{{- range $i, $field := .Field }}
val, ok = m["{{.}}"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"{{.}}\" for {{$entity.Name}}", ErrTypeNotFound))
break
}
{{- if (ne $i $keyField.Field.LastIndex ) }}
if m, ok = val.(map[string]any); !ok {
// nested field value is not a map[string]interface so don't use it
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to nested Key Field \"{{.}}\" value not matching map[string]any for {{$entity.Name}}", ErrTypeNotFound))
break
}
{{- else}}
if allNull {
allNull = val == nil
}
{{- end}}
{{- end}}
{{- end }}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for {{$entity.Name}}", ErrTypeNotFound))
break
}
return "{{.ResolverName}}", nil
}
{{- end }}
return "", fmt.Errorf("%w for {{$entity.Name}} due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
{{- end }}
{{- end }}
{{end}}
================================================
FILE: plugin/federation/federation_computedrequires_test.go
================================================
//go:generate go run ../../testdata/gqlgen.go -config testdata/computedrequires/gqlgen.yml
package federation
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/99designs/gqlgen/client"
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/handler/transport"
"github.com/99designs/gqlgen/plugin/federation/testdata/computedrequires"
"github.com/99designs/gqlgen/plugin/federation/testdata/computedrequires/generated"
)
func TestComputedRequires(t *testing.T) {
srv := handler.New(
generated.NewExecutableSchema(generated.Config{
Resolvers: &computedrequires.Resolver{},
}),
)
srv.AddTransport(transport.POST{})
c := client.New(srv)
t.Run("PlanetRequires entities with requires directive", func(t *testing.T) {
representations := []map[string]any{
{
"__typename": "PlanetRequires",
"name": "earth",
"diameter": 12,
}, {
"__typename": "PlanetRequires",
"name": "mars",
"diameter": 10,
},
}
var resp struct {
Entities []struct {
Name string `json:"name"`
Size int `json:"size"`
} `json:"_entities"`
}
err := c.Post(
entityQuery([]string{
"PlanetRequires {name size}",
}),
&resp,
client.Var("representations", representations),
)
require.NoError(t, err)
require.Equal(t, "earth", resp.Entities[0].Name)
require.Equal(t, 12, resp.Entities[0].Size)
require.Equal(t, "mars", resp.Entities[1].Name)
require.Equal(t, 10, resp.Entities[1].Size)
})
t.Run("PlanetRequires entities with multiple required fields directive", func(t *testing.T) {
representations := []map[string]any{
{
"__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"`
Weight int `json:"weight"`
} `json:"_entities"`
}
err := c.Post(
entityQuery([]string{
"PlanetMultipleRequires {name weight}",
}),
&resp,
client.Var("representations", representations),
)
require.NoError(t, err)
require.Equal(t, "earth", resp.Entities[0].Name)
require.Equal(t, 812, resp.Entities[0].Weight)
require.Equal(t, "mars", resp.Entities[1].Name)
require.Equal(t, 860, resp.Entities[1].Weight)
})
t.Run(
"PlanetRequiresNested entities with requires directive having nested field",
func(t *testing.T) {
representations := []map[string]any{
{
"__typename": "PlanetRequiresNested",
"name": "earth",
"world": map[string]any{
"foo": "A",
},
}, {
"__typename": "PlanetRequiresNested",
"name": "mars",
"world": map[string]any{
"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, "earth", resp.Entities[0].Name)
require.Equal(t, "A", resp.Entities[0].World.Foo)
require.Equal(t, "mars", resp.Entities[1].Name)
require.Equal(t, "B", resp.Entities[1].World.Foo)
},
)
}
func TestMultiComputedRequires(t *testing.T) {
srv := handler.New(
generated.NewExecutableSchema(generated.Config{
Resolvers: &computedrequires.Resolver{},
}),
)
srv.AddTransport(transport.POST{})
c := client.New(srv)
t.Run("MultiHelloRequires entities with requires directive", func(t *testing.T) {
representations := []map[string]any{
{
"__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"`
Key2 string `json:"key2"`
} `json:"_entities"`
}
err := c.Post(
entityQuery([]string{
"MultiHelloRequires {name, key2}",
}),
&resp,
client.Var("representations", representations),
)
require.NoError(t, err)
require.Equal(t, "first name - 1", resp.Entities[0].Name)
require.Equal(t, "key1 - 1", resp.Entities[0].Key2)
require.Equal(t, "first name - 2", resp.Entities[1].Name)
require.Equal(t, "key1 - 2", resp.Entities[1].Key2)
})
t.Run("MultiHelloMultipleRequires entities with multiple required fields", func(t *testing.T) {
representations := []map[string]any{
{
"__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"`
Key3 string `json:"key3"`
} `json:"_entities"`
}
err := c.Post(
entityQuery([]string{
"MultiHelloMultipleRequires {name, key3}",
}),
&resp,
client.Var("representations", representations),
)
require.NoError(t, err)
require.Equal(t, "first name - 1", resp.Entities[0].Name)
require.Equal(t, "key1 - 1:key2 - 1", resp.Entities[0].Key3)
require.Equal(t, "first name - 2", resp.Entities[1].Name)
require.Equal(t, "key1 - 2:key2 - 2", resp.Entities[1].Key3)
})
t.Run(
"MultiPlanetRequiresNested entities with requires directive having nested field",
func(t *testing.T) {
representations := []map[string]any{
{
"__typename": "MultiPlanetRequiresNested",
"name": "earth",
"world": map[string]any{
"foo": "A",
},
}, {
"__typename": "MultiPlanetRequiresNested",
"name": "mars",
"world": map[string]any{
"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, "earth", resp.Entities[0].Name)
require.Equal(t, "A", resp.Entities[0].World.Foo)
require.Equal(t, "mars", resp.Entities[1].Name)
require.Equal(t, "B", resp.Entities[1].World.Foo)
},
)
}
================================================
FILE: plugin/federation/federation_entitydirectives_test.go
================================================
package federation
//go:generate go run ../../testdata/gqlgen.go -config testdata/entitydirectives/gqlgen.yml
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// TestEntityObjectDirectives validates that OBJECT-level directives
// are correctly identified and filtered on federated entities.
func TestEntityObjectDirectives(t *testing.T) {
t.Run("entities_identified_with_directives", func(t *testing.T) {
f, _ := load(t, "testdata/entitydirectives/gqlgen.yml")
// Verify entities are created with @key directives
require.Len(t, f.Entities, 3, "should have 3 entities with @key directives")
// Find entities
var personEntity *Entity
var productEntity *Entity
var basicEntity *Entity
for _, e := range f.Entities {
switch e.Name {
case "Person":
personEntity = e
case "Product":
productEntity = e
case "Basic":
basicEntity = e
}
}
require.NotNil(t, personEntity, "Person entity should exist")
require.NotNil(t, productEntity, "Product entity should exist")
require.NotNil(t, basicEntity, "Basic entity should exist")
// Verify NonFederationDirectives filters correctly at AST level
// Person has @key and @guard, should only return @guard
personNonFedDirectives := personEntity.NonFederationDirectives()
require.Len(t, personNonFedDirectives, 1, "Person should have 1 non-federation directive")
assert.Equal(t, "guard", personNonFedDirectives[0].Name)
// Product has @key, @auth, and @guard, should return @auth and @guard
productNonFedDirectives := productEntity.NonFederationDirectives()
require.Len(
t,
productNonFedDirectives,
2,
"Product should have 2 non-federation directives",
)
directiveNames := []string{productNonFedDirectives[0].Name, productNonFedDirectives[1].Name}
assert.Contains(t, directiveNames, "guard")
assert.Contains(t, directiveNames, "auth")
// Basic has only @key, should have no non-federation directives
basicNonFedDirectives := basicEntity.NonFederationDirectives()
assert.Nil(t, basicNonFedDirectives, "Basic should have no non-federation directives")
})
t.Run("federation_directives_excluded", func(t *testing.T) {
// Verify that federation directives are correctly filtered
testCases := []string{
"key", "requires", "provides", "external", "extends",
"tag", "inaccessible", "shareable", "interfaceObject",
"override", "composeDirective", "link",
"authenticated", "requiresScopes", "policy",
"entityResolver", "goModel", "goField", "goTag",
}
for _, name := range testCases {
assert.True(t, federationDirectiveNames[name],
"federation directive %q should be in exclusion list", name)
}
})
t.Run("non_federation_directives_preserved", func(t *testing.T) {
f, cfg := load(t, "testdata/entitydirectives/gqlgen.yml")
require.NoError(t, f.MutateConfig(cfg))
// Find Person entity and check AST-level directives
var personEntity *Entity
for _, e := range f.Entities {
if e.Name == "Person" {
personEntity = e
break
}
}
require.NotNil(t, personEntity)
// NonFederationDirectives should return only @guard (not @key)
nonFedDirectives := personEntity.NonFederationDirectives()
require.Len(t, nonFedDirectives, 1)
assert.Equal(t, "guard", nonFedDirectives[0].Name)
// Verify @key is filtered out
allDirectives := personEntity.Def.Directives
hasKey := false
for _, d := range allDirectives {
if d.Name == "key" {
hasKey = true
break
}
}
assert.True(t, hasKey, "Person should have @key in full directive list")
})
}
================================================
FILE: plugin/federation/federation_entityresolver_test.go
================================================
//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/99designs/gqlgen/client"
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/handler/transport"
"github.com/99designs/gqlgen/plugin/federation/testdata/entityresolver"
"github.com/99designs/gqlgen/plugin/federation/testdata/entityresolver/generated"
)
func TestEntityResolver(t *testing.T) {
srv := handler.New(
generated.NewExecutableSchema(generated.Config{
Resolvers: &entityresolver.Resolver{},
}),
)
srv.AddTransport(transport.POST{})
c := client.New(srv)
t.Run("Hello entities", func(t *testing.T) {
representations := []map[string]any{
{
"__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, "first name - 1", resp.Entities[0].Name)
require.Equal(t, "first name - 2", resp.Entities[1].Name)
})
t.Run("HelloWithError entities", func(t *testing.T) {
representations := []map[string]any{
{
"__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, "first name - 1", resp.Entities[0].Name)
require.Equal(t, "first name - 2", resp.Entities[1].Name)
require.Empty(t, resp.Entities[2].Name)
require.Equal(t, "first name - 3", resp.Entities[3].Name)
require.Empty(t, resp.Entities[4].Name)
})
t.Run("World entities with nested key", func(t *testing.T) {
representations := []map[string]any{
{
"__typename": "World",
"hello": map[string]any{
"name": "world name - 1",
},
"foo": "foo 1",
}, {
"__typename": "World",
"hello": map[string]any{
"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, "foo 1", resp.Entities[0].Foo)
require.Equal(t, "world name - 1", resp.Entities[0].Hello.Name)
require.Equal(t, "foo 2", resp.Entities[1].Foo)
require.Equal(t, "world name - 2", resp.Entities[1].Hello.Name)
})
t.Run("World entities with multiple keys", func(t *testing.T) {
representations := []map[string]any{
{
"__typename": "WorldWithMultipleKeys",
"hello": map[string]any{
"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"`
}
eq := entityQuery([]string{
"WorldWithMultipleKeys {foo hello {name}}",
"WorldWithMultipleKeys {bar}",
})
err := c.Post(
eq,
&resp,
client.Var("representations", representations),
)
require.NoError(t, err)
require.Equal(t, "foo 1", resp.Entities[0].Foo)
require.Equal(t, "world name - 1", resp.Entities[0].Hello.Name)
require.Equal(t, 11, resp.Entities[1].Bar)
})
t.Run(
"World entities with one single-key nil should hit resolver without nils",
func(t *testing.T) {
representations := []map[string]any{
{
"__typename": "WorldWithMultipleKeys",
"hello": map[string]any{
"name": "world name - 1",
},
"foo": "foo 1",
"bar": nil,
},
}
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} bar}",
}),
&resp,
client.Var("representations", representations),
)
require.NoError(t, err)
require.Len(t, resp.Entities, 1)
require.Equal(t, "foo 1", resp.Entities[0].Foo)
require.Equal(t, "world name - 1", resp.Entities[0].Hello.Name)
require.Equal(
t,
entityresolver.FindWorldWithMultipleKeysByHelloNameAndFooBarValue,
resp.Entities[0].Bar,
)
},
)
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]any{}
count := 10
for i := range count {
if i%2 == 0 {
representations = append(representations, map[string]any{
"__typename": "Hello",
"name": "hello - " + strconv.Itoa(i),
})
} else {
representations = append(representations, map[string]any{
"__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 := range count {
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]any{
{
"__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, "earth", resp.Entities[0].Name)
require.Equal(t, 12, resp.Entities[0].Diameter)
require.Equal(t, "mars", resp.Entities[1].Name)
require.Equal(t, 10, resp.Entities[1].Diameter)
})
t.Run("PlanetRequires entities with multiple required fields directive", func(t *testing.T) {
representations := []map[string]any{
{
"__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, "earth", resp.Entities[0].Name)
require.Equal(t, 12, resp.Entities[0].Diameter)
require.Equal(t, 800, resp.Entities[0].Density)
require.Equal(t, "mars", resp.Entities[1].Name)
require.Equal(t, 10, resp.Entities[1].Diameter)
require.Equal(t, 850, resp.Entities[1].Density)
})
t.Run(
"PlanetRequiresNested entities with requires directive having nested field",
func(t *testing.T) {
representations := []map[string]any{
{
"__typename": "PlanetRequiresNested",
"name": "earth",
"world": map[string]any{
"foo": "A",
},
}, {
"__typename": "PlanetRequiresNested",
"name": "mars",
"world": map[string]any{
"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, "earth", resp.Entities[0].Name)
require.Equal(t, "A", resp.Entities[0].World.Foo)
require.Equal(t, "mars", resp.Entities[1].Name)
require.Equal(t, "B", resp.Entities[1].World.Foo)
},
)
}
func TestMultiEntityResolver(t *testing.T) {
srv := handler.New(
generated.NewExecutableSchema(generated.Config{
Resolvers: &entityresolver.Resolver{},
}),
)
srv.AddTransport(transport.POST{})
c := client.New(srv)
t.Run("MultiHello entities", func(t *testing.T) {
itemCount := 10
representations := []map[string]any{}
for i := range itemCount {
representations = append(representations, map[string]any{
"__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 := range itemCount {
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]any{}
for i := range itemCount {
// Let's interleve the representations to test ordering of the
// responses from the entity query
if i%2 == 0 {
representations = append(representations, map[string]any{
"__typename": "MultiHello",
"name": "world name - " + strconv.Itoa(i),
})
} else {
representations = append(representations, map[string]any{
"__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 := range itemCount {
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]any{}
for i := range itemCount {
representations = append(representations, map[string]any{
"__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]any{
{
"__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, "first name - 1", resp.Entities[0].Name)
require.Equal(t, "key1 - 1", resp.Entities[0].Key1)
require.Equal(t, "first name - 2", resp.Entities[1].Name)
require.Equal(t, "key1 - 2", resp.Entities[1].Key1)
})
t.Run("MultiHelloMultipleRequires entities with multiple required fields", func(t *testing.T) {
representations := []map[string]any{
{
"__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, "first name - 1", resp.Entities[0].Name)
require.Equal(t, "key1 - 1", resp.Entities[0].Key1)
require.Equal(t, "key2 - 1", resp.Entities[0].Key2)
require.Equal(t, "first name - 2", resp.Entities[1].Name)
require.Equal(t, "key1 - 2", resp.Entities[1].Key1)
require.Equal(t, "key2 - 2", resp.Entities[1].Key2)
})
t.Run(
"MultiPlanetRequiresNested entities with requires directive having nested field",
func(t *testing.T) {
representations := []map[string]any{
{
"__typename": "MultiPlanetRequiresNested",
"name": "earth",
"world": map[string]any{
"foo": "A",
},
}, {
"__typename": "MultiPlanetRequiresNested",
"name": "mars",
"world": map[string]any{
"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, "earth", resp.Entities[0].Name)
require.Equal(t, "A", resp.Entities[0].World.Foo)
require.Equal(t, "mars", resp.Entities[1].Name)
require.Equal(t, "B", resp.Entities[1].World.Foo)
},
)
}
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
}
================================================
FILE: plugin/federation/federation_explicitrequires_test.go
================================================
//go:generate go run ../../testdata/gqlgen.go -config testdata/explicitrequires/gqlgen.yml
package federation
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/99designs/gqlgen/client"
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/handler/transport"
"github.com/99designs/gqlgen/plugin/federation/testdata/explicitrequires"
"github.com/99designs/gqlgen/plugin/federation/testdata/explicitrequires/generated"
)
func TestExplicitRequires(t *testing.T) {
srv := handler.New(
generated.NewExecutableSchema(generated.Config{
Resolvers: &explicitrequires.Resolver{},
}),
)
srv.AddTransport(transport.POST{})
c := client.New(srv)
t.Run("PlanetRequires entities with requires directive", func(t *testing.T) {
representations := []map[string]any{
{
"__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, "earth", resp.Entities[0].Name)
require.Equal(t, 12, resp.Entities[0].Diameter)
require.Equal(t, "mars", resp.Entities[1].Name)
require.Equal(t, 10, resp.Entities[1].Diameter)
})
t.Run(
"PlanetMultipleRequires entities with multiple required fields directive",
func(t *testing.T) {
representations := []map[string]any{
{
"__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, "earth", resp.Entities[0].Name)
require.Equal(t, 12, resp.Entities[0].Diameter)
require.Equal(t, 800, resp.Entities[0].Density)
require.Equal(t, "mars", resp.Entities[1].Name)
require.Equal(t, 10, resp.Entities[1].Diameter)
require.Equal(t, 850, resp.Entities[1].Density)
},
)
t.Run(
"PlanetRequiresNested entities with requires directive having nested field",
func(t *testing.T) {
representations := []map[string]any{
{
"__typename": "PlanetRequiresNested",
"name": "earth",
"world": map[string]any{
"foo": "A",
},
}, {
"__typename": "PlanetRequiresNested",
"name": "mars",
"world": map[string]any{
"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, "earth", resp.Entities[0].Name)
require.Equal(t, "A", resp.Entities[0].World.Foo)
require.Equal(t, "mars", resp.Entities[1].Name)
require.Equal(t, "B", resp.Entities[1].World.Foo)
},
)
}
func TestMultiExplicitRequires(t *testing.T) {
srv := handler.New(
generated.NewExecutableSchema(generated.Config{
Resolvers: &explicitrequires.Resolver{},
}),
)
srv.AddTransport(transport.POST{})
c := client.New(srv)
t.Run("MultiHelloRequires entities with requires directive", func(t *testing.T) {
representations := []map[string]any{
{
"__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, "first name - 1", resp.Entities[0].Name)
require.Equal(t, "key1 - 1", resp.Entities[0].Key1)
require.Equal(t, "first name - 2", resp.Entities[1].Name)
require.Equal(t, "key1 - 2", resp.Entities[1].Key1)
})
t.Run("MultiHelloMultipleRequires entities with multiple required fields", func(t *testing.T) {
representations := []map[string]any{
{
"__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, "first name - 1", resp.Entities[0].Name)
require.Equal(t, "key1 - 1", resp.Entities[0].Key1)
require.Equal(t, "key2 - 1", resp.Entities[0].Key2)
require.Equal(t, "first name - 2", resp.Entities[1].Name)
require.Equal(t, "key1 - 2", resp.Entities[1].Key1)
require.Equal(t, "key2 - 2", resp.Entities[1].Key2)
})
t.Run(
"MultiPlanetRequiresNested entities with requires directive having nested field",
func(t *testing.T) {
representations := []map[string]any{
{
"__typename": "MultiPlanetRequiresNested",
"name": "earth",
"world": map[string]any{
"foo": "A",
},
}, {
"__typename": "MultiPlanetRequiresNested",
"name": "mars",
"world": map[string]any{
"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, "earth", resp.Entities[0].Name)
require.Equal(t, "A", resp.Entities[0].World.Foo)
require.Equal(t, "mars", resp.Entities[1].Name)
require.Equal(t, "B", resp.Entities[1].World.Foo)
},
)
}
================================================
FILE: plugin/federation/federation_test.go
================================================
package federation
//go:generate go run ../../testdata/gqlgen.go -config testdata/entityinterfaces/interface.yml
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/99designs/gqlgen/codegen"
"github.com/99designs/gqlgen/codegen/config"
"github.com/99designs/gqlgen/plugin/federation/fieldset"
)
func TestNew(t *testing.T) {
t.Parallel()
t.Run("success_no_options", func(t *testing.T) {
cfg := &config.Config{
Federation: config.PackageConfig{
Options: map[string]bool{},
},
}
plugin, err := New(1, cfg)
require.NoError(t, err)
assert.NotNil(t, plugin)
})
t.Run("success_computed", func(t *testing.T) {
cfg := &config.Config{
Federation: config.PackageConfig{
Version: 2,
Options: map[string]bool{
"computed_requires": true,
},
},
CallArgumentDirectivesWithNull: true,
}
plugin, err := New(1, cfg)
require.NoError(t, err)
assert.NotNil(t, plugin)
})
t.Run("error_computed_verion_1", func(t *testing.T) {
cfg := &config.Config{
Federation: config.PackageConfig{
Version: 1,
Options: map[string]bool{
"computed_requires": true,
},
},
CallArgumentDirectivesWithNull: true,
}
plugin, err := New(1, cfg)
require.Error(t, err)
assert.Nil(t, plugin)
})
t.Run("error_computed_CallArgumentDirectivesWithNull_is_false", func(t *testing.T) {
cfg := &config.Config{
Federation: config.PackageConfig{
Version: 2,
Options: map[string]bool{
"computed_requires": true,
},
},
CallArgumentDirectivesWithNull: false,
}
plugin, err := New(1, cfg)
require.Error(t, err)
assert.Nil(t, plugin)
})
t.Run("error_both_explicit_and_computed_set", func(t *testing.T) {
cfg := &config.Config{
Federation: config.PackageConfig{
Version: 2,
Options: map[string]bool{
"explicit_requires": true,
"computed_requires": true,
},
},
}
plugin, err := New(1, cfg)
require.Error(t, err)
assert.Nil(t, plugin)
})
}
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.Empty(t, f.Entities[2].Resolvers)
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, "id", f.Entities[5].Requires[0].Name)
require.Equal(t, "helloSecondary", f.Entities[5].Requires[1].Name)
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.Empty(t, f.Entities)
}
func TestUnusedInterfaceKeyDirective(t *testing.T) {
f, cfg := load(t, "testdata/interfaces/unused_key.yml")
err := f.MutateConfig(cfg)
require.NoError(t, err)
require.Empty(t, f.Entities)
}
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)
require.NoError(t, 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)
require.NoError(t, 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 TestHandlesRequiresArgumentCorrectlyIfNoSpace(t *testing.T) {
requiresFieldSet := fieldset.New("foo bar baz(limit:4)", nil)
assert.Len(t, requiresFieldSet, 3)
assert.Equal(t, "Foo", requiresFieldSet[0].ToGo())
assert.Equal(t, "Bar", requiresFieldSet[1].ToGo())
assert.Equal(t, "Baz(limit:4)", requiresFieldSet[2].ToGo())
}
func TestHandlesArgumentGeneration(t *testing.T) {
e := &Entity{
Name: "",
Def: nil,
Resolvers: nil,
Requires: nil,
}
raw := "foo bar baz(limit:4)"
requiresFieldSet := fieldset.New(raw, nil)
for _, field := range requiresFieldSet {
e.Requires = append(e.Requires, &Requires{
Name: field.ToGoPrivate(),
Field: field,
})
}
}
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}
s, err := f.InjectSourcesEarly()
require.NoError(t, err)
cfg.Sources = append(cfg.Sources, s...)
require.NoError(t, cfg.LoadSchema())
l, err := f.InjectSourcesLate(cfg.Schema)
require.NoError(t, err)
if l != nil {
cfg.Sources = append(cfg.Sources, l...)
}
require.NoError(t, cfg.LoadSchema())
require.NoError(t, cfg.Init())
return f, cfg
}
================================================
FILE: plugin/federation/federation_use_function_syntax_for_execution_context_test.go
================================================
//go:generate go run ../../testdata/gqlgen.go -config testdata/usefunctionsyntaxforexecutioncontext/gqlgen.yml
package federation
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/99designs/gqlgen/client"
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/handler/transport"
"github.com/99designs/gqlgen/plugin/federation/testdata/usefunctionsyntaxforexecutioncontext"
"github.com/99designs/gqlgen/plugin/federation/testdata/usefunctionsyntaxforexecutioncontext/generated"
)
func TestFederationWithUseFunctionSyntaxForExecutionContext(t *testing.T) {
srv := handler.New(
generated.NewExecutableSchema(generated.Config{
Resolvers: &usefunctionsyntaxforexecutioncontext.Resolver{},
}),
)
srv.AddTransport(transport.POST{})
c := client.New(srv)
t.Run("Hello entities", func(t *testing.T) {
representations := []map[string]any{
{
"__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, "first name - 1", resp.Entities[0].Name)
require.Equal(t, "first name - 2", resp.Entities[1].Name)
})
}
================================================
FILE: plugin/federation/fedruntime/directives.go
================================================
package fedruntime
import (
"context"
"fmt"
)
// ResolverFunc is a function that resolves a value in the context of federation entity resolution.
// It matches the signature used throughout the GraphQL execution pipeline.
type ResolverFunc func(context.Context) (any, error)
// DirectiveFunc wraps a resolver with directive middleware logic.
// It receives the context and the next resolver in the chain, and returns the result.
type DirectiveFunc func(context.Context, ResolverFunc) (any, error)
// ChainDirectives applies a chain of directives to a base resolver function.
// Directives are applied in reverse order, with each directive wrapping the next one.
func ChainDirectives(
ctx context.Context, base ResolverFunc, directives []DirectiveFunc,
) (any, error) {
if len(directives) == 0 {
return base(ctx)
}
// Build chain from the end to the beginning (outermost to innermost)
// The last directive in the slice wraps the base resolver
// Each previous directive wraps the result of the next directive
resolver := base
for i := len(directives) - 1; i >= 0; i-- {
directive := directives[i]
next := resolver
resolver = func(ctx context.Context) (any, error) {
return directive(ctx, next)
}
}
return resolver(ctx)
}
// WrapEntityResolver wraps an entity resolver with directive middleware.
// If no directives are provided, the resolver is called directly.
// Otherwise, directives are applied and the result is type-checked.
func WrapEntityResolver[T any](
ctx context.Context,
typedResolver func(context.Context) (T, error),
directives []DirectiveFunc,
) (T, error) {
var zero T
// Fast path: no directives, call resolver directly
if len(directives) == 0 {
return typedResolver(ctx)
}
// Slow path: wrap with directives
// Convert typed resolver to untyped for directive chain
base := func(ctx context.Context) (any, error) {
return typedResolver(ctx)
}
result, err := ChainDirectives(ctx, base, directives)
if err != nil {
return zero, err
}
// Type assert the result back to the expected type
typedResult, ok := result.(T)
if !ok {
return zero, fmt.Errorf(
"unexpected type %T from directive chain, expected %T",
result,
zero,
)
}
return typedResult, nil
}
================================================
FILE: plugin/federation/fedruntime/directives_test.go
================================================
package fedruntime
import (
"context"
"errors"
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestChainDirectives_NoDirectives(t *testing.T) {
ctx := context.Background()
base := func(ctx context.Context) (any, error) {
return "base result", nil
}
result, err := ChainDirectives(ctx, base, nil)
require.NoError(t, err)
assert.Equal(t, "base result", result)
}
func TestChainDirectives_SingleDirective(t *testing.T) {
ctx := context.Background()
base := func(ctx context.Context) (any, error) {
return "base", nil
}
directives := []DirectiveFunc{
func(ctx context.Context, next ResolverFunc) (any, error) {
result, err := next(ctx)
if err != nil {
return nil, err
}
return fmt.Sprintf("directive1(%v)", result), nil
},
}
result, err := ChainDirectives(ctx, base, directives)
require.NoError(t, err)
assert.Equal(t, "directive1(base)", result)
}
func TestChainDirectives_MultipleDirectives(t *testing.T) {
ctx := context.Background()
base := func(ctx context.Context) (any, error) {
return "base", nil
}
// Directives are applied in order: directive1 wraps directive2 wraps base
directives := []DirectiveFunc{
func(ctx context.Context, next ResolverFunc) (any, error) {
result, err := next(ctx)
if err != nil {
return nil, err
}
return fmt.Sprintf("d1(%v)", result), nil
},
func(ctx context.Context, next ResolverFunc) (any, error) {
result, err := next(ctx)
if err != nil {
return nil, err
}
return fmt.Sprintf("d2(%v)", result), nil
},
func(ctx context.Context, next ResolverFunc) (any, error) {
result, err := next(ctx)
if err != nil {
return nil, err
}
return fmt.Sprintf("d3(%v)", result), nil
},
}
result, err := ChainDirectives(ctx, base, directives)
require.NoError(t, err)
// Execution order: d1 -> d2 -> d3 -> base
// Result builds up: base -> d3(base) -> d2(d3(base)) -> d1(d2(d3(base)))
assert.Equal(t, "d1(d2(d3(base)))", result)
}
func TestChainDirectives_ErrorPropagation(t *testing.T) {
ctx := context.Background()
t.Run("error from base", func(t *testing.T) {
base := func(ctx context.Context) (any, error) {
return nil, errors.New("base error")
}
directives := []DirectiveFunc{
func(ctx context.Context, next ResolverFunc) (any, error) {
return next(ctx)
},
}
result, err := ChainDirectives(ctx, base, directives)
require.Error(t, err)
assert.Nil(t, result)
assert.Equal(t, "base error", err.Error())
})
t.Run("error from directive", func(t *testing.T) {
base := func(ctx context.Context) (any, error) {
return "base", nil
}
directives := []DirectiveFunc{
func(ctx context.Context, next ResolverFunc) (any, error) {
return next(ctx)
},
func(ctx context.Context, next ResolverFunc) (any, error) {
return nil, errors.New("directive error")
},
}
result, err := ChainDirectives(ctx, base, directives)
require.Error(t, err)
assert.Nil(t, result)
assert.Equal(t, "directive error", err.Error())
})
}
func TestChainDirectives_ContextPropagation(t *testing.T) {
type contextKey string
key := contextKey("test-key")
ctx := context.WithValue(context.Background(), key, "test-value")
base := func(ctx context.Context) (any, error) {
val := ctx.Value(key)
return val, nil
}
directives := []DirectiveFunc{
func(ctx context.Context, next ResolverFunc) (any, error) {
// Verify context is passed through
assert.Equal(t, "test-value", ctx.Value(key))
return next(ctx)
},
}
result, err := ChainDirectives(ctx, base, directives)
require.NoError(t, err)
assert.Equal(t, "test-value", result)
}
func TestChainDirectives_DirectiveModifiesContext(t *testing.T) {
type contextKey string
key := contextKey("counter")
ctx := context.WithValue(context.Background(), key, 0)
base := func(ctx context.Context) (any, error) {
val := ctx.Value(key)
return val, nil
}
directives := []DirectiveFunc{
func(ctx context.Context, next ResolverFunc) (any, error) {
// Directive 1 increments counter
currentVal := ctx.Value(key).(int)
ctx = context.WithValue(ctx, key, currentVal+1)
return next(ctx)
},
func(ctx context.Context, next ResolverFunc) (any, error) {
// Directive 2 increments counter
currentVal := ctx.Value(key).(int)
ctx = context.WithValue(ctx, key, currentVal+1)
return next(ctx)
},
}
result, err := ChainDirectives(ctx, base, directives)
require.NoError(t, err)
// Both directives increment, so base should see 2
assert.Equal(t, 2, result)
}
func TestChainDirectives_RealWorldAuthExample(t *testing.T) {
type contextKey string
userKey := contextKey("user")
t.Run("authenticated request", func(t *testing.T) {
ctx := context.WithValue(context.Background(), userKey, "alice")
base := func(ctx context.Context) (any, error) {
return map[string]string{"user": "alice", "email": "alice@example.com"}, nil
}
// Simulate @auth directive
authDirective := func(ctx context.Context, next ResolverFunc) (any, error) {
user := ctx.Value(userKey)
if user == nil {
return nil, errors.New("unauthorized")
}
return next(ctx)
}
// Simulate @log directive
logDirective := func(ctx context.Context, next ResolverFunc) (any, error) {
t.Logf("@log: before resolver")
result, err := next(ctx)
t.Logf("@log: after resolver, result=%v, err=%v", result, err)
return result, err
}
directives := []DirectiveFunc{authDirective, logDirective}
result, err := ChainDirectives(ctx, base, directives)
require.NoError(t, err)
assert.NotNil(t, result)
})
t.Run("unauthenticated request blocked", func(t *testing.T) {
ctx := context.Background() // No user in context
base := func(ctx context.Context) (any, error) {
t.Fatal("base should not be called")
return nil, nil
}
authDirective := func(ctx context.Context, next ResolverFunc) (any, error) {
user := ctx.Value(userKey)
if user == nil {
return nil, errors.New("unauthorized")
}
return next(ctx)
}
directives := []DirectiveFunc{authDirective}
result, err := ChainDirectives(ctx, base, directives)
require.Error(t, err)
assert.Nil(t, result)
assert.Equal(t, "unauthorized", err.Error())
})
}
func TestWrapEntityResolver_NoDirectives(t *testing.T) {
ctx := context.Background()
resolver := func(ctx context.Context) (string, error) {
return "result", nil
}
result, err := WrapEntityResolver(ctx, resolver, nil)
require.NoError(t, err)
assert.Equal(t, "result", result)
}
func TestWrapEntityResolver_WithDirectives(t *testing.T) {
ctx := context.Background()
resolver := func(ctx context.Context) (string, error) {
return "base", nil
}
directive := func(ctx context.Context, next ResolverFunc) (any, error) {
result, err := next(ctx)
if err != nil {
return nil, err
}
return result.(string) + " + wrapped", nil
}
result, err := WrapEntityResolver(ctx, resolver, []DirectiveFunc{directive})
require.NoError(t, err)
assert.Equal(t, "base + wrapped", result)
}
func TestWrapEntityResolver_TypeAssertion(t *testing.T) {
ctx := context.Background()
t.Run("correct type returned", func(t *testing.T) {
type User struct {
ID string
Name string
}
resolver := func(ctx context.Context) (*User, error) {
return &User{ID: "1", Name: "Alice"}, nil
}
directive := func(ctx context.Context, next ResolverFunc) (any, error) {
result, err := next(ctx)
if err != nil {
return nil, err
}
user := result.(*User)
user.Name += " (modified)"
return user, nil
}
result, err := WrapEntityResolver(ctx, resolver, []DirectiveFunc{directive})
require.NoError(t, err)
assert.Equal(t, "Alice (modified)", result.Name)
})
t.Run("wrong type from directive", func(t *testing.T) {
resolver := func(ctx context.Context) (string, error) {
return "correct type", nil
}
// Directive returns wrong type
directive := func(ctx context.Context, next ResolverFunc) (any, error) {
_, err := next(ctx)
if err != nil {
return nil, err
}
return 123, nil // wrong type - should be string
}
_, err := WrapEntityResolver(ctx, resolver, []DirectiveFunc{directive})
require.Error(t, err)
assert.Contains(t, err.Error(), "unexpected type")
})
}
func TestWrapEntityResolver_ErrorPropagation(t *testing.T) {
ctx := context.Background()
t.Run("resolver error", func(t *testing.T) {
expectedErr := errors.New("resolver error")
resolver := func(ctx context.Context) (string, error) {
return "", expectedErr
}
result, err := WrapEntityResolver(ctx, resolver, nil)
require.Error(t, err)
assert.Equal(t, expectedErr, err)
assert.Empty(t, result)
})
t.Run("directive error", func(t *testing.T) {
resolver := func(ctx context.Context) (string, error) {
return "result", nil
}
expectedErr := errors.New("directive error")
directive := func(ctx context.Context, next ResolverFunc) (any, error) {
return nil, expectedErr
}
result, err := WrapEntityResolver(ctx, resolver, []DirectiveFunc{directive})
require.Error(t, err)
assert.Equal(t, expectedErr, err)
assert.Empty(t, result)
})
}
func TestWrapEntityResolver_ComplexTypes(t *testing.T) {
type EmailHost struct {
ID string
Domain string
}
t.Run("pointer to struct", func(t *testing.T) {
ctx := context.Background()
resolver := func(ctx context.Context) (*EmailHost, error) {
return &EmailHost{ID: "1", Domain: "example.com"}, nil
}
result, err := WrapEntityResolver(ctx, resolver, nil)
require.NoError(t, err)
assert.Equal(t, "1", result.ID)
assert.Equal(t, "example.com", result.Domain)
})
t.Run("interface type", func(t *testing.T) {
ctx := context.Background()
resolver := func(ctx context.Context) (any, error) {
return map[string]string{"key": "value"}, nil
}
result, err := WrapEntityResolver(ctx, resolver, nil)
require.NoError(t, err)
assert.Equal(t, map[string]string{"key": "value"}, result)
})
t.Run("slice type", func(t *testing.T) {
ctx := context.Background()
resolver := func(ctx context.Context) ([]string, error) {
return []string{"a", "b", "c"}, nil
}
result, err := WrapEntityResolver(ctx, resolver, nil)
require.NoError(t, err)
assert.Equal(t, []string{"a", "b", "c"}, result)
})
}
func TestValidateEntityKeys_SingleResolver(t *testing.T) {
t.Run("valid single key field", func(t *testing.T) {
rep := map[string]any{"id": "123"}
checks := []ResolverKeyCheck{
{
ResolverName: "findUserByID",
KeyFields: []KeyFieldCheck{
{FieldPath: []string{"id"}},
},
},
}
resolverName, err := ValidateEntityKeys("User", rep, checks)
require.NoError(t, err)
assert.Equal(t, "findUserByID", resolverName)
})
t.Run("missing key field", func(t *testing.T) {
rep := map[string]any{"name": "Alice"}
checks := []ResolverKeyCheck{
{
ResolverName: "findUserByID",
KeyFields: []KeyFieldCheck{
{FieldPath: []string{"id"}},
},
},
}
_, err := ValidateEntityKeys("User", rep, checks)
require.Error(t, err)
assert.Contains(t, err.Error(), "missing Key Field")
})
t.Run("null key field", func(t *testing.T) {
rep := map[string]any{"id": nil}
checks := []ResolverKeyCheck{
{
ResolverName: "findUserByID",
KeyFields: []KeyFieldCheck{
{FieldPath: []string{"id"}},
},
},
}
_, err := ValidateEntityKeys("User", rep, checks)
require.Error(t, err)
assert.Contains(t, err.Error(), "all null value KeyFields")
})
}
func TestValidateEntityKeys_MultipleResolvers(t *testing.T) {
t.Run("first resolver matches", func(t *testing.T) {
rep := map[string]any{"id": "123"}
checks := []ResolverKeyCheck{
{
ResolverName: "findUserByID",
KeyFields: []KeyFieldCheck{
{FieldPath: []string{"id"}},
},
},
{
ResolverName: "findUserByEmail",
KeyFields: []KeyFieldCheck{
{FieldPath: []string{"email"}},
},
},
}
resolverName, err := ValidateEntityKeys("User", rep, checks)
require.NoError(t, err)
assert.Equal(t, "findUserByID", resolverName)
})
t.Run("second resolver matches", func(t *testing.T) {
rep := map[string]any{"email": "alice@example.com"}
checks := []ResolverKeyCheck{
{
ResolverName: "findUserByID",
KeyFields: []KeyFieldCheck{
{FieldPath: []string{"id"}},
},
},
{
ResolverName: "findUserByEmail",
KeyFields: []KeyFieldCheck{
{FieldPath: []string{"email"}},
},
},
}
resolverName, err := ValidateEntityKeys("User", rep, checks)
require.NoError(t, err)
assert.Equal(t, "findUserByEmail", resolverName)
})
t.Run("no resolver matches", func(t *testing.T) {
rep := map[string]any{"name": "Alice"}
checks := []ResolverKeyCheck{
{
ResolverName: "findUserByID",
KeyFields: []KeyFieldCheck{
{FieldPath: []string{"id"}},
},
},
{
ResolverName: "findUserByEmail",
KeyFields: []KeyFieldCheck{
{FieldPath: []string{"email"}},
},
},
}
_, err := ValidateEntityKeys("User", rep, checks)
require.Error(t, err)
assert.Contains(t, err.Error(), "type not found")
})
}
func TestValidateEntityKeys_NestedFields(t *testing.T) {
t.Run("valid nested field", func(t *testing.T) {
rep := map[string]any{
"user": map[string]any{
"id": "123",
},
}
checks := []ResolverKeyCheck{
{
ResolverName: "findByUserID",
KeyFields: []KeyFieldCheck{
{FieldPath: []string{"user", "id"}},
},
},
}
resolverName, err := ValidateEntityKeys("Review", rep, checks)
require.NoError(t, err)
assert.Equal(t, "findByUserID", resolverName)
})
t.Run("missing nested field", func(t *testing.T) {
rep := map[string]any{
"user": map[string]any{
"name": "Alice",
},
}
checks := []ResolverKeyCheck{
{
ResolverName: "findByUserID",
KeyFields: []KeyFieldCheck{
{FieldPath: []string{"user", "id"}},
},
},
}
_, err := ValidateEntityKeys("Review", rep, checks)
require.Error(t, err)
assert.Contains(t, err.Error(), "missing Key Field")
})
t.Run("intermediate field not a map", func(t *testing.T) {
rep := map[string]any{
"user": "not-a-map",
}
checks := []ResolverKeyCheck{
{
ResolverName: "findByUserID",
KeyFields: []KeyFieldCheck{
{FieldPath: []string{"user", "id"}},
},
},
}
_, err := ValidateEntityKeys("Review", rep, checks)
require.Error(t, err)
assert.Contains(t, err.Error(), "not matching map[string]any")
})
}
func TestValidateEntityKeys_MultipleKeyFields(t *testing.T) {
t.Run("all key fields present", func(t *testing.T) {
rep := map[string]any{
"manufacturerID": "mfg-123",
"productID": "prod-456",
}
checks := []ResolverKeyCheck{
{
ResolverName: "findProductByManufacturerAndProduct",
KeyFields: []KeyFieldCheck{
{FieldPath: []string{"manufacturerID"}},
{FieldPath: []string{"productID"}},
},
},
}
resolverName, err := ValidateEntityKeys("Product", rep, checks)
require.NoError(t, err)
assert.Equal(t, "findProductByManufacturerAndProduct", resolverName)
})
t.Run("one key field missing", func(t *testing.T) {
rep := map[string]any{
"manufacturerID": "mfg-123",
}
checks := []ResolverKeyCheck{
{
ResolverName: "findProductByManufacturerAndProduct",
KeyFields: []KeyFieldCheck{
{FieldPath: []string{"manufacturerID"}},
{FieldPath: []string{"productID"}},
},
},
}
_, err := ValidateEntityKeys("Product", rep, checks)
require.Error(t, err)
assert.Contains(t, err.Error(), "missing Key Field")
})
t.Run("all key fields null", func(t *testing.T) {
rep := map[string]any{
"manufacturerID": nil,
"productID": nil,
}
checks := []ResolverKeyCheck{
{
ResolverName: "findProductByManufacturerAndProduct",
KeyFields: []KeyFieldCheck{
{FieldPath: []string{"manufacturerID"}},
{FieldPath: []string{"productID"}},
},
},
}
_, err := ValidateEntityKeys("Product", rep, checks)
require.Error(t, err)
assert.Contains(t, err.Error(), "all null value KeyFields")
})
t.Run("some key fields null but not all", func(t *testing.T) {
rep := map[string]any{
"manufacturerID": "mfg-123",
"productID": nil,
}
checks := []ResolverKeyCheck{
{
ResolverName: "findProductByManufacturerAndProduct",
KeyFields: []KeyFieldCheck{
{FieldPath: []string{"manufacturerID"}},
{FieldPath: []string{"productID"}},
},
},
}
resolverName, err := ValidateEntityKeys("Product", rep, checks)
require.NoError(t, err)
assert.Equal(t, "findProductByManufacturerAndProduct", resolverName)
})
}
================================================
FILE: plugin/federation/fedruntime/runtime.go
================================================
package fedruntime
import (
"errors"
"fmt"
)
// 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 any
var (
// ErrUnknownType is returned when an unknown entity type is encountered
ErrUnknownType = errors.New("unknown type")
// ErrTypeNotFound is returned when an entity type cannot be resolved
ErrTypeNotFound = errors.New("type not found")
)
// KeyFieldCheck represents a key field validation check.
type KeyFieldCheck struct {
// FieldPath is the path to the field (e.g., ["id"] or ["user", "id"] for nested fields)
FieldPath []string
}
// ResolverKeyCheck represents the key requirements for a resolver.
type ResolverKeyCheck struct {
// ResolverName is the name of the resolver function
ResolverName string
// KeyFields are the required key fields for this resolver
KeyFields []KeyFieldCheck
}
// ValidateEntityKeys determines which resolver to use for an entity representation.
// It checks that all required key fields exist and are not all null.
// Returns the resolver name if valid, or an error if no resolver matches.
func ValidateEntityKeys(
entityName string,
rep map[string]any,
resolverChecks []ResolverKeyCheck,
) (string, error) {
var allErrors []error
for _, resolverCheck := range resolverChecks {
if err := validateResolverKeys(entityName, rep, resolverCheck); err != nil {
allErrors = append(allErrors, err)
continue
}
// Found a valid resolver
return resolverCheck.ResolverName, nil
}
// No valid resolver found
if len(allErrors) > 0 {
return "", fmt.Errorf("%w for %s due to %v",
ErrTypeNotFound, entityName, errors.Join(allErrors...))
}
return "", fmt.Errorf("%w for %s: no resolvers defined", ErrTypeNotFound, entityName)
}
// validateResolverKeys checks if a resolver's key fields are valid.
func validateResolverKeys(entityName string, rep map[string]any, check ResolverKeyCheck) error {
allNull := true
for _, keyField := range check.KeyFields {
val, err := getNestedField(rep, keyField.FieldPath)
if err != nil {
return fmt.Errorf("%w: %v", ErrTypeNotFound, err)
}
if val != nil {
allNull = false
}
}
if allNull {
return fmt.Errorf("%w due to all null value KeyFields for %s",
ErrTypeNotFound, entityName)
}
return nil
}
// getNestedField retrieves a value from a nested map by following a field path.
func getNestedField(rep map[string]any, path []string) (any, error) {
if len(path) == 0 {
return nil, errors.New("empty field path")
}
current := rep
for i, fieldName := range path {
val, ok := current[fieldName]
if !ok {
return nil, fmt.Errorf("missing Key Field %q", fieldName)
}
// If this is not the last field in the path, it should be a map
if i < len(path)-1 {
nextMap, ok := val.(map[string]any)
if !ok {
return nil, fmt.Errorf(
"nested Key Field %q value not matching map[string]any",
fieldName,
)
}
current = nextMap
} else {
// Last field - return its value
return val, nil
}
}
return nil, errors.New("unexpected: empty path processed")
}
================================================
FILE: plugin/federation/fieldset/fieldset.go
================================================
package fieldset
import (
"fmt"
"strings"
"github.com/vektah/gqlparser/v2/ast"
"github.com/99designs/gqlgen/codegen"
"github.com/99designs/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
var retSb91 strings.Builder
for _, field := range f {
retSb91.WriteString(templates.ToGo(field))
}
ret += retSb91.String()
return ret
}
// ToGoPrivate converts a (possibly nested) field into a proper private Go name.
func (f Field) ToGoPrivate() string {
var ret string
var retSb101 strings.Builder
for i, field := range f {
if i == 0 {
field = trimArgumentFromFieldName(field)
retSb101.WriteString(templates.ToGoPrivate(field))
continue
}
retSb101.WriteString(templates.ToGo(field))
}
ret += retSb101.String()
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{}
unionField := false
for s := range strings.FieldsSeq(raw) {
if s == "..." {
continue
}
if s == "on" {
unionField = true
continue
}
if unionField {
s = "... on " + s
unionField = false
}
next := prefix[0:len(prefix):len(prefix)]
next = append(next, s)
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 trimArgumentFromFieldName(
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 {
field.Name = trimArgumentFromFieldName(field.Name)
if field.Name == name {
return field
}
}
return nil
}
// trimArgumentFromFieldName removes any arguments from the field name.
// It removes any suffixes from the raw string, starting from the argument-open character `(`
func trimArgumentFromFieldName(raw string) string {
return strings.Split(raw, "(")[0]
}
================================================
FILE: plugin/federation/fieldset/fieldset_test.go
================================================
package fieldset
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/vektah/gqlparser/v2/ast"
"github.com/99designs/gqlgen/codegen"
)
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
}
```
**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`
================================================
FILE: plugin/federation/requires.gotpl
================================================
{{ range .ExistingImports }}
{{ if ne .Alias "" }}
{{ reserveImport .ImportPath .Alias }}
{{ else }}
{{ reserveImport .ImportPath }}
{{ end }}
{{ end }}
{{ range .Populators -}}
{{ if .Comment -}}
// {{.Comment}}
{{- else -}}
// {{.FuncName}} is the requires populator for the {{.Entity.Def.Name}} entity.
{{- end }}
func (ec *executionContext) {{.FuncName}}(ctx context.Context, entity *{{.Entity.GetTypeInfo}}, reps map[string]any) error {
{{.Implementation}}
}
{{ end }}
{{ .OriginalSource }}
================================================
FILE: plugin/federation/test_data/model/federation.go
================================================
package model
type _FieldSet string //nolint: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() {}
================================================
FILE: plugin/federation/test_data/model2/federation.go
================================================
package model2
type FieldSet string
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() {}
================================================
FILE: plugin/federation/testdata/allthethings/generated/federation.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package generated
import (
"context"
"errors"
"fmt"
"strings"
"sync"
"github.com/99designs/gqlgen/plugin/federation/fedruntime"
"github.com/99designs/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]any) []fedruntime.Entity {
list := make([]fedruntime.Entity, len(representations))
repsMap := ec.buildRepresentationGroups(ctx, representations)
switch len(repsMap) {
case 0:
return list
case 1:
for typeName, reps := range repsMap {
ec.resolveEntityGroup(ctx, typeName, reps, list)
}
return list
default:
var g sync.WaitGroup
g.Add(len(repsMap))
for typeName, reps := range repsMap {
go func(typeName string, reps []EntityWithIndex) {
ec.resolveEntityGroup(ctx, typeName, reps, list)
g.Done()
}(typeName, reps)
}
g.Wait()
return list
}
}
type EntityWithIndex struct {
// The index in the original representation array
index int
entity EntityRepresentation
}
// EntityRepresentation is the JSON representation of an entity sent by the Router
// used as the inputs for us to resolve.
//
// We make it a map because we know the top level JSON is always an object.
type EntityRepresentation map[string]any
// We group entities by typename so that we can parallelize their resolution.
// This is particularly helpful when there are entity groups in multi mode.
func (ec *executionContext) buildRepresentationGroups(
ctx context.Context,
representations []map[string]any,
) map[string][]EntityWithIndex {
repsMap := make(map[string][]EntityWithIndex)
for i, rep := range representations {
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
}
repsMap[typeName] = append(repsMap[typeName], EntityWithIndex{
index: i,
entity: rep,
})
}
return repsMap
}
func (ec *executionContext) resolveEntityGroup(
ctx context.Context,
typeName string,
reps []EntityWithIndex,
list []fedruntime.Entity,
) {
if isMulti(typeName) {
err := ec.resolveManyEntities(ctx, typeName, reps, list)
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 EntityWithIndex) {
entity, err := ec.resolveEntity(ctx, typeName, rep.entity)
if err != nil {
ec.Error(ctx, err)
} else {
list[rep.index] = entity
}
e.Done()
}(i, rep)
}
e.Wait()
}
}
func isMulti(typeName string) bool {
switch typeName {
case "MultiHelloMultiKey":
return true
default:
return false
}
}
func (ec *executionContext) resolveEntity(
ctx context.Context,
typeName string,
rep EntityRepresentation,
) (e fedruntime.Entity, 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 nil, fmt.Errorf(`finding resolver for Entity "ExternalExtension": %w`, err)
}
switch resolverName {
case "findExternalExtensionByUpc":
id0, err := ec.unmarshalNString2string(ctx, rep["upc"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findExternalExtensionByUpc(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindExternalExtensionByUpc(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "ExternalExtension": %w`, err)
}
return entity, nil
}
case "Hello":
resolverName, err := entityResolverNameForHello(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "Hello": %w`, err)
}
switch resolverName {
case "findHelloByName":
id0, err := ec.unmarshalNString2string(ctx, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findHelloByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindHelloByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "Hello": %w`, err)
}
return entity, nil
}
case "NestedKey":
resolverName, err := entityResolverNameForNestedKey(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "NestedKey": %w`, err)
}
switch resolverName {
case "findNestedKeyByIDAndHelloName":
id0, err := ec.unmarshalNString2string(ctx, rep["id"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findNestedKeyByIDAndHelloName(): %w`, err)
}
id1, err := ec.unmarshalNString2string(ctx, rep["hello"].(map[string]any)["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 1 for findNestedKeyByIDAndHelloName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindNestedKeyByIDAndHelloName(ctx, id0, id1)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "NestedKey": %w`, err)
}
return entity, nil
}
case "VeryNestedKey":
resolverName, err := entityResolverNameForVeryNestedKey(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "VeryNestedKey": %w`, err)
}
switch resolverName {
case "findVeryNestedKeyByIDAndHelloNameAndWorldFooAndWorldBarAndMoreWorldFoo":
id0, err := ec.unmarshalNString2string(ctx, rep["id"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findVeryNestedKeyByIDAndHelloNameAndWorldFooAndWorldBarAndMoreWorldFoo(): %w`, err)
}
id1, err := ec.unmarshalNString2string(ctx, rep["hello"].(map[string]any)["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 1 for findVeryNestedKeyByIDAndHelloNameAndWorldFooAndWorldBarAndMoreWorldFoo(): %w`, err)
}
id2, err := ec.unmarshalNString2string(ctx, rep["world"].(map[string]any)["foo"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 2 for findVeryNestedKeyByIDAndHelloNameAndWorldFooAndWorldBarAndMoreWorldFoo(): %w`, err)
}
id3, err := ec.unmarshalNInt2int(ctx, rep["world"].(map[string]any)["bar"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 3 for findVeryNestedKeyByIDAndHelloNameAndWorldFooAndWorldBarAndMoreWorldFoo(): %w`, err)
}
id4, err := ec.unmarshalNString2string(ctx, rep["more"].(map[string]any)["world"].(map[string]any)["foo"])
if err != nil {
return nil, 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 nil, fmt.Errorf(`resolving Entity "VeryNestedKey": %w`, err)
}
entity.ID, err = ec.unmarshalNString2string(ctx, rep["id"])
if err != nil {
return nil, err
}
entity.Hello.Secondary, err = ec.unmarshalNString2string(ctx, rep["hello"].(map[string]any)["secondary"])
if err != nil {
return nil, err
}
return entity, nil
}
case "World":
resolverName, err := entityResolverNameForWorld(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "World": %w`, err)
}
switch resolverName {
case "findWorldByFoo":
id0, err := ec.unmarshalNString2string(ctx, rep["foo"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findWorldByFoo(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindWorldByFoo(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "World": %w`, err)
}
return entity, nil
case "findWorldByBar":
id0, err := ec.unmarshalNInt2int(ctx, rep["bar"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findWorldByBar(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindWorldByBar(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "World": %w`, err)
}
return entity, nil
}
}
return nil, fmt.Errorf("%w: %s", ErrUnknownType, typeName)
}
func (ec *executionContext) resolveManyEntities(
ctx context.Context,
typeName string,
reps []EntityWithIndex,
list []fedruntime.Entity,
) (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].entity)
if err != nil {
return fmt.Errorf(`finding resolver for Entity "MultiHelloMultiKey": %w`, err)
}
switch resolverName {
case "findManyMultiHelloMultiKeyByNames":
typedReps := make([]*model.MultiHelloMultiKeyByNamesInput, len(reps))
for i, rep := range reps {
id0, err := ec.unmarshalNString2string(ctx, rep.entity["name"])
if err != nil {
return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name"))
}
typedReps[i] = &model.MultiHelloMultiKeyByNamesInput{
Name: id0,
}
}
entities, err := ec.Resolvers.Entity().FindManyMultiHelloMultiKeyByNames(ctx, typedReps)
if err != nil {
return err
}
for i, entity := range entities {
list[reps[i].index] = entity
}
return nil
case "findManyMultiHelloMultiKeyByKey2s":
typedReps := make([]*model.MultiHelloMultiKeyByKey2sInput, len(reps))
for i, rep := range reps {
id0, err := ec.unmarshalNString2string(ctx, rep.entity["key2"])
if err != nil {
return errors.New(fmt.Sprintf("Field %s undefined in schema.", "key2"))
}
typedReps[i] = &model.MultiHelloMultiKeyByKey2sInput{
Key2: id0,
}
}
entities, err := ec.Resolvers.Entity().FindManyMultiHelloMultiKeyByKey2s(ctx, typedReps)
if err != nil {
return err
}
for i, entity := range entities {
list[reps[i].index] = entity
}
return nil
default:
return fmt.Errorf("unknown resolver: %s", resolverName)
}
default:
return errors.New("unknown type: " + typeName)
}
}
func entityResolverNameForExternalExtension(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["upc"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"upc\" for ExternalExtension", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for ExternalExtension", ErrTypeNotFound))
break
}
return "findExternalExtensionByUpc", nil
}
return "", fmt.Errorf("%w for ExternalExtension due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForHello(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for Hello", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for Hello", ErrTypeNotFound))
break
}
return "findHelloByName", nil
}
return "", fmt.Errorf("%w for Hello due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForMultiHelloMultiKey(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for MultiHelloMultiKey", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for MultiHelloMultiKey", ErrTypeNotFound))
break
}
return "findManyMultiHelloMultiKeyByNames", nil
}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["key2"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"key2\" for MultiHelloMultiKey", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for MultiHelloMultiKey", ErrTypeNotFound))
break
}
return "findManyMultiHelloMultiKeyByKey2s", nil
}
return "", fmt.Errorf("%w for MultiHelloMultiKey due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForNestedKey(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["id"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"id\" for NestedKey", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
m = rep
val, ok = m["hello"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"hello\" for NestedKey", ErrTypeNotFound))
break
}
if m, ok = val.(map[string]any); !ok {
// nested field value is not a map[string]interface so don't use it
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to nested Key Field \"hello\" value not matching map[string]any for NestedKey", ErrTypeNotFound))
break
}
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for NestedKey", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for NestedKey", ErrTypeNotFound))
break
}
return "findNestedKeyByIDAndHelloName", nil
}
return "", fmt.Errorf("%w for NestedKey due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForVeryNestedKey(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["id"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"id\" for VeryNestedKey", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
m = rep
val, ok = m["hello"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"hello\" for VeryNestedKey", ErrTypeNotFound))
break
}
if m, ok = val.(map[string]any); !ok {
// nested field value is not a map[string]interface so don't use it
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to nested Key Field \"hello\" value not matching map[string]any for VeryNestedKey", ErrTypeNotFound))
break
}
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for VeryNestedKey", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
m = rep
val, ok = m["world"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"world\" for VeryNestedKey", ErrTypeNotFound))
break
}
if m, ok = val.(map[string]any); !ok {
// nested field value is not a map[string]interface so don't use it
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to nested Key Field \"world\" value not matching map[string]any for VeryNestedKey", ErrTypeNotFound))
break
}
val, ok = m["foo"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"foo\" for VeryNestedKey", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
m = rep
val, ok = m["world"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"world\" for VeryNestedKey", ErrTypeNotFound))
break
}
if m, ok = val.(map[string]any); !ok {
// nested field value is not a map[string]interface so don't use it
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to nested Key Field \"world\" value not matching map[string]any for VeryNestedKey", ErrTypeNotFound))
break
}
val, ok = m["bar"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"bar\" for VeryNestedKey", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
m = rep
val, ok = m["more"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"more\" for VeryNestedKey", ErrTypeNotFound))
break
}
if m, ok = val.(map[string]any); !ok {
// nested field value is not a map[string]interface so don't use it
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to nested Key Field \"more\" value not matching map[string]any for VeryNestedKey", ErrTypeNotFound))
break
}
val, ok = m["world"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"world\" for VeryNestedKey", ErrTypeNotFound))
break
}
if m, ok = val.(map[string]any); !ok {
// nested field value is not a map[string]interface so don't use it
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to nested Key Field \"world\" value not matching map[string]any for VeryNestedKey", ErrTypeNotFound))
break
}
val, ok = m["foo"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"foo\" for VeryNestedKey", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for VeryNestedKey", ErrTypeNotFound))
break
}
return "findVeryNestedKeyByIDAndHelloNameAndWorldFooAndWorldBarAndMoreWorldFoo", nil
}
return "", fmt.Errorf("%w for VeryNestedKey due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForWorld(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["foo"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"foo\" for World", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for World", ErrTypeNotFound))
break
}
return "findWorldByFoo", nil
}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["bar"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"bar\" for World", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for World", ErrTypeNotFound))
break
}
return "findWorldByBar", nil
}
return "", fmt.Errorf("%w for World due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
================================================
FILE: plugin/federation/testdata/allthethings/gqlgen.yml
================================================
schema:
- "testdata/allthethings/schema.graphql"
exec:
filename: testdata/allthethings/generated/exec.go
federation:
filename: testdata/allthethings/generated/federation.go
autobind:
- "github.com/99designs/gqlgen/plugin/federation/testdata/allthethings/model"
================================================
FILE: plugin/federation/testdata/allthethings/model/federation.go
================================================
package model
type _FieldSet string //nolint: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"`
}
================================================
FILE: plugin/federation/testdata/allthethings/schema.graphql
================================================
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!
}
================================================
FILE: plugin/federation/testdata/computedrequires/entity.resolvers.go
================================================
package computedrequires
// 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/99designs/gqlgen version v0.17.88-dev
import (
"context"
"fmt"
computedrequires "github.com/99designs/gqlgen/plugin/federation/testdata/computedrequires/generated"
model "github.com/99designs/gqlgen/plugin/federation/testdata/computedrequires/generated/models"
)
// 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, ErrResolvingHelloWithErrorsByName
} else if name == "" {
return nil, 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
}
// FindPersonByName is the resolver for the findPersonByName field.
func (r *entityResolver) FindPersonByName(ctx context.Context, name string) (*model.Person, error) {
panic(fmt.Errorf("not implemented: FindPersonByName - findPersonByName"))
}
// 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 computedrequires.EntityResolver implementation.
func (r *Resolver) Entity() computedrequires.EntityResolver { return &entityResolver{r} }
type entityResolver struct{ *Resolver }
================================================
FILE: plugin/federation/testdata/computedrequires/errors.go
================================================
package computedrequires
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")
)
================================================
FILE: plugin/federation/testdata/computedrequires/generated/exec.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package generated
import (
"bytes"
"context"
"errors"
"fmt"
"strconv"
"sync/atomic"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/introspection"
"github.com/99designs/gqlgen/plugin/federation/fedruntime"
model "github.com/99designs/gqlgen/plugin/federation/testdata/computedrequires/generated/models"
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{SchemaData: cfg.Schema, Resolvers: cfg.Resolvers, Directives: cfg.Directives, ComplexityRoot: cfg.Complexity}
}
type Config = graphql.Config[ResolverRoot, DirectiveRoot, ComplexityRoot]
type ResolverRoot interface {
Entity() EntityResolver
MultiHelloMultipleRequires() MultiHelloMultipleRequiresResolver
MultiHelloRequires() MultiHelloRequiresResolver
MultiPlanetRequiresNested() MultiPlanetRequiresNestedResolver
Person() PersonResolver
PlanetMultipleRequires() PlanetMultipleRequiresResolver
PlanetRequires() PlanetRequiresResolver
PlanetRequiresNested() PlanetRequiresNestedResolver
Query() QueryResolver
}
type DirectiveRoot struct {
}
type ComplexityRoot struct {
}
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)
FindPersonByName(ctx context.Context, name string) (*model.Person, 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 MultiHelloMultipleRequiresResolver interface {
Key3(ctx context.Context, obj *model.MultiHelloMultipleRequires, federationRequires map[string]any) (string, error)
}
type MultiHelloRequiresResolver interface {
Key2(ctx context.Context, obj *model.MultiHelloRequires, federationRequires map[string]any) (string, error)
}
type MultiPlanetRequiresNestedResolver interface {
Size(ctx context.Context, obj *model.MultiPlanetRequiresNested, federationRequires map[string]any) (int, error)
Sizes(ctx context.Context, obj *model.MultiPlanetRequiresNested, federationRequires map[string]any) ([]int, error)
}
type PersonResolver interface {
WelcomeMessage(ctx context.Context, obj *model.Person, federationRequires map[string]any) (*string, error)
}
type PlanetMultipleRequiresResolver interface {
Weight(ctx context.Context, obj *model.PlanetMultipleRequires, foo *string, federationRequires map[string]any) (int, error)
}
type PlanetRequiresResolver interface {
Size(ctx context.Context, obj *model.PlanetRequires, federationRequires map[string]any) (int, error)
}
type PlanetRequiresNestedResolver interface {
Size(ctx context.Context, obj *model.PlanetRequiresNested, federationRequires map[string]any) (int, error)
Sizes(ctx context.Context, obj *model.PlanetRequiresNested, federationRequires map[string]any) ([]int, error)
}
type QueryResolver interface {
Test(ctx context.Context) (*string, error)
}
var (
builtInDirectivePopulateFromRepresentations = func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) {
fc := graphql.GetFieldContext(ctx)
// We get the Federation representations argument from the _entities resolver
representations, ok := fc.Parent.Parent.Args["representations"].([]map[string]any)
if !ok {
return nil, errors.New("must be called from within _entities")
}
// Get the index of the current entity in the representations list. This is
// set by the execution context after the _entities resolver is called.
index := fc.Parent.Index
if index == nil {
return nil, errors.New("couldn't find input index for entity")
}
if len(representations) < *index {
return nil, errors.New("representation not found")
}
return representations[*index], nil
}
)
type executableSchema graphql.ExecutableSchemaState[ResolverRoot, DirectiveRoot, ComplexityRoot]
func (e *executableSchema) Schema() *ast.Schema {
if e.SchemaData != nil {
return e.SchemaData
}
return parsedSchema
}
func (e *executableSchema) Complexity(ctx context.Context, typeName, field string, childComplexity int, rawArgs map[string]any) (int, bool) {
ec := newExecutionContext(nil, e, nil)
_ = ec
return 0, false
}
func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
opCtx := graphql.GetOperationContext(ctx)
ec := newExecutionContext(opCtx, e, make(chan graphql.DeferredResult))
inputUnmarshalMap := graphql.BuildUnmarshalerMap(
ec.unmarshalInputMultiHelloByNamesInput,
ec.unmarshalInputMultiHelloMultipleRequiresByNamesInput,
ec.unmarshalInputMultiHelloRequiresByNamesInput,
ec.unmarshalInputMultiHelloWithErrorByNamesInput,
ec.unmarshalInputMultiPlanetRequiresNestedByNamesInput,
)
first := true
switch opCtx.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, opCtx.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.ExecutionContextState[ResolverRoot, DirectiveRoot, ComplexityRoot]
}
func newExecutionContext(
opCtx *graphql.OperationContext,
execSchema *executableSchema,
deferredResults chan graphql.DeferredResult,
) executionContext {
return executionContext{
ExecutionContextState: graphql.NewExecutionContextState[ResolverRoot, DirectiveRoot, ComplexityRoot](
opCtx,
(*graphql.ExecutableSchemaState[ResolverRoot, DirectiveRoot, ComplexityRoot])(execSchema),
parsedSchema,
deferredResults,
),
}
}
var sources = []*ast.Source{
{Name: "../schema.graphql", Input: `directive @entityResolver(multi: Boolean) on OBJECT
directive @goField(
forceResolver: Boolean
name: String
omittable: Boolean
type: String
) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION
type Query {
test: String
}
type Hello @key(fields: "name") {
name: String!
secondary: String!
}
type World @key(fields: "hello { name } foo ") {
foo: String!
bar: Int!
hello: Hello
}
type Person @key(fields: "name") {
name: String!
gender: Gender!
welcomeMessage: String
@requires(
fields: "gender { ... on Male {description} ... on Female {description}}"
)
}
union Gender = Male | Female
type Male {
description: String!
}
type Female {
description: String!
}
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(foo: String): Int!
@requires(fields: "diameter density")
@goField(forceResolver: true)
anotherField(foobar: String): String
}
type PlanetRequiresNested @key(fields: "name") {
name: String! @external
world: World! @external
worlds: [World!] @external
size: Int! @requires(fields: "world{ foo }")
sizes: [Int!] @requires(fields: "worlds{ foo }")
}
type MultiPlanetRequiresNested
@key(fields: "name")
@entityResolver(multi: true) {
name: String! @external
world: World! @external
worlds: [World!] @external
size: Int! @requires(fields: "world{ foo }")
sizes: [Int!] @requires(fields: "worlds{ 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 @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!, label: String) on FIELD_DEFINITION
directive @policy(policies: [[federation__Policy!]!]!) on
| FIELD_DEFINITION
| OBJECT
| INTERFACE
| SCALAR
| ENUM
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__Policy
scalar federation__Scope
`, 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 | Person | 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]
findPersonByName(name: String!,): Person!
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) field_Entity_findHelloByName_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "key1", ec.unmarshalNString2string)
if err != nil {
return nil, err
}
args["key1"] = arg0
arg1, err := graphql.ProcessArgField(ctx, rawArgs, "key2", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "reps", ec.unmarshalNMultiHelloByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHelloByNamesInput)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "reps", ec.unmarshalNMultiHelloMultipleRequiresByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHelloMultipleRequiresByNamesInput)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "reps", ec.unmarshalNMultiHelloRequiresByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHelloRequiresByNamesInput)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "reps", ec.unmarshalNMultiHelloWithErrorByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHelloWithErrorByNamesInput)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "reps", ec.unmarshalNMultiPlanetRequiresNestedByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiPlanetRequiresNestedByNamesInput)
if err != nil {
return nil, err
}
args["reps"] = arg0
return args, nil
}
func (ec *executionContext) field_Entity_findPersonByName_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
if err != nil {
return nil, err
}
args["name"] = arg0
return args, nil
}
func (ec *executionContext) field_Entity_findPlanetMultipleRequiresByName_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "helloName", ec.unmarshalNString2string)
if err != nil {
return nil, err
}
args["helloName"] = arg0
arg1, err := graphql.ProcessArgField(ctx, rawArgs, "foo", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "bar", ec.unmarshalNInt2int)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "helloName", ec.unmarshalNString2string)
if err != nil {
return nil, err
}
args["helloName"] = arg0
arg1, err := graphql.ProcessArgField(ctx, rawArgs, "foo", ec.unmarshalNString2string)
if err != nil {
return nil, err
}
args["foo"] = arg1
return args, nil
}
func (ec *executionContext) field_MultiHelloMultipleRequires_key3_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := ec.field_MultiHelloMultipleRequires_key3_argsFederationRequires(ctx, rawArgs)
if err != nil {
return nil, err
}
args["_federationRequires"] = arg0
return args, nil
}
func (ec *executionContext) field_MultiHelloMultipleRequires_key3_argsFederationRequires(
ctx context.Context,
rawArgs map[string]any,
) (map[string]any, error) {
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("_federationRequires"))
directive0 := func(ctx context.Context) (any, error) {
tmp, ok := rawArgs["_federationRequires"]
if !ok {
var zeroVal map[string]any
return zeroVal, nil
}
return ec.unmarshalO_RequiresMap2map(ctx, tmp)
}
directive1 := func(ctx context.Context) (any, error) {
return builtInDirectivePopulateFromRepresentations(ctx, rawArgs, directive0)
}
tmp, err := directive1(ctx)
if err != nil {
var zeroVal map[string]any
return zeroVal, graphql.ErrorOnPath(ctx, err)
}
if data, ok := tmp.(map[string]any); ok {
return data, nil
} else if tmp == nil {
var zeroVal map[string]any
return zeroVal, nil
} else {
var zeroVal map[string]any
return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be map[string]any`, tmp))
}
}
func (ec *executionContext) field_MultiHelloRequires_key2_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := ec.field_MultiHelloRequires_key2_argsFederationRequires(ctx, rawArgs)
if err != nil {
return nil, err
}
args["_federationRequires"] = arg0
return args, nil
}
func (ec *executionContext) field_MultiHelloRequires_key2_argsFederationRequires(
ctx context.Context,
rawArgs map[string]any,
) (map[string]any, error) {
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("_federationRequires"))
directive0 := func(ctx context.Context) (any, error) {
tmp, ok := rawArgs["_federationRequires"]
if !ok {
var zeroVal map[string]any
return zeroVal, nil
}
return ec.unmarshalO_RequiresMap2map(ctx, tmp)
}
directive1 := func(ctx context.Context) (any, error) {
return builtInDirectivePopulateFromRepresentations(ctx, rawArgs, directive0)
}
tmp, err := directive1(ctx)
if err != nil {
var zeroVal map[string]any
return zeroVal, graphql.ErrorOnPath(ctx, err)
}
if data, ok := tmp.(map[string]any); ok {
return data, nil
} else if tmp == nil {
var zeroVal map[string]any
return zeroVal, nil
} else {
var zeroVal map[string]any
return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be map[string]any`, tmp))
}
}
func (ec *executionContext) field_MultiPlanetRequiresNested_size_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := ec.field_MultiPlanetRequiresNested_size_argsFederationRequires(ctx, rawArgs)
if err != nil {
return nil, err
}
args["_federationRequires"] = arg0
return args, nil
}
func (ec *executionContext) field_MultiPlanetRequiresNested_size_argsFederationRequires(
ctx context.Context,
rawArgs map[string]any,
) (map[string]any, error) {
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("_federationRequires"))
directive0 := func(ctx context.Context) (any, error) {
tmp, ok := rawArgs["_federationRequires"]
if !ok {
var zeroVal map[string]any
return zeroVal, nil
}
return ec.unmarshalO_RequiresMap2map(ctx, tmp)
}
directive1 := func(ctx context.Context) (any, error) {
return builtInDirectivePopulateFromRepresentations(ctx, rawArgs, directive0)
}
tmp, err := directive1(ctx)
if err != nil {
var zeroVal map[string]any
return zeroVal, graphql.ErrorOnPath(ctx, err)
}
if data, ok := tmp.(map[string]any); ok {
return data, nil
} else if tmp == nil {
var zeroVal map[string]any
return zeroVal, nil
} else {
var zeroVal map[string]any
return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be map[string]any`, tmp))
}
}
func (ec *executionContext) field_MultiPlanetRequiresNested_sizes_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := ec.field_MultiPlanetRequiresNested_sizes_argsFederationRequires(ctx, rawArgs)
if err != nil {
return nil, err
}
args["_federationRequires"] = arg0
return args, nil
}
func (ec *executionContext) field_MultiPlanetRequiresNested_sizes_argsFederationRequires(
ctx context.Context,
rawArgs map[string]any,
) (map[string]any, error) {
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("_federationRequires"))
directive0 := func(ctx context.Context) (any, error) {
tmp, ok := rawArgs["_federationRequires"]
if !ok {
var zeroVal map[string]any
return zeroVal, nil
}
return ec.unmarshalO_RequiresMap2map(ctx, tmp)
}
directive1 := func(ctx context.Context) (any, error) {
return builtInDirectivePopulateFromRepresentations(ctx, rawArgs, directive0)
}
tmp, err := directive1(ctx)
if err != nil {
var zeroVal map[string]any
return zeroVal, graphql.ErrorOnPath(ctx, err)
}
if data, ok := tmp.(map[string]any); ok {
return data, nil
} else if tmp == nil {
var zeroVal map[string]any
return zeroVal, nil
} else {
var zeroVal map[string]any
return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be map[string]any`, tmp))
}
}
func (ec *executionContext) field_Person_welcomeMessage_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := ec.field_Person_welcomeMessage_argsFederationRequires(ctx, rawArgs)
if err != nil {
return nil, err
}
args["_federationRequires"] = arg0
return args, nil
}
func (ec *executionContext) field_Person_welcomeMessage_argsFederationRequires(
ctx context.Context,
rawArgs map[string]any,
) (map[string]any, error) {
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("_federationRequires"))
directive0 := func(ctx context.Context) (any, error) {
tmp, ok := rawArgs["_federationRequires"]
if !ok {
var zeroVal map[string]any
return zeroVal, nil
}
return ec.unmarshalO_RequiresMap2map(ctx, tmp)
}
directive1 := func(ctx context.Context) (any, error) {
return builtInDirectivePopulateFromRepresentations(ctx, rawArgs, directive0)
}
tmp, err := directive1(ctx)
if err != nil {
var zeroVal map[string]any
return zeroVal, graphql.ErrorOnPath(ctx, err)
}
if data, ok := tmp.(map[string]any); ok {
return data, nil
} else if tmp == nil {
var zeroVal map[string]any
return zeroVal, nil
} else {
var zeroVal map[string]any
return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be map[string]any`, tmp))
}
}
func (ec *executionContext) field_PlanetMultipleRequires_anotherField_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "foobar", ec.unmarshalOString2ᚖstring)
if err != nil {
return nil, err
}
args["foobar"] = arg0
return args, nil
}
func (ec *executionContext) field_PlanetMultipleRequires_weight_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "foo", ec.unmarshalOString2ᚖstring)
if err != nil {
return nil, err
}
args["foo"] = arg0
arg1, err := ec.field_PlanetMultipleRequires_weight_argsFederationRequires(ctx, rawArgs)
if err != nil {
return nil, err
}
args["_federationRequires"] = arg1
return args, nil
}
func (ec *executionContext) field_PlanetMultipleRequires_weight_argsFederationRequires(
ctx context.Context,
rawArgs map[string]any,
) (map[string]any, error) {
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("_federationRequires"))
directive0 := func(ctx context.Context) (any, error) {
tmp, ok := rawArgs["_federationRequires"]
if !ok {
var zeroVal map[string]any
return zeroVal, nil
}
return ec.unmarshalO_RequiresMap2map(ctx, tmp)
}
directive1 := func(ctx context.Context) (any, error) {
return builtInDirectivePopulateFromRepresentations(ctx, rawArgs, directive0)
}
tmp, err := directive1(ctx)
if err != nil {
var zeroVal map[string]any
return zeroVal, graphql.ErrorOnPath(ctx, err)
}
if data, ok := tmp.(map[string]any); ok {
return data, nil
} else if tmp == nil {
var zeroVal map[string]any
return zeroVal, nil
} else {
var zeroVal map[string]any
return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be map[string]any`, tmp))
}
}
func (ec *executionContext) field_PlanetRequiresNested_size_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := ec.field_PlanetRequiresNested_size_argsFederationRequires(ctx, rawArgs)
if err != nil {
return nil, err
}
args["_federationRequires"] = arg0
return args, nil
}
func (ec *executionContext) field_PlanetRequiresNested_size_argsFederationRequires(
ctx context.Context,
rawArgs map[string]any,
) (map[string]any, error) {
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("_federationRequires"))
directive0 := func(ctx context.Context) (any, error) {
tmp, ok := rawArgs["_federationRequires"]
if !ok {
var zeroVal map[string]any
return zeroVal, nil
}
return ec.unmarshalO_RequiresMap2map(ctx, tmp)
}
directive1 := func(ctx context.Context) (any, error) {
return builtInDirectivePopulateFromRepresentations(ctx, rawArgs, directive0)
}
tmp, err := directive1(ctx)
if err != nil {
var zeroVal map[string]any
return zeroVal, graphql.ErrorOnPath(ctx, err)
}
if data, ok := tmp.(map[string]any); ok {
return data, nil
} else if tmp == nil {
var zeroVal map[string]any
return zeroVal, nil
} else {
var zeroVal map[string]any
return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be map[string]any`, tmp))
}
}
func (ec *executionContext) field_PlanetRequiresNested_sizes_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := ec.field_PlanetRequiresNested_sizes_argsFederationRequires(ctx, rawArgs)
if err != nil {
return nil, err
}
args["_federationRequires"] = arg0
return args, nil
}
func (ec *executionContext) field_PlanetRequiresNested_sizes_argsFederationRequires(
ctx context.Context,
rawArgs map[string]any,
) (map[string]any, error) {
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("_federationRequires"))
directive0 := func(ctx context.Context) (any, error) {
tmp, ok := rawArgs["_federationRequires"]
if !ok {
var zeroVal map[string]any
return zeroVal, nil
}
return ec.unmarshalO_RequiresMap2map(ctx, tmp)
}
directive1 := func(ctx context.Context) (any, error) {
return builtInDirectivePopulateFromRepresentations(ctx, rawArgs, directive0)
}
tmp, err := directive1(ctx)
if err != nil {
var zeroVal map[string]any
return zeroVal, graphql.ErrorOnPath(ctx, err)
}
if data, ok := tmp.(map[string]any); ok {
return data, nil
} else if tmp == nil {
var zeroVal map[string]any
return zeroVal, nil
} else {
var zeroVal map[string]any
return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be map[string]any`, tmp))
}
}
func (ec *executionContext) field_PlanetRequires_size_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := ec.field_PlanetRequires_size_argsFederationRequires(ctx, rawArgs)
if err != nil {
return nil, err
}
args["_federationRequires"] = arg0
return args, nil
}
func (ec *executionContext) field_PlanetRequires_size_argsFederationRequires(
ctx context.Context,
rawArgs map[string]any,
) (map[string]any, error) {
ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("_federationRequires"))
directive0 := func(ctx context.Context) (any, error) {
tmp, ok := rawArgs["_federationRequires"]
if !ok {
var zeroVal map[string]any
return zeroVal, nil
}
return ec.unmarshalO_RequiresMap2map(ctx, tmp)
}
directive1 := func(ctx context.Context) (any, error) {
return builtInDirectivePopulateFromRepresentations(ctx, rawArgs, directive0)
}
tmp, err := directive1(ctx)
if err != nil {
var zeroVal map[string]any
return zeroVal, graphql.ErrorOnPath(ctx, err)
}
if data, ok := tmp.(map[string]any); ok {
return data, nil
} else if tmp == nil {
var zeroVal map[string]any
return zeroVal, nil
} else {
var zeroVal map[string]any
return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be map[string]any`, tmp))
}
}
func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "representations", ec.unmarshalN_Any2ᚕmapᚄ)
if err != nil {
return nil, err
}
args["representations"] = arg0
return args, nil
}
func (ec *executionContext) field___Directive_args_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2ᚖbool)
if err != nil {
return nil, err
}
args["includeDeprecated"] = arg0
return args, nil
}
func (ec *executionContext) field___Field_args_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2ᚖbool)
if err != nil {
return nil, err
}
args["includeDeprecated"] = arg0
return args, nil
}
func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2bool)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2bool)
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findHelloByName,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindHelloByName(ctx, fc.Args["name"].(string))
},
nil,
ec.marshalNHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐHello,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findHelloMultiSingleKeysByKey1AndKey2,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindHelloMultiSingleKeysByKey1AndKey2(ctx, fc.Args["key1"].(string), fc.Args["key2"].(string))
},
nil,
ec.marshalNHelloMultiSingleKeys2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐHelloMultiSingleKeys,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findHelloWithErrorsByName,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindHelloWithErrorsByName(ctx, fc.Args["name"].(string))
},
nil,
ec.marshalNHelloWithErrors2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐHelloWithErrors,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findManyMultiHelloByNames,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindManyMultiHelloByNames(ctx, fc.Args["reps"].([]*model.MultiHelloByNamesInput))
},
nil,
ec.marshalOMultiHello2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHello,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findManyMultiHelloMultipleRequiresByNames,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindManyMultiHelloMultipleRequiresByNames(ctx, fc.Args["reps"].([]*model.MultiHelloMultipleRequiresByNamesInput))
},
nil,
ec.marshalOMultiHelloMultipleRequires2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHelloMultipleRequires,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findManyMultiHelloRequiresByNames,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindManyMultiHelloRequiresByNames(ctx, fc.Args["reps"].([]*model.MultiHelloRequiresByNamesInput))
},
nil,
ec.marshalOMultiHelloRequires2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHelloRequires,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findManyMultiHelloWithErrorByNames,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindManyMultiHelloWithErrorByNames(ctx, fc.Args["reps"].([]*model.MultiHelloWithErrorByNamesInput))
},
nil,
ec.marshalOMultiHelloWithError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHelloWithError,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findManyMultiPlanetRequiresNestedByNames,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindManyMultiPlanetRequiresNestedByNames(ctx, fc.Args["reps"].([]*model.MultiPlanetRequiresNestedByNamesInput))
},
nil,
ec.marshalOMultiPlanetRequiresNested2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiPlanetRequiresNested,
true,
false,
)
}
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 "worlds":
return ec.fieldContext_MultiPlanetRequiresNested_worlds(ctx, field)
case "size":
return ec.fieldContext_MultiPlanetRequiresNested_size(ctx, field)
case "sizes":
return ec.fieldContext_MultiPlanetRequiresNested_sizes(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_findPersonByName(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findPersonByName,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindPersonByName(ctx, fc.Args["name"].(string))
},
nil,
ec.marshalNPerson2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐPerson,
true,
true,
)
}
func (ec *executionContext) fieldContext_Entity_findPersonByName(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_Person_name(ctx, field)
case "gender":
return ec.fieldContext_Person_gender(ctx, field)
case "welcomeMessage":
return ec.fieldContext_Person_welcomeMessage(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Person", 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_findPersonByName_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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findPlanetMultipleRequiresByName,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindPlanetMultipleRequiresByName(ctx, fc.Args["name"].(string))
},
nil,
ec.marshalNPlanetMultipleRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐPlanetMultipleRequires,
true,
true,
)
}
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)
case "anotherField":
return ec.fieldContext_PlanetMultipleRequires_anotherField(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findPlanetRequiresByName,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindPlanetRequiresByName(ctx, fc.Args["name"].(string))
},
nil,
ec.marshalNPlanetRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐPlanetRequires,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findPlanetRequiresNestedByName,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindPlanetRequiresNestedByName(ctx, fc.Args["name"].(string))
},
nil,
ec.marshalNPlanetRequiresNested2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐPlanetRequiresNested,
true,
true,
)
}
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 "worlds":
return ec.fieldContext_PlanetRequiresNested_worlds(ctx, field)
case "size":
return ec.fieldContext_PlanetRequiresNested_size(ctx, field)
case "sizes":
return ec.fieldContext_PlanetRequiresNested_sizes(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findWorldByHelloNameAndFoo,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindWorldByHelloNameAndFoo(ctx, fc.Args["helloName"].(string), fc.Args["foo"].(string))
},
nil,
ec.marshalNWorld2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐWorld,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findWorldNameByName,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindWorldNameByName(ctx, fc.Args["name"].(string))
},
nil,
ec.marshalNWorldName2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐWorldName,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findWorldWithMultipleKeysByHelloNameAndFoo,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindWorldWithMultipleKeysByHelloNameAndFoo(ctx, fc.Args["helloName"].(string), fc.Args["foo"].(string))
},
nil,
ec.marshalNWorldWithMultipleKeys2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐWorldWithMultipleKeys,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findWorldWithMultipleKeysByBar,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindWorldWithMultipleKeysByBar(ctx, fc.Args["bar"].(int))
},
nil,
ec.marshalNWorldWithMultipleKeys2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐWorldWithMultipleKeys,
true,
true,
)
}
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) _Female_description(ctx context.Context, field graphql.CollectedField, obj *model.Female) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Female_description,
func(ctx context.Context) (any, error) {
return obj.Description, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Female_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Female",
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_name(ctx context.Context, field graphql.CollectedField, obj *model.Hello) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Hello_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Hello_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Hello_secondary,
func(ctx context.Context) (any, error) {
return obj.Secondary, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Hello_secondary(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_HelloMultiSingleKeys_key1,
func(ctx context.Context) (any, error) {
return obj.Key1, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_HelloMultiSingleKeys_key1(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_HelloMultiSingleKeys_key2,
func(ctx context.Context) (any, error) {
return obj.Key2, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_HelloMultiSingleKeys_key2(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_HelloWithErrors_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_HelloWithErrors_name(_ 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) _Male_description(ctx context.Context, field graphql.CollectedField, obj *model.Male) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Male_description,
func(ctx context.Context) (any, error) {
return obj.Description, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Male_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Male",
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHello_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiHello_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHelloMultipleRequires_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiHelloMultipleRequires_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHelloMultipleRequires_key1,
func(ctx context.Context) (any, error) {
return obj.Key1, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiHelloMultipleRequires_key1(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHelloMultipleRequires_key2,
func(ctx context.Context) (any, error) {
return obj.Key2, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiHelloMultipleRequires_key2(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHelloMultipleRequires_key3,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.MultiHelloMultipleRequires().Key3(ctx, obj, fc.Args["_federationRequires"].(map[string]any))
},
nil,
ec.marshalNString2string,
true,
true,
)
}
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: 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_MultiHelloMultipleRequires_key3_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) _MultiHelloRequires_name(ctx context.Context, field graphql.CollectedField, obj *model.MultiHelloRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHelloRequires_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiHelloRequires_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHelloRequires_key1,
func(ctx context.Context) (any, error) {
return obj.Key1, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiHelloRequires_key1(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHelloRequires_key2,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.MultiHelloRequires().Key2(ctx, obj, fc.Args["_federationRequires"].(map[string]any))
},
nil,
ec.marshalNString2string,
true,
true,
)
}
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: 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_MultiHelloRequires_key2_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) _MultiHelloWithError_name(ctx context.Context, field graphql.CollectedField, obj *model.MultiHelloWithError) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHelloWithError_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiHelloWithError_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiPlanetRequiresNested_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiPlanetRequiresNested_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiPlanetRequiresNested_world,
func(ctx context.Context) (any, error) {
return obj.World, nil
},
nil,
ec.marshalNWorld2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐWorld,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiPlanetRequiresNested_world(_ 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_worlds(ctx context.Context, field graphql.CollectedField, obj *model.MultiPlanetRequiresNested) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiPlanetRequiresNested_worlds,
func(ctx context.Context) (any, error) {
return obj.Worlds, nil
},
nil,
ec.marshalOWorld2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐWorldᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext_MultiPlanetRequiresNested_worlds(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiPlanetRequiresNested_size,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.MultiPlanetRequiresNested().Size(ctx, obj, fc.Args["_federationRequires"].(map[string]any))
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
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: 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")
},
}
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_MultiPlanetRequiresNested_size_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) _MultiPlanetRequiresNested_sizes(ctx context.Context, field graphql.CollectedField, obj *model.MultiPlanetRequiresNested) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiPlanetRequiresNested_sizes,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.MultiPlanetRequiresNested().Sizes(ctx, obj, fc.Args["_federationRequires"].(map[string]any))
},
nil,
ec.marshalOInt2ᚕintᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext_MultiPlanetRequiresNested_sizes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "MultiPlanetRequiresNested",
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")
},
}
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_MultiPlanetRequiresNested_sizes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) _Person_name(ctx context.Context, field graphql.CollectedField, obj *model.Person) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Person_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Person_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Person",
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) _Person_gender(ctx context.Context, field graphql.CollectedField, obj *model.Person) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Person_gender,
func(ctx context.Context) (any, error) {
return obj.Gender, nil
},
nil,
ec.marshalNGender2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐGender,
true,
true,
)
}
func (ec *executionContext) fieldContext_Person_gender(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Person",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type Gender does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _Person_welcomeMessage(ctx context.Context, field graphql.CollectedField, obj *model.Person) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Person_welcomeMessage,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Person().WelcomeMessage(ctx, obj, fc.Args["_federationRequires"].(map[string]any))
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext_Person_welcomeMessage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Person",
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_Person_welcomeMessage_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) _PlanetMultipleRequires_name(ctx context.Context, field graphql.CollectedField, obj *model.PlanetMultipleRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetMultipleRequires_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetMultipleRequires_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetMultipleRequires_diameter,
func(ctx context.Context) (any, error) {
return obj.Diameter, nil
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetMultipleRequires_diameter(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetMultipleRequires_density,
func(ctx context.Context) (any, error) {
return obj.Density, nil
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetMultipleRequires_density(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetMultipleRequires_weight,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.PlanetMultipleRequires().Weight(ctx, obj, fc.Args["foo"].(*string), fc.Args["_federationRequires"].(map[string]any))
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
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: 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")
},
}
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_PlanetMultipleRequires_weight_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) _PlanetMultipleRequires_anotherField(ctx context.Context, field graphql.CollectedField, obj *model.PlanetMultipleRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetMultipleRequires_anotherField,
func(ctx context.Context) (any, error) {
return obj.AnotherField, nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext_PlanetMultipleRequires_anotherField(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")
},
}
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_PlanetMultipleRequires_anotherField_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) _PlanetRequires_name(ctx context.Context, field graphql.CollectedField, obj *model.PlanetRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetRequires_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetRequires_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetRequires_size,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.PlanetRequires().Size(ctx, obj, fc.Args["_federationRequires"].(map[string]any))
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
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: 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")
},
}
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_PlanetRequires_size_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) _PlanetRequires_diameter(ctx context.Context, field graphql.CollectedField, obj *model.PlanetRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetRequires_diameter,
func(ctx context.Context) (any, error) {
return obj.Diameter, nil
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetRequires_diameter(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetRequiresNested_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetRequiresNested_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetRequiresNested_world,
func(ctx context.Context) (any, error) {
return obj.World, nil
},
nil,
ec.marshalNWorld2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐWorld,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetRequiresNested_world(_ 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_worlds(ctx context.Context, field graphql.CollectedField, obj *model.PlanetRequiresNested) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetRequiresNested_worlds,
func(ctx context.Context) (any, error) {
return obj.Worlds, nil
},
nil,
ec.marshalOWorld2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐWorldᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext_PlanetRequiresNested_worlds(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetRequiresNested_size,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.PlanetRequiresNested().Size(ctx, obj, fc.Args["_federationRequires"].(map[string]any))
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
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: 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")
},
}
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_PlanetRequiresNested_size_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) _PlanetRequiresNested_sizes(ctx context.Context, field graphql.CollectedField, obj *model.PlanetRequiresNested) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetRequiresNested_sizes,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.PlanetRequiresNested().Sizes(ctx, obj, fc.Args["_federationRequires"].(map[string]any))
},
nil,
ec.marshalOInt2ᚕintᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext_PlanetRequiresNested_sizes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "PlanetRequiresNested",
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")
},
}
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_PlanetRequiresNested_sizes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) _Query_test(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query_test,
func(ctx context.Context) (any, error) {
return ec.Resolvers.Query().Test(ctx)
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext_Query_test(_ 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__entities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query__entities,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.__resolve_entities(ctx, fc.Args["representations"].([]map[string]any)), nil
},
nil,
ec.marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query__service,
func(ctx context.Context) (any, error) {
return ec.__resolve__service(ctx)
},
nil,
ec.marshalN_Service2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService,
true,
true,
)
}
func (ec *executionContext) fieldContext_Query__service(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query___type,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.IntrospectType(fc.Args["name"].(string))
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query___schema,
func(ctx context.Context) (any, error) {
return ec.IntrospectSchema()
},
nil,
ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema,
true,
false,
)
}
func (ec *executionContext) fieldContext_Query___schema(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_World_foo,
func(ctx context.Context) (any, error) {
return obj.Foo, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_World_foo(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_World_bar,
func(ctx context.Context) (any, error) {
return obj.Bar, nil
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
func (ec *executionContext) fieldContext_World_bar(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_World_hello,
func(ctx context.Context) (any, error) {
return obj.Hello, nil
},
nil,
ec.marshalOHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐHello,
true,
false,
)
}
func (ec *executionContext) fieldContext_World_hello(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_WorldName_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_WorldName_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_WorldWithMultipleKeys_foo,
func(ctx context.Context) (any, error) {
return obj.Foo, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_WorldWithMultipleKeys_foo(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_WorldWithMultipleKeys_bar,
func(ctx context.Context) (any, error) {
return obj.Bar, nil
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
func (ec *executionContext) fieldContext_WorldWithMultipleKeys_bar(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_WorldWithMultipleKeys_hello,
func(ctx context.Context) (any, error) {
return obj.Hello, nil
},
nil,
ec.marshalOHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐHello,
true,
false,
)
}
func (ec *executionContext) fieldContext_WorldWithMultipleKeys_hello(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext__Service_sdl,
func(ctx context.Context) (any, error) {
return obj.SDL, nil
},
nil,
ec.marshalOString2string,
true,
false,
)
}
func (ec *executionContext) fieldContext__Service_sdl(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Directive_description(_ 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_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_isRepeatable,
func(ctx context.Context) (any, error) {
return obj.IsRepeatable, nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_isRepeatable(_ 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) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_locations,
func(ctx context.Context) (any, error) {
return obj.Locations, nil
},
nil,
ec.marshalN__DirectiveLocation2ᚕstringᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_locations(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_args,
func(ctx context.Context) (any, error) {
return obj.Args, nil
},
nil,
ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
true,
)
}
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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __InputValue", 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___Directive_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___EnumValue_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___EnumValue_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___EnumValue_isDeprecated(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___EnumValue_deprecationReason(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Field_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_args,
func(ctx context.Context) (any, error) {
return obj.Args, nil
},
nil,
ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
true,
)
}
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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __InputValue", 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___Field_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_type,
func(ctx context.Context) (any, error) {
return obj.Type, nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_type(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_isDeprecated(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Field_deprecationReason(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_type,
func(ctx context.Context) (any, error) {
return obj.Type, nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_type(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_defaultValue,
func(ctx context.Context) (any, error) {
return obj.DefaultValue, nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_defaultValue(_ 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_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_isDeprecated(_ 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 Boolean does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) ___InputValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_deprecationReason(_ 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) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_types,
func(ctx context.Context) (any, error) {
return obj.Types(), nil
},
nil,
ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_types(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_queryType,
func(ctx context.Context) (any, error) {
return obj.QueryType(), nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_queryType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_mutationType,
func(ctx context.Context) (any, error) {
return obj.MutationType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_mutationType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_subscriptionType,
func(ctx context.Context) (any, error) {
return obj.SubscriptionType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_subscriptionType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_directives,
func(ctx context.Context) (any, error) {
return obj.Directives(), nil
},
nil,
ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_directives(_ 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 "isRepeatable":
return ec.fieldContext___Directive_isRepeatable(ctx, field)
case "locations":
return ec.fieldContext___Directive_locations(ctx, field)
case "args":
return ec.fieldContext___Directive_args(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_kind,
func(ctx context.Context) (any, error) {
return obj.Kind(), nil
},
nil,
ec.marshalN__TypeKind2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Type_kind(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_name,
func(ctx context.Context) (any, error) {
return obj.Name(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_description(_ 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_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_specifiedByURL,
func(ctx context.Context) (any, error) {
return obj.SpecifiedByURL(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_specifiedByURL(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_fields,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil
},
nil,
ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_interfaces,
func(ctx context.Context) (any, error) {
return obj.Interfaces(), nil
},
nil,
ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_interfaces(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_possibleTypes,
func(ctx context.Context) (any, error) {
return obj.PossibleTypes(), nil
},
nil,
ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_possibleTypes(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_enumValues,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil
},
nil,
ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_inputFields,
func(ctx context.Context) (any, error) {
return obj.InputFields(), nil
},
nil,
ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_inputFields(_ 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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_ofType,
func(ctx context.Context) (any, error) {
return obj.OfType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_ofType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) ___Type_isOneOf(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_isOneOf,
func(ctx context.Context) (any, error) {
return obj.IsOneOf(), nil
},
nil,
ec.marshalOBoolean2bool,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_isOneOf(_ 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 Boolean does not have child fields")
},
}
return fc, nil
}
// endregion **************************** field.gotpl *****************************
// region **************************** input.gotpl *****************************
func (ec *executionContext) unmarshalInputMultiHelloByNamesInput(ctx context.Context, obj any) (model.MultiHelloByNamesInput, error) {
var it model.MultiHelloByNamesInput
if obj == nil {
return it, nil
}
asMap := map[string]any{}
for k, v := range obj.(map[string]any) {
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 any) (model.MultiHelloMultipleRequiresByNamesInput, error) {
var it model.MultiHelloMultipleRequiresByNamesInput
if obj == nil {
return it, nil
}
asMap := map[string]any{}
for k, v := range obj.(map[string]any) {
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 any) (model.MultiHelloRequiresByNamesInput, error) {
var it model.MultiHelloRequiresByNamesInput
if obj == nil {
return it, nil
}
asMap := map[string]any{}
for k, v := range obj.(map[string]any) {
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 any) (model.MultiHelloWithErrorByNamesInput, error) {
var it model.MultiHelloWithErrorByNamesInput
if obj == nil {
return it, nil
}
asMap := map[string]any{}
for k, v := range obj.(map[string]any) {
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 any) (model.MultiPlanetRequiresNestedByNamesInput, error) {
var it model.MultiPlanetRequiresNestedByNamesInput
if obj == nil {
return it, nil
}
asMap := map[string]any{}
for k, v := range obj.(map[string]any) {
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) _Gender(ctx context.Context, sel ast.SelectionSet, obj model.Gender) graphql.Marshaler {
switch obj := (obj).(type) {
case nil:
return graphql.Null
case model.Male:
return ec._Male(ctx, sel, &obj)
case *model.Male:
if obj == nil {
return graphql.Null
}
return ec._Male(ctx, sel, obj)
case model.Female:
return ec._Female(ctx, sel, &obj)
case *model.Female:
if obj == nil {
return graphql.Null
}
return ec._Female(ctx, sel, obj)
default:
if typedObj, ok := obj.(graphql.Marshaler); ok {
return typedObj
} else {
panic(fmt.Errorf("unexpected type %T; non-generated variants of Gender must implement graphql.Marshaler", 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 model.WorldWithMultipleKeys:
return ec._WorldWithMultipleKeys(ctx, sel, &obj)
case *model.WorldWithMultipleKeys:
if obj == nil {
return graphql.Null
}
return ec._WorldWithMultipleKeys(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.World:
return ec._World(ctx, sel, &obj)
case *model.World:
if obj == nil {
return graphql.Null
}
return ec._World(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.PlanetRequires:
return ec._PlanetRequires(ctx, sel, &obj)
case *model.PlanetRequires:
if obj == nil {
return graphql.Null
}
return ec._PlanetRequires(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.Person:
return ec._Person(ctx, sel, &obj)
case *model.Person:
if obj == nil {
return graphql.Null
}
return ec._Person(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.MultiHelloWithError:
return ec._MultiHelloWithError(ctx, sel, &obj)
case *model.MultiHelloWithError:
if obj == nil {
return graphql.Null
}
return ec._MultiHelloWithError(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.MultiHelloMultipleRequires:
return ec._MultiHelloMultipleRequires(ctx, sel, &obj)
case *model.MultiHelloMultipleRequires:
if obj == nil {
return graphql.Null
}
return ec._MultiHelloMultipleRequires(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.HelloWithErrors:
return ec._HelloWithErrors(ctx, sel, &obj)
case *model.HelloWithErrors:
if obj == nil {
return graphql.Null
}
return ec._HelloWithErrors(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.Hello:
return ec._Hello(ctx, sel, &obj)
case *model.Hello:
if obj == nil {
return graphql.Null
}
return ec._Hello(ctx, sel, obj)
default:
if typedObj, ok := obj.(graphql.Marshaler); ok {
return typedObj
} else {
panic(fmt.Errorf("unexpected type %T; non-generated variants of _Entity must implement graphql.Marshaler", 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, _ *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, _ *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, _ *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, _ *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, _ *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 "findPersonByName":
field := field
innerFunc := func(ctx 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_findPersonByName(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 "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 femaleImplementors = []string{"Female", "Gender"}
func (ec *executionContext) _Female(ctx context.Context, sel ast.SelectionSet, obj *model.Female) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, femaleImplementors)
out := graphql.NewFieldSet(fields)
deferred := make(map[string]*graphql.FieldSet)
for i, field := range fields {
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Female")
case "description":
out.Values[i] = ec._Female_description(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 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 maleImplementors = []string{"Male", "Gender"}
func (ec *executionContext) _Male(ctx context.Context, sel ast.SelectionSet, obj *model.Male) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, maleImplementors)
out := graphql.NewFieldSet(fields)
deferred := make(map[string]*graphql.FieldSet)
for i, field := range fields {
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Male")
case "description":
out.Values[i] = ec._Male_description(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 {
atomic.AddUint32(&out.Invalids, 1)
}
case "key1":
out.Values[i] = ec._MultiHelloMultipleRequires_key1(ctx, field, obj)
if out.Values[i] == graphql.Null {
atomic.AddUint32(&out.Invalids, 1)
}
case "key2":
out.Values[i] = ec._MultiHelloMultipleRequires_key2(ctx, field, obj)
if out.Values[i] == graphql.Null {
atomic.AddUint32(&out.Invalids, 1)
}
case "key3":
field := field
innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._MultiHelloMultipleRequires_key3(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 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 {
atomic.AddUint32(&out.Invalids, 1)
}
case "key1":
out.Values[i] = ec._MultiHelloRequires_key1(ctx, field, obj)
if out.Values[i] == graphql.Null {
atomic.AddUint32(&out.Invalids, 1)
}
case "key2":
field := field
innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._MultiHelloRequires_key2(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 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 {
atomic.AddUint32(&out.Invalids, 1)
}
case "world":
out.Values[i] = ec._MultiPlanetRequiresNested_world(ctx, field, obj)
if out.Values[i] == graphql.Null {
atomic.AddUint32(&out.Invalids, 1)
}
case "worlds":
out.Values[i] = ec._MultiPlanetRequiresNested_worlds(ctx, field, obj)
case "size":
field := field
innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._MultiPlanetRequiresNested_size(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 "sizes":
field := field
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._MultiPlanetRequiresNested_sizes(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 personImplementors = []string{"Person", "_Entity"}
func (ec *executionContext) _Person(ctx context.Context, sel ast.SelectionSet, obj *model.Person) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, personImplementors)
out := graphql.NewFieldSet(fields)
deferred := make(map[string]*graphql.FieldSet)
for i, field := range fields {
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Person")
case "name":
out.Values[i] = ec._Person_name(ctx, field, obj)
if out.Values[i] == graphql.Null {
atomic.AddUint32(&out.Invalids, 1)
}
case "gender":
out.Values[i] = ec._Person_gender(ctx, field, obj)
if out.Values[i] == graphql.Null {
atomic.AddUint32(&out.Invalids, 1)
}
case "welcomeMessage":
field := field
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._Person_welcomeMessage(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 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 {
atomic.AddUint32(&out.Invalids, 1)
}
case "diameter":
out.Values[i] = ec._PlanetMultipleRequires_diameter(ctx, field, obj)
if out.Values[i] == graphql.Null {
atomic.AddUint32(&out.Invalids, 1)
}
case "density":
out.Values[i] = ec._PlanetMultipleRequires_density(ctx, field, obj)
if out.Values[i] == graphql.Null {
atomic.AddUint32(&out.Invalids, 1)
}
case "weight":
field := field
innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._PlanetMultipleRequires_weight(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 "anotherField":
out.Values[i] = ec._PlanetMultipleRequires_anotherField(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 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 {
atomic.AddUint32(&out.Invalids, 1)
}
case "size":
field := field
innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._PlanetRequires_size(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 "diameter":
out.Values[i] = ec._PlanetRequires_diameter(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 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 {
atomic.AddUint32(&out.Invalids, 1)
}
case "world":
out.Values[i] = ec._PlanetRequiresNested_world(ctx, field, obj)
if out.Values[i] == graphql.Null {
atomic.AddUint32(&out.Invalids, 1)
}
case "worlds":
out.Values[i] = ec._PlanetRequiresNested_worlds(ctx, field, obj)
case "size":
field := field
innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._PlanetRequiresNested_size(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 "sizes":
field := field
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._PlanetRequiresNested_sizes(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 "test":
field := field
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._Query_test(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 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 "isRepeatable":
out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
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++
}
default:
panic("unknown field " + strconv.Quote(field.Name))
}
}
out.Dispatch(ctx)
if out.Invalids > 0 {
return graphql.Null
}
atomic.AddInt32(&ec.Deferred, int32(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)
case "isDeprecated":
out.Values[i] = ec.___InputValue_isDeprecated(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "deprecationReason":
out.Values[i] = ec.___InputValue_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 __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 "specifiedByURL":
out.Values[i] = ec.___Type_specifiedByURL(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 "isOneOf":
out.Values[i] = ec.___Type_isOneOf(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 any) (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 {
_ = sel
res := graphql.MarshalBoolean(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalNFieldSet2string(ctx context.Context, v any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) marshalNGender2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐGender(ctx context.Context, sel ast.SelectionSet, v model.Gender) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return ec._Gender(ctx, sel, v)
}
func (ec *executionContext) marshalNHello2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐHello(ctx context.Context, sel ast.SelectionSet, v model.Hello) graphql.Marshaler {
return ec._Hello(ctx, sel, &v)
}
func (ec *executionContext) marshalNHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐHello(ctx context.Context, sel ast.SelectionSet, v *model.Hello) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐHelloMultiSingleKeys(ctx context.Context, sel ast.SelectionSet, v model.HelloMultiSingleKeys) graphql.Marshaler {
return ec._HelloMultiSingleKeys(ctx, sel, &v)
}
func (ec *executionContext) marshalNHelloMultiSingleKeys2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐHelloMultiSingleKeys(ctx context.Context, sel ast.SelectionSet, v *model.HelloMultiSingleKeys) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐHelloWithErrors(ctx context.Context, sel ast.SelectionSet, v model.HelloWithErrors) graphql.Marshaler {
return ec._HelloWithErrors(ctx, sel, &v)
}
func (ec *executionContext) marshalNHelloWithErrors2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐHelloWithErrors(ctx context.Context, sel ast.SelectionSet, v *model.HelloWithErrors) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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 any) (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 {
_ = sel
res := graphql.MarshalInt(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalNMultiHelloByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHelloByNamesInput(ctx context.Context, v any) ([]*model.MultiHelloByNamesInput, error) {
var vSlice []any
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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHelloByNamesInput(ctx, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil
}
func (ec *executionContext) unmarshalNMultiHelloMultipleRequiresByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHelloMultipleRequiresByNamesInput(ctx context.Context, v any) ([]*model.MultiHelloMultipleRequiresByNamesInput, error) {
var vSlice []any
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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHelloMultipleRequiresByNamesInput(ctx, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil
}
func (ec *executionContext) unmarshalNMultiHelloRequiresByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHelloRequiresByNamesInput(ctx context.Context, v any) ([]*model.MultiHelloRequiresByNamesInput, error) {
var vSlice []any
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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHelloRequiresByNamesInput(ctx, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil
}
func (ec *executionContext) unmarshalNMultiHelloWithErrorByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHelloWithErrorByNamesInput(ctx context.Context, v any) ([]*model.MultiHelloWithErrorByNamesInput, error) {
var vSlice []any
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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHelloWithErrorByNamesInput(ctx, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil
}
func (ec *executionContext) unmarshalNMultiPlanetRequiresNestedByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiPlanetRequiresNestedByNamesInput(ctx context.Context, v any) ([]*model.MultiPlanetRequiresNestedByNamesInput, error) {
var vSlice []any
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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiPlanetRequiresNestedByNamesInput(ctx, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil
}
func (ec *executionContext) marshalNPerson2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐPerson(ctx context.Context, sel ast.SelectionSet, v model.Person) graphql.Marshaler {
return ec._Person(ctx, sel, &v)
}
func (ec *executionContext) marshalNPerson2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐPerson(ctx context.Context, sel ast.SelectionSet, v *model.Person) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return ec._Person(ctx, sel, v)
}
func (ec *executionContext) marshalNPlanetMultipleRequires2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐPlanetMultipleRequires(ctx context.Context, sel ast.SelectionSet, v model.PlanetMultipleRequires) graphql.Marshaler {
return ec._PlanetMultipleRequires(ctx, sel, &v)
}
func (ec *executionContext) marshalNPlanetMultipleRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐPlanetMultipleRequires(ctx context.Context, sel ast.SelectionSet, v *model.PlanetMultipleRequires) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐPlanetRequires(ctx context.Context, sel ast.SelectionSet, v model.PlanetRequires) graphql.Marshaler {
return ec._PlanetRequires(ctx, sel, &v)
}
func (ec *executionContext) marshalNPlanetRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐPlanetRequires(ctx context.Context, sel ast.SelectionSet, v *model.PlanetRequires) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐPlanetRequiresNested(ctx context.Context, sel ast.SelectionSet, v model.PlanetRequiresNested) graphql.Marshaler {
return ec._PlanetRequiresNested(ctx, sel, &v)
}
func (ec *executionContext) marshalNPlanetRequiresNested2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐPlanetRequiresNested(ctx context.Context, sel ast.SelectionSet, v *model.PlanetRequiresNested) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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 any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) marshalNWorld2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐWorld(ctx context.Context, sel ast.SelectionSet, v model.World) graphql.Marshaler {
return ec._World(ctx, sel, &v)
}
func (ec *executionContext) marshalNWorld2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐWorld(ctx context.Context, sel ast.SelectionSet, v *model.World) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐWorldName(ctx context.Context, sel ast.SelectionSet, v model.WorldName) graphql.Marshaler {
return ec._WorldName(ctx, sel, &v)
}
func (ec *executionContext) marshalNWorldName2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐWorldName(ctx context.Context, sel ast.SelectionSet, v *model.WorldName) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐWorldWithMultipleKeys(ctx context.Context, sel ast.SelectionSet, v model.WorldWithMultipleKeys) graphql.Marshaler {
return ec._WorldWithMultipleKeys(ctx, sel, &v)
}
func (ec *executionContext) marshalNWorldWithMultipleKeys2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐWorldWithMultipleKeys(ctx context.Context, sel ast.SelectionSet, v *model.WorldWithMultipleKeys) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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 any) (map[string]any, 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]any) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
_ = sel
res := graphql.MarshalMap(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalN_Any2ᚕmapᚄ(ctx context.Context, v any) ([]map[string]any, error) {
var vSlice []any
vSlice = graphql.CoerceList(v)
var err error
res := make([]map[string]any, 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]any) 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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v []fedruntime.Entity) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalO_Entity2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, sel, v[i])
})
return ret
}
func (ec *executionContext) marshalN_Service2githubᚗcomᚋ99designsᚋ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ᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler {
return ec.___Directive(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v any) ([]string, error) {
var vSlice []any
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 := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__DirectiveLocation2string(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler {
return ec.___EnumValue(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler {
return ec.___Field(ctx, sel, &v)
}
func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler {
return ec.___InputValue(ctx, sel, &v)
}
func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler {
return ec.___Type(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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 any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalNfederation__Policy2string(ctx context.Context, v any) (string, error) {
res, err := graphql.UnmarshalString(v)
return res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalNfederation__Policy2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalNfederation__Policy2ᚕstringᚄ(ctx context.Context, v any) ([]string, error) {
var vSlice []any
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__Policy2string(ctx, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil
}
func (ec *executionContext) marshalNfederation__Policy2ᚕ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__Policy2string(ctx, sel, v[i])
}
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) unmarshalNfederation__Policy2ᚕᚕstringᚄ(ctx context.Context, v any) ([][]string, error) {
var vSlice []any
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__Policy2ᚕstringᚄ(ctx, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil
}
func (ec *executionContext) marshalNfederation__Policy2ᚕᚕ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__Policy2ᚕstringᚄ(ctx, sel, v[i])
}
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) unmarshalNfederation__Scope2string(ctx context.Context, v any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalNfederation__Scope2ᚕstringᚄ(ctx context.Context, v any) ([]string, error) {
var vSlice []any
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 any) ([][]string, error) {
var vSlice []any
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 any) (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 {
_ = sel
_ = ctx
res := graphql.MarshalBoolean(v)
return res
}
func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v any) (*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
}
_ = sel
_ = ctx
res := graphql.MarshalBoolean(*v)
return res
}
func (ec *executionContext) marshalOHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐ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) unmarshalOInt2ᚕintᚄ(ctx context.Context, v any) ([]int, error) {
if v == nil {
return nil, nil
}
var vSlice []any
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) marshalOMultiHello2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHello(ctx context.Context, sel ast.SelectionSet, v []*model.MultiHello) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalOMultiHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHello(ctx, sel, v[i])
})
return ret
}
func (ec *executionContext) marshalOMultiHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐ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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHelloByNamesInput(ctx context.Context, v any) (*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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHelloMultipleRequires(ctx context.Context, sel ast.SelectionSet, v []*model.MultiHelloMultipleRequires) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalOMultiHelloMultipleRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHelloMultipleRequires(ctx, sel, v[i])
})
return ret
}
func (ec *executionContext) marshalOMultiHelloMultipleRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐ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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHelloMultipleRequiresByNamesInput(ctx context.Context, v any) (*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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHelloRequires(ctx context.Context, sel ast.SelectionSet, v []*model.MultiHelloRequires) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalOMultiHelloRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHelloRequires(ctx, sel, v[i])
})
return ret
}
func (ec *executionContext) marshalOMultiHelloRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐ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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHelloRequiresByNamesInput(ctx context.Context, v any) (*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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHelloWithError(ctx context.Context, sel ast.SelectionSet, v []*model.MultiHelloWithError) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalOMultiHelloWithError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHelloWithError(ctx, sel, v[i])
})
return ret
}
func (ec *executionContext) marshalOMultiHelloWithError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐ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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiHelloWithErrorByNamesInput(ctx context.Context, v any) (*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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiPlanetRequiresNested(ctx context.Context, sel ast.SelectionSet, v []*model.MultiPlanetRequiresNested) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalOMultiPlanetRequiresNested2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiPlanetRequiresNested(ctx, sel, v[i])
})
return ret
}
func (ec *executionContext) marshalOMultiPlanetRequiresNested2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐ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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐMultiPlanetRequiresNestedByNamesInput(ctx context.Context, v any) (*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 any) (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 {
_ = sel
_ = ctx
res := graphql.MarshalString(v)
return res
}
func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v any) ([]string, error) {
if v == nil {
return nil, nil
}
var vSlice []any
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 any) (*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
}
_ = sel
_ = ctx
res := graphql.MarshalString(*v)
return res
}
func (ec *executionContext) marshalOWorld2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐWorldᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.World) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalNWorld2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋcomputedrequiresᚋgeneratedᚋmodelsᚐWorld(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO_Entity2githubᚗcomᚋ99designsᚋ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) unmarshalO_RequiresMap2map(ctx context.Context, v any) (map[string]any, error) {
if v == nil {
return nil, nil
}
res, err := graphql.UnmarshalMap(v)
return res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalO_RequiresMap2map(ctx context.Context, sel ast.SelectionSet, v map[string]any) graphql.Marshaler {
if v == nil {
return graphql.Null
}
_ = sel
_ = ctx
res := graphql.MarshalMap(v)
return res
}
func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec.___Schema(ctx, sel, v)
}
func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec.___Type(ctx, sel, v)
}
// endregion ***************************** type.gotpl *****************************
================================================
FILE: plugin/federation/testdata/computedrequires/generated/federation.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package generated
import (
"context"
"errors"
"fmt"
"strings"
"sync"
"github.com/99designs/gqlgen/plugin/federation/fedruntime"
model "github.com/99designs/gqlgen/plugin/federation/testdata/computedrequires/generated/models"
)
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]any) []fedruntime.Entity {
list := make([]fedruntime.Entity, len(representations))
repsMap := ec.buildRepresentationGroups(ctx, representations)
switch len(repsMap) {
case 0:
return list
case 1:
for typeName, reps := range repsMap {
ec.resolveEntityGroup(ctx, typeName, reps, list)
}
return list
default:
var g sync.WaitGroup
g.Add(len(repsMap))
for typeName, reps := range repsMap {
go func(typeName string, reps []EntityWithIndex) {
ec.resolveEntityGroup(ctx, typeName, reps, list)
g.Done()
}(typeName, reps)
}
g.Wait()
return list
}
}
type EntityWithIndex struct {
// The index in the original representation array
index int
entity EntityRepresentation
}
// EntityRepresentation is the JSON representation of an entity sent by the Router
// used as the inputs for us to resolve.
//
// We make it a map because we know the top level JSON is always an object.
type EntityRepresentation map[string]any
// We group entities by typename so that we can parallelize their resolution.
// This is particularly helpful when there are entity groups in multi mode.
func (ec *executionContext) buildRepresentationGroups(
ctx context.Context,
representations []map[string]any,
) map[string][]EntityWithIndex {
repsMap := make(map[string][]EntityWithIndex)
for i, rep := range representations {
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
}
repsMap[typeName] = append(repsMap[typeName], EntityWithIndex{
index: i,
entity: rep,
})
}
return repsMap
}
func (ec *executionContext) resolveEntityGroup(
ctx context.Context,
typeName string,
reps []EntityWithIndex,
list []fedruntime.Entity,
) {
if isMulti(typeName) {
err := ec.resolveManyEntities(ctx, typeName, reps, list)
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 EntityWithIndex) {
entity, err := ec.resolveEntity(ctx, typeName, rep.entity)
if err != nil {
ec.Error(ctx, err)
} else {
list[rep.index] = entity
}
e.Done()
}(i, rep)
}
e.Wait()
}
}
func isMulti(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
}
}
func (ec *executionContext) resolveEntity(
ctx context.Context,
typeName string,
rep EntityRepresentation,
) (e fedruntime.Entity, 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 nil, fmt.Errorf(`finding resolver for Entity "Hello": %w`, err)
}
switch resolverName {
case "findHelloByName":
id0, err := ec.unmarshalNString2string(ctx, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findHelloByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindHelloByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "Hello": %w`, err)
}
return entity, nil
}
case "HelloMultiSingleKeys":
resolverName, err := entityResolverNameForHelloMultiSingleKeys(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "HelloMultiSingleKeys": %w`, err)
}
switch resolverName {
case "findHelloMultiSingleKeysByKey1AndKey2":
id0, err := ec.unmarshalNString2string(ctx, rep["key1"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findHelloMultiSingleKeysByKey1AndKey2(): %w`, err)
}
id1, err := ec.unmarshalNString2string(ctx, rep["key2"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 1 for findHelloMultiSingleKeysByKey1AndKey2(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindHelloMultiSingleKeysByKey1AndKey2(ctx, id0, id1)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "HelloMultiSingleKeys": %w`, err)
}
return entity, nil
}
case "HelloWithErrors":
resolverName, err := entityResolverNameForHelloWithErrors(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "HelloWithErrors": %w`, err)
}
switch resolverName {
case "findHelloWithErrorsByName":
id0, err := ec.unmarshalNString2string(ctx, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findHelloWithErrorsByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindHelloWithErrorsByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "HelloWithErrors": %w`, err)
}
return entity, nil
}
case "Person":
resolverName, err := entityResolverNameForPerson(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "Person": %w`, err)
}
switch resolverName {
case "findPersonByName":
id0, err := ec.unmarshalNString2string(ctx, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findPersonByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindPersonByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "Person": %w`, err)
}
return entity, nil
}
case "PlanetMultipleRequires":
resolverName, err := entityResolverNameForPlanetMultipleRequires(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "PlanetMultipleRequires": %w`, err)
}
switch resolverName {
case "findPlanetMultipleRequiresByName":
id0, err := ec.unmarshalNString2string(ctx, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findPlanetMultipleRequiresByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindPlanetMultipleRequiresByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "PlanetMultipleRequires": %w`, err)
}
return entity, nil
}
case "PlanetRequires":
resolverName, err := entityResolverNameForPlanetRequires(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "PlanetRequires": %w`, err)
}
switch resolverName {
case "findPlanetRequiresByName":
id0, err := ec.unmarshalNString2string(ctx, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findPlanetRequiresByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindPlanetRequiresByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "PlanetRequires": %w`, err)
}
return entity, nil
}
case "PlanetRequiresNested":
resolverName, err := entityResolverNameForPlanetRequiresNested(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "PlanetRequiresNested": %w`, err)
}
switch resolverName {
case "findPlanetRequiresNestedByName":
id0, err := ec.unmarshalNString2string(ctx, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findPlanetRequiresNestedByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindPlanetRequiresNestedByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "PlanetRequiresNested": %w`, err)
}
return entity, nil
}
case "World":
resolverName, err := entityResolverNameForWorld(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "World": %w`, err)
}
switch resolverName {
case "findWorldByHelloNameAndFoo":
id0, err := ec.unmarshalNString2string(ctx, rep["hello"].(map[string]any)["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findWorldByHelloNameAndFoo(): %w`, err)
}
id1, err := ec.unmarshalNString2string(ctx, rep["foo"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 1 for findWorldByHelloNameAndFoo(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindWorldByHelloNameAndFoo(ctx, id0, id1)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "World": %w`, err)
}
return entity, nil
}
case "WorldName":
resolverName, err := entityResolverNameForWorldName(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "WorldName": %w`, err)
}
switch resolverName {
case "findWorldNameByName":
id0, err := ec.unmarshalNString2string(ctx, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findWorldNameByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindWorldNameByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "WorldName": %w`, err)
}
return entity, nil
}
case "WorldWithMultipleKeys":
resolverName, err := entityResolverNameForWorldWithMultipleKeys(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "WorldWithMultipleKeys": %w`, err)
}
switch resolverName {
case "findWorldWithMultipleKeysByHelloNameAndFoo":
id0, err := ec.unmarshalNString2string(ctx, rep["hello"].(map[string]any)["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findWorldWithMultipleKeysByHelloNameAndFoo(): %w`, err)
}
id1, err := ec.unmarshalNString2string(ctx, rep["foo"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 1 for findWorldWithMultipleKeysByHelloNameAndFoo(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindWorldWithMultipleKeysByHelloNameAndFoo(ctx, id0, id1)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "WorldWithMultipleKeys": %w`, err)
}
return entity, nil
case "findWorldWithMultipleKeysByBar":
id0, err := ec.unmarshalNInt2int(ctx, rep["bar"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findWorldWithMultipleKeysByBar(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindWorldWithMultipleKeysByBar(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "WorldWithMultipleKeys": %w`, err)
}
return entity, nil
}
}
return nil, fmt.Errorf("%w: %s", ErrUnknownType, typeName)
}
func (ec *executionContext) resolveManyEntities(
ctx context.Context,
typeName string,
reps []EntityWithIndex,
list []fedruntime.Entity,
) (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].entity)
if err != nil {
return fmt.Errorf(`finding resolver for Entity "MultiHello": %w`, err)
}
switch resolverName {
case "findManyMultiHelloByNames":
typedReps := make([]*model.MultiHelloByNamesInput, len(reps))
for i, rep := range reps {
id0, err := ec.unmarshalNString2string(ctx, rep.entity["name"])
if err != nil {
return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name"))
}
typedReps[i] = &model.MultiHelloByNamesInput{
Name: id0,
}
}
entities, err := ec.Resolvers.Entity().FindManyMultiHelloByNames(ctx, typedReps)
if err != nil {
return err
}
for i, entity := range entities {
list[reps[i].index] = entity
}
return nil
default:
return fmt.Errorf("unknown resolver: %s", resolverName)
}
case "MultiHelloMultipleRequires":
resolverName, err := entityResolverNameForMultiHelloMultipleRequires(ctx, reps[0].entity)
if err != nil {
return fmt.Errorf(`finding resolver for Entity "MultiHelloMultipleRequires": %w`, err)
}
switch resolverName {
case "findManyMultiHelloMultipleRequiresByNames":
typedReps := make([]*model.MultiHelloMultipleRequiresByNamesInput, len(reps))
for i, rep := range reps {
id0, err := ec.unmarshalNString2string(ctx, rep.entity["name"])
if err != nil {
return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name"))
}
typedReps[i] = &model.MultiHelloMultipleRequiresByNamesInput{
Name: id0,
}
}
entities, err := ec.Resolvers.Entity().FindManyMultiHelloMultipleRequiresByNames(ctx, typedReps)
if err != nil {
return err
}
for i, entity := range entities {
list[reps[i].index] = entity
}
return nil
default:
return fmt.Errorf("unknown resolver: %s", resolverName)
}
case "MultiHelloRequires":
resolverName, err := entityResolverNameForMultiHelloRequires(ctx, reps[0].entity)
if err != nil {
return fmt.Errorf(`finding resolver for Entity "MultiHelloRequires": %w`, err)
}
switch resolverName {
case "findManyMultiHelloRequiresByNames":
typedReps := make([]*model.MultiHelloRequiresByNamesInput, len(reps))
for i, rep := range reps {
id0, err := ec.unmarshalNString2string(ctx, rep.entity["name"])
if err != nil {
return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name"))
}
typedReps[i] = &model.MultiHelloRequiresByNamesInput{
Name: id0,
}
}
entities, err := ec.Resolvers.Entity().FindManyMultiHelloRequiresByNames(ctx, typedReps)
if err != nil {
return err
}
for i, entity := range entities {
list[reps[i].index] = entity
}
return nil
default:
return fmt.Errorf("unknown resolver: %s", resolverName)
}
case "MultiHelloWithError":
resolverName, err := entityResolverNameForMultiHelloWithError(ctx, reps[0].entity)
if err != nil {
return fmt.Errorf(`finding resolver for Entity "MultiHelloWithError": %w`, err)
}
switch resolverName {
case "findManyMultiHelloWithErrorByNames":
typedReps := make([]*model.MultiHelloWithErrorByNamesInput, len(reps))
for i, rep := range reps {
id0, err := ec.unmarshalNString2string(ctx, rep.entity["name"])
if err != nil {
return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name"))
}
typedReps[i] = &model.MultiHelloWithErrorByNamesInput{
Name: id0,
}
}
entities, err := ec.Resolvers.Entity().FindManyMultiHelloWithErrorByNames(ctx, typedReps)
if err != nil {
return err
}
for i, entity := range entities {
list[reps[i].index] = entity
}
return nil
default:
return fmt.Errorf("unknown resolver: %s", resolverName)
}
case "MultiPlanetRequiresNested":
resolverName, err := entityResolverNameForMultiPlanetRequiresNested(ctx, reps[0].entity)
if err != nil {
return fmt.Errorf(`finding resolver for Entity "MultiPlanetRequiresNested": %w`, err)
}
switch resolverName {
case "findManyMultiPlanetRequiresNestedByNames":
typedReps := make([]*model.MultiPlanetRequiresNestedByNamesInput, len(reps))
for i, rep := range reps {
id0, err := ec.unmarshalNString2string(ctx, rep.entity["name"])
if err != nil {
return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name"))
}
typedReps[i] = &model.MultiPlanetRequiresNestedByNamesInput{
Name: id0,
}
}
entities, err := ec.Resolvers.Entity().FindManyMultiPlanetRequiresNestedByNames(ctx, typedReps)
if err != nil {
return err
}
for i, entity := range entities {
list[reps[i].index] = entity
}
return nil
default:
return fmt.Errorf("unknown resolver: %s", resolverName)
}
default:
return errors.New("unknown type: " + typeName)
}
}
func entityResolverNameForHello(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for Hello", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for Hello", ErrTypeNotFound))
break
}
return "findHelloByName", nil
}
return "", fmt.Errorf("%w for Hello due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForHelloMultiSingleKeys(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["key1"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"key1\" for HelloMultiSingleKeys", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
m = rep
val, ok = m["key2"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"key2\" for HelloMultiSingleKeys", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for HelloMultiSingleKeys", ErrTypeNotFound))
break
}
return "findHelloMultiSingleKeysByKey1AndKey2", nil
}
return "", fmt.Errorf("%w for HelloMultiSingleKeys due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForHelloWithErrors(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for HelloWithErrors", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for HelloWithErrors", ErrTypeNotFound))
break
}
return "findHelloWithErrorsByName", nil
}
return "", fmt.Errorf("%w for HelloWithErrors due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForMultiHello(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for MultiHello", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for MultiHello", ErrTypeNotFound))
break
}
return "findManyMultiHelloByNames", nil
}
return "", fmt.Errorf("%w for MultiHello due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForMultiHelloMultipleRequires(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for MultiHelloMultipleRequires", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for MultiHelloMultipleRequires", ErrTypeNotFound))
break
}
return "findManyMultiHelloMultipleRequiresByNames", nil
}
return "", fmt.Errorf("%w for MultiHelloMultipleRequires due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForMultiHelloRequires(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for MultiHelloRequires", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for MultiHelloRequires", ErrTypeNotFound))
break
}
return "findManyMultiHelloRequiresByNames", nil
}
return "", fmt.Errorf("%w for MultiHelloRequires due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForMultiHelloWithError(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for MultiHelloWithError", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for MultiHelloWithError", ErrTypeNotFound))
break
}
return "findManyMultiHelloWithErrorByNames", nil
}
return "", fmt.Errorf("%w for MultiHelloWithError due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForMultiPlanetRequiresNested(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for MultiPlanetRequiresNested", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for MultiPlanetRequiresNested", ErrTypeNotFound))
break
}
return "findManyMultiPlanetRequiresNestedByNames", nil
}
return "", fmt.Errorf("%w for MultiPlanetRequiresNested due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForPerson(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for Person", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for Person", ErrTypeNotFound))
break
}
return "findPersonByName", nil
}
return "", fmt.Errorf("%w for Person due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForPlanetMultipleRequires(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for PlanetMultipleRequires", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for PlanetMultipleRequires", ErrTypeNotFound))
break
}
return "findPlanetMultipleRequiresByName", nil
}
return "", fmt.Errorf("%w for PlanetMultipleRequires due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForPlanetRequires(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for PlanetRequires", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for PlanetRequires", ErrTypeNotFound))
break
}
return "findPlanetRequiresByName", nil
}
return "", fmt.Errorf("%w for PlanetRequires due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForPlanetRequiresNested(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for PlanetRequiresNested", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for PlanetRequiresNested", ErrTypeNotFound))
break
}
return "findPlanetRequiresNestedByName", nil
}
return "", fmt.Errorf("%w for PlanetRequiresNested due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForWorld(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["hello"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"hello\" for World", ErrTypeNotFound))
break
}
if m, ok = val.(map[string]any); !ok {
// nested field value is not a map[string]interface so don't use it
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to nested Key Field \"hello\" value not matching map[string]any for World", ErrTypeNotFound))
break
}
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for World", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
m = rep
val, ok = m["foo"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"foo\" for World", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for World", ErrTypeNotFound))
break
}
return "findWorldByHelloNameAndFoo", nil
}
return "", fmt.Errorf("%w for World due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForWorldName(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for WorldName", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for WorldName", ErrTypeNotFound))
break
}
return "findWorldNameByName", nil
}
return "", fmt.Errorf("%w for WorldName due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForWorldWithMultipleKeys(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["hello"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"hello\" for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
if m, ok = val.(map[string]any); !ok {
// nested field value is not a map[string]interface so don't use it
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to nested Key Field \"hello\" value not matching map[string]any for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
m = rep
val, ok = m["foo"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"foo\" for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
return "findWorldWithMultipleKeysByHelloNameAndFoo", nil
}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["bar"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"bar\" for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
return "findWorldWithMultipleKeysByBar", nil
}
return "", fmt.Errorf("%w for WorldWithMultipleKeys due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
================================================
FILE: plugin/federation/testdata/computedrequires/generated/models/models.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package model
type Gender interface {
IsGender()
}
type Female struct {
Description string `json:"description"`
}
func (Female) IsGender() {}
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 Male struct {
Description string `json:"description"`
}
func (Male) IsGender() {}
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"`
Worlds []*World `json:"worlds,omitempty"`
Size int `json:"size"`
Sizes []int `json:"sizes,omitempty"`
}
func (MultiPlanetRequiresNested) IsEntity() {}
type MultiPlanetRequiresNestedByNamesInput struct {
Name string `json:"Name"`
}
type Person struct {
Name string `json:"name"`
Gender Gender `json:"gender"`
WelcomeMessage *string `json:"welcomeMessage,omitempty"`
}
func (Person) IsEntity() {}
type PlanetMultipleRequires struct {
Name string `json:"name"`
Diameter int `json:"diameter"`
Density int `json:"density"`
Weight int `json:"weight"`
AnotherField *string `json:"anotherField,omitempty"`
}
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"`
Worlds []*World `json:"worlds,omitempty"`
Size int `json:"size"`
Sizes []int `json:"sizes,omitempty"`
}
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() {}
================================================
FILE: plugin/federation/testdata/computedrequires/gqlgen.yml
================================================
schema:
- "testdata/computedrequires/schema.graphql"
exec:
filename: testdata/computedrequires/generated/exec.go
package: generated
federation:
filename: testdata/computedrequires/generated/federation.go
package: generated
version: 2
options:
computed_requires: true
model:
package: model
filename: testdata/computedrequires/generated/models/models.go
resolver:
filename: testdata/computedrequires/resolver.go
layout: follow-schema
dir: testdata/computedrequires
package: computedrequires
omit_complexity: true
call_argument_directives_with_null: true
================================================
FILE: plugin/federation/testdata/computedrequires/main/server.go
================================================
package main
import (
"log"
"net/http"
"os"
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/handler/debug"
"github.com/99designs/gqlgen/graphql/handler/transport"
"github.com/99designs/gqlgen/graphql/playground"
"github.com/99designs/gqlgen/plugin/federation/testdata/computedrequires"
"github.com/99designs/gqlgen/plugin/federation/testdata/computedrequires/generated"
)
const defaultPort = "4003"
func main() {
port := os.Getenv("PORT")
if port == "" {
port = defaultPort
}
srv := handler.New(
generated.NewExecutableSchema(generated.Config{Resolvers: &computedrequires.Resolver{}}),
)
srv.AddTransport(transport.GET{})
srv.AddTransport(transport.POST{})
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))
}
================================================
FILE: plugin/federation/testdata/computedrequires/resolver.go
================================================
package computedrequires
// This file will not be regenerated automatically.
//
// It serves as dependency injection for your app, add any dependencies you require here.
type Resolver struct{}
================================================
FILE: plugin/federation/testdata/computedrequires/schema.graphql
================================================
directive @entityResolver(multi: Boolean) on OBJECT
directive @goField(
forceResolver: Boolean
name: String
omittable: Boolean
type: String
) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION
type Query {
test: String
}
type Hello @key(fields: "name") {
name: String!
secondary: String!
}
type World @key(fields: "hello { name } foo ") {
foo: String!
bar: Int!
hello: Hello
}
type Person @key(fields: "name") {
name: String!
gender: Gender!
welcomeMessage: String
@requires(
fields: "gender { ... on Male {description} ... on Female {description}}"
)
}
union Gender = Male | Female
type Male {
description: String!
}
type Female {
description: String!
}
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(foo: String): Int!
@requires(fields: "diameter density")
@goField(forceResolver: true)
anotherField(foobar: String): String
}
type PlanetRequiresNested @key(fields: "name") {
name: String! @external
world: World! @external
worlds: [World!] @external
size: Int! @requires(fields: "world{ foo }")
sizes: [Int!] @requires(fields: "worlds{ foo }")
}
type MultiPlanetRequiresNested
@key(fields: "name")
@entityResolver(multi: true) {
name: String! @external
world: World! @external
worlds: [World!] @external
size: Int! @requires(fields: "world{ foo }")
sizes: [Int!] @requires(fields: "worlds{ 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")
}
================================================
FILE: plugin/federation/testdata/computedrequires/schema.resolvers.go
================================================
package computedrequires
// 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/99designs/gqlgen version v0.17.88-dev
import (
"context"
"encoding/json"
"fmt"
explicitrequires "github.com/99designs/gqlgen/plugin/federation/testdata/computedrequires/generated"
model "github.com/99designs/gqlgen/plugin/federation/testdata/computedrequires/generated/models"
)
// Key3 is the resolver for the key3 field.
func (r *multiHelloMultipleRequiresResolver) Key3(ctx context.Context, obj *model.MultiHelloMultipleRequires, federationRequires map[string]any) (string, error) {
key1 := federationRequires["key1"].(string)
key2 := federationRequires["key2"].(string)
return key1 + ":" + key2, nil
}
// Key2 is the resolver for the key2 field.
func (r *multiHelloRequiresResolver) Key2(ctx context.Context, obj *model.MultiHelloRequires, federationRequires map[string]any) (string, error) {
key1 := federationRequires["key1"].(string)
return key1, nil
}
// Size is the resolver for the size field.
func (r *multiPlanetRequiresNestedResolver) Size(ctx context.Context, obj *model.MultiPlanetRequiresNested, federationRequires map[string]any) (int, error) {
foo := federationRequires["world"].(map[string]any)["foo"].(string)
return len(foo), nil
}
// Sizes is the resolver for the sizes field.
func (r *multiPlanetRequiresNestedResolver) Sizes(ctx context.Context, obj *model.MultiPlanetRequiresNested, federationRequires map[string]any) ([]int, error) {
panic(fmt.Errorf("not implemented: Sizes - sizes"))
}
// WelcomeMessage is the resolver for the welcomeMessage field.
func (r *personResolver) WelcomeMessage(ctx context.Context, obj *model.Person, federationRequires map[string]any) (*string, error) {
panic(fmt.Errorf("not implemented: WelcomeMessage - welcomeMessage"))
}
// Weight is the resolver for the weight field.
func (r *planetMultipleRequiresResolver) Weight(ctx context.Context, obj *model.PlanetMultipleRequires, foo *string, federationRequires map[string]any) (int, error) {
diameter, err := federationRequires["diameter"].(json.Number).Int64()
if err != nil {
return 0, err
}
density, err := federationRequires["density"].(json.Number).Int64()
if err != nil {
return 0, err
}
return int(diameter) + int(density), nil
}
// Size is the resolver for the size field.
func (r *planetRequiresResolver) Size(ctx context.Context, obj *model.PlanetRequires, federationRequires map[string]any) (int, error) {
diameter, err := federationRequires["diameter"].(json.Number).Int64()
if err != nil {
return 0, err
}
return int(diameter), nil
}
// Size is the resolver for the size field.
func (r *planetRequiresNestedResolver) Size(ctx context.Context, obj *model.PlanetRequiresNested, federationRequires map[string]any) (int, error) {
foo := federationRequires["world"].(map[string]any)["foo"].(string)
return len(foo), nil
}
// Sizes is the resolver for the sizes field.
func (r *planetRequiresNestedResolver) Sizes(ctx context.Context, obj *model.PlanetRequiresNested, federationRequires map[string]any) ([]int, error) {
foo := federationRequires["world"].(map[string]any)["foo"].(string)
return []int{len(foo)}, nil
}
// Test is the resolver for the test field.
func (r *queryResolver) Test(ctx context.Context) (*string, error) {
panic(fmt.Errorf("not implemented: Test - test"))
}
// MultiHelloMultipleRequires returns explicitrequires.MultiHelloMultipleRequiresResolver implementation.
func (r *Resolver) MultiHelloMultipleRequires() explicitrequires.MultiHelloMultipleRequiresResolver {
return &multiHelloMultipleRequiresResolver{r}
}
// MultiHelloRequires returns explicitrequires.MultiHelloRequiresResolver implementation.
func (r *Resolver) MultiHelloRequires() explicitrequires.MultiHelloRequiresResolver {
return &multiHelloRequiresResolver{r}
}
// MultiPlanetRequiresNested returns explicitrequires.MultiPlanetRequiresNestedResolver implementation.
func (r *Resolver) MultiPlanetRequiresNested() explicitrequires.MultiPlanetRequiresNestedResolver {
return &multiPlanetRequiresNestedResolver{r}
}
// Person returns explicitrequires.PersonResolver implementation.
func (r *Resolver) Person() explicitrequires.PersonResolver { return &personResolver{r} }
// PlanetMultipleRequires returns explicitrequires.PlanetMultipleRequiresResolver implementation.
func (r *Resolver) PlanetMultipleRequires() explicitrequires.PlanetMultipleRequiresResolver {
return &planetMultipleRequiresResolver{r}
}
// PlanetRequires returns explicitrequires.PlanetRequiresResolver implementation.
func (r *Resolver) PlanetRequires() explicitrequires.PlanetRequiresResolver {
return &planetRequiresResolver{r}
}
// PlanetRequiresNested returns explicitrequires.PlanetRequiresNestedResolver implementation.
func (r *Resolver) PlanetRequiresNested() explicitrequires.PlanetRequiresNestedResolver {
return &planetRequiresNestedResolver{r}
}
// Query returns explicitrequires.QueryResolver implementation.
func (r *Resolver) Query() explicitrequires.QueryResolver { return &queryResolver{r} }
type multiHelloMultipleRequiresResolver struct{ *Resolver }
type multiHelloRequiresResolver struct{ *Resolver }
type multiPlanetRequiresNestedResolver struct{ *Resolver }
type personResolver struct{ *Resolver }
type planetMultipleRequiresResolver struct{ *Resolver }
type planetRequiresResolver struct{ *Resolver }
type planetRequiresNestedResolver struct{ *Resolver }
type queryResolver struct{ *Resolver }
================================================
FILE: plugin/federation/testdata/entities/nokey.graphql
================================================
type Hello {
name: String!
}
type Query {
hello: Hello!
}
================================================
FILE: plugin/federation/testdata/entities/nokey.yml
================================================
schema:
- "testdata/entities/nokey.graphql"
exec:
filename: testdata/entities/generated/exec.go
federation:
filename: testdata/entities/generated/federation.go
autobind:
- "github.com/99designs/gqlgen/plugin/federation/test_data/model"
================================================
FILE: plugin/federation/testdata/entitydirectives/generated/exec.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package generated
import (
"bytes"
"context"
"errors"
"fmt"
"strconv"
"sync/atomic"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/introspection"
"github.com/99designs/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{SchemaData: cfg.Schema, Resolvers: cfg.Resolvers, Directives: cfg.Directives, ComplexityRoot: cfg.Complexity}
}
type Config = graphql.Config[ResolverRoot, DirectiveRoot, ComplexityRoot]
type ResolverRoot interface {
Entity() EntityResolver
Query() QueryResolver
}
type DirectiveRoot struct {
Auth func(ctx context.Context, obj any, next graphql.Resolver, requires string) (res any, err error)
Guard func(ctx context.Context, obj any, next graphql.Resolver, name string) (res any, err error)
}
type ComplexityRoot struct {
Basic struct {
ID func(childComplexity int) int
Value func(childComplexity int) int
}
Entity struct {
FindBasicByID func(childComplexity int, id string) int
FindPersonByID func(childComplexity int, id string) int
FindProductBySku func(childComplexity int, sku string) int
}
Person struct {
Email func(childComplexity int) int
ID func(childComplexity int) int
Phone func(childComplexity int) int
}
Product struct {
Name func(childComplexity int) int
Price func(childComplexity int) int
Sku func(childComplexity int) int
}
Query struct {
GetBasic func(childComplexity int, id string) int
GetPerson func(childComplexity int, id string) int
GetProduct func(childComplexity int, sku string) int
__resolve__service func(childComplexity int) int
__resolve_entities func(childComplexity int, representations []map[string]any) int
}
_Service struct {
SDL func(childComplexity int) int
}
}
type EntityResolver interface {
FindBasicByID(ctx context.Context, id string) (*Basic, error)
FindPersonByID(ctx context.Context, id string) (*Person, error)
FindProductBySku(ctx context.Context, sku string) (*Product, error)
}
type QueryResolver interface {
GetPerson(ctx context.Context, id string) (*Person, error)
GetProduct(ctx context.Context, sku string) (*Product, error)
GetBasic(ctx context.Context, id string) (*Basic, error)
}
type executableSchema graphql.ExecutableSchemaState[ResolverRoot, DirectiveRoot, ComplexityRoot]
func (e *executableSchema) Schema() *ast.Schema {
if e.SchemaData != nil {
return e.SchemaData
}
return parsedSchema
}
func (e *executableSchema) Complexity(ctx context.Context, typeName, field string, childComplexity int, rawArgs map[string]any) (int, bool) {
ec := newExecutionContext(nil, e, nil)
_ = ec
switch typeName + "." + field {
case "Basic.id":
if e.ComplexityRoot.Basic.ID == nil {
break
}
return e.ComplexityRoot.Basic.ID(childComplexity), true
case "Basic.value":
if e.ComplexityRoot.Basic.Value == nil {
break
}
return e.ComplexityRoot.Basic.Value(childComplexity), true
case "Entity.findBasicByID":
if e.ComplexityRoot.Entity.FindBasicByID == nil {
break
}
args, err := ec.field_Entity_findBasicByID_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindBasicByID(childComplexity, args["id"].(string)), true
case "Entity.findPersonByID":
if e.ComplexityRoot.Entity.FindPersonByID == nil {
break
}
args, err := ec.field_Entity_findPersonByID_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindPersonByID(childComplexity, args["id"].(string)), true
case "Entity.findProductBySku":
if e.ComplexityRoot.Entity.FindProductBySku == nil {
break
}
args, err := ec.field_Entity_findProductBySku_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindProductBySku(childComplexity, args["sku"].(string)), true
case "Person.email":
if e.ComplexityRoot.Person.Email == nil {
break
}
return e.ComplexityRoot.Person.Email(childComplexity), true
case "Person.id":
if e.ComplexityRoot.Person.ID == nil {
break
}
return e.ComplexityRoot.Person.ID(childComplexity), true
case "Person.phone":
if e.ComplexityRoot.Person.Phone == nil {
break
}
return e.ComplexityRoot.Person.Phone(childComplexity), true
case "Product.name":
if e.ComplexityRoot.Product.Name == nil {
break
}
return e.ComplexityRoot.Product.Name(childComplexity), true
case "Product.price":
if e.ComplexityRoot.Product.Price == nil {
break
}
return e.ComplexityRoot.Product.Price(childComplexity), true
case "Product.sku":
if e.ComplexityRoot.Product.Sku == nil {
break
}
return e.ComplexityRoot.Product.Sku(childComplexity), true
case "Query.getBasic":
if e.ComplexityRoot.Query.GetBasic == nil {
break
}
args, err := ec.field_Query_getBasic_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Query.GetBasic(childComplexity, args["id"].(string)), true
case "Query.getPerson":
if e.ComplexityRoot.Query.GetPerson == nil {
break
}
args, err := ec.field_Query_getPerson_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Query.GetPerson(childComplexity, args["id"].(string)), true
case "Query.getProduct":
if e.ComplexityRoot.Query.GetProduct == nil {
break
}
args, err := ec.field_Query_getProduct_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Query.GetProduct(childComplexity, args["sku"].(string)), true
case "Query._service":
if e.ComplexityRoot.Query.__resolve__service == nil {
break
}
return e.ComplexityRoot.Query.__resolve__service(childComplexity), true
case "Query._entities":
if e.ComplexityRoot.Query.__resolve_entities == nil {
break
}
args, err := ec.field_Query__entities_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Query.__resolve_entities(childComplexity, args["representations"].([]map[string]any)), true
case "_Service.sdl":
if e.ComplexityRoot._Service.SDL == nil {
break
}
return e.ComplexityRoot._Service.SDL(childComplexity), true
}
return 0, false
}
func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
opCtx := graphql.GetOperationContext(ctx)
ec := newExecutionContext(opCtx, e, make(chan graphql.DeferredResult))
inputUnmarshalMap := graphql.BuildUnmarshalerMap()
first := true
switch opCtx.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, opCtx.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.ExecutionContextState[ResolverRoot, DirectiveRoot, ComplexityRoot]
}
func newExecutionContext(
opCtx *graphql.OperationContext,
execSchema *executableSchema,
deferredResults chan graphql.DeferredResult,
) executionContext {
return executionContext{
ExecutionContextState: graphql.NewExecutionContextState[ResolverRoot, DirectiveRoot, ComplexityRoot](
opCtx,
(*graphql.ExecutableSchemaState[ResolverRoot, DirectiveRoot, ComplexityRoot])(execSchema),
parsedSchema,
deferredResults,
),
}
}
var sources = []*ast.Source{
{Name: "../schema.graphql", Input: `directive @guard(name: String!) on OBJECT | FIELD_DEFINITION
directive @auth(requires: String!) on OBJECT | FIELD_DEFINITION
type Person @key(fields: "id") @guard(name: "PersonGuard") {
id: String!
email: String!
phone: String!
}
type Product @key(fields: "sku") @auth(requires: "admin") @guard(name: "ProductGuard") {
sku: String!
name: String!
price: Float!
}
# Entity without directives for comparison
type Basic @key(fields: "id") {
id: String!
value: String!
}
type Query {
getPerson(id: String!): Person
getProduct(sku: String!): Product
getBasic(id: String!): Basic
}
`, 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 = Basic | Person | Product
# fake type to build resolver interfaces for users to implement
type Entity {
findBasicByID(id: String!,): Basic!
findPersonByID(id: String!,): Person!
findProductBySku(sku: 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) dir_auth_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "requires", ec.unmarshalNString2string)
if err != nil {
return nil, err
}
args["requires"] = arg0
return args, nil
}
func (ec *executionContext) dir_guard_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
if err != nil {
return nil, err
}
args["name"] = arg0
return args, nil
}
func (ec *executionContext) field_Entity_findBasicByID_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", ec.unmarshalNString2string)
if err != nil {
return nil, err
}
args["id"] = arg0
return args, nil
}
func (ec *executionContext) field_Entity_findPersonByID_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", ec.unmarshalNString2string)
if err != nil {
return nil, err
}
args["id"] = arg0
return args, nil
}
func (ec *executionContext) field_Entity_findProductBySku_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "sku", ec.unmarshalNString2string)
if err != nil {
return nil, err
}
args["sku"] = arg0
return args, nil
}
func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "representations", ec.unmarshalN_Any2ᚕmapᚄ)
if err != nil {
return nil, err
}
args["representations"] = arg0
return args, nil
}
func (ec *executionContext) field_Query_getBasic_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", ec.unmarshalNString2string)
if err != nil {
return nil, err
}
args["id"] = arg0
return args, nil
}
func (ec *executionContext) field_Query_getPerson_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", ec.unmarshalNString2string)
if err != nil {
return nil, err
}
args["id"] = arg0
return args, nil
}
func (ec *executionContext) field_Query_getProduct_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "sku", ec.unmarshalNString2string)
if err != nil {
return nil, err
}
args["sku"] = arg0
return args, nil
}
func (ec *executionContext) field___Directive_args_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2ᚖbool)
if err != nil {
return nil, err
}
args["includeDeprecated"] = arg0
return args, nil
}
func (ec *executionContext) field___Field_args_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2ᚖbool)
if err != nil {
return nil, err
}
args["includeDeprecated"] = arg0
return args, nil
}
func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2bool)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2bool)
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) _Basic_id(ctx context.Context, field graphql.CollectedField, obj *Basic) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Basic_id,
func(ctx context.Context) (any, error) {
return obj.ID, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Basic_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Basic",
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) _Basic_value(ctx context.Context, field graphql.CollectedField, obj *Basic) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Basic_value,
func(ctx context.Context) (any, error) {
return obj.Value, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Basic_value(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Basic",
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_findBasicByID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findBasicByID,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindBasicByID(ctx, fc.Args["id"].(string))
},
nil,
ec.marshalNBasic2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentitydirectivesᚋgeneratedᚐBasic,
true,
true,
)
}
func (ec *executionContext) fieldContext_Entity_findBasicByID(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_Basic_id(ctx, field)
case "value":
return ec.fieldContext_Basic_value(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Basic", 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_findBasicByID_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) _Entity_findPersonByID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findPersonByID,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindPersonByID(ctx, fc.Args["id"].(string))
},
func(ctx context.Context, next graphql.Resolver) graphql.Resolver {
directive0 := next
directive1 := func(ctx context.Context) (any, error) {
name, err := ec.unmarshalNString2string(ctx, "PersonGuard")
if err != nil {
var zeroVal *Person
return zeroVal, err
}
if ec.Directives.Guard == nil {
var zeroVal *Person
return zeroVal, errors.New("directive guard is not implemented")
}
return ec.Directives.Guard(ctx, nil, directive0, name)
}
next = directive1
return next
},
ec.marshalNPerson2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentitydirectivesᚋgeneratedᚐPerson,
true,
true,
)
}
func (ec *executionContext) fieldContext_Entity_findPersonByID(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_Person_id(ctx, field)
case "email":
return ec.fieldContext_Person_email(ctx, field)
case "phone":
return ec.fieldContext_Person_phone(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Person", 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_findPersonByID_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) _Entity_findProductBySku(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findProductBySku,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindProductBySku(ctx, fc.Args["sku"].(string))
},
func(ctx context.Context, next graphql.Resolver) graphql.Resolver {
directive0 := next
directive1 := func(ctx context.Context) (any, error) {
requires, err := ec.unmarshalNString2string(ctx, "admin")
if err != nil {
var zeroVal *Product
return zeroVal, err
}
if ec.Directives.Auth == nil {
var zeroVal *Product
return zeroVal, errors.New("directive auth is not implemented")
}
return ec.Directives.Auth(ctx, nil, directive0, requires)
}
directive2 := func(ctx context.Context) (any, error) {
name, err := ec.unmarshalNString2string(ctx, "ProductGuard")
if err != nil {
var zeroVal *Product
return zeroVal, err
}
if ec.Directives.Guard == nil {
var zeroVal *Product
return zeroVal, errors.New("directive guard is not implemented")
}
return ec.Directives.Guard(ctx, nil, directive1, name)
}
next = directive2
return next
},
ec.marshalNProduct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentitydirectivesᚋgeneratedᚐProduct,
true,
true,
)
}
func (ec *executionContext) fieldContext_Entity_findProductBySku(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 "sku":
return ec.fieldContext_Product_sku(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_findProductBySku_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) _Person_id(ctx context.Context, field graphql.CollectedField, obj *Person) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Person_id,
func(ctx context.Context) (any, error) {
return obj.ID, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Person_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Person",
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) _Person_email(ctx context.Context, field graphql.CollectedField, obj *Person) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Person_email,
func(ctx context.Context) (any, error) {
return obj.Email, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Person_email(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Person",
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) _Person_phone(ctx context.Context, field graphql.CollectedField, obj *Person) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Person_phone,
func(ctx context.Context) (any, error) {
return obj.Phone, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Person_phone(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Person",
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_sku(ctx context.Context, field graphql.CollectedField, obj *Product) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Product_sku,
func(ctx context.Context) (any, error) {
return obj.Sku, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Product_sku(_ 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 *Product) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Product_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Product_name(_ 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 *Product) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Product_price,
func(ctx context.Context) (any, error) {
return obj.Price, nil
},
nil,
ec.marshalNFloat2float64,
true,
true,
)
}
func (ec *executionContext) fieldContext_Product_price(_ 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 Float does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _Query_getPerson(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query_getPerson,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Query().GetPerson(ctx, fc.Args["id"].(string))
},
func(ctx context.Context, next graphql.Resolver) graphql.Resolver {
directive0 := next
directive1 := func(ctx context.Context) (any, error) {
name, err := ec.unmarshalNString2string(ctx, "PersonGuard")
if err != nil {
var zeroVal *Person
return zeroVal, err
}
if ec.Directives.Guard == nil {
var zeroVal *Person
return zeroVal, errors.New("directive guard is not implemented")
}
return ec.Directives.Guard(ctx, nil, directive0, name)
}
next = directive1
return next
},
ec.marshalOPerson2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentitydirectivesᚋgeneratedᚐPerson,
true,
false,
)
}
func (ec *executionContext) fieldContext_Query_getPerson(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_Person_id(ctx, field)
case "email":
return ec.fieldContext_Person_email(ctx, field)
case "phone":
return ec.fieldContext_Person_phone(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Person", 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_getPerson_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) _Query_getProduct(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query_getProduct,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Query().GetProduct(ctx, fc.Args["sku"].(string))
},
func(ctx context.Context, next graphql.Resolver) graphql.Resolver {
directive0 := next
directive1 := func(ctx context.Context) (any, error) {
requires, err := ec.unmarshalNString2string(ctx, "admin")
if err != nil {
var zeroVal *Product
return zeroVal, err
}
if ec.Directives.Auth == nil {
var zeroVal *Product
return zeroVal, errors.New("directive auth is not implemented")
}
return ec.Directives.Auth(ctx, nil, directive0, requires)
}
directive2 := func(ctx context.Context) (any, error) {
name, err := ec.unmarshalNString2string(ctx, "ProductGuard")
if err != nil {
var zeroVal *Product
return zeroVal, err
}
if ec.Directives.Guard == nil {
var zeroVal *Product
return zeroVal, errors.New("directive guard is not implemented")
}
return ec.Directives.Guard(ctx, nil, directive1, name)
}
next = directive2
return next
},
ec.marshalOProduct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentitydirectivesᚋgeneratedᚐProduct,
true,
false,
)
}
func (ec *executionContext) fieldContext_Query_getProduct(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 "sku":
return ec.fieldContext_Product_sku(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_getProduct_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) _Query_getBasic(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query_getBasic,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Query().GetBasic(ctx, fc.Args["id"].(string))
},
nil,
ec.marshalOBasic2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentitydirectivesᚋgeneratedᚐBasic,
true,
false,
)
}
func (ec *executionContext) fieldContext_Query_getBasic(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_Basic_id(ctx, field)
case "value":
return ec.fieldContext_Basic_value(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Basic", 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_getBasic_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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query__entities,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.__resolve_entities(ctx, fc.Args["representations"].([]map[string]any)), nil
},
nil,
ec.marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query__service,
func(ctx context.Context) (any, error) {
return ec.__resolve__service(ctx)
},
nil,
ec.marshalN_Service2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService,
true,
true,
)
}
func (ec *executionContext) fieldContext_Query__service(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query___type,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.IntrospectType(fc.Args["name"].(string))
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query___schema,
func(ctx context.Context) (any, error) {
return ec.IntrospectSchema()
},
nil,
ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema,
true,
false,
)
}
func (ec *executionContext) fieldContext_Query___schema(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext__Service_sdl,
func(ctx context.Context) (any, error) {
return obj.SDL, nil
},
nil,
ec.marshalOString2string,
true,
false,
)
}
func (ec *executionContext) fieldContext__Service_sdl(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Directive_description(_ 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_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_isRepeatable,
func(ctx context.Context) (any, error) {
return obj.IsRepeatable, nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_isRepeatable(_ 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) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_locations,
func(ctx context.Context) (any, error) {
return obj.Locations, nil
},
nil,
ec.marshalN__DirectiveLocation2ᚕstringᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_locations(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_args,
func(ctx context.Context) (any, error) {
return obj.Args, nil
},
nil,
ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
true,
)
}
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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __InputValue", 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___Directive_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___EnumValue_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___EnumValue_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___EnumValue_isDeprecated(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___EnumValue_deprecationReason(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Field_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_args,
func(ctx context.Context) (any, error) {
return obj.Args, nil
},
nil,
ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
true,
)
}
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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __InputValue", 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___Field_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_type,
func(ctx context.Context) (any, error) {
return obj.Type, nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_type(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_isDeprecated(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Field_deprecationReason(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_type,
func(ctx context.Context) (any, error) {
return obj.Type, nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_type(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_defaultValue,
func(ctx context.Context) (any, error) {
return obj.DefaultValue, nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_defaultValue(_ 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_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_isDeprecated(_ 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 Boolean does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) ___InputValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_deprecationReason(_ 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) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_types,
func(ctx context.Context) (any, error) {
return obj.Types(), nil
},
nil,
ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_types(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_queryType,
func(ctx context.Context) (any, error) {
return obj.QueryType(), nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_queryType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_mutationType,
func(ctx context.Context) (any, error) {
return obj.MutationType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_mutationType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_subscriptionType,
func(ctx context.Context) (any, error) {
return obj.SubscriptionType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_subscriptionType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_directives,
func(ctx context.Context) (any, error) {
return obj.Directives(), nil
},
nil,
ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_directives(_ 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 "isRepeatable":
return ec.fieldContext___Directive_isRepeatable(ctx, field)
case "locations":
return ec.fieldContext___Directive_locations(ctx, field)
case "args":
return ec.fieldContext___Directive_args(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_kind,
func(ctx context.Context) (any, error) {
return obj.Kind(), nil
},
nil,
ec.marshalN__TypeKind2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Type_kind(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_name,
func(ctx context.Context) (any, error) {
return obj.Name(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_description(_ 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_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_specifiedByURL,
func(ctx context.Context) (any, error) {
return obj.SpecifiedByURL(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_specifiedByURL(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_fields,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil
},
nil,
ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_interfaces,
func(ctx context.Context) (any, error) {
return obj.Interfaces(), nil
},
nil,
ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_interfaces(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_possibleTypes,
func(ctx context.Context) (any, error) {
return obj.PossibleTypes(), nil
},
nil,
ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_possibleTypes(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_enumValues,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil
},
nil,
ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_inputFields,
func(ctx context.Context) (any, error) {
return obj.InputFields(), nil
},
nil,
ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_inputFields(_ 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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_ofType,
func(ctx context.Context) (any, error) {
return obj.OfType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_ofType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) ___Type_isOneOf(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_isOneOf,
func(ctx context.Context) (any, error) {
return obj.IsOneOf(), nil
},
nil,
ec.marshalOBoolean2bool,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_isOneOf(_ 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 Boolean 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 Product:
return ec._Product(ctx, sel, &obj)
case *Product:
if obj == nil {
return graphql.Null
}
return ec._Product(ctx, sel, obj)
case Person:
return ec._Person(ctx, sel, &obj)
case *Person:
if obj == nil {
return graphql.Null
}
return ec._Person(ctx, sel, obj)
case Basic:
return ec._Basic(ctx, sel, &obj)
case *Basic:
if obj == nil {
return graphql.Null
}
return ec._Basic(ctx, sel, obj)
default:
if typedObj, ok := obj.(graphql.Marshaler); ok {
return typedObj
} else {
panic(fmt.Errorf("unexpected type %T; non-generated variants of _Entity must implement graphql.Marshaler", obj))
}
}
}
// endregion ************************** interface.gotpl ***************************
// region **************************** object.gotpl ****************************
var basicImplementors = []string{"Basic", "_Entity"}
func (ec *executionContext) _Basic(ctx context.Context, sel ast.SelectionSet, obj *Basic) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, basicImplementors)
out := graphql.NewFieldSet(fields)
deferred := make(map[string]*graphql.FieldSet)
for i, field := range fields {
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Basic")
case "id":
out.Values[i] = ec._Basic_id(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "value":
out.Values[i] = ec._Basic_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 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 "findBasicByID":
field := field
innerFunc := func(ctx 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_findBasicByID(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 "findPersonByID":
field := field
innerFunc := func(ctx 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_findPersonByID(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 "findProductBySku":
field := field
innerFunc := func(ctx 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_findProductBySku(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 personImplementors = []string{"Person", "_Entity"}
func (ec *executionContext) _Person(ctx context.Context, sel ast.SelectionSet, obj *Person) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, personImplementors)
out := graphql.NewFieldSet(fields)
deferred := make(map[string]*graphql.FieldSet)
for i, field := range fields {
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Person")
case "id":
out.Values[i] = ec._Person_id(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "email":
out.Values[i] = ec._Person_email(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "phone":
out.Values[i] = ec._Person_phone(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 *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 "sku":
out.Values[i] = ec._Product_sku(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 "getPerson":
field := field
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._Query_getPerson(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 "getProduct":
field := field
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._Query_getProduct(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 "getBasic":
field := field
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = ec._Query_getBasic(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 "isRepeatable":
out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
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++
}
default:
panic("unknown field " + strconv.Quote(field.Name))
}
}
out.Dispatch(ctx)
if out.Invalids > 0 {
return graphql.Null
}
atomic.AddInt32(&ec.Deferred, int32(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)
case "isDeprecated":
out.Values[i] = ec.___InputValue_isDeprecated(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "deprecationReason":
out.Values[i] = ec.___InputValue_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 __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 "specifiedByURL":
out.Values[i] = ec.___Type_specifiedByURL(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 "isOneOf":
out.Values[i] = ec.___Type_isOneOf(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) marshalNBasic2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentitydirectivesᚋgeneratedᚐBasic(ctx context.Context, sel ast.SelectionSet, v Basic) graphql.Marshaler {
return ec._Basic(ctx, sel, &v)
}
func (ec *executionContext) marshalNBasic2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentitydirectivesᚋgeneratedᚐBasic(ctx context.Context, sel ast.SelectionSet, v *Basic) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return ec._Basic(ctx, sel, v)
}
func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v any) (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 {
_ = sel
res := graphql.MarshalBoolean(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalNFloat2float64(ctx context.Context, v any) (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 {
_ = sel
res := graphql.MarshalFloatContext(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return graphql.WrapContextMarshaler(ctx, res)
}
func (ec *executionContext) marshalNPerson2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentitydirectivesᚋgeneratedᚐPerson(ctx context.Context, sel ast.SelectionSet, v Person) graphql.Marshaler {
return ec._Person(ctx, sel, &v)
}
func (ec *executionContext) marshalNPerson2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentitydirectivesᚋgeneratedᚐPerson(ctx context.Context, sel ast.SelectionSet, v *Person) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return ec._Person(ctx, sel, v)
}
func (ec *executionContext) marshalNProduct2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentitydirectivesᚋgeneratedᚐProduct(ctx context.Context, sel ast.SelectionSet, v Product) graphql.Marshaler {
return ec._Product(ctx, sel, &v)
}
func (ec *executionContext) marshalNProduct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentitydirectivesᚋgeneratedᚐProduct(ctx context.Context, sel ast.SelectionSet, v *Product) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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 any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalN_Any2map(ctx context.Context, v any) (map[string]any, 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]any) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
_ = sel
res := graphql.MarshalMap(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalN_Any2ᚕmapᚄ(ctx context.Context, v any) ([]map[string]any, error) {
var vSlice []any
vSlice = graphql.CoerceList(v)
var err error
res := make([]map[string]any, 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]any) 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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v []fedruntime.Entity) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalO_Entity2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, sel, v[i])
})
return ret
}
func (ec *executionContext) unmarshalN_FieldSet2string(ctx context.Context, v any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) marshalN_Service2githubᚗcomᚋ99designsᚋ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ᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler {
return ec.___Directive(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v any) ([]string, error) {
var vSlice []any
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 := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__DirectiveLocation2string(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler {
return ec.___EnumValue(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler {
return ec.___Field(ctx, sel, &v)
}
func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler {
return ec.___InputValue(ctx, sel, &v)
}
func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler {
return ec.___Type(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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 any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) marshalOBasic2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentitydirectivesᚋgeneratedᚐBasic(ctx context.Context, sel ast.SelectionSet, v *Basic) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._Basic(ctx, sel, v)
}
func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v any) (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 {
_ = sel
_ = ctx
res := graphql.MarshalBoolean(v)
return res
}
func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v any) (*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
}
_ = sel
_ = ctx
res := graphql.MarshalBoolean(*v)
return res
}
func (ec *executionContext) marshalOPerson2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentitydirectivesᚋgeneratedᚐPerson(ctx context.Context, sel ast.SelectionSet, v *Person) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._Person(ctx, sel, v)
}
func (ec *executionContext) marshalOProduct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentitydirectivesᚋgeneratedᚐProduct(ctx context.Context, sel ast.SelectionSet, v *Product) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._Product(ctx, sel, v)
}
func (ec *executionContext) unmarshalOString2string(ctx context.Context, v any) (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 {
_ = sel
_ = ctx
res := graphql.MarshalString(v)
return res
}
func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v any) (*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
}
_ = sel
_ = ctx
res := graphql.MarshalString(*v)
return res
}
func (ec *executionContext) marshalO_Entity2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v fedruntime.Entity) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec.__Entity(ctx, sel, v)
}
func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec.___Schema(ctx, sel, v)
}
func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec.___Type(ctx, sel, v)
}
// endregion ***************************** type.gotpl *****************************
================================================
FILE: plugin/federation/testdata/entitydirectives/generated/federation.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package generated
import (
"context"
"errors"
"fmt"
"strings"
"sync"
"github.com/99designs/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]any) []fedruntime.Entity {
list := make([]fedruntime.Entity, len(representations))
repsMap := ec.buildRepresentationGroups(ctx, representations)
switch len(repsMap) {
case 0:
return list
case 1:
for typeName, reps := range repsMap {
ec.resolveEntityGroup(ctx, typeName, reps, list)
}
return list
default:
var g sync.WaitGroup
g.Add(len(repsMap))
for typeName, reps := range repsMap {
go func(typeName string, reps []EntityWithIndex) {
ec.resolveEntityGroup(ctx, typeName, reps, list)
g.Done()
}(typeName, reps)
}
g.Wait()
return list
}
}
type EntityWithIndex struct {
// The index in the original representation array
index int
entity EntityRepresentation
}
// EntityRepresentation is the JSON representation of an entity sent by the Router
// used as the inputs for us to resolve.
//
// We make it a map because we know the top level JSON is always an object.
type EntityRepresentation map[string]any
// We group entities by typename so that we can parallelize their resolution.
// This is particularly helpful when there are entity groups in multi mode.
func (ec *executionContext) buildRepresentationGroups(
ctx context.Context,
representations []map[string]any,
) map[string][]EntityWithIndex {
repsMap := make(map[string][]EntityWithIndex)
for i, rep := range representations {
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
}
repsMap[typeName] = append(repsMap[typeName], EntityWithIndex{
index: i,
entity: rep,
})
}
return repsMap
}
func (ec *executionContext) resolveEntityGroup(
ctx context.Context,
typeName string,
reps []EntityWithIndex,
list []fedruntime.Entity,
) {
if isMulti(typeName) {
err := ec.resolveManyEntities(ctx, typeName, reps, list)
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 EntityWithIndex) {
entity, err := ec.resolveEntity(ctx, typeName, rep.entity)
if err != nil {
ec.Error(ctx, err)
} else {
list[rep.index] = entity
}
e.Done()
}(i, rep)
}
e.Wait()
}
}
func isMulti(typeName string) bool {
switch typeName {
default:
return false
}
}
func (ec *executionContext) resolveEntity(
ctx context.Context,
typeName string,
rep EntityRepresentation,
) (e fedruntime.Entity, 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 "Basic":
resolverName, err := entityResolverNameForBasic(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "Basic": %w`, err)
}
switch resolverName {
case "findBasicByID":
id0, err := ec.unmarshalNString2string(ctx, rep["id"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findBasicByID(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindBasicByID(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "Basic": %w`, err)
}
return entity, nil
}
case "Person":
resolverName, err := entityResolverNameForPerson(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "Person": %w`, err)
}
switch resolverName {
case "findPersonByID":
id0, err := ec.unmarshalNString2string(ctx, rep["id"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findPersonByID(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindPersonByID(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "Person": %w`, err)
}
return entity, nil
}
case "Product":
resolverName, err := entityResolverNameForProduct(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "Product": %w`, err)
}
switch resolverName {
case "findProductBySku":
id0, err := ec.unmarshalNString2string(ctx, rep["sku"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findProductBySku(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindProductBySku(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "Product": %w`, err)
}
return entity, nil
}
}
return nil, fmt.Errorf("%w: %s", ErrUnknownType, typeName)
}
func (ec *executionContext) resolveManyEntities(
ctx context.Context,
typeName string,
reps []EntityWithIndex,
list []fedruntime.Entity,
) (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)
}
}
func entityResolverNameForBasic(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["id"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"id\" for Basic", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for Basic", ErrTypeNotFound))
break
}
return "findBasicByID", nil
}
return "", fmt.Errorf("%w for Basic due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForPerson(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["id"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"id\" for Person", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for Person", ErrTypeNotFound))
break
}
return "findPersonByID", nil
}
return "", fmt.Errorf("%w for Person due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForProduct(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["sku"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"sku\" for Product", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for Product", ErrTypeNotFound))
break
}
return "findProductBySku", nil
}
return "", fmt.Errorf("%w for Product due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
================================================
FILE: plugin/federation/testdata/entitydirectives/generated/models_gen.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package generated
type Basic struct {
ID string `json:"id"`
Value string `json:"value"`
}
func (Basic) IsEntity() {}
type Person struct {
ID string `json:"id"`
Email string `json:"email"`
Phone string `json:"phone"`
}
func (Person) IsEntity() {}
type Product struct {
Sku string `json:"sku"`
Name string `json:"name"`
Price float64 `json:"price"`
}
func (Product) IsEntity() {}
type Query struct {
}
================================================
FILE: plugin/federation/testdata/entitydirectives/gqlgen.yml
================================================
schema:
- "testdata/entitydirectives/schema.graphql"
exec:
filename: testdata/entitydirectives/generated/exec.go
model:
filename: testdata/entitydirectives/generated/models_gen.go
federation:
filename: testdata/entitydirectives/generated/federation.go
version: 1
models:
_FieldSet:
model: github.com/99designs/gqlgen/graphql.String
directives:
guard:
skip_runtime: false
auth:
skip_runtime: false
================================================
FILE: plugin/federation/testdata/entitydirectives/schema.graphql
================================================
directive @guard(name: String!) on OBJECT | FIELD_DEFINITION
directive @auth(requires: String!) on OBJECT | FIELD_DEFINITION
type Person @key(fields: "id") @guard(name: "PersonGuard") {
id: String!
email: String!
phone: String!
}
type Product @key(fields: "sku") @auth(requires: "admin") @guard(name: "ProductGuard") {
sku: String!
name: String!
price: Float!
}
# Entity without directives for comparison
type Basic @key(fields: "id") {
id: String!
value: String!
}
type Query {
getPerson(id: String!): Person
getProduct(sku: String!): Product
getBasic(id: String!): Basic
}
================================================
FILE: plugin/federation/testdata/entityinterfaces/generated/exec.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package generated
import (
"bytes"
"context"
"errors"
"fmt"
"strconv"
"sync/atomic"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/introspection"
"github.com/99designs/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{SchemaData: cfg.Schema, Resolvers: cfg.Resolvers, Directives: cfg.Directives, ComplexityRoot: cfg.Complexity}
}
type Config = graphql.Config[ResolverRoot, DirectiveRoot, 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]any) 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 graphql.ExecutableSchemaState[ResolverRoot, DirectiveRoot, ComplexityRoot]
func (e *executableSchema) Schema() *ast.Schema {
if e.SchemaData != nil {
return e.SchemaData
}
return parsedSchema
}
func (e *executableSchema) Complexity(ctx context.Context, typeName, field string, childComplexity int, rawArgs map[string]any) (int, bool) {
ec := newExecutionContext(nil, e, nil)
_ = ec
switch typeName + "." + field {
case "Entity.findHelloByID":
if e.ComplexityRoot.Entity.FindHelloByID == nil {
break
}
args, err := ec.field_Entity_findHelloByID_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindHelloByID(childComplexity, args["id"].(string)), true
case "Entity.findWorldByID":
if e.ComplexityRoot.Entity.FindWorldByID == nil {
break
}
args, err := ec.field_Entity_findWorldByID_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindWorldByID(childComplexity, args["id"].(string)), true
case "Query._service":
if e.ComplexityRoot.Query.__resolve__service == nil {
break
}
return e.ComplexityRoot.Query.__resolve__service(childComplexity), true
case "Query._entities":
if e.ComplexityRoot.Query.__resolve_entities == nil {
break
}
args, err := ec.field_Query__entities_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Query.__resolve_entities(childComplexity, args["representations"].([]map[string]any)), true
case "World.id":
if e.ComplexityRoot.World.ID == nil {
break
}
return e.ComplexityRoot.World.ID(childComplexity), true
case "World.title":
if e.ComplexityRoot.World.Title == nil {
break
}
return e.ComplexityRoot.World.Title(childComplexity), true
case "_Service.sdl":
if e.ComplexityRoot._Service.SDL == nil {
break
}
return e.ComplexityRoot._Service.SDL(childComplexity), true
}
return 0, false
}
func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
opCtx := graphql.GetOperationContext(ctx)
ec := newExecutionContext(opCtx, e, make(chan graphql.DeferredResult))
inputUnmarshalMap := graphql.BuildUnmarshalerMap()
first := true
switch opCtx.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, opCtx.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.ExecutionContextState[ResolverRoot, DirectiveRoot, ComplexityRoot]
}
func newExecutionContext(
opCtx *graphql.OperationContext,
execSchema *executableSchema,
deferredResults chan graphql.DeferredResult,
) executionContext {
return executionContext{
ExecutionContextState: graphql.NewExecutionContextState[ResolverRoot, DirectiveRoot, ComplexityRoot](
opCtx,
(*graphql.ExecutableSchemaState[ResolverRoot, DirectiveRoot, ComplexityRoot])(execSchema),
parsedSchema,
deferredResults,
),
}
}
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!, label: String) on FIELD_DEFINITION
directive @policy(policies: [[federation__Policy!]!]!) on
| FIELD_DEFINITION
| OBJECT
| INTERFACE
| SCALAR
| ENUM
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__Policy
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "representations", ec.unmarshalN_Any2ᚕmapᚄ)
if err != nil {
return nil, err
}
args["representations"] = arg0
return args, nil
}
func (ec *executionContext) field___Directive_args_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2ᚖbool)
if err != nil {
return nil, err
}
args["includeDeprecated"] = arg0
return args, nil
}
func (ec *executionContext) field___Field_args_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2ᚖbool)
if err != nil {
return nil, err
}
args["includeDeprecated"] = arg0
return args, nil
}
func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2bool)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2bool)
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findHelloByID,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindHelloByID(ctx, fc.Args["id"].(string))
},
nil,
ec.marshalNHello2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityinterfacesᚋgeneratedᚐHello,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findWorldByID,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindWorldByID(ctx, fc.Args["id"].(string))
},
nil,
ec.marshalNWorld2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityinterfacesᚋgeneratedᚐWorld,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query__entities,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.__resolve_entities(ctx, fc.Args["representations"].([]map[string]any)), nil
},
nil,
ec.marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query__service,
func(ctx context.Context) (any, error) {
return ec.__resolve__service(ctx)
},
nil,
ec.marshalN_Service2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService,
true,
true,
)
}
func (ec *executionContext) fieldContext_Query__service(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query___type,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.IntrospectType(fc.Args["name"].(string))
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query___schema,
func(ctx context.Context) (any, error) {
return ec.IntrospectSchema()
},
nil,
ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema,
true,
false,
)
}
func (ec *executionContext) fieldContext_Query___schema(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_World_id,
func(ctx context.Context) (any, error) {
return obj.ID, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_World_id(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_World_title,
func(ctx context.Context) (any, error) {
return obj.Title, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_World_title(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext__Service_sdl,
func(ctx context.Context) (any, error) {
return obj.SDL, nil
},
nil,
ec.marshalOString2string,
true,
false,
)
}
func (ec *executionContext) fieldContext__Service_sdl(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Directive_description(_ 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_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_isRepeatable,
func(ctx context.Context) (any, error) {
return obj.IsRepeatable, nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_isRepeatable(_ 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) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_locations,
func(ctx context.Context) (any, error) {
return obj.Locations, nil
},
nil,
ec.marshalN__DirectiveLocation2ᚕstringᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_locations(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_args,
func(ctx context.Context) (any, error) {
return obj.Args, nil
},
nil,
ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
true,
)
}
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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __InputValue", 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___Directive_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___EnumValue_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___EnumValue_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___EnumValue_isDeprecated(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___EnumValue_deprecationReason(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Field_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_args,
func(ctx context.Context) (any, error) {
return obj.Args, nil
},
nil,
ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
true,
)
}
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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __InputValue", 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___Field_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_type,
func(ctx context.Context) (any, error) {
return obj.Type, nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_type(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_isDeprecated(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Field_deprecationReason(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_type,
func(ctx context.Context) (any, error) {
return obj.Type, nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_type(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_defaultValue,
func(ctx context.Context) (any, error) {
return obj.DefaultValue, nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_defaultValue(_ 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_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_isDeprecated(_ 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 Boolean does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) ___InputValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_deprecationReason(_ 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) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_types,
func(ctx context.Context) (any, error) {
return obj.Types(), nil
},
nil,
ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_types(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_queryType,
func(ctx context.Context) (any, error) {
return obj.QueryType(), nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_queryType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_mutationType,
func(ctx context.Context) (any, error) {
return obj.MutationType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_mutationType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_subscriptionType,
func(ctx context.Context) (any, error) {
return obj.SubscriptionType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_subscriptionType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_directives,
func(ctx context.Context) (any, error) {
return obj.Directives(), nil
},
nil,
ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_directives(_ 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 "isRepeatable":
return ec.fieldContext___Directive_isRepeatable(ctx, field)
case "locations":
return ec.fieldContext___Directive_locations(ctx, field)
case "args":
return ec.fieldContext___Directive_args(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_kind,
func(ctx context.Context) (any, error) {
return obj.Kind(), nil
},
nil,
ec.marshalN__TypeKind2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Type_kind(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_name,
func(ctx context.Context) (any, error) {
return obj.Name(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_description(_ 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_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_specifiedByURL,
func(ctx context.Context) (any, error) {
return obj.SpecifiedByURL(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_specifiedByURL(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_fields,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil
},
nil,
ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_interfaces,
func(ctx context.Context) (any, error) {
return obj.Interfaces(), nil
},
nil,
ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_interfaces(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_possibleTypes,
func(ctx context.Context) (any, error) {
return obj.PossibleTypes(), nil
},
nil,
ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_possibleTypes(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_enumValues,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil
},
nil,
ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_inputFields,
func(ctx context.Context) (any, error) {
return obj.InputFields(), nil
},
nil,
ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_inputFields(_ 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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_ofType,
func(ctx context.Context) (any, error) {
return obj.OfType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_ofType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) ___Type_isOneOf(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_isOneOf,
func(ctx context.Context) (any, error) {
return obj.IsOneOf(), nil
},
nil,
ec.marshalOBoolean2bool,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_isOneOf(_ 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 Boolean 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:
if typedObj, ok := obj.(graphql.Marshaler); ok {
return typedObj
} else {
panic(fmt.Errorf("unexpected type %T; non-generated variants of Hello must implement graphql.Marshaler", 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:
if typedObj, ok := obj.(graphql.Marshaler); ok {
return typedObj
} else {
panic(fmt.Errorf("unexpected type %T; non-generated variants of _Entity must implement graphql.Marshaler", 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 "isRepeatable":
out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
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++
}
default:
panic("unknown field " + strconv.Quote(field.Name))
}
}
out.Dispatch(ctx)
if out.Invalids > 0 {
return graphql.Null
}
atomic.AddInt32(&ec.Deferred, int32(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)
case "isDeprecated":
out.Values[i] = ec.___InputValue_isDeprecated(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "deprecationReason":
out.Values[i] = ec.___InputValue_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 __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 "specifiedByURL":
out.Values[i] = ec.___Type_specifiedByURL(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 "isOneOf":
out.Values[i] = ec.___Type_isOneOf(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 any) (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 {
_ = sel
res := graphql.MarshalBoolean(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalNFieldSet2string(ctx context.Context, v any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) marshalNHello2githubᚗcomᚋ99designsᚋ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)) {
graphql.AddErrorf(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 any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) marshalNWorld2githubᚗcomᚋ99designsᚋ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ᚋ99designsᚋ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)) {
graphql.AddErrorf(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 any) (map[string]any, 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]any) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
_ = sel
res := graphql.MarshalMap(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalN_Any2ᚕmapᚄ(ctx context.Context, v any) ([]map[string]any, error) {
var vSlice []any
vSlice = graphql.CoerceList(v)
var err error
res := make([]map[string]any, 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]any) 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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v []fedruntime.Entity) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalO_Entity2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, sel, v[i])
})
return ret
}
func (ec *executionContext) marshalN_Service2githubᚗcomᚋ99designsᚋ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ᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler {
return ec.___Directive(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v any) ([]string, error) {
var vSlice []any
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 := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__DirectiveLocation2string(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler {
return ec.___EnumValue(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler {
return ec.___Field(ctx, sel, &v)
}
func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler {
return ec.___InputValue(ctx, sel, &v)
}
func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler {
return ec.___Type(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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 any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalNfederation__Policy2string(ctx context.Context, v any) (string, error) {
res, err := graphql.UnmarshalString(v)
return res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalNfederation__Policy2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalNfederation__Policy2ᚕstringᚄ(ctx context.Context, v any) ([]string, error) {
var vSlice []any
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__Policy2string(ctx, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil
}
func (ec *executionContext) marshalNfederation__Policy2ᚕ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__Policy2string(ctx, sel, v[i])
}
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) unmarshalNfederation__Policy2ᚕᚕstringᚄ(ctx context.Context, v any) ([][]string, error) {
var vSlice []any
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__Policy2ᚕstringᚄ(ctx, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil
}
func (ec *executionContext) marshalNfederation__Policy2ᚕᚕ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__Policy2ᚕstringᚄ(ctx, sel, v[i])
}
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) unmarshalNfederation__Scope2string(ctx context.Context, v any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalNfederation__Scope2ᚕstringᚄ(ctx context.Context, v any) ([]string, error) {
var vSlice []any
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 any) ([][]string, error) {
var vSlice []any
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 any) (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 {
_ = sel
_ = ctx
res := graphql.MarshalBoolean(v)
return res
}
func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v any) (*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
}
_ = sel
_ = ctx
res := graphql.MarshalBoolean(*v)
return res
}
func (ec *executionContext) unmarshalOString2string(ctx context.Context, v any) (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 {
_ = sel
_ = ctx
res := graphql.MarshalString(v)
return res
}
func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v any) ([]string, error) {
if v == nil {
return nil, nil
}
var vSlice []any
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 any) (*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
}
_ = sel
_ = ctx
res := graphql.MarshalString(*v)
return res
}
func (ec *executionContext) marshalO_Entity2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v fedruntime.Entity) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec.__Entity(ctx, sel, v)
}
func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec.___Schema(ctx, sel, v)
}
func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec.___Type(ctx, sel, v)
}
// endregion ***************************** type.gotpl *****************************
================================================
FILE: plugin/federation/testdata/entityinterfaces/generated/federation.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package generated
import (
"context"
"errors"
"fmt"
"strings"
"sync"
"github.com/99designs/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]any) []fedruntime.Entity {
list := make([]fedruntime.Entity, len(representations))
repsMap := ec.buildRepresentationGroups(ctx, representations)
switch len(repsMap) {
case 0:
return list
case 1:
for typeName, reps := range repsMap {
ec.resolveEntityGroup(ctx, typeName, reps, list)
}
return list
default:
var g sync.WaitGroup
g.Add(len(repsMap))
for typeName, reps := range repsMap {
go func(typeName string, reps []EntityWithIndex) {
ec.resolveEntityGroup(ctx, typeName, reps, list)
g.Done()
}(typeName, reps)
}
g.Wait()
return list
}
}
type EntityWithIndex struct {
// The index in the original representation array
index int
entity EntityRepresentation
}
// EntityRepresentation is the JSON representation of an entity sent by the Router
// used as the inputs for us to resolve.
//
// We make it a map because we know the top level JSON is always an object.
type EntityRepresentation map[string]any
// We group entities by typename so that we can parallelize their resolution.
// This is particularly helpful when there are entity groups in multi mode.
func (ec *executionContext) buildRepresentationGroups(
ctx context.Context,
representations []map[string]any,
) map[string][]EntityWithIndex {
repsMap := make(map[string][]EntityWithIndex)
for i, rep := range representations {
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
}
repsMap[typeName] = append(repsMap[typeName], EntityWithIndex{
index: i,
entity: rep,
})
}
return repsMap
}
func (ec *executionContext) resolveEntityGroup(
ctx context.Context,
typeName string,
reps []EntityWithIndex,
list []fedruntime.Entity,
) {
if isMulti(typeName) {
err := ec.resolveManyEntities(ctx, typeName, reps, list)
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 EntityWithIndex) {
entity, err := ec.resolveEntity(ctx, typeName, rep.entity)
if err != nil {
ec.Error(ctx, err)
} else {
list[rep.index] = entity
}
e.Done()
}(i, rep)
}
e.Wait()
}
}
func isMulti(typeName string) bool {
switch typeName {
default:
return false
}
}
func (ec *executionContext) resolveEntity(
ctx context.Context,
typeName string,
rep EntityRepresentation,
) (e fedruntime.Entity, 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 nil, fmt.Errorf(`finding resolver for Entity "Hello": %w`, err)
}
switch resolverName {
case "findHelloByID":
id0, err := ec.unmarshalNString2string(ctx, rep["id"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findHelloByID(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindHelloByID(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "Hello": %w`, err)
}
return entity, nil
}
case "World":
resolverName, err := entityResolverNameForWorld(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "World": %w`, err)
}
switch resolverName {
case "findWorldByID":
id0, err := ec.unmarshalNString2string(ctx, rep["id"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findWorldByID(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindWorldByID(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "World": %w`, err)
}
return entity, nil
}
}
return nil, fmt.Errorf("%w: %s", ErrUnknownType, typeName)
}
func (ec *executionContext) resolveManyEntities(
ctx context.Context,
typeName string,
reps []EntityWithIndex,
list []fedruntime.Entity,
) (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)
}
}
func entityResolverNameForHello(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["id"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"id\" for Hello", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for Hello", ErrTypeNotFound))
break
}
return "findHelloByID", nil
}
return "", fmt.Errorf("%w for Hello due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForWorld(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["id"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"id\" for World", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for World", ErrTypeNotFound))
break
}
return "findWorldByID", nil
}
return "", fmt.Errorf("%w for World due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
================================================
FILE: plugin/federation/testdata/entityinterfaces/generated/models_gen.go
================================================
// Code generated by github.com/99designs/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() {}
================================================
FILE: plugin/federation/testdata/entityinterfaces/interface.graphql
================================================
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!
}
================================================
FILE: plugin/federation/testdata/entityinterfaces/interface.yml
================================================
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
================================================
FILE: plugin/federation/testdata/entityresolver/entity.resolvers.go
================================================
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/99designs/gqlgen version v0.17.88-dev
import (
"context"
"fmt"
"github.com/99designs/gqlgen/plugin/federation/testdata/entityresolver/generated"
"github.com/99designs/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,
Bar: FindWorldWithMultipleKeysByHelloNameAndFooBarValue,
}, 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 }
================================================
FILE: plugin/federation/testdata/entityresolver/generated/errors.go
================================================
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")
)
================================================
FILE: plugin/federation/testdata/entityresolver/generated/exec.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package generated
import (
"bytes"
"context"
"errors"
"fmt"
"strconv"
"sync/atomic"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/introspection"
"github.com/99designs/gqlgen/plugin/federation/fedruntime"
"github.com/99designs/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{SchemaData: cfg.Schema, Resolvers: cfg.Resolvers, Directives: cfg.Directives, ComplexityRoot: cfg.Complexity}
}
type Config = graphql.Config[ResolverRoot, DirectiveRoot, ComplexityRoot]
type ResolverRoot interface {
Entity() EntityResolver
}
type DirectiveRoot struct {
}
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]any) 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 graphql.ExecutableSchemaState[ResolverRoot, DirectiveRoot, ComplexityRoot]
func (e *executableSchema) Schema() *ast.Schema {
if e.SchemaData != nil {
return e.SchemaData
}
return parsedSchema
}
func (e *executableSchema) Complexity(ctx context.Context, typeName, field string, childComplexity int, rawArgs map[string]any) (int, bool) {
ec := newExecutionContext(nil, e, nil)
_ = ec
switch typeName + "." + field {
case "Entity.findHelloByName":
if e.ComplexityRoot.Entity.FindHelloByName == nil {
break
}
args, err := ec.field_Entity_findHelloByName_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindHelloByName(childComplexity, args["name"].(string)), true
case "Entity.findHelloMultiSingleKeysByKey1AndKey2":
if e.ComplexityRoot.Entity.FindHelloMultiSingleKeysByKey1AndKey2 == nil {
break
}
args, err := ec.field_Entity_findHelloMultiSingleKeysByKey1AndKey2_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindHelloMultiSingleKeysByKey1AndKey2(childComplexity, args["key1"].(string), args["key2"].(string)), true
case "Entity.findHelloWithErrorsByName":
if e.ComplexityRoot.Entity.FindHelloWithErrorsByName == nil {
break
}
args, err := ec.field_Entity_findHelloWithErrorsByName_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindHelloWithErrorsByName(childComplexity, args["name"].(string)), true
case "Entity.findManyMultiHelloByNames":
if e.ComplexityRoot.Entity.FindManyMultiHelloByNames == nil {
break
}
args, err := ec.field_Entity_findManyMultiHelloByNames_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindManyMultiHelloByNames(childComplexity, args["reps"].([]*model.MultiHelloByNamesInput)), true
case "Entity.findManyMultiHelloMultipleRequiresByNames":
if e.ComplexityRoot.Entity.FindManyMultiHelloMultipleRequiresByNames == nil {
break
}
args, err := ec.field_Entity_findManyMultiHelloMultipleRequiresByNames_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindManyMultiHelloMultipleRequiresByNames(childComplexity, args["reps"].([]*model.MultiHelloMultipleRequiresByNamesInput)), true
case "Entity.findManyMultiHelloRequiresByNames":
if e.ComplexityRoot.Entity.FindManyMultiHelloRequiresByNames == nil {
break
}
args, err := ec.field_Entity_findManyMultiHelloRequiresByNames_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindManyMultiHelloRequiresByNames(childComplexity, args["reps"].([]*model.MultiHelloRequiresByNamesInput)), true
case "Entity.findManyMultiHelloWithErrorByNames":
if e.ComplexityRoot.Entity.FindManyMultiHelloWithErrorByNames == nil {
break
}
args, err := ec.field_Entity_findManyMultiHelloWithErrorByNames_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindManyMultiHelloWithErrorByNames(childComplexity, args["reps"].([]*model.MultiHelloWithErrorByNamesInput)), true
case "Entity.findManyMultiPlanetRequiresNestedByNames":
if e.ComplexityRoot.Entity.FindManyMultiPlanetRequiresNestedByNames == nil {
break
}
args, err := ec.field_Entity_findManyMultiPlanetRequiresNestedByNames_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindManyMultiPlanetRequiresNestedByNames(childComplexity, args["reps"].([]*model.MultiPlanetRequiresNestedByNamesInput)), true
case "Entity.findPlanetMultipleRequiresByName":
if e.ComplexityRoot.Entity.FindPlanetMultipleRequiresByName == nil {
break
}
args, err := ec.field_Entity_findPlanetMultipleRequiresByName_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindPlanetMultipleRequiresByName(childComplexity, args["name"].(string)), true
case "Entity.findPlanetRequiresByName":
if e.ComplexityRoot.Entity.FindPlanetRequiresByName == nil {
break
}
args, err := ec.field_Entity_findPlanetRequiresByName_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindPlanetRequiresByName(childComplexity, args["name"].(string)), true
case "Entity.findPlanetRequiresNestedByName":
if e.ComplexityRoot.Entity.FindPlanetRequiresNestedByName == nil {
break
}
args, err := ec.field_Entity_findPlanetRequiresNestedByName_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindPlanetRequiresNestedByName(childComplexity, args["name"].(string)), true
case "Entity.findWorldByHelloNameAndFoo":
if e.ComplexityRoot.Entity.FindWorldByHelloNameAndFoo == nil {
break
}
args, err := ec.field_Entity_findWorldByHelloNameAndFoo_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindWorldByHelloNameAndFoo(childComplexity, args["helloName"].(string), args["foo"].(string)), true
case "Entity.findWorldNameByName":
if e.ComplexityRoot.Entity.FindWorldNameByName == nil {
break
}
args, err := ec.field_Entity_findWorldNameByName_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindWorldNameByName(childComplexity, args["name"].(string)), true
case "Entity.findWorldWithMultipleKeysByBar":
if e.ComplexityRoot.Entity.FindWorldWithMultipleKeysByBar == nil {
break
}
args, err := ec.field_Entity_findWorldWithMultipleKeysByBar_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindWorldWithMultipleKeysByBar(childComplexity, args["bar"].(int)), true
case "Entity.findWorldWithMultipleKeysByHelloNameAndFoo":
if e.ComplexityRoot.Entity.FindWorldWithMultipleKeysByHelloNameAndFoo == nil {
break
}
args, err := ec.field_Entity_findWorldWithMultipleKeysByHelloNameAndFoo_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindWorldWithMultipleKeysByHelloNameAndFoo(childComplexity, args["helloName"].(string), args["foo"].(string)), true
case "Hello.name":
if e.ComplexityRoot.Hello.Name == nil {
break
}
return e.ComplexityRoot.Hello.Name(childComplexity), true
case "Hello.secondary":
if e.ComplexityRoot.Hello.Secondary == nil {
break
}
return e.ComplexityRoot.Hello.Secondary(childComplexity), true
case "HelloMultiSingleKeys.key1":
if e.ComplexityRoot.HelloMultiSingleKeys.Key1 == nil {
break
}
return e.ComplexityRoot.HelloMultiSingleKeys.Key1(childComplexity), true
case "HelloMultiSingleKeys.key2":
if e.ComplexityRoot.HelloMultiSingleKeys.Key2 == nil {
break
}
return e.ComplexityRoot.HelloMultiSingleKeys.Key2(childComplexity), true
case "HelloWithErrors.name":
if e.ComplexityRoot.HelloWithErrors.Name == nil {
break
}
return e.ComplexityRoot.HelloWithErrors.Name(childComplexity), true
case "MultiHello.name":
if e.ComplexityRoot.MultiHello.Name == nil {
break
}
return e.ComplexityRoot.MultiHello.Name(childComplexity), true
case "MultiHelloMultipleRequires.key1":
if e.ComplexityRoot.MultiHelloMultipleRequires.Key1 == nil {
break
}
return e.ComplexityRoot.MultiHelloMultipleRequires.Key1(childComplexity), true
case "MultiHelloMultipleRequires.key2":
if e.ComplexityRoot.MultiHelloMultipleRequires.Key2 == nil {
break
}
return e.ComplexityRoot.MultiHelloMultipleRequires.Key2(childComplexity), true
case "MultiHelloMultipleRequires.key3":
if e.ComplexityRoot.MultiHelloMultipleRequires.Key3 == nil {
break
}
return e.ComplexityRoot.MultiHelloMultipleRequires.Key3(childComplexity), true
case "MultiHelloMultipleRequires.name":
if e.ComplexityRoot.MultiHelloMultipleRequires.Name == nil {
break
}
return e.ComplexityRoot.MultiHelloMultipleRequires.Name(childComplexity), true
case "MultiHelloRequires.key1":
if e.ComplexityRoot.MultiHelloRequires.Key1 == nil {
break
}
return e.ComplexityRoot.MultiHelloRequires.Key1(childComplexity), true
case "MultiHelloRequires.key2":
if e.ComplexityRoot.MultiHelloRequires.Key2 == nil {
break
}
return e.ComplexityRoot.MultiHelloRequires.Key2(childComplexity), true
case "MultiHelloRequires.name":
if e.ComplexityRoot.MultiHelloRequires.Name == nil {
break
}
return e.ComplexityRoot.MultiHelloRequires.Name(childComplexity), true
case "MultiHelloWithError.name":
if e.ComplexityRoot.MultiHelloWithError.Name == nil {
break
}
return e.ComplexityRoot.MultiHelloWithError.Name(childComplexity), true
case "MultiPlanetRequiresNested.name":
if e.ComplexityRoot.MultiPlanetRequiresNested.Name == nil {
break
}
return e.ComplexityRoot.MultiPlanetRequiresNested.Name(childComplexity), true
case "MultiPlanetRequiresNested.size":
if e.ComplexityRoot.MultiPlanetRequiresNested.Size == nil {
break
}
return e.ComplexityRoot.MultiPlanetRequiresNested.Size(childComplexity), true
case "MultiPlanetRequiresNested.world":
if e.ComplexityRoot.MultiPlanetRequiresNested.World == nil {
break
}
return e.ComplexityRoot.MultiPlanetRequiresNested.World(childComplexity), true
case "PlanetMultipleRequires.density":
if e.ComplexityRoot.PlanetMultipleRequires.Density == nil {
break
}
return e.ComplexityRoot.PlanetMultipleRequires.Density(childComplexity), true
case "PlanetMultipleRequires.diameter":
if e.ComplexityRoot.PlanetMultipleRequires.Diameter == nil {
break
}
return e.ComplexityRoot.PlanetMultipleRequires.Diameter(childComplexity), true
case "PlanetMultipleRequires.name":
if e.ComplexityRoot.PlanetMultipleRequires.Name == nil {
break
}
return e.ComplexityRoot.PlanetMultipleRequires.Name(childComplexity), true
case "PlanetMultipleRequires.weight":
if e.ComplexityRoot.PlanetMultipleRequires.Weight == nil {
break
}
return e.ComplexityRoot.PlanetMultipleRequires.Weight(childComplexity), true
case "PlanetRequires.diameter":
if e.ComplexityRoot.PlanetRequires.Diameter == nil {
break
}
return e.ComplexityRoot.PlanetRequires.Diameter(childComplexity), true
case "PlanetRequires.name":
if e.ComplexityRoot.PlanetRequires.Name == nil {
break
}
return e.ComplexityRoot.PlanetRequires.Name(childComplexity), true
case "PlanetRequires.size":
if e.ComplexityRoot.PlanetRequires.Size == nil {
break
}
return e.ComplexityRoot.PlanetRequires.Size(childComplexity), true
case "PlanetRequiresNested.name":
if e.ComplexityRoot.PlanetRequiresNested.Name == nil {
break
}
return e.ComplexityRoot.PlanetRequiresNested.Name(childComplexity), true
case "PlanetRequiresNested.size":
if e.ComplexityRoot.PlanetRequiresNested.Size == nil {
break
}
return e.ComplexityRoot.PlanetRequiresNested.Size(childComplexity), true
case "PlanetRequiresNested.world":
if e.ComplexityRoot.PlanetRequiresNested.World == nil {
break
}
return e.ComplexityRoot.PlanetRequiresNested.World(childComplexity), true
case "Query._service":
if e.ComplexityRoot.Query.__resolve__service == nil {
break
}
return e.ComplexityRoot.Query.__resolve__service(childComplexity), true
case "Query._entities":
if e.ComplexityRoot.Query.__resolve_entities == nil {
break
}
args, err := ec.field_Query__entities_args(ctx, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Query.__resolve_entities(childComplexity, args["representations"].([]map[string]any)), true
case "World.bar":
if e.ComplexityRoot.World.Bar == nil {
break
}
return e.ComplexityRoot.World.Bar(childComplexity), true
case "World.foo":
if e.ComplexityRoot.World.Foo == nil {
break
}
return e.ComplexityRoot.World.Foo(childComplexity), true
case "World.hello":
if e.ComplexityRoot.World.Hello == nil {
break
}
return e.ComplexityRoot.World.Hello(childComplexity), true
case "WorldName.name":
if e.ComplexityRoot.WorldName.Name == nil {
break
}
return e.ComplexityRoot.WorldName.Name(childComplexity), true
case "WorldWithMultipleKeys.bar":
if e.ComplexityRoot.WorldWithMultipleKeys.Bar == nil {
break
}
return e.ComplexityRoot.WorldWithMultipleKeys.Bar(childComplexity), true
case "WorldWithMultipleKeys.foo":
if e.ComplexityRoot.WorldWithMultipleKeys.Foo == nil {
break
}
return e.ComplexityRoot.WorldWithMultipleKeys.Foo(childComplexity), true
case "WorldWithMultipleKeys.hello":
if e.ComplexityRoot.WorldWithMultipleKeys.Hello == nil {
break
}
return e.ComplexityRoot.WorldWithMultipleKeys.Hello(childComplexity), true
case "_Service.sdl":
if e.ComplexityRoot._Service.SDL == nil {
break
}
return e.ComplexityRoot._Service.SDL(childComplexity), true
}
return 0, false
}
func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
opCtx := graphql.GetOperationContext(ctx)
ec := newExecutionContext(opCtx, e, make(chan graphql.DeferredResult))
inputUnmarshalMap := graphql.BuildUnmarshalerMap(
ec.unmarshalInputMultiHelloByNamesInput,
ec.unmarshalInputMultiHelloMultipleRequiresByNamesInput,
ec.unmarshalInputMultiHelloRequiresByNamesInput,
ec.unmarshalInputMultiHelloWithErrorByNamesInput,
ec.unmarshalInputMultiPlanetRequiresNestedByNamesInput,
)
first := true
switch opCtx.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, opCtx.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.ExecutionContextState[ResolverRoot, DirectiveRoot, ComplexityRoot]
}
func newExecutionContext(
opCtx *graphql.OperationContext,
execSchema *executableSchema,
deferredResults chan graphql.DeferredResult,
) executionContext {
return executionContext{
ExecutionContextState: graphql.NewExecutionContextState[ResolverRoot, DirectiveRoot, ComplexityRoot](
opCtx,
(*graphql.ExecutableSchemaState[ResolverRoot, DirectiveRoot, ComplexityRoot])(execSchema),
parsedSchema,
deferredResults,
),
}
}
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) field_Entity_findHelloByName_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "key1", ec.unmarshalNString2string)
if err != nil {
return nil, err
}
args["key1"] = arg0
arg1, err := graphql.ProcessArgField(ctx, rawArgs, "key2", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "reps", ec.unmarshalNMultiHelloByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloByNamesInput)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "reps", ec.unmarshalNMultiHelloMultipleRequiresByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloMultipleRequiresByNamesInput)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "reps", ec.unmarshalNMultiHelloRequiresByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloRequiresByNamesInput)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "reps", ec.unmarshalNMultiHelloWithErrorByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloWithErrorByNamesInput)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "reps", ec.unmarshalNMultiPlanetRequiresNestedByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiPlanetRequiresNestedByNamesInput)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "helloName", ec.unmarshalNString2string)
if err != nil {
return nil, err
}
args["helloName"] = arg0
arg1, err := graphql.ProcessArgField(ctx, rawArgs, "foo", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "bar", ec.unmarshalNInt2int)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "helloName", ec.unmarshalNString2string)
if err != nil {
return nil, err
}
args["helloName"] = arg0
arg1, err := graphql.ProcessArgField(ctx, rawArgs, "foo", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "representations", ec.unmarshalN_Any2ᚕmapᚄ)
if err != nil {
return nil, err
}
args["representations"] = arg0
return args, nil
}
func (ec *executionContext) field___Directive_args_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2ᚖbool)
if err != nil {
return nil, err
}
args["includeDeprecated"] = arg0
return args, nil
}
func (ec *executionContext) field___Field_args_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2ᚖbool)
if err != nil {
return nil, err
}
args["includeDeprecated"] = arg0
return args, nil
}
func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2bool)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2bool)
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findHelloByName,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindHelloByName(ctx, fc.Args["name"].(string))
},
nil,
ec.marshalNHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐHello,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findHelloMultiSingleKeysByKey1AndKey2,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindHelloMultiSingleKeysByKey1AndKey2(ctx, fc.Args["key1"].(string), fc.Args["key2"].(string))
},
nil,
ec.marshalNHelloMultiSingleKeys2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐHelloMultiSingleKeys,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findHelloWithErrorsByName,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindHelloWithErrorsByName(ctx, fc.Args["name"].(string))
},
nil,
ec.marshalNHelloWithErrors2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐHelloWithErrors,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findManyMultiHelloByNames,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindManyMultiHelloByNames(ctx, fc.Args["reps"].([]*model.MultiHelloByNamesInput))
},
nil,
ec.marshalOMultiHello2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHello,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findManyMultiHelloMultipleRequiresByNames,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindManyMultiHelloMultipleRequiresByNames(ctx, fc.Args["reps"].([]*model.MultiHelloMultipleRequiresByNamesInput))
},
nil,
ec.marshalOMultiHelloMultipleRequires2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloMultipleRequires,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findManyMultiHelloRequiresByNames,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindManyMultiHelloRequiresByNames(ctx, fc.Args["reps"].([]*model.MultiHelloRequiresByNamesInput))
},
nil,
ec.marshalOMultiHelloRequires2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloRequires,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findManyMultiHelloWithErrorByNames,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindManyMultiHelloWithErrorByNames(ctx, fc.Args["reps"].([]*model.MultiHelloWithErrorByNamesInput))
},
nil,
ec.marshalOMultiHelloWithError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloWithError,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findManyMultiPlanetRequiresNestedByNames,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindManyMultiPlanetRequiresNestedByNames(ctx, fc.Args["reps"].([]*model.MultiPlanetRequiresNestedByNamesInput))
},
nil,
ec.marshalOMultiPlanetRequiresNested2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiPlanetRequiresNested,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findPlanetMultipleRequiresByName,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindPlanetMultipleRequiresByName(ctx, fc.Args["name"].(string))
},
nil,
ec.marshalNPlanetMultipleRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐPlanetMultipleRequires,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findPlanetRequiresByName,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindPlanetRequiresByName(ctx, fc.Args["name"].(string))
},
nil,
ec.marshalNPlanetRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐPlanetRequires,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findPlanetRequiresNestedByName,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindPlanetRequiresNestedByName(ctx, fc.Args["name"].(string))
},
nil,
ec.marshalNPlanetRequiresNested2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐPlanetRequiresNested,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findWorldByHelloNameAndFoo,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindWorldByHelloNameAndFoo(ctx, fc.Args["helloName"].(string), fc.Args["foo"].(string))
},
nil,
ec.marshalNWorld2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐWorld,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findWorldNameByName,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindWorldNameByName(ctx, fc.Args["name"].(string))
},
nil,
ec.marshalNWorldName2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐWorldName,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findWorldWithMultipleKeysByHelloNameAndFoo,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindWorldWithMultipleKeysByHelloNameAndFoo(ctx, fc.Args["helloName"].(string), fc.Args["foo"].(string))
},
nil,
ec.marshalNWorldWithMultipleKeys2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐWorldWithMultipleKeys,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findWorldWithMultipleKeysByBar,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindWorldWithMultipleKeysByBar(ctx, fc.Args["bar"].(int))
},
nil,
ec.marshalNWorldWithMultipleKeys2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐWorldWithMultipleKeys,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Hello_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Hello_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Hello_secondary,
func(ctx context.Context) (any, error) {
return obj.Secondary, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Hello_secondary(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_HelloMultiSingleKeys_key1,
func(ctx context.Context) (any, error) {
return obj.Key1, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_HelloMultiSingleKeys_key1(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_HelloMultiSingleKeys_key2,
func(ctx context.Context) (any, error) {
return obj.Key2, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_HelloMultiSingleKeys_key2(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_HelloWithErrors_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_HelloWithErrors_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHello_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiHello_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHelloMultipleRequires_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiHelloMultipleRequires_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHelloMultipleRequires_key1,
func(ctx context.Context) (any, error) {
return obj.Key1, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiHelloMultipleRequires_key1(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHelloMultipleRequires_key2,
func(ctx context.Context) (any, error) {
return obj.Key2, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiHelloMultipleRequires_key2(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHelloMultipleRequires_key3,
func(ctx context.Context) (any, error) {
return obj.Key3, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiHelloMultipleRequires_key3(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHelloRequires_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiHelloRequires_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHelloRequires_key1,
func(ctx context.Context) (any, error) {
return obj.Key1, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiHelloRequires_key1(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHelloRequires_key2,
func(ctx context.Context) (any, error) {
return obj.Key2, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiHelloRequires_key2(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHelloWithError_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiHelloWithError_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiPlanetRequiresNested_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiPlanetRequiresNested_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiPlanetRequiresNested_world,
func(ctx context.Context) (any, error) {
return obj.World, nil
},
nil,
ec.marshalNWorld2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐWorld,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiPlanetRequiresNested_world(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiPlanetRequiresNested_size,
func(ctx context.Context) (any, error) {
return obj.Size, nil
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiPlanetRequiresNested_size(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetMultipleRequires_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetMultipleRequires_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetMultipleRequires_diameter,
func(ctx context.Context) (any, error) {
return obj.Diameter, nil
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetMultipleRequires_diameter(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetMultipleRequires_density,
func(ctx context.Context) (any, error) {
return obj.Density, nil
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetMultipleRequires_density(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetMultipleRequires_weight,
func(ctx context.Context) (any, error) {
return obj.Weight, nil
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetMultipleRequires_weight(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetRequires_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetRequires_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetRequires_size,
func(ctx context.Context) (any, error) {
return obj.Size, nil
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetRequires_size(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetRequires_diameter,
func(ctx context.Context) (any, error) {
return obj.Diameter, nil
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetRequires_diameter(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetRequiresNested_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetRequiresNested_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetRequiresNested_world,
func(ctx context.Context) (any, error) {
return obj.World, nil
},
nil,
ec.marshalNWorld2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐWorld,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetRequiresNested_world(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetRequiresNested_size,
func(ctx context.Context) (any, error) {
return obj.Size, nil
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetRequiresNested_size(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query__entities,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.__resolve_entities(ctx, fc.Args["representations"].([]map[string]any)), nil
},
nil,
ec.marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query__service,
func(ctx context.Context) (any, error) {
return ec.__resolve__service(ctx)
},
nil,
ec.marshalN_Service2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService,
true,
true,
)
}
func (ec *executionContext) fieldContext_Query__service(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query___type,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.IntrospectType(fc.Args["name"].(string))
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query___schema,
func(ctx context.Context) (any, error) {
return ec.IntrospectSchema()
},
nil,
ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema,
true,
false,
)
}
func (ec *executionContext) fieldContext_Query___schema(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_World_foo,
func(ctx context.Context) (any, error) {
return obj.Foo, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_World_foo(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_World_bar,
func(ctx context.Context) (any, error) {
return obj.Bar, nil
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
func (ec *executionContext) fieldContext_World_bar(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_World_hello,
func(ctx context.Context) (any, error) {
return obj.Hello, nil
},
nil,
ec.marshalOHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐHello,
true,
false,
)
}
func (ec *executionContext) fieldContext_World_hello(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_WorldName_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_WorldName_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_WorldWithMultipleKeys_foo,
func(ctx context.Context) (any, error) {
return obj.Foo, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_WorldWithMultipleKeys_foo(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_WorldWithMultipleKeys_bar,
func(ctx context.Context) (any, error) {
return obj.Bar, nil
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
func (ec *executionContext) fieldContext_WorldWithMultipleKeys_bar(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_WorldWithMultipleKeys_hello,
func(ctx context.Context) (any, error) {
return obj.Hello, nil
},
nil,
ec.marshalOHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐHello,
true,
false,
)
}
func (ec *executionContext) fieldContext_WorldWithMultipleKeys_hello(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext__Service_sdl,
func(ctx context.Context) (any, error) {
return obj.SDL, nil
},
nil,
ec.marshalOString2string,
true,
false,
)
}
func (ec *executionContext) fieldContext__Service_sdl(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Directive_description(_ 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_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_isRepeatable,
func(ctx context.Context) (any, error) {
return obj.IsRepeatable, nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_isRepeatable(_ 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) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_locations,
func(ctx context.Context) (any, error) {
return obj.Locations, nil
},
nil,
ec.marshalN__DirectiveLocation2ᚕstringᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_locations(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_args,
func(ctx context.Context) (any, error) {
return obj.Args, nil
},
nil,
ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
true,
)
}
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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __InputValue", 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___Directive_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___EnumValue_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___EnumValue_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___EnumValue_isDeprecated(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___EnumValue_deprecationReason(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Field_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_args,
func(ctx context.Context) (any, error) {
return obj.Args, nil
},
nil,
ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
true,
)
}
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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __InputValue", 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___Field_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_type,
func(ctx context.Context) (any, error) {
return obj.Type, nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_type(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_isDeprecated(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Field_deprecationReason(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_type,
func(ctx context.Context) (any, error) {
return obj.Type, nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_type(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_defaultValue,
func(ctx context.Context) (any, error) {
return obj.DefaultValue, nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_defaultValue(_ 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_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_isDeprecated(_ 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 Boolean does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) ___InputValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_deprecationReason(_ 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) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_types,
func(ctx context.Context) (any, error) {
return obj.Types(), nil
},
nil,
ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_types(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_queryType,
func(ctx context.Context) (any, error) {
return obj.QueryType(), nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_queryType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_mutationType,
func(ctx context.Context) (any, error) {
return obj.MutationType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_mutationType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_subscriptionType,
func(ctx context.Context) (any, error) {
return obj.SubscriptionType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_subscriptionType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_directives,
func(ctx context.Context) (any, error) {
return obj.Directives(), nil
},
nil,
ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_directives(_ 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 "isRepeatable":
return ec.fieldContext___Directive_isRepeatable(ctx, field)
case "locations":
return ec.fieldContext___Directive_locations(ctx, field)
case "args":
return ec.fieldContext___Directive_args(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_kind,
func(ctx context.Context) (any, error) {
return obj.Kind(), nil
},
nil,
ec.marshalN__TypeKind2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Type_kind(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_name,
func(ctx context.Context) (any, error) {
return obj.Name(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_description(_ 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_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_specifiedByURL,
func(ctx context.Context) (any, error) {
return obj.SpecifiedByURL(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_specifiedByURL(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_fields,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil
},
nil,
ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_interfaces,
func(ctx context.Context) (any, error) {
return obj.Interfaces(), nil
},
nil,
ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_interfaces(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_possibleTypes,
func(ctx context.Context) (any, error) {
return obj.PossibleTypes(), nil
},
nil,
ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_possibleTypes(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_enumValues,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil
},
nil,
ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_inputFields,
func(ctx context.Context) (any, error) {
return obj.InputFields(), nil
},
nil,
ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_inputFields(_ 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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_ofType,
func(ctx context.Context) (any, error) {
return obj.OfType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_ofType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) ___Type_isOneOf(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_isOneOf,
func(ctx context.Context) (any, error) {
return obj.IsOneOf(), nil
},
nil,
ec.marshalOBoolean2bool,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_isOneOf(_ 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 Boolean does not have child fields")
},
}
return fc, nil
}
// endregion **************************** field.gotpl *****************************
// region **************************** input.gotpl *****************************
func (ec *executionContext) unmarshalInputMultiHelloByNamesInput(ctx context.Context, obj any) (model.MultiHelloByNamesInput, error) {
var it model.MultiHelloByNamesInput
if obj == nil {
return it, nil
}
asMap := map[string]any{}
for k, v := range obj.(map[string]any) {
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 any) (model.MultiHelloMultipleRequiresByNamesInput, error) {
var it model.MultiHelloMultipleRequiresByNamesInput
if obj == nil {
return it, nil
}
asMap := map[string]any{}
for k, v := range obj.(map[string]any) {
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 any) (model.MultiHelloRequiresByNamesInput, error) {
var it model.MultiHelloRequiresByNamesInput
if obj == nil {
return it, nil
}
asMap := map[string]any{}
for k, v := range obj.(map[string]any) {
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 any) (model.MultiHelloWithErrorByNamesInput, error) {
var it model.MultiHelloWithErrorByNamesInput
if obj == nil {
return it, nil
}
asMap := map[string]any{}
for k, v := range obj.(map[string]any) {
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 any) (model.MultiPlanetRequiresNestedByNamesInput, error) {
var it model.MultiPlanetRequiresNestedByNamesInput
if obj == nil {
return it, nil
}
asMap := map[string]any{}
for k, v := range obj.(map[string]any) {
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.WorldWithMultipleKeys:
return ec._WorldWithMultipleKeys(ctx, sel, &obj)
case *model.WorldWithMultipleKeys:
if obj == nil {
return graphql.Null
}
return ec._WorldWithMultipleKeys(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.World:
return ec._World(ctx, sel, &obj)
case *model.World:
if obj == nil {
return graphql.Null
}
return ec._World(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.PlanetRequires:
return ec._PlanetRequires(ctx, sel, &obj)
case *model.PlanetRequires:
if obj == nil {
return graphql.Null
}
return ec._PlanetRequires(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.MultiPlanetRequiresNested:
return ec._MultiPlanetRequiresNested(ctx, sel, &obj)
case *model.MultiPlanetRequiresNested:
if obj == nil {
return graphql.Null
}
return ec._MultiPlanetRequiresNested(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.MultiHelloRequires:
return ec._MultiHelloRequires(ctx, sel, &obj)
case *model.MultiHelloRequires:
if obj == nil {
return graphql.Null
}
return ec._MultiHelloRequires(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.MultiHello:
return ec._MultiHello(ctx, sel, &obj)
case *model.MultiHello:
if obj == nil {
return graphql.Null
}
return ec._MultiHello(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.HelloMultiSingleKeys:
return ec._HelloMultiSingleKeys(ctx, sel, &obj)
case *model.HelloMultiSingleKeys:
if obj == nil {
return graphql.Null
}
return ec._HelloMultiSingleKeys(ctx, sel, obj)
case model.Hello:
return ec._Hello(ctx, sel, &obj)
case *model.Hello:
if obj == nil {
return graphql.Null
}
return ec._Hello(ctx, sel, obj)
default:
if typedObj, ok := obj.(graphql.Marshaler); ok {
return typedObj
} else {
panic(fmt.Errorf("unexpected type %T; non-generated variants of _Entity must implement graphql.Marshaler", 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, _ *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, _ *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, _ *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, _ *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, _ *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 "isRepeatable":
out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
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++
}
default:
panic("unknown field " + strconv.Quote(field.Name))
}
}
out.Dispatch(ctx)
if out.Invalids > 0 {
return graphql.Null
}
atomic.AddInt32(&ec.Deferred, int32(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)
case "isDeprecated":
out.Values[i] = ec.___InputValue_isDeprecated(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "deprecationReason":
out.Values[i] = ec.___InputValue_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 __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 "specifiedByURL":
out.Values[i] = ec.___Type_specifiedByURL(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 "isOneOf":
out.Values[i] = ec.___Type_isOneOf(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 any) (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 {
_ = sel
res := graphql.MarshalBoolean(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) marshalNHello2githubᚗcomᚋ99designsᚋ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ᚋ99designsᚋ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)) {
graphql.AddErrorf(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ᚋ99designsᚋ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ᚋ99designsᚋ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)) {
graphql.AddErrorf(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ᚋ99designsᚋ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ᚋ99designsᚋ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)) {
graphql.AddErrorf(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 any) (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 {
_ = sel
res := graphql.MarshalInt(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalNMultiHelloByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloByNamesInput(ctx context.Context, v any) ([]*model.MultiHelloByNamesInput, error) {
var vSlice []any
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ᚋ99designsᚋ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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloMultipleRequiresByNamesInput(ctx context.Context, v any) ([]*model.MultiHelloMultipleRequiresByNamesInput, error) {
var vSlice []any
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ᚋ99designsᚋ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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloRequiresByNamesInput(ctx context.Context, v any) ([]*model.MultiHelloRequiresByNamesInput, error) {
var vSlice []any
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ᚋ99designsᚋ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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloWithErrorByNamesInput(ctx context.Context, v any) ([]*model.MultiHelloWithErrorByNamesInput, error) {
var vSlice []any
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ᚋ99designsᚋ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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiPlanetRequiresNestedByNamesInput(ctx context.Context, v any) ([]*model.MultiPlanetRequiresNestedByNamesInput, error) {
var vSlice []any
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ᚋ99designsᚋ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ᚋ99designsᚋ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ᚋ99designsᚋ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)) {
graphql.AddErrorf(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ᚋ99designsᚋ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ᚋ99designsᚋ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)) {
graphql.AddErrorf(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ᚋ99designsᚋ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ᚋ99designsᚋ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)) {
graphql.AddErrorf(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 any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) marshalNWorld2githubᚗcomᚋ99designsᚋ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ᚋ99designsᚋ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)) {
graphql.AddErrorf(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ᚋ99designsᚋ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ᚋ99designsᚋ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)) {
graphql.AddErrorf(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ᚋ99designsᚋ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ᚋ99designsᚋ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)) {
graphql.AddErrorf(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 any) (map[string]any, 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]any) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
_ = sel
res := graphql.MarshalMap(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalN_Any2ᚕmapᚄ(ctx context.Context, v any) ([]map[string]any, error) {
var vSlice []any
vSlice = graphql.CoerceList(v)
var err error
res := make([]map[string]any, 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]any) 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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v []fedruntime.Entity) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalO_Entity2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, sel, v[i])
})
return ret
}
func (ec *executionContext) unmarshalN_FieldSet2string(ctx context.Context, v any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) marshalN_Service2githubᚗcomᚋ99designsᚋ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ᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler {
return ec.___Directive(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v any) ([]string, error) {
var vSlice []any
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 := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__DirectiveLocation2string(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler {
return ec.___EnumValue(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler {
return ec.___Field(ctx, sel, &v)
}
func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler {
return ec.___InputValue(ctx, sel, &v)
}
func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler {
return ec.___Type(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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 any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v any) (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 {
_ = sel
_ = ctx
res := graphql.MarshalBoolean(v)
return res
}
func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v any) (*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
}
_ = sel
_ = ctx
res := graphql.MarshalBoolean(*v)
return res
}
func (ec *executionContext) marshalOHello2ᚖgithubᚗcomᚋ99designsᚋ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ᚋ99designsᚋ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 := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalOMultiHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHello(ctx, sel, v[i])
})
return ret
}
func (ec *executionContext) marshalOMultiHello2ᚖgithubᚗcomᚋ99designsᚋ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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloByNamesInput(ctx context.Context, v any) (*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ᚋ99designsᚋ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 := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalOMultiHelloMultipleRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloMultipleRequires(ctx, sel, v[i])
})
return ret
}
func (ec *executionContext) marshalOMultiHelloMultipleRequires2ᚖgithubᚗcomᚋ99designsᚋ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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloMultipleRequiresByNamesInput(ctx context.Context, v any) (*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ᚋ99designsᚋ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 := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalOMultiHelloRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloRequires(ctx, sel, v[i])
})
return ret
}
func (ec *executionContext) marshalOMultiHelloRequires2ᚖgithubᚗcomᚋ99designsᚋ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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloRequiresByNamesInput(ctx context.Context, v any) (*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ᚋ99designsᚋ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 := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalOMultiHelloWithError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloWithError(ctx, sel, v[i])
})
return ret
}
func (ec *executionContext) marshalOMultiHelloWithError2ᚖgithubᚗcomᚋ99designsᚋ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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiHelloWithErrorByNamesInput(ctx context.Context, v any) (*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ᚋ99designsᚋ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 := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalOMultiPlanetRequiresNested2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiPlanetRequiresNested(ctx, sel, v[i])
})
return ret
}
func (ec *executionContext) marshalOMultiPlanetRequiresNested2ᚖgithubᚗcomᚋ99designsᚋ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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋentityresolverᚋgeneratedᚋmodelᚐMultiPlanetRequiresNestedByNamesInput(ctx context.Context, v any) (*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 any) (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 {
_ = sel
_ = ctx
res := graphql.MarshalString(v)
return res
}
func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v any) (*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
}
_ = sel
_ = ctx
res := graphql.MarshalString(*v)
return res
}
func (ec *executionContext) marshalO_Entity2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v fedruntime.Entity) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec.__Entity(ctx, sel, v)
}
func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec.___Schema(ctx, sel, v)
}
func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec.___Type(ctx, sel, v)
}
// endregion ***************************** type.gotpl *****************************
================================================
FILE: plugin/federation/testdata/entityresolver/generated/federation.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package generated
import (
"context"
"errors"
"fmt"
"strings"
"sync"
"github.com/99designs/gqlgen/plugin/federation/fedruntime"
"github.com/99designs/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]any) []fedruntime.Entity {
list := make([]fedruntime.Entity, len(representations))
repsMap := ec.buildRepresentationGroups(ctx, representations)
switch len(repsMap) {
case 0:
return list
case 1:
for typeName, reps := range repsMap {
ec.resolveEntityGroup(ctx, typeName, reps, list)
}
return list
default:
var g sync.WaitGroup
g.Add(len(repsMap))
for typeName, reps := range repsMap {
go func(typeName string, reps []EntityWithIndex) {
ec.resolveEntityGroup(ctx, typeName, reps, list)
g.Done()
}(typeName, reps)
}
g.Wait()
return list
}
}
type EntityWithIndex struct {
// The index in the original representation array
index int
entity EntityRepresentation
}
// EntityRepresentation is the JSON representation of an entity sent by the Router
// used as the inputs for us to resolve.
//
// We make it a map because we know the top level JSON is always an object.
type EntityRepresentation map[string]any
// We group entities by typename so that we can parallelize their resolution.
// This is particularly helpful when there are entity groups in multi mode.
func (ec *executionContext) buildRepresentationGroups(
ctx context.Context,
representations []map[string]any,
) map[string][]EntityWithIndex {
repsMap := make(map[string][]EntityWithIndex)
for i, rep := range representations {
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
}
repsMap[typeName] = append(repsMap[typeName], EntityWithIndex{
index: i,
entity: rep,
})
}
return repsMap
}
func (ec *executionContext) resolveEntityGroup(
ctx context.Context,
typeName string,
reps []EntityWithIndex,
list []fedruntime.Entity,
) {
if isMulti(typeName) {
err := ec.resolveManyEntities(ctx, typeName, reps, list)
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 EntityWithIndex) {
entity, err := ec.resolveEntity(ctx, typeName, rep.entity)
if err != nil {
ec.Error(ctx, err)
} else {
list[rep.index] = entity
}
e.Done()
}(i, rep)
}
e.Wait()
}
}
func isMulti(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
}
}
func (ec *executionContext) resolveEntity(
ctx context.Context,
typeName string,
rep EntityRepresentation,
) (e fedruntime.Entity, 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 nil, fmt.Errorf(`finding resolver for Entity "Hello": %w`, err)
}
switch resolverName {
case "findHelloByName":
id0, err := ec.unmarshalNString2string(ctx, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findHelloByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindHelloByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "Hello": %w`, err)
}
return entity, nil
}
case "HelloMultiSingleKeys":
resolverName, err := entityResolverNameForHelloMultiSingleKeys(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "HelloMultiSingleKeys": %w`, err)
}
switch resolverName {
case "findHelloMultiSingleKeysByKey1AndKey2":
id0, err := ec.unmarshalNString2string(ctx, rep["key1"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findHelloMultiSingleKeysByKey1AndKey2(): %w`, err)
}
id1, err := ec.unmarshalNString2string(ctx, rep["key2"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 1 for findHelloMultiSingleKeysByKey1AndKey2(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindHelloMultiSingleKeysByKey1AndKey2(ctx, id0, id1)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "HelloMultiSingleKeys": %w`, err)
}
return entity, nil
}
case "HelloWithErrors":
resolverName, err := entityResolverNameForHelloWithErrors(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "HelloWithErrors": %w`, err)
}
switch resolverName {
case "findHelloWithErrorsByName":
id0, err := ec.unmarshalNString2string(ctx, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findHelloWithErrorsByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindHelloWithErrorsByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "HelloWithErrors": %w`, err)
}
return entity, nil
}
case "PlanetMultipleRequires":
resolverName, err := entityResolverNameForPlanetMultipleRequires(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "PlanetMultipleRequires": %w`, err)
}
switch resolverName {
case "findPlanetMultipleRequiresByName":
id0, err := ec.unmarshalNString2string(ctx, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findPlanetMultipleRequiresByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindPlanetMultipleRequiresByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "PlanetMultipleRequires": %w`, err)
}
entity.Diameter, err = ec.unmarshalNInt2int(ctx, rep["diameter"])
if err != nil {
return nil, err
}
entity.Density, err = ec.unmarshalNInt2int(ctx, rep["density"])
if err != nil {
return nil, err
}
return entity, nil
}
case "PlanetRequires":
resolverName, err := entityResolverNameForPlanetRequires(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "PlanetRequires": %w`, err)
}
switch resolverName {
case "findPlanetRequiresByName":
id0, err := ec.unmarshalNString2string(ctx, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findPlanetRequiresByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindPlanetRequiresByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "PlanetRequires": %w`, err)
}
entity.Diameter, err = ec.unmarshalNInt2int(ctx, rep["diameter"])
if err != nil {
return nil, err
}
return entity, nil
}
case "PlanetRequiresNested":
resolverName, err := entityResolverNameForPlanetRequiresNested(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "PlanetRequiresNested": %w`, err)
}
switch resolverName {
case "findPlanetRequiresNestedByName":
id0, err := ec.unmarshalNString2string(ctx, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findPlanetRequiresNestedByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindPlanetRequiresNestedByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "PlanetRequiresNested": %w`, err)
}
entity.World.Foo, err = ec.unmarshalNString2string(ctx, rep["world"].(map[string]any)["foo"])
if err != nil {
return nil, err
}
return entity, nil
}
case "World":
resolverName, err := entityResolverNameForWorld(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "World": %w`, err)
}
switch resolverName {
case "findWorldByHelloNameAndFoo":
id0, err := ec.unmarshalNString2string(ctx, rep["hello"].(map[string]any)["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findWorldByHelloNameAndFoo(): %w`, err)
}
id1, err := ec.unmarshalNString2string(ctx, rep["foo"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 1 for findWorldByHelloNameAndFoo(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindWorldByHelloNameAndFoo(ctx, id0, id1)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "World": %w`, err)
}
return entity, nil
}
case "WorldName":
resolverName, err := entityResolverNameForWorldName(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "WorldName": %w`, err)
}
switch resolverName {
case "findWorldNameByName":
id0, err := ec.unmarshalNString2string(ctx, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findWorldNameByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindWorldNameByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "WorldName": %w`, err)
}
return entity, nil
}
case "WorldWithMultipleKeys":
resolverName, err := entityResolverNameForWorldWithMultipleKeys(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "WorldWithMultipleKeys": %w`, err)
}
switch resolverName {
case "findWorldWithMultipleKeysByHelloNameAndFoo":
id0, err := ec.unmarshalNString2string(ctx, rep["hello"].(map[string]any)["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findWorldWithMultipleKeysByHelloNameAndFoo(): %w`, err)
}
id1, err := ec.unmarshalNString2string(ctx, rep["foo"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 1 for findWorldWithMultipleKeysByHelloNameAndFoo(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindWorldWithMultipleKeysByHelloNameAndFoo(ctx, id0, id1)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "WorldWithMultipleKeys": %w`, err)
}
return entity, nil
case "findWorldWithMultipleKeysByBar":
id0, err := ec.unmarshalNInt2int(ctx, rep["bar"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findWorldWithMultipleKeysByBar(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindWorldWithMultipleKeysByBar(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "WorldWithMultipleKeys": %w`, err)
}
return entity, nil
}
}
return nil, fmt.Errorf("%w: %s", ErrUnknownType, typeName)
}
func (ec *executionContext) resolveManyEntities(
ctx context.Context,
typeName string,
reps []EntityWithIndex,
list []fedruntime.Entity,
) (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].entity)
if err != nil {
return fmt.Errorf(`finding resolver for Entity "MultiHello": %w`, err)
}
switch resolverName {
case "findManyMultiHelloByNames":
typedReps := make([]*model.MultiHelloByNamesInput, len(reps))
for i, rep := range reps {
id0, err := ec.unmarshalNString2string(ctx, rep.entity["name"])
if err != nil {
return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name"))
}
typedReps[i] = &model.MultiHelloByNamesInput{
Name: id0,
}
}
entities, err := ec.Resolvers.Entity().FindManyMultiHelloByNames(ctx, typedReps)
if err != nil {
return err
}
for i, entity := range entities {
list[reps[i].index] = entity
}
return nil
default:
return fmt.Errorf("unknown resolver: %s", resolverName)
}
case "MultiHelloMultipleRequires":
resolverName, err := entityResolverNameForMultiHelloMultipleRequires(ctx, reps[0].entity)
if err != nil {
return fmt.Errorf(`finding resolver for Entity "MultiHelloMultipleRequires": %w`, err)
}
switch resolverName {
case "findManyMultiHelloMultipleRequiresByNames":
typedReps := make([]*model.MultiHelloMultipleRequiresByNamesInput, len(reps))
for i, rep := range reps {
id0, err := ec.unmarshalNString2string(ctx, rep.entity["name"])
if err != nil {
return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name"))
}
typedReps[i] = &model.MultiHelloMultipleRequiresByNamesInput{
Name: id0,
}
}
entities, err := ec.Resolvers.Entity().FindManyMultiHelloMultipleRequiresByNames(ctx, typedReps)
if err != nil {
return err
}
for i, entity := range entities {
entity.Key1, err = ec.unmarshalNString2string(ctx, reps[i].entity["key1"])
if err != nil {
return err
}
entity.Key2, err = ec.unmarshalNString2string(ctx, reps[i].entity["key2"])
if err != nil {
return err
}
list[reps[i].index] = entity
}
return nil
default:
return fmt.Errorf("unknown resolver: %s", resolverName)
}
case "MultiHelloRequires":
resolverName, err := entityResolverNameForMultiHelloRequires(ctx, reps[0].entity)
if err != nil {
return fmt.Errorf(`finding resolver for Entity "MultiHelloRequires": %w`, err)
}
switch resolverName {
case "findManyMultiHelloRequiresByNames":
typedReps := make([]*model.MultiHelloRequiresByNamesInput, len(reps))
for i, rep := range reps {
id0, err := ec.unmarshalNString2string(ctx, rep.entity["name"])
if err != nil {
return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name"))
}
typedReps[i] = &model.MultiHelloRequiresByNamesInput{
Name: id0,
}
}
entities, err := ec.Resolvers.Entity().FindManyMultiHelloRequiresByNames(ctx, typedReps)
if err != nil {
return err
}
for i, entity := range entities {
entity.Key1, err = ec.unmarshalNString2string(ctx, reps[i].entity["key1"])
if err != nil {
return err
}
list[reps[i].index] = entity
}
return nil
default:
return fmt.Errorf("unknown resolver: %s", resolverName)
}
case "MultiHelloWithError":
resolverName, err := entityResolverNameForMultiHelloWithError(ctx, reps[0].entity)
if err != nil {
return fmt.Errorf(`finding resolver for Entity "MultiHelloWithError": %w`, err)
}
switch resolverName {
case "findManyMultiHelloWithErrorByNames":
typedReps := make([]*model.MultiHelloWithErrorByNamesInput, len(reps))
for i, rep := range reps {
id0, err := ec.unmarshalNString2string(ctx, rep.entity["name"])
if err != nil {
return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name"))
}
typedReps[i] = &model.MultiHelloWithErrorByNamesInput{
Name: id0,
}
}
entities, err := ec.Resolvers.Entity().FindManyMultiHelloWithErrorByNames(ctx, typedReps)
if err != nil {
return err
}
for i, entity := range entities {
list[reps[i].index] = entity
}
return nil
default:
return fmt.Errorf("unknown resolver: %s", resolverName)
}
case "MultiPlanetRequiresNested":
resolverName, err := entityResolverNameForMultiPlanetRequiresNested(ctx, reps[0].entity)
if err != nil {
return fmt.Errorf(`finding resolver for Entity "MultiPlanetRequiresNested": %w`, err)
}
switch resolverName {
case "findManyMultiPlanetRequiresNestedByNames":
typedReps := make([]*model.MultiPlanetRequiresNestedByNamesInput, len(reps))
for i, rep := range reps {
id0, err := ec.unmarshalNString2string(ctx, rep.entity["name"])
if err != nil {
return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name"))
}
typedReps[i] = &model.MultiPlanetRequiresNestedByNamesInput{
Name: id0,
}
}
entities, err := ec.Resolvers.Entity().FindManyMultiPlanetRequiresNestedByNames(ctx, typedReps)
if err != nil {
return err
}
for i, entity := range entities {
entity.World.Foo, err = ec.unmarshalNString2string(ctx, reps[i].entity["world"].(map[string]any)["foo"])
if err != nil {
return err
}
list[reps[i].index] = entity
}
return nil
default:
return fmt.Errorf("unknown resolver: %s", resolverName)
}
default:
return errors.New("unknown type: " + typeName)
}
}
func entityResolverNameForHello(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for Hello", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for Hello", ErrTypeNotFound))
break
}
return "findHelloByName", nil
}
return "", fmt.Errorf("%w for Hello due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForHelloMultiSingleKeys(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["key1"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"key1\" for HelloMultiSingleKeys", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
m = rep
val, ok = m["key2"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"key2\" for HelloMultiSingleKeys", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for HelloMultiSingleKeys", ErrTypeNotFound))
break
}
return "findHelloMultiSingleKeysByKey1AndKey2", nil
}
return "", fmt.Errorf("%w for HelloMultiSingleKeys due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForHelloWithErrors(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for HelloWithErrors", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for HelloWithErrors", ErrTypeNotFound))
break
}
return "findHelloWithErrorsByName", nil
}
return "", fmt.Errorf("%w for HelloWithErrors due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForMultiHello(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for MultiHello", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for MultiHello", ErrTypeNotFound))
break
}
return "findManyMultiHelloByNames", nil
}
return "", fmt.Errorf("%w for MultiHello due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForMultiHelloMultipleRequires(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for MultiHelloMultipleRequires", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for MultiHelloMultipleRequires", ErrTypeNotFound))
break
}
return "findManyMultiHelloMultipleRequiresByNames", nil
}
return "", fmt.Errorf("%w for MultiHelloMultipleRequires due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForMultiHelloRequires(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for MultiHelloRequires", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for MultiHelloRequires", ErrTypeNotFound))
break
}
return "findManyMultiHelloRequiresByNames", nil
}
return "", fmt.Errorf("%w for MultiHelloRequires due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForMultiHelloWithError(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for MultiHelloWithError", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for MultiHelloWithError", ErrTypeNotFound))
break
}
return "findManyMultiHelloWithErrorByNames", nil
}
return "", fmt.Errorf("%w for MultiHelloWithError due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForMultiPlanetRequiresNested(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for MultiPlanetRequiresNested", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for MultiPlanetRequiresNested", ErrTypeNotFound))
break
}
return "findManyMultiPlanetRequiresNestedByNames", nil
}
return "", fmt.Errorf("%w for MultiPlanetRequiresNested due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForPlanetMultipleRequires(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for PlanetMultipleRequires", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for PlanetMultipleRequires", ErrTypeNotFound))
break
}
return "findPlanetMultipleRequiresByName", nil
}
return "", fmt.Errorf("%w for PlanetMultipleRequires due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForPlanetRequires(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for PlanetRequires", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for PlanetRequires", ErrTypeNotFound))
break
}
return "findPlanetRequiresByName", nil
}
return "", fmt.Errorf("%w for PlanetRequires due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForPlanetRequiresNested(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for PlanetRequiresNested", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for PlanetRequiresNested", ErrTypeNotFound))
break
}
return "findPlanetRequiresNestedByName", nil
}
return "", fmt.Errorf("%w for PlanetRequiresNested due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForWorld(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["hello"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"hello\" for World", ErrTypeNotFound))
break
}
if m, ok = val.(map[string]any); !ok {
// nested field value is not a map[string]interface so don't use it
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to nested Key Field \"hello\" value not matching map[string]any for World", ErrTypeNotFound))
break
}
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for World", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
m = rep
val, ok = m["foo"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"foo\" for World", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for World", ErrTypeNotFound))
break
}
return "findWorldByHelloNameAndFoo", nil
}
return "", fmt.Errorf("%w for World due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForWorldName(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for WorldName", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for WorldName", ErrTypeNotFound))
break
}
return "findWorldNameByName", nil
}
return "", fmt.Errorf("%w for WorldName due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForWorldWithMultipleKeys(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["hello"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"hello\" for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
if m, ok = val.(map[string]any); !ok {
// nested field value is not a map[string]interface so don't use it
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to nested Key Field \"hello\" value not matching map[string]any for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
m = rep
val, ok = m["foo"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"foo\" for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
return "findWorldWithMultipleKeysByHelloNameAndFoo", nil
}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["bar"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"bar\" for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
return "findWorldWithMultipleKeysByBar", nil
}
return "", fmt.Errorf("%w for WorldWithMultipleKeys due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
================================================
FILE: plugin/federation/testdata/entityresolver/generated/model/models.go
================================================
// Code generated by github.com/99designs/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() {}
================================================
FILE: plugin/federation/testdata/entityresolver/gqlgen.yml
================================================
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
================================================
FILE: plugin/federation/testdata/entityresolver/resolver.go
================================================
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{}
// FindWorldWithMultipleKeysByHelloNameAndFooBarValue shows we hit the FindWorldWithMultipleKeysByHelloNameAndFoo resolver
const FindWorldWithMultipleKeysByHelloNameAndFooBarValue = 99
================================================
FILE: plugin/federation/testdata/entityresolver/schema.graphql
================================================
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")
}
================================================
FILE: plugin/federation/testdata/entityresolver/schema.resolvers.go
================================================
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.
================================================
FILE: plugin/federation/testdata/explicitrequires/entity.resolvers.go
================================================
package explicitrequires
// 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/99designs/gqlgen version v0.17.88-dev
import (
"context"
"fmt"
"github.com/99designs/gqlgen/plugin/federation/testdata/explicitrequires/generated"
)
// FindHelloByName is the resolver for the findHelloByName field.
func (r *entityResolver) FindHelloByName(ctx context.Context, name string) (*generated.Hello, error) {
return &generated.Hello{
Name: name,
}, nil
}
// FindHelloMultiSingleKeysByKey1AndKey2 is the resolver for the findHelloMultiSingleKeysByKey1AndKey2 field.
func (r *entityResolver) FindHelloMultiSingleKeysByKey1AndKey2(ctx context.Context, key1 string, key2 string) (*generated.HelloMultiSingleKeys, error) {
panic(fmt.Errorf("not implemented"))
}
// FindHelloWithErrorsByName is the resolver for the findHelloWithErrorsByName field.
func (r *entityResolver) FindHelloWithErrorsByName(ctx context.Context, name string) (*generated.HelloWithErrors, error) {
if name == "inject error" {
return nil, generated.ErrResolvingHelloWithErrorsByName
} else if name == "" {
return nil, generated.ErrEmptyKeyResolvingHelloWithErrorsByName
}
return &generated.HelloWithErrors{
Name: name,
}, nil
}
// FindManyMultiHelloByNames is the resolver for the findManyMultiHelloByNames field.
func (r *entityResolver) FindManyMultiHelloByNames(ctx context.Context, reps []*generated.MultiHelloByNamesInput) ([]*generated.MultiHello, error) {
results := []*generated.MultiHello{}
for _, item := range reps {
results = append(results, &generated.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 []*generated.MultiHelloMultipleRequiresByNamesInput) ([]*generated.MultiHelloMultipleRequires, error) {
results := make([]*generated.MultiHelloMultipleRequires, len(reps))
for i := range reps {
results[i] = &generated.MultiHelloMultipleRequires{
Name: reps[i].Name,
}
}
return results, nil
}
// FindManyMultiHelloRequiresByNames is the resolver for the findManyMultiHelloRequiresByNames field.
func (r *entityResolver) FindManyMultiHelloRequiresByNames(ctx context.Context, reps []*generated.MultiHelloRequiresByNamesInput) ([]*generated.MultiHelloRequires, error) {
results := make([]*generated.MultiHelloRequires, len(reps))
for i := range reps {
results[i] = &generated.MultiHelloRequires{
Name: reps[i].Name,
}
}
return results, nil
}
// FindManyMultiHelloWithErrorByNames is the resolver for the findManyMultiHelloWithErrorByNames field.
func (r *entityResolver) FindManyMultiHelloWithErrorByNames(ctx context.Context, reps []*generated.MultiHelloWithErrorByNamesInput) ([]*generated.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 []*generated.MultiPlanetRequiresNestedByNamesInput) ([]*generated.MultiPlanetRequiresNested, error) {
worlds := map[string]*generated.World{
"earth": {
Foo: "A",
},
"mars": {
Foo: "B",
},
}
results := make([]*generated.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] = &generated.MultiPlanetRequiresNested{
Name: name,
World: world,
}
}
return results, nil
}
// FindPersonByName is the resolver for the findPersonByName field.
func (r *entityResolver) FindPersonByName(ctx context.Context, name string) (*generated.Person, error) {
panic(fmt.Errorf("not implemented: FindPersonByName - findPersonByName"))
}
// FindPlanetMultipleRequiresByName is the resolver for the findPlanetMultipleRequiresByName field.
func (r *entityResolver) FindPlanetMultipleRequiresByName(ctx context.Context, name string) (*generated.PlanetMultipleRequires, error) {
return &generated.PlanetMultipleRequires{Name: name}, nil
}
// FindPlanetRequiresByName is the resolver for the findPlanetRequiresByName field.
func (r *entityResolver) FindPlanetRequiresByName(ctx context.Context, name string) (*generated.PlanetRequires, error) {
return &generated.PlanetRequires{
Name: name,
}, nil
}
// FindPlanetRequiresNestedByName is the resolver for the findPlanetRequiresNestedByName field.
func (r *entityResolver) FindPlanetRequiresNestedByName(ctx context.Context, name string) (*generated.PlanetRequiresNested, error) {
worlds := map[string]*generated.World{
"earth": {
Foo: "A",
},
"mars": {
Foo: "B",
},
}
world, ok := worlds[name]
if !ok {
return nil, fmt.Errorf("unknown planet: %s", name)
}
return &generated.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) (*generated.World, error) {
return &generated.World{
Hello: &generated.Hello{
Name: helloName,
},
Foo: foo,
}, nil
}
// FindWorldNameByName is the resolver for the findWorldNameByName field.
func (r *entityResolver) FindWorldNameByName(ctx context.Context, name string) (*generated.WorldName, error) {
return &generated.WorldName{
Name: name,
}, nil
}
// FindWorldWithMultipleKeysByHelloNameAndFoo is the resolver for the findWorldWithMultipleKeysByHelloNameAndFoo field.
func (r *entityResolver) FindWorldWithMultipleKeysByHelloNameAndFoo(ctx context.Context, helloName string, foo string) (*generated.WorldWithMultipleKeys, error) {
return &generated.WorldWithMultipleKeys{
Hello: &generated.Hello{
Name: helloName,
},
Foo: foo,
}, nil
}
// FindWorldWithMultipleKeysByBar is the resolver for the findWorldWithMultipleKeysByBar field.
func (r *entityResolver) FindWorldWithMultipleKeysByBar(ctx context.Context, bar int) (*generated.WorldWithMultipleKeys, error) {
return &generated.WorldWithMultipleKeys{
Bar: bar,
}, nil
}
// Entity returns generated.EntityResolver implementation.
func (r *Resolver) Entity() generated.EntityResolver { return &entityResolver{r} }
type entityResolver struct{ *Resolver }
================================================
FILE: plugin/federation/testdata/explicitrequires/generated/errors.go
================================================
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")
)
================================================
FILE: plugin/federation/testdata/explicitrequires/generated/exec.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package generated
import (
"bytes"
"context"
"errors"
"fmt"
"strconv"
"sync/atomic"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/introspection"
"github.com/99designs/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{SchemaData: cfg.Schema, Resolvers: cfg.Resolvers, Directives: cfg.Directives, ComplexityRoot: cfg.Complexity}
}
type Config = graphql.Config[ResolverRoot, DirectiveRoot, ComplexityRoot]
type ResolverRoot interface {
Entity() EntityResolver
}
type DirectiveRoot struct {
}
type ComplexityRoot struct {
}
type EntityResolver interface {
FindHelloByName(ctx context.Context, name string) (*Hello, error)
FindHelloMultiSingleKeysByKey1AndKey2(ctx context.Context, key1 string, key2 string) (*HelloMultiSingleKeys, error)
FindHelloWithErrorsByName(ctx context.Context, name string) (*HelloWithErrors, error)
FindManyMultiHelloByNames(ctx context.Context, reps []*MultiHelloByNamesInput) ([]*MultiHello, error)
FindManyMultiHelloMultipleRequiresByNames(ctx context.Context, reps []*MultiHelloMultipleRequiresByNamesInput) ([]*MultiHelloMultipleRequires, error)
FindManyMultiHelloRequiresByNames(ctx context.Context, reps []*MultiHelloRequiresByNamesInput) ([]*MultiHelloRequires, error)
FindManyMultiHelloWithErrorByNames(ctx context.Context, reps []*MultiHelloWithErrorByNamesInput) ([]*MultiHelloWithError, error)
FindManyMultiPlanetRequiresNestedByNames(ctx context.Context, reps []*MultiPlanetRequiresNestedByNamesInput) ([]*MultiPlanetRequiresNested, error)
FindPersonByName(ctx context.Context, name string) (*Person, error)
FindPlanetMultipleRequiresByName(ctx context.Context, name string) (*PlanetMultipleRequires, error)
FindPlanetRequiresByName(ctx context.Context, name string) (*PlanetRequires, error)
FindPlanetRequiresNestedByName(ctx context.Context, name string) (*PlanetRequiresNested, error)
FindWorldByHelloNameAndFoo(ctx context.Context, helloName string, foo string) (*World, error)
FindWorldNameByName(ctx context.Context, name string) (*WorldName, error)
FindWorldWithMultipleKeysByHelloNameAndFoo(ctx context.Context, helloName string, foo string) (*WorldWithMultipleKeys, error)
FindWorldWithMultipleKeysByBar(ctx context.Context, bar int) (*WorldWithMultipleKeys, error)
}
type executableSchema graphql.ExecutableSchemaState[ResolverRoot, DirectiveRoot, ComplexityRoot]
func (e *executableSchema) Schema() *ast.Schema {
if e.SchemaData != nil {
return e.SchemaData
}
return parsedSchema
}
func (e *executableSchema) Complexity(ctx context.Context, typeName, field string, childComplexity int, rawArgs map[string]any) (int, bool) {
ec := newExecutionContext(nil, e, nil)
_ = ec
return 0, false
}
func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
opCtx := graphql.GetOperationContext(ctx)
ec := newExecutionContext(opCtx, e, make(chan graphql.DeferredResult))
inputUnmarshalMap := graphql.BuildUnmarshalerMap(
ec.unmarshalInputMultiHelloByNamesInput,
ec.unmarshalInputMultiHelloMultipleRequiresByNamesInput,
ec.unmarshalInputMultiHelloRequiresByNamesInput,
ec.unmarshalInputMultiHelloWithErrorByNamesInput,
ec.unmarshalInputMultiPlanetRequiresNestedByNamesInput,
)
first := true
switch opCtx.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, opCtx.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.ExecutionContextState[ResolverRoot, DirectiveRoot, ComplexityRoot]
}
func newExecutionContext(
opCtx *graphql.OperationContext,
execSchema *executableSchema,
deferredResults chan graphql.DeferredResult,
) executionContext {
return executionContext{
ExecutionContextState: graphql.NewExecutionContextState[ResolverRoot, DirectiveRoot, ComplexityRoot](
opCtx,
(*graphql.ExecutableSchemaState[ResolverRoot, DirectiveRoot, ComplexityRoot])(execSchema),
parsedSchema,
deferredResults,
),
}
}
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 Person @key(fields: "name"){
name: String!
gender: Gender!
welcomeMessage: String @requires(fields:"gender { ... on Male {description} ... on Female {description}}")
}
union Gender = Male | Female
type Male {
description: String!
}
type Female {
description: String!
}
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
worlds: [World!] @external
size: Int! @requires(fields: "world{ foo }")
sizes: [Int!] @requires(fields: "worlds{ foo }")
}
type MultiPlanetRequiresNested @key(fields: "name") @entityResolver(multi: true) {
name: String! @external
world: World! @external
worlds: [World!] @external
size: Int! @requires(fields: "world{ foo }")
sizes: [Int!] @requires(fields: "worlds{ 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 | Person | 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]
findPersonByName(name: String!,): Person!
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) field_Entity_findHelloByName_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "key1", ec.unmarshalNString2string)
if err != nil {
return nil, err
}
args["key1"] = arg0
arg1, err := graphql.ProcessArgField(ctx, rawArgs, "key2", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "reps", ec.unmarshalNMultiHelloByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloByNamesInput)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "reps", ec.unmarshalNMultiHelloMultipleRequiresByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloMultipleRequiresByNamesInput)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "reps", ec.unmarshalNMultiHelloRequiresByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloRequiresByNamesInput)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "reps", ec.unmarshalNMultiHelloWithErrorByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloWithErrorByNamesInput)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "reps", ec.unmarshalNMultiPlanetRequiresNestedByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiPlanetRequiresNestedByNamesInput)
if err != nil {
return nil, err
}
args["reps"] = arg0
return args, nil
}
func (ec *executionContext) field_Entity_findPersonByName_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
if err != nil {
return nil, err
}
args["name"] = arg0
return args, nil
}
func (ec *executionContext) field_Entity_findPlanetMultipleRequiresByName_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "helloName", ec.unmarshalNString2string)
if err != nil {
return nil, err
}
args["helloName"] = arg0
arg1, err := graphql.ProcessArgField(ctx, rawArgs, "foo", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "bar", ec.unmarshalNInt2int)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "helloName", ec.unmarshalNString2string)
if err != nil {
return nil, err
}
args["helloName"] = arg0
arg1, err := graphql.ProcessArgField(ctx, rawArgs, "foo", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "representations", ec.unmarshalN_Any2ᚕmapᚄ)
if err != nil {
return nil, err
}
args["representations"] = arg0
return args, nil
}
func (ec *executionContext) field___Directive_args_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2ᚖbool)
if err != nil {
return nil, err
}
args["includeDeprecated"] = arg0
return args, nil
}
func (ec *executionContext) field___Field_args_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2ᚖbool)
if err != nil {
return nil, err
}
args["includeDeprecated"] = arg0
return args, nil
}
func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2bool)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2bool)
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findHelloByName,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindHelloByName(ctx, fc.Args["name"].(string))
},
nil,
ec.marshalNHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐHello,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findHelloMultiSingleKeysByKey1AndKey2,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindHelloMultiSingleKeysByKey1AndKey2(ctx, fc.Args["key1"].(string), fc.Args["key2"].(string))
},
nil,
ec.marshalNHelloMultiSingleKeys2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐHelloMultiSingleKeys,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findHelloWithErrorsByName,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindHelloWithErrorsByName(ctx, fc.Args["name"].(string))
},
nil,
ec.marshalNHelloWithErrors2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐHelloWithErrors,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findManyMultiHelloByNames,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindManyMultiHelloByNames(ctx, fc.Args["reps"].([]*MultiHelloByNamesInput))
},
nil,
ec.marshalOMultiHello2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHello,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findManyMultiHelloMultipleRequiresByNames,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindManyMultiHelloMultipleRequiresByNames(ctx, fc.Args["reps"].([]*MultiHelloMultipleRequiresByNamesInput))
},
nil,
ec.marshalOMultiHelloMultipleRequires2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloMultipleRequires,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findManyMultiHelloRequiresByNames,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindManyMultiHelloRequiresByNames(ctx, fc.Args["reps"].([]*MultiHelloRequiresByNamesInput))
},
nil,
ec.marshalOMultiHelloRequires2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloRequires,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findManyMultiHelloWithErrorByNames,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindManyMultiHelloWithErrorByNames(ctx, fc.Args["reps"].([]*MultiHelloWithErrorByNamesInput))
},
nil,
ec.marshalOMultiHelloWithError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloWithError,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findManyMultiPlanetRequiresNestedByNames,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindManyMultiPlanetRequiresNestedByNames(ctx, fc.Args["reps"].([]*MultiPlanetRequiresNestedByNamesInput))
},
nil,
ec.marshalOMultiPlanetRequiresNested2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiPlanetRequiresNested,
true,
false,
)
}
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 "worlds":
return ec.fieldContext_MultiPlanetRequiresNested_worlds(ctx, field)
case "size":
return ec.fieldContext_MultiPlanetRequiresNested_size(ctx, field)
case "sizes":
return ec.fieldContext_MultiPlanetRequiresNested_sizes(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_findPersonByName(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findPersonByName,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindPersonByName(ctx, fc.Args["name"].(string))
},
nil,
ec.marshalNPerson2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐPerson,
true,
true,
)
}
func (ec *executionContext) fieldContext_Entity_findPersonByName(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_Person_name(ctx, field)
case "gender":
return ec.fieldContext_Person_gender(ctx, field)
case "welcomeMessage":
return ec.fieldContext_Person_welcomeMessage(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Person", 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_findPersonByName_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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findPlanetMultipleRequiresByName,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindPlanetMultipleRequiresByName(ctx, fc.Args["name"].(string))
},
nil,
ec.marshalNPlanetMultipleRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐPlanetMultipleRequires,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findPlanetRequiresByName,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindPlanetRequiresByName(ctx, fc.Args["name"].(string))
},
nil,
ec.marshalNPlanetRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐPlanetRequires,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findPlanetRequiresNestedByName,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindPlanetRequiresNestedByName(ctx, fc.Args["name"].(string))
},
nil,
ec.marshalNPlanetRequiresNested2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐPlanetRequiresNested,
true,
true,
)
}
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 "worlds":
return ec.fieldContext_PlanetRequiresNested_worlds(ctx, field)
case "size":
return ec.fieldContext_PlanetRequiresNested_size(ctx, field)
case "sizes":
return ec.fieldContext_PlanetRequiresNested_sizes(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findWorldByHelloNameAndFoo,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindWorldByHelloNameAndFoo(ctx, fc.Args["helloName"].(string), fc.Args["foo"].(string))
},
nil,
ec.marshalNWorld2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐWorld,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findWorldNameByName,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindWorldNameByName(ctx, fc.Args["name"].(string))
},
nil,
ec.marshalNWorldName2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐWorldName,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findWorldWithMultipleKeysByHelloNameAndFoo,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindWorldWithMultipleKeysByHelloNameAndFoo(ctx, fc.Args["helloName"].(string), fc.Args["foo"].(string))
},
nil,
ec.marshalNWorldWithMultipleKeys2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐWorldWithMultipleKeys,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Entity_findWorldWithMultipleKeysByBar,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindWorldWithMultipleKeysByBar(ctx, fc.Args["bar"].(int))
},
nil,
ec.marshalNWorldWithMultipleKeys2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐWorldWithMultipleKeys,
true,
true,
)
}
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) _Female_description(ctx context.Context, field graphql.CollectedField, obj *Female) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Female_description,
func(ctx context.Context) (any, error) {
return obj.Description, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Female_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Female",
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_name(ctx context.Context, field graphql.CollectedField, obj *Hello) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Hello_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Hello_name(_ 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 *Hello) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Hello_secondary,
func(ctx context.Context) (any, error) {
return obj.Secondary, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Hello_secondary(_ 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 *HelloMultiSingleKeys) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_HelloMultiSingleKeys_key1,
func(ctx context.Context) (any, error) {
return obj.Key1, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_HelloMultiSingleKeys_key1(_ 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 *HelloMultiSingleKeys) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_HelloMultiSingleKeys_key2,
func(ctx context.Context) (any, error) {
return obj.Key2, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_HelloMultiSingleKeys_key2(_ 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 *HelloWithErrors) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_HelloWithErrors_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_HelloWithErrors_name(_ 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) _Male_description(ctx context.Context, field graphql.CollectedField, obj *Male) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Male_description,
func(ctx context.Context) (any, error) {
return obj.Description, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Male_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Male",
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 *MultiHello) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHello_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiHello_name(_ 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 *MultiHelloMultipleRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHelloMultipleRequires_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiHelloMultipleRequires_name(_ 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 *MultiHelloMultipleRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHelloMultipleRequires_key1,
func(ctx context.Context) (any, error) {
return obj.Key1, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiHelloMultipleRequires_key1(_ 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 *MultiHelloMultipleRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHelloMultipleRequires_key2,
func(ctx context.Context) (any, error) {
return obj.Key2, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiHelloMultipleRequires_key2(_ 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 *MultiHelloMultipleRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHelloMultipleRequires_key3,
func(ctx context.Context) (any, error) {
return obj.Key3, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiHelloMultipleRequires_key3(_ 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 *MultiHelloRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHelloRequires_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiHelloRequires_name(_ 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 *MultiHelloRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHelloRequires_key1,
func(ctx context.Context) (any, error) {
return obj.Key1, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiHelloRequires_key1(_ 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 *MultiHelloRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHelloRequires_key2,
func(ctx context.Context) (any, error) {
return obj.Key2, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiHelloRequires_key2(_ 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 *MultiHelloWithError) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiHelloWithError_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiHelloWithError_name(_ 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 *MultiPlanetRequiresNested) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiPlanetRequiresNested_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiPlanetRequiresNested_name(_ 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 *MultiPlanetRequiresNested) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiPlanetRequiresNested_world,
func(ctx context.Context) (any, error) {
return obj.World, nil
},
nil,
ec.marshalNWorld2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐWorld,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiPlanetRequiresNested_world(_ 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_worlds(ctx context.Context, field graphql.CollectedField, obj *MultiPlanetRequiresNested) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiPlanetRequiresNested_worlds,
func(ctx context.Context) (any, error) {
return obj.Worlds, nil
},
nil,
ec.marshalOWorld2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐWorldᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext_MultiPlanetRequiresNested_worlds(_ 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 *MultiPlanetRequiresNested) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiPlanetRequiresNested_size,
func(ctx context.Context) (any, error) {
return obj.Size, nil
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
func (ec *executionContext) fieldContext_MultiPlanetRequiresNested_size(_ 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) _MultiPlanetRequiresNested_sizes(ctx context.Context, field graphql.CollectedField, obj *MultiPlanetRequiresNested) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_MultiPlanetRequiresNested_sizes,
func(ctx context.Context) (any, error) {
return obj.Sizes, nil
},
nil,
ec.marshalOInt2ᚕintᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext_MultiPlanetRequiresNested_sizes(_ 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) _Person_name(ctx context.Context, field graphql.CollectedField, obj *Person) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Person_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_Person_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Person",
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) _Person_gender(ctx context.Context, field graphql.CollectedField, obj *Person) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Person_gender,
func(ctx context.Context) (any, error) {
return obj.Gender, nil
},
nil,
ec.marshalNGender2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐGender,
true,
true,
)
}
func (ec *executionContext) fieldContext_Person_gender(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Person",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type Gender does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _Person_welcomeMessage(ctx context.Context, field graphql.CollectedField, obj *Person) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Person_welcomeMessage,
func(ctx context.Context) (any, error) {
return obj.WelcomeMessage, nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext_Person_welcomeMessage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Person",
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_name(ctx context.Context, field graphql.CollectedField, obj *PlanetMultipleRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetMultipleRequires_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetMultipleRequires_name(_ 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 *PlanetMultipleRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetMultipleRequires_diameter,
func(ctx context.Context) (any, error) {
return obj.Diameter, nil
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetMultipleRequires_diameter(_ 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 *PlanetMultipleRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetMultipleRequires_density,
func(ctx context.Context) (any, error) {
return obj.Density, nil
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetMultipleRequires_density(_ 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 *PlanetMultipleRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetMultipleRequires_weight,
func(ctx context.Context) (any, error) {
return obj.Weight, nil
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetMultipleRequires_weight(_ 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 *PlanetRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetRequires_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetRequires_name(_ 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 *PlanetRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetRequires_size,
func(ctx context.Context) (any, error) {
return obj.Size, nil
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetRequires_size(_ 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 *PlanetRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetRequires_diameter,
func(ctx context.Context) (any, error) {
return obj.Diameter, nil
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetRequires_diameter(_ 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 *PlanetRequiresNested) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetRequiresNested_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetRequiresNested_name(_ 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 *PlanetRequiresNested) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetRequiresNested_world,
func(ctx context.Context) (any, error) {
return obj.World, nil
},
nil,
ec.marshalNWorld2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐWorld,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetRequiresNested_world(_ 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_worlds(ctx context.Context, field graphql.CollectedField, obj *PlanetRequiresNested) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetRequiresNested_worlds,
func(ctx context.Context) (any, error) {
return obj.Worlds, nil
},
nil,
ec.marshalOWorld2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐWorldᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext_PlanetRequiresNested_worlds(_ 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 *PlanetRequiresNested) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetRequiresNested_size,
func(ctx context.Context) (any, error) {
return obj.Size, nil
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
func (ec *executionContext) fieldContext_PlanetRequiresNested_size(_ 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) _PlanetRequiresNested_sizes(ctx context.Context, field graphql.CollectedField, obj *PlanetRequiresNested) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_PlanetRequiresNested_sizes,
func(ctx context.Context) (any, error) {
return obj.Sizes, nil
},
nil,
ec.marshalOInt2ᚕintᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext_PlanetRequiresNested_sizes(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query__entities,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.__resolve_entities(ctx, fc.Args["representations"].([]map[string]any)), nil
},
nil,
ec.marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity,
true,
true,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query__service,
func(ctx context.Context) (any, error) {
return ec.__resolve__service(ctx)
},
nil,
ec.marshalN_Service2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService,
true,
true,
)
}
func (ec *executionContext) fieldContext_Query__service(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query___type,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.IntrospectType(fc.Args["name"].(string))
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query___schema,
func(ctx context.Context) (any, error) {
return ec.IntrospectSchema()
},
nil,
ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema,
true,
false,
)
}
func (ec *executionContext) fieldContext_Query___schema(_ 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 *World) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_World_foo,
func(ctx context.Context) (any, error) {
return obj.Foo, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_World_foo(_ 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 *World) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_World_bar,
func(ctx context.Context) (any, error) {
return obj.Bar, nil
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
func (ec *executionContext) fieldContext_World_bar(_ 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 *World) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_World_hello,
func(ctx context.Context) (any, error) {
return obj.Hello, nil
},
nil,
ec.marshalOHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐHello,
true,
false,
)
}
func (ec *executionContext) fieldContext_World_hello(_ 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 *WorldName) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_WorldName_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_WorldName_name(_ 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 *WorldWithMultipleKeys) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_WorldWithMultipleKeys_foo,
func(ctx context.Context) (any, error) {
return obj.Foo, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext_WorldWithMultipleKeys_foo(_ 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 *WorldWithMultipleKeys) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_WorldWithMultipleKeys_bar,
func(ctx context.Context) (any, error) {
return obj.Bar, nil
},
nil,
ec.marshalNInt2int,
true,
true,
)
}
func (ec *executionContext) fieldContext_WorldWithMultipleKeys_bar(_ 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 *WorldWithMultipleKeys) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_WorldWithMultipleKeys_hello,
func(ctx context.Context) (any, error) {
return obj.Hello, nil
},
nil,
ec.marshalOHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐHello,
true,
false,
)
}
func (ec *executionContext) fieldContext_WorldWithMultipleKeys_hello(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext__Service_sdl,
func(ctx context.Context) (any, error) {
return obj.SDL, nil
},
nil,
ec.marshalOString2string,
true,
false,
)
}
func (ec *executionContext) fieldContext__Service_sdl(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Directive_description(_ 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_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_isRepeatable,
func(ctx context.Context) (any, error) {
return obj.IsRepeatable, nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_isRepeatable(_ 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) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_locations,
func(ctx context.Context) (any, error) {
return obj.Locations, nil
},
nil,
ec.marshalN__DirectiveLocation2ᚕstringᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_locations(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_args,
func(ctx context.Context) (any, error) {
return obj.Args, nil
},
nil,
ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
true,
)
}
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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __InputValue", 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___Directive_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___EnumValue_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___EnumValue_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___EnumValue_isDeprecated(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___EnumValue_deprecationReason(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Field_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_args,
func(ctx context.Context) (any, error) {
return obj.Args, nil
},
nil,
ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
true,
)
}
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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __InputValue", 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___Field_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_type,
func(ctx context.Context) (any, error) {
return obj.Type, nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_type(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_isDeprecated(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Field_deprecationReason(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_type,
func(ctx context.Context) (any, error) {
return obj.Type, nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_type(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_defaultValue,
func(ctx context.Context) (any, error) {
return obj.DefaultValue, nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_defaultValue(_ 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_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_isDeprecated(_ 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 Boolean does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) ___InputValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_deprecationReason(_ 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) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_types,
func(ctx context.Context) (any, error) {
return obj.Types(), nil
},
nil,
ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_types(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_queryType,
func(ctx context.Context) (any, error) {
return obj.QueryType(), nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_queryType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_mutationType,
func(ctx context.Context) (any, error) {
return obj.MutationType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_mutationType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_subscriptionType,
func(ctx context.Context) (any, error) {
return obj.SubscriptionType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_subscriptionType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_directives,
func(ctx context.Context) (any, error) {
return obj.Directives(), nil
},
nil,
ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_directives(_ 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 "isRepeatable":
return ec.fieldContext___Directive_isRepeatable(ctx, field)
case "locations":
return ec.fieldContext___Directive_locations(ctx, field)
case "args":
return ec.fieldContext___Directive_args(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_kind,
func(ctx context.Context) (any, error) {
return obj.Kind(), nil
},
nil,
ec.marshalN__TypeKind2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Type_kind(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_name,
func(ctx context.Context) (any, error) {
return obj.Name(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_description(_ 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_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_specifiedByURL,
func(ctx context.Context) (any, error) {
return obj.SpecifiedByURL(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_specifiedByURL(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_fields,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil
},
nil,
ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_interfaces,
func(ctx context.Context) (any, error) {
return obj.Interfaces(), nil
},
nil,
ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_interfaces(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_possibleTypes,
func(ctx context.Context) (any, error) {
return obj.PossibleTypes(), nil
},
nil,
ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_possibleTypes(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_enumValues,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil
},
nil,
ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_inputFields,
func(ctx context.Context) (any, error) {
return obj.InputFields(), nil
},
nil,
ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_inputFields(_ 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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_ofType,
func(ctx context.Context) (any, error) {
return obj.OfType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_ofType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) ___Type_isOneOf(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_isOneOf,
func(ctx context.Context) (any, error) {
return obj.IsOneOf(), nil
},
nil,
ec.marshalOBoolean2bool,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_isOneOf(_ 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 Boolean does not have child fields")
},
}
return fc, nil
}
// endregion **************************** field.gotpl *****************************
// region **************************** input.gotpl *****************************
func (ec *executionContext) unmarshalInputMultiHelloByNamesInput(ctx context.Context, obj any) (MultiHelloByNamesInput, error) {
var it MultiHelloByNamesInput
if obj == nil {
return it, nil
}
asMap := map[string]any{}
for k, v := range obj.(map[string]any) {
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 any) (MultiHelloMultipleRequiresByNamesInput, error) {
var it MultiHelloMultipleRequiresByNamesInput
if obj == nil {
return it, nil
}
asMap := map[string]any{}
for k, v := range obj.(map[string]any) {
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 any) (MultiHelloRequiresByNamesInput, error) {
var it MultiHelloRequiresByNamesInput
if obj == nil {
return it, nil
}
asMap := map[string]any{}
for k, v := range obj.(map[string]any) {
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 any) (MultiHelloWithErrorByNamesInput, error) {
var it MultiHelloWithErrorByNamesInput
if obj == nil {
return it, nil
}
asMap := map[string]any{}
for k, v := range obj.(map[string]any) {
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 any) (MultiPlanetRequiresNestedByNamesInput, error) {
var it MultiPlanetRequiresNestedByNamesInput
if obj == nil {
return it, nil
}
asMap := map[string]any{}
for k, v := range obj.(map[string]any) {
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) _Gender(ctx context.Context, sel ast.SelectionSet, obj Gender) graphql.Marshaler {
switch obj := (obj).(type) {
case nil:
return graphql.Null
case Male:
return ec._Male(ctx, sel, &obj)
case *Male:
if obj == nil {
return graphql.Null
}
return ec._Male(ctx, sel, obj)
case Female:
return ec._Female(ctx, sel, &obj)
case *Female:
if obj == nil {
return graphql.Null
}
return ec._Female(ctx, sel, obj)
default:
if typedObj, ok := obj.(graphql.Marshaler); ok {
return typedObj
} else {
panic(fmt.Errorf("unexpected type %T; non-generated variants of Gender must implement graphql.Marshaler", 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 WorldWithMultipleKeys:
return ec._WorldWithMultipleKeys(ctx, sel, &obj)
case *WorldWithMultipleKeys:
if obj == nil {
return graphql.Null
}
return ec._WorldWithMultipleKeys(ctx, sel, obj)
case WorldName:
return ec._WorldName(ctx, sel, &obj)
case *WorldName:
if obj == nil {
return graphql.Null
}
return ec._WorldName(ctx, sel, obj)
case World:
return ec._World(ctx, sel, &obj)
case *World:
if obj == nil {
return graphql.Null
}
return ec._World(ctx, sel, obj)
case PlanetRequiresNested:
return ec._PlanetRequiresNested(ctx, sel, &obj)
case *PlanetRequiresNested:
if obj == nil {
return graphql.Null
}
return ec._PlanetRequiresNested(ctx, sel, obj)
case PlanetRequires:
return ec._PlanetRequires(ctx, sel, &obj)
case *PlanetRequires:
if obj == nil {
return graphql.Null
}
return ec._PlanetRequires(ctx, sel, obj)
case PlanetMultipleRequires:
return ec._PlanetMultipleRequires(ctx, sel, &obj)
case *PlanetMultipleRequires:
if obj == nil {
return graphql.Null
}
return ec._PlanetMultipleRequires(ctx, sel, obj)
case Person:
return ec._Person(ctx, sel, &obj)
case *Person:
if obj == nil {
return graphql.Null
}
return ec._Person(ctx, sel, obj)
case MultiPlanetRequiresNested:
return ec._MultiPlanetRequiresNested(ctx, sel, &obj)
case *MultiPlanetRequiresNested:
if obj == nil {
return graphql.Null
}
return ec._MultiPlanetRequiresNested(ctx, sel, obj)
case MultiHelloWithError:
return ec._MultiHelloWithError(ctx, sel, &obj)
case *MultiHelloWithError:
if obj == nil {
return graphql.Null
}
return ec._MultiHelloWithError(ctx, sel, obj)
case MultiHelloRequires:
return ec._MultiHelloRequires(ctx, sel, &obj)
case *MultiHelloRequires:
if obj == nil {
return graphql.Null
}
return ec._MultiHelloRequires(ctx, sel, obj)
case MultiHelloMultipleRequires:
return ec._MultiHelloMultipleRequires(ctx, sel, &obj)
case *MultiHelloMultipleRequires:
if obj == nil {
return graphql.Null
}
return ec._MultiHelloMultipleRequires(ctx, sel, obj)
case MultiHello:
return ec._MultiHello(ctx, sel, &obj)
case *MultiHello:
if obj == nil {
return graphql.Null
}
return ec._MultiHello(ctx, sel, obj)
case HelloWithErrors:
return ec._HelloWithErrors(ctx, sel, &obj)
case *HelloWithErrors:
if obj == nil {
return graphql.Null
}
return ec._HelloWithErrors(ctx, sel, obj)
case HelloMultiSingleKeys:
return ec._HelloMultiSingleKeys(ctx, sel, &obj)
case *HelloMultiSingleKeys:
if obj == nil {
return graphql.Null
}
return ec._HelloMultiSingleKeys(ctx, sel, obj)
case Hello:
return ec._Hello(ctx, sel, &obj)
case *Hello:
if obj == nil {
return graphql.Null
}
return ec._Hello(ctx, sel, obj)
default:
if typedObj, ok := obj.(graphql.Marshaler); ok {
return typedObj
} else {
panic(fmt.Errorf("unexpected type %T; non-generated variants of _Entity must implement graphql.Marshaler", 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, _ *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, _ *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, _ *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, _ *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, _ *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 "findPersonByName":
field := field
innerFunc := func(ctx 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_findPersonByName(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 "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 femaleImplementors = []string{"Female", "Gender"}
func (ec *executionContext) _Female(ctx context.Context, sel ast.SelectionSet, obj *Female) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, femaleImplementors)
out := graphql.NewFieldSet(fields)
deferred := make(map[string]*graphql.FieldSet)
for i, field := range fields {
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Female")
case "description":
out.Values[i] = ec._Female_description(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 helloImplementors = []string{"Hello", "_Entity"}
func (ec *executionContext) _Hello(ctx context.Context, sel ast.SelectionSet, obj *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 *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 *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 maleImplementors = []string{"Male", "Gender"}
func (ec *executionContext) _Male(ctx context.Context, sel ast.SelectionSet, obj *Male) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, maleImplementors)
out := graphql.NewFieldSet(fields)
deferred := make(map[string]*graphql.FieldSet)
for i, field := range fields {
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Male")
case "description":
out.Values[i] = ec._Male_description(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 *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 *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 *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 *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 *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 "worlds":
out.Values[i] = ec._MultiPlanetRequiresNested_worlds(ctx, field, obj)
case "size":
out.Values[i] = ec._MultiPlanetRequiresNested_size(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "sizes":
out.Values[i] = ec._MultiPlanetRequiresNested_sizes(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 personImplementors = []string{"Person", "_Entity"}
func (ec *executionContext) _Person(ctx context.Context, sel ast.SelectionSet, obj *Person) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, personImplementors)
out := graphql.NewFieldSet(fields)
deferred := make(map[string]*graphql.FieldSet)
for i, field := range fields {
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Person")
case "name":
out.Values[i] = ec._Person_name(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "gender":
out.Values[i] = ec._Person_gender(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "welcomeMessage":
out.Values[i] = ec._Person_welcomeMessage(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 planetMultipleRequiresImplementors = []string{"PlanetMultipleRequires", "_Entity"}
func (ec *executionContext) _PlanetMultipleRequires(ctx context.Context, sel ast.SelectionSet, obj *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 *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 *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 "worlds":
out.Values[i] = ec._PlanetRequiresNested_worlds(ctx, field, obj)
case "size":
out.Values[i] = ec._PlanetRequiresNested_size(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "sizes":
out.Values[i] = ec._PlanetRequiresNested_sizes(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 worldImplementors = []string{"World", "_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 "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 *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 *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 "isRepeatable":
out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
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++
}
default:
panic("unknown field " + strconv.Quote(field.Name))
}
}
out.Dispatch(ctx)
if out.Invalids > 0 {
return graphql.Null
}
atomic.AddInt32(&ec.Deferred, int32(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)
case "isDeprecated":
out.Values[i] = ec.___InputValue_isDeprecated(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "deprecationReason":
out.Values[i] = ec.___InputValue_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 __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 "specifiedByURL":
out.Values[i] = ec.___Type_specifiedByURL(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 "isOneOf":
out.Values[i] = ec.___Type_isOneOf(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 any) (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 {
_ = sel
res := graphql.MarshalBoolean(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) marshalNGender2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐGender(ctx context.Context, sel ast.SelectionSet, v Gender) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return ec._Gender(ctx, sel, v)
}
func (ec *executionContext) marshalNHello2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐHello(ctx context.Context, sel ast.SelectionSet, v Hello) graphql.Marshaler {
return ec._Hello(ctx, sel, &v)
}
func (ec *executionContext) marshalNHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐHello(ctx context.Context, sel ast.SelectionSet, v *Hello) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐHelloMultiSingleKeys(ctx context.Context, sel ast.SelectionSet, v HelloMultiSingleKeys) graphql.Marshaler {
return ec._HelloMultiSingleKeys(ctx, sel, &v)
}
func (ec *executionContext) marshalNHelloMultiSingleKeys2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐHelloMultiSingleKeys(ctx context.Context, sel ast.SelectionSet, v *HelloMultiSingleKeys) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐHelloWithErrors(ctx context.Context, sel ast.SelectionSet, v HelloWithErrors) graphql.Marshaler {
return ec._HelloWithErrors(ctx, sel, &v)
}
func (ec *executionContext) marshalNHelloWithErrors2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐHelloWithErrors(ctx context.Context, sel ast.SelectionSet, v *HelloWithErrors) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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 any) (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 {
_ = sel
res := graphql.MarshalInt(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalNMultiHelloByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloByNamesInput(ctx context.Context, v any) ([]*MultiHelloByNamesInput, error) {
var vSlice []any
vSlice = graphql.CoerceList(v)
var err error
res := make([]*MultiHelloByNamesInput, len(vSlice))
for i := range vSlice {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
res[i], err = ec.unmarshalOMultiHelloByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloByNamesInput(ctx, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil
}
func (ec *executionContext) unmarshalNMultiHelloMultipleRequiresByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloMultipleRequiresByNamesInput(ctx context.Context, v any) ([]*MultiHelloMultipleRequiresByNamesInput, error) {
var vSlice []any
vSlice = graphql.CoerceList(v)
var err error
res := make([]*MultiHelloMultipleRequiresByNamesInput, len(vSlice))
for i := range vSlice {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
res[i], err = ec.unmarshalOMultiHelloMultipleRequiresByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloMultipleRequiresByNamesInput(ctx, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil
}
func (ec *executionContext) unmarshalNMultiHelloRequiresByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloRequiresByNamesInput(ctx context.Context, v any) ([]*MultiHelloRequiresByNamesInput, error) {
var vSlice []any
vSlice = graphql.CoerceList(v)
var err error
res := make([]*MultiHelloRequiresByNamesInput, len(vSlice))
for i := range vSlice {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
res[i], err = ec.unmarshalOMultiHelloRequiresByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloRequiresByNamesInput(ctx, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil
}
func (ec *executionContext) unmarshalNMultiHelloWithErrorByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloWithErrorByNamesInput(ctx context.Context, v any) ([]*MultiHelloWithErrorByNamesInput, error) {
var vSlice []any
vSlice = graphql.CoerceList(v)
var err error
res := make([]*MultiHelloWithErrorByNamesInput, len(vSlice))
for i := range vSlice {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
res[i], err = ec.unmarshalOMultiHelloWithErrorByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloWithErrorByNamesInput(ctx, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil
}
func (ec *executionContext) unmarshalNMultiPlanetRequiresNestedByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiPlanetRequiresNestedByNamesInput(ctx context.Context, v any) ([]*MultiPlanetRequiresNestedByNamesInput, error) {
var vSlice []any
vSlice = graphql.CoerceList(v)
var err error
res := make([]*MultiPlanetRequiresNestedByNamesInput, len(vSlice))
for i := range vSlice {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
res[i], err = ec.unmarshalOMultiPlanetRequiresNestedByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiPlanetRequiresNestedByNamesInput(ctx, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil
}
func (ec *executionContext) marshalNPerson2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐPerson(ctx context.Context, sel ast.SelectionSet, v Person) graphql.Marshaler {
return ec._Person(ctx, sel, &v)
}
func (ec *executionContext) marshalNPerson2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐPerson(ctx context.Context, sel ast.SelectionSet, v *Person) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return ec._Person(ctx, sel, v)
}
func (ec *executionContext) marshalNPlanetMultipleRequires2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐPlanetMultipleRequires(ctx context.Context, sel ast.SelectionSet, v PlanetMultipleRequires) graphql.Marshaler {
return ec._PlanetMultipleRequires(ctx, sel, &v)
}
func (ec *executionContext) marshalNPlanetMultipleRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐPlanetMultipleRequires(ctx context.Context, sel ast.SelectionSet, v *PlanetMultipleRequires) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐPlanetRequires(ctx context.Context, sel ast.SelectionSet, v PlanetRequires) graphql.Marshaler {
return ec._PlanetRequires(ctx, sel, &v)
}
func (ec *executionContext) marshalNPlanetRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐPlanetRequires(ctx context.Context, sel ast.SelectionSet, v *PlanetRequires) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐPlanetRequiresNested(ctx context.Context, sel ast.SelectionSet, v PlanetRequiresNested) graphql.Marshaler {
return ec._PlanetRequiresNested(ctx, sel, &v)
}
func (ec *executionContext) marshalNPlanetRequiresNested2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐPlanetRequiresNested(ctx context.Context, sel ast.SelectionSet, v *PlanetRequiresNested) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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 any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) marshalNWorld2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐWorld(ctx context.Context, sel ast.SelectionSet, v World) graphql.Marshaler {
return ec._World(ctx, sel, &v)
}
func (ec *executionContext) marshalNWorld2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐWorld(ctx context.Context, sel ast.SelectionSet, v *World) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐWorldName(ctx context.Context, sel ast.SelectionSet, v WorldName) graphql.Marshaler {
return ec._WorldName(ctx, sel, &v)
}
func (ec *executionContext) marshalNWorldName2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐWorldName(ctx context.Context, sel ast.SelectionSet, v *WorldName) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐWorldWithMultipleKeys(ctx context.Context, sel ast.SelectionSet, v WorldWithMultipleKeys) graphql.Marshaler {
return ec._WorldWithMultipleKeys(ctx, sel, &v)
}
func (ec *executionContext) marshalNWorldWithMultipleKeys2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐWorldWithMultipleKeys(ctx context.Context, sel ast.SelectionSet, v *WorldWithMultipleKeys) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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 any) (map[string]any, 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]any) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
_ = sel
res := graphql.MarshalMap(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalN_Any2ᚕmapᚄ(ctx context.Context, v any) ([]map[string]any, error) {
var vSlice []any
vSlice = graphql.CoerceList(v)
var err error
res := make([]map[string]any, 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]any) 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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v []fedruntime.Entity) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalO_Entity2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, sel, v[i])
})
return ret
}
func (ec *executionContext) unmarshalN_FieldSet2string(ctx context.Context, v any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) marshalN_Service2githubᚗcomᚋ99designsᚋ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ᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler {
return ec.___Directive(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v any) ([]string, error) {
var vSlice []any
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 := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__DirectiveLocation2string(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler {
return ec.___EnumValue(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler {
return ec.___Field(ctx, sel, &v)
}
func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler {
return ec.___InputValue(ctx, sel, &v)
}
func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler {
return ec.___Type(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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 any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v any) (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 {
_ = sel
_ = ctx
res := graphql.MarshalBoolean(v)
return res
}
func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v any) (*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
}
_ = sel
_ = ctx
res := graphql.MarshalBoolean(*v)
return res
}
func (ec *executionContext) marshalOHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐHello(ctx context.Context, sel ast.SelectionSet, v *Hello) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._Hello(ctx, sel, v)
}
func (ec *executionContext) unmarshalOInt2ᚕintᚄ(ctx context.Context, v any) ([]int, error) {
if v == nil {
return nil, nil
}
var vSlice []any
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) marshalOMultiHello2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHello(ctx context.Context, sel ast.SelectionSet, v []*MultiHello) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalOMultiHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHello(ctx, sel, v[i])
})
return ret
}
func (ec *executionContext) marshalOMultiHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHello(ctx context.Context, sel ast.SelectionSet, v *MultiHello) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._MultiHello(ctx, sel, v)
}
func (ec *executionContext) unmarshalOMultiHelloByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloByNamesInput(ctx context.Context, v any) (*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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloMultipleRequires(ctx context.Context, sel ast.SelectionSet, v []*MultiHelloMultipleRequires) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalOMultiHelloMultipleRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloMultipleRequires(ctx, sel, v[i])
})
return ret
}
func (ec *executionContext) marshalOMultiHelloMultipleRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloMultipleRequires(ctx context.Context, sel ast.SelectionSet, v *MultiHelloMultipleRequires) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._MultiHelloMultipleRequires(ctx, sel, v)
}
func (ec *executionContext) unmarshalOMultiHelloMultipleRequiresByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloMultipleRequiresByNamesInput(ctx context.Context, v any) (*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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloRequires(ctx context.Context, sel ast.SelectionSet, v []*MultiHelloRequires) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalOMultiHelloRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloRequires(ctx, sel, v[i])
})
return ret
}
func (ec *executionContext) marshalOMultiHelloRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloRequires(ctx context.Context, sel ast.SelectionSet, v *MultiHelloRequires) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._MultiHelloRequires(ctx, sel, v)
}
func (ec *executionContext) unmarshalOMultiHelloRequiresByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloRequiresByNamesInput(ctx context.Context, v any) (*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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloWithError(ctx context.Context, sel ast.SelectionSet, v []*MultiHelloWithError) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalOMultiHelloWithError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloWithError(ctx, sel, v[i])
})
return ret
}
func (ec *executionContext) marshalOMultiHelloWithError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloWithError(ctx context.Context, sel ast.SelectionSet, v *MultiHelloWithError) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._MultiHelloWithError(ctx, sel, v)
}
func (ec *executionContext) unmarshalOMultiHelloWithErrorByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiHelloWithErrorByNamesInput(ctx context.Context, v any) (*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ᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiPlanetRequiresNested(ctx context.Context, sel ast.SelectionSet, v []*MultiPlanetRequiresNested) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalOMultiPlanetRequiresNested2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiPlanetRequiresNested(ctx, sel, v[i])
})
return ret
}
func (ec *executionContext) marshalOMultiPlanetRequiresNested2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiPlanetRequiresNested(ctx context.Context, sel ast.SelectionSet, v *MultiPlanetRequiresNested) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._MultiPlanetRequiresNested(ctx, sel, v)
}
func (ec *executionContext) unmarshalOMultiPlanetRequiresNestedByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐMultiPlanetRequiresNestedByNamesInput(ctx context.Context, v any) (*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 any) (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 {
_ = sel
_ = ctx
res := graphql.MarshalString(v)
return res
}
func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v any) (*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
}
_ = sel
_ = ctx
res := graphql.MarshalString(*v)
return res
}
func (ec *executionContext) marshalOWorld2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐWorldᚄ(ctx context.Context, sel ast.SelectionSet, v []*World) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalNWorld2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋexplicitrequiresᚋgeneratedᚐWorld(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO_Entity2githubᚗcomᚋ99designsᚋ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ᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec.___Schema(ctx, sel, v)
}
func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec.___Type(ctx, sel, v)
}
// endregion ***************************** type.gotpl *****************************
================================================
FILE: plugin/federation/testdata/explicitrequires/generated/federation.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package generated
import (
"context"
"errors"
"fmt"
"strings"
"sync"
"github.com/99designs/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]any) []fedruntime.Entity {
list := make([]fedruntime.Entity, len(representations))
repsMap := ec.buildRepresentationGroups(ctx, representations)
switch len(repsMap) {
case 0:
return list
case 1:
for typeName, reps := range repsMap {
ec.resolveEntityGroup(ctx, typeName, reps, list)
}
return list
default:
var g sync.WaitGroup
g.Add(len(repsMap))
for typeName, reps := range repsMap {
go func(typeName string, reps []EntityWithIndex) {
ec.resolveEntityGroup(ctx, typeName, reps, list)
g.Done()
}(typeName, reps)
}
g.Wait()
return list
}
}
type EntityWithIndex struct {
// The index in the original representation array
index int
entity EntityRepresentation
}
// EntityRepresentation is the JSON representation of an entity sent by the Router
// used as the inputs for us to resolve.
//
// We make it a map because we know the top level JSON is always an object.
type EntityRepresentation map[string]any
// We group entities by typename so that we can parallelize their resolution.
// This is particularly helpful when there are entity groups in multi mode.
func (ec *executionContext) buildRepresentationGroups(
ctx context.Context,
representations []map[string]any,
) map[string][]EntityWithIndex {
repsMap := make(map[string][]EntityWithIndex)
for i, rep := range representations {
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
}
repsMap[typeName] = append(repsMap[typeName], EntityWithIndex{
index: i,
entity: rep,
})
}
return repsMap
}
func (ec *executionContext) resolveEntityGroup(
ctx context.Context,
typeName string,
reps []EntityWithIndex,
list []fedruntime.Entity,
) {
if isMulti(typeName) {
err := ec.resolveManyEntities(ctx, typeName, reps, list)
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 EntityWithIndex) {
entity, err := ec.resolveEntity(ctx, typeName, rep.entity)
if err != nil {
ec.Error(ctx, err)
} else {
list[rep.index] = entity
}
e.Done()
}(i, rep)
}
e.Wait()
}
}
func isMulti(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
}
}
func (ec *executionContext) resolveEntity(
ctx context.Context,
typeName string,
rep EntityRepresentation,
) (e fedruntime.Entity, 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 nil, fmt.Errorf(`finding resolver for Entity "Hello": %w`, err)
}
switch resolverName {
case "findHelloByName":
id0, err := ec.unmarshalNString2string(ctx, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findHelloByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindHelloByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "Hello": %w`, err)
}
return entity, nil
}
case "HelloMultiSingleKeys":
resolverName, err := entityResolverNameForHelloMultiSingleKeys(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "HelloMultiSingleKeys": %w`, err)
}
switch resolverName {
case "findHelloMultiSingleKeysByKey1AndKey2":
id0, err := ec.unmarshalNString2string(ctx, rep["key1"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findHelloMultiSingleKeysByKey1AndKey2(): %w`, err)
}
id1, err := ec.unmarshalNString2string(ctx, rep["key2"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 1 for findHelloMultiSingleKeysByKey1AndKey2(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindHelloMultiSingleKeysByKey1AndKey2(ctx, id0, id1)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "HelloMultiSingleKeys": %w`, err)
}
return entity, nil
}
case "HelloWithErrors":
resolverName, err := entityResolverNameForHelloWithErrors(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "HelloWithErrors": %w`, err)
}
switch resolverName {
case "findHelloWithErrorsByName":
id0, err := ec.unmarshalNString2string(ctx, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findHelloWithErrorsByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindHelloWithErrorsByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "HelloWithErrors": %w`, err)
}
return entity, nil
}
case "Person":
resolverName, err := entityResolverNameForPerson(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "Person": %w`, err)
}
switch resolverName {
case "findPersonByName":
id0, err := ec.unmarshalNString2string(ctx, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findPersonByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindPersonByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "Person": %w`, err)
}
err = ec.PopulatePersonRequires(ctx, entity, rep)
if err != nil {
return nil, fmt.Errorf(`populating requires for Entity "Person": %w`, err)
}
return entity, nil
}
case "PlanetMultipleRequires":
resolverName, err := entityResolverNameForPlanetMultipleRequires(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "PlanetMultipleRequires": %w`, err)
}
switch resolverName {
case "findPlanetMultipleRequiresByName":
id0, err := ec.unmarshalNString2string(ctx, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findPlanetMultipleRequiresByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindPlanetMultipleRequiresByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "PlanetMultipleRequires": %w`, err)
}
err = ec.PopulatePlanetMultipleRequiresRequires(ctx, entity, rep)
if err != nil {
return nil, fmt.Errorf(`populating requires for Entity "PlanetMultipleRequires": %w`, err)
}
return entity, nil
}
case "PlanetRequires":
resolverName, err := entityResolverNameForPlanetRequires(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "PlanetRequires": %w`, err)
}
switch resolverName {
case "findPlanetRequiresByName":
id0, err := ec.unmarshalNString2string(ctx, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findPlanetRequiresByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindPlanetRequiresByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "PlanetRequires": %w`, err)
}
err = ec.PopulatePlanetRequiresRequires(ctx, entity, rep)
if err != nil {
return nil, fmt.Errorf(`populating requires for Entity "PlanetRequires": %w`, err)
}
return entity, nil
}
case "PlanetRequiresNested":
resolverName, err := entityResolverNameForPlanetRequiresNested(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "PlanetRequiresNested": %w`, err)
}
switch resolverName {
case "findPlanetRequiresNestedByName":
id0, err := ec.unmarshalNString2string(ctx, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findPlanetRequiresNestedByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindPlanetRequiresNestedByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "PlanetRequiresNested": %w`, err)
}
err = ec.PopulatePlanetRequiresNestedRequires(ctx, entity, rep)
if err != nil {
return nil, fmt.Errorf(`populating requires for Entity "PlanetRequiresNested": %w`, err)
}
return entity, nil
}
case "World":
resolverName, err := entityResolverNameForWorld(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "World": %w`, err)
}
switch resolverName {
case "findWorldByHelloNameAndFoo":
id0, err := ec.unmarshalNString2string(ctx, rep["hello"].(map[string]any)["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findWorldByHelloNameAndFoo(): %w`, err)
}
id1, err := ec.unmarshalNString2string(ctx, rep["foo"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 1 for findWorldByHelloNameAndFoo(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindWorldByHelloNameAndFoo(ctx, id0, id1)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "World": %w`, err)
}
return entity, nil
}
case "WorldName":
resolverName, err := entityResolverNameForWorldName(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "WorldName": %w`, err)
}
switch resolverName {
case "findWorldNameByName":
id0, err := ec.unmarshalNString2string(ctx, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findWorldNameByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindWorldNameByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "WorldName": %w`, err)
}
return entity, nil
}
case "WorldWithMultipleKeys":
resolverName, err := entityResolverNameForWorldWithMultipleKeys(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "WorldWithMultipleKeys": %w`, err)
}
switch resolverName {
case "findWorldWithMultipleKeysByHelloNameAndFoo":
id0, err := ec.unmarshalNString2string(ctx, rep["hello"].(map[string]any)["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findWorldWithMultipleKeysByHelloNameAndFoo(): %w`, err)
}
id1, err := ec.unmarshalNString2string(ctx, rep["foo"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 1 for findWorldWithMultipleKeysByHelloNameAndFoo(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindWorldWithMultipleKeysByHelloNameAndFoo(ctx, id0, id1)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "WorldWithMultipleKeys": %w`, err)
}
return entity, nil
case "findWorldWithMultipleKeysByBar":
id0, err := ec.unmarshalNInt2int(ctx, rep["bar"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findWorldWithMultipleKeysByBar(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindWorldWithMultipleKeysByBar(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "WorldWithMultipleKeys": %w`, err)
}
return entity, nil
}
}
return nil, fmt.Errorf("%w: %s", ErrUnknownType, typeName)
}
func (ec *executionContext) resolveManyEntities(
ctx context.Context,
typeName string,
reps []EntityWithIndex,
list []fedruntime.Entity,
) (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].entity)
if err != nil {
return fmt.Errorf(`finding resolver for Entity "MultiHello": %w`, err)
}
switch resolverName {
case "findManyMultiHelloByNames":
typedReps := make([]*MultiHelloByNamesInput, len(reps))
for i, rep := range reps {
id0, err := ec.unmarshalNString2string(ctx, rep.entity["name"])
if err != nil {
return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name"))
}
typedReps[i] = &MultiHelloByNamesInput{
Name: id0,
}
}
entities, err := ec.Resolvers.Entity().FindManyMultiHelloByNames(ctx, typedReps)
if err != nil {
return err
}
for i, entity := range entities {
list[reps[i].index] = entity
}
return nil
default:
return fmt.Errorf("unknown resolver: %s", resolverName)
}
case "MultiHelloMultipleRequires":
resolverName, err := entityResolverNameForMultiHelloMultipleRequires(ctx, reps[0].entity)
if err != nil {
return fmt.Errorf(`finding resolver for Entity "MultiHelloMultipleRequires": %w`, err)
}
switch resolverName {
case "findManyMultiHelloMultipleRequiresByNames":
typedReps := make([]*MultiHelloMultipleRequiresByNamesInput, len(reps))
for i, rep := range reps {
id0, err := ec.unmarshalNString2string(ctx, rep.entity["name"])
if err != nil {
return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name"))
}
typedReps[i] = &MultiHelloMultipleRequiresByNamesInput{
Name: id0,
}
}
entities, err := ec.Resolvers.Entity().FindManyMultiHelloMultipleRequiresByNames(ctx, typedReps)
if err != nil {
return err
}
for i, entity := range entities {
err = ec.PopulateMultiHelloMultipleRequiresRequires(ctx, entity, reps[i].entity)
if err != nil {
return fmt.Errorf(`populating requires for Entity "MultiHelloMultipleRequires": %w`, err)
}
list[reps[i].index] = entity
}
return nil
default:
return fmt.Errorf("unknown resolver: %s", resolverName)
}
case "MultiHelloRequires":
resolverName, err := entityResolverNameForMultiHelloRequires(ctx, reps[0].entity)
if err != nil {
return fmt.Errorf(`finding resolver for Entity "MultiHelloRequires": %w`, err)
}
switch resolverName {
case "findManyMultiHelloRequiresByNames":
typedReps := make([]*MultiHelloRequiresByNamesInput, len(reps))
for i, rep := range reps {
id0, err := ec.unmarshalNString2string(ctx, rep.entity["name"])
if err != nil {
return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name"))
}
typedReps[i] = &MultiHelloRequiresByNamesInput{
Name: id0,
}
}
entities, err := ec.Resolvers.Entity().FindManyMultiHelloRequiresByNames(ctx, typedReps)
if err != nil {
return err
}
for i, entity := range entities {
err = ec.PopulateMultiHelloRequiresRequires(ctx, entity, reps[i].entity)
if err != nil {
return fmt.Errorf(`populating requires for Entity "MultiHelloRequires": %w`, err)
}
list[reps[i].index] = entity
}
return nil
default:
return fmt.Errorf("unknown resolver: %s", resolverName)
}
case "MultiHelloWithError":
resolverName, err := entityResolverNameForMultiHelloWithError(ctx, reps[0].entity)
if err != nil {
return fmt.Errorf(`finding resolver for Entity "MultiHelloWithError": %w`, err)
}
switch resolverName {
case "findManyMultiHelloWithErrorByNames":
typedReps := make([]*MultiHelloWithErrorByNamesInput, len(reps))
for i, rep := range reps {
id0, err := ec.unmarshalNString2string(ctx, rep.entity["name"])
if err != nil {
return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name"))
}
typedReps[i] = &MultiHelloWithErrorByNamesInput{
Name: id0,
}
}
entities, err := ec.Resolvers.Entity().FindManyMultiHelloWithErrorByNames(ctx, typedReps)
if err != nil {
return err
}
for i, entity := range entities {
list[reps[i].index] = entity
}
return nil
default:
return fmt.Errorf("unknown resolver: %s", resolverName)
}
case "MultiPlanetRequiresNested":
resolverName, err := entityResolverNameForMultiPlanetRequiresNested(ctx, reps[0].entity)
if err != nil {
return fmt.Errorf(`finding resolver for Entity "MultiPlanetRequiresNested": %w`, err)
}
switch resolverName {
case "findManyMultiPlanetRequiresNestedByNames":
typedReps := make([]*MultiPlanetRequiresNestedByNamesInput, len(reps))
for i, rep := range reps {
id0, err := ec.unmarshalNString2string(ctx, rep.entity["name"])
if err != nil {
return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name"))
}
typedReps[i] = &MultiPlanetRequiresNestedByNamesInput{
Name: id0,
}
}
entities, err := ec.Resolvers.Entity().FindManyMultiPlanetRequiresNestedByNames(ctx, typedReps)
if err != nil {
return err
}
for i, entity := range entities {
err = ec.PopulateMultiPlanetRequiresNestedRequires(ctx, entity, reps[i].entity)
if err != nil {
return fmt.Errorf(`populating requires for Entity "MultiPlanetRequiresNested": %w`, err)
}
list[reps[i].index] = entity
}
return nil
default:
return fmt.Errorf("unknown resolver: %s", resolverName)
}
default:
return errors.New("unknown type: " + typeName)
}
}
func entityResolverNameForHello(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for Hello", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for Hello", ErrTypeNotFound))
break
}
return "findHelloByName", nil
}
return "", fmt.Errorf("%w for Hello due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForHelloMultiSingleKeys(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["key1"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"key1\" for HelloMultiSingleKeys", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
m = rep
val, ok = m["key2"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"key2\" for HelloMultiSingleKeys", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for HelloMultiSingleKeys", ErrTypeNotFound))
break
}
return "findHelloMultiSingleKeysByKey1AndKey2", nil
}
return "", fmt.Errorf("%w for HelloMultiSingleKeys due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForHelloWithErrors(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for HelloWithErrors", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for HelloWithErrors", ErrTypeNotFound))
break
}
return "findHelloWithErrorsByName", nil
}
return "", fmt.Errorf("%w for HelloWithErrors due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForMultiHello(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for MultiHello", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for MultiHello", ErrTypeNotFound))
break
}
return "findManyMultiHelloByNames", nil
}
return "", fmt.Errorf("%w for MultiHello due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForMultiHelloMultipleRequires(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for MultiHelloMultipleRequires", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for MultiHelloMultipleRequires", ErrTypeNotFound))
break
}
return "findManyMultiHelloMultipleRequiresByNames", nil
}
return "", fmt.Errorf("%w for MultiHelloMultipleRequires due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForMultiHelloRequires(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for MultiHelloRequires", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for MultiHelloRequires", ErrTypeNotFound))
break
}
return "findManyMultiHelloRequiresByNames", nil
}
return "", fmt.Errorf("%w for MultiHelloRequires due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForMultiHelloWithError(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for MultiHelloWithError", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for MultiHelloWithError", ErrTypeNotFound))
break
}
return "findManyMultiHelloWithErrorByNames", nil
}
return "", fmt.Errorf("%w for MultiHelloWithError due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForMultiPlanetRequiresNested(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for MultiPlanetRequiresNested", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for MultiPlanetRequiresNested", ErrTypeNotFound))
break
}
return "findManyMultiPlanetRequiresNestedByNames", nil
}
return "", fmt.Errorf("%w for MultiPlanetRequiresNested due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForPerson(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for Person", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for Person", ErrTypeNotFound))
break
}
return "findPersonByName", nil
}
return "", fmt.Errorf("%w for Person due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForPlanetMultipleRequires(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for PlanetMultipleRequires", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for PlanetMultipleRequires", ErrTypeNotFound))
break
}
return "findPlanetMultipleRequiresByName", nil
}
return "", fmt.Errorf("%w for PlanetMultipleRequires due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForPlanetRequires(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for PlanetRequires", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for PlanetRequires", ErrTypeNotFound))
break
}
return "findPlanetRequiresByName", nil
}
return "", fmt.Errorf("%w for PlanetRequires due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForPlanetRequiresNested(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for PlanetRequiresNested", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for PlanetRequiresNested", ErrTypeNotFound))
break
}
return "findPlanetRequiresNestedByName", nil
}
return "", fmt.Errorf("%w for PlanetRequiresNested due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForWorld(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["hello"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"hello\" for World", ErrTypeNotFound))
break
}
if m, ok = val.(map[string]any); !ok {
// nested field value is not a map[string]interface so don't use it
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to nested Key Field \"hello\" value not matching map[string]any for World", ErrTypeNotFound))
break
}
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for World", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
m = rep
val, ok = m["foo"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"foo\" for World", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for World", ErrTypeNotFound))
break
}
return "findWorldByHelloNameAndFoo", nil
}
return "", fmt.Errorf("%w for World due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForWorldName(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for WorldName", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for WorldName", ErrTypeNotFound))
break
}
return "findWorldNameByName", nil
}
return "", fmt.Errorf("%w for WorldName due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForWorldWithMultipleKeys(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["hello"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"hello\" for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
if m, ok = val.(map[string]any); !ok {
// nested field value is not a map[string]interface so don't use it
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to nested Key Field \"hello\" value not matching map[string]any for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
m = rep
val, ok = m["foo"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"foo\" for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
return "findWorldWithMultipleKeysByHelloNameAndFoo", nil
}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["bar"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"bar\" for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
return "findWorldWithMultipleKeysByBar", nil
}
return "", fmt.Errorf("%w for WorldWithMultipleKeys due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
================================================
FILE: plugin/federation/testdata/explicitrequires/generated/federation.requires.go
================================================
package generated
import (
"context"
"encoding/json"
"fmt"
)
// PopulateMultiHelloMultipleRequiresRequires is the requires populator for the MultiHelloMultipleRequires entity.
func (ec *executionContext) PopulateMultiHelloMultipleRequiresRequires(ctx context.Context, entity *MultiHelloMultipleRequires, reps map[string]any) error {
entity.Name, _ = reps["name"].(string)
entity.Key1, _ = reps["key1"].(string)
entity.Key2, _ = reps["key2"].(string)
return nil
}
// PopulateMultiHelloRequiresRequires is the requires populator for the MultiHelloRequires entity.
func (ec *executionContext) PopulateMultiHelloRequiresRequires(ctx context.Context, entity *MultiHelloRequires, reps map[string]any) error {
entity.Name, _ = reps["name"].(string)
entity.Key1, _ = reps["key1"].(string)
return nil
}
// PopulateMultiPlanetRequiresNestedRequires is the requires populator for the MultiPlanetRequiresNested entity.
func (ec *executionContext) PopulateMultiPlanetRequiresNestedRequires(ctx context.Context, entity *MultiPlanetRequiresNested, reps map[string]any) error {
entity.Name = reps["name"].(string)
entity.World = &World{
Foo: reps["world"].(map[string]any)["foo"].(string),
}
return nil
}
// PopulatePersonRequires is the requires populator for the Person entity.
func (ec *executionContext) PopulatePersonRequires(ctx context.Context, entity *Person, reps map[string]any) error {
panic(fmt.Errorf("not implemented: PopulatePersonRequires"))
}
// PopulatePlanetMultipleRequiresRequires is the requires populator for the PlanetMultipleRequires entity.
func (ec *executionContext) PopulatePlanetMultipleRequiresRequires(ctx context.Context, entity *PlanetMultipleRequires, reps map[string]any) error {
diameter, _ := reps["diameter"].(json.Number).Int64()
density, _ := reps["density"].(json.Number).Int64()
entity.Name = reps["name"].(string)
entity.Diameter = int(diameter)
entity.Density = int(density)
return nil
}
// PopulatePlanetRequiresNestedRequires is the requires populator for the PlanetRequiresNested entity.
func (ec *executionContext) PopulatePlanetRequiresNestedRequires(ctx context.Context, entity *PlanetRequiresNested, reps map[string]any) error {
entity.Name = reps["name"].(string)
entity.World = &World{
Foo: reps["world"].(map[string]any)["foo"].(string),
}
return nil
}
// PopulatePlanetRequiresRequires is the requires populator for the PlanetRequires entity.
func (ec *executionContext) PopulatePlanetRequiresRequires(ctx context.Context, entity *PlanetRequires, reps map[string]any) error {
diameter, _ := reps["diameter"].(json.Number).Int64()
entity.Name = reps["name"].(string)
entity.Diameter = int(diameter)
return nil
}
================================================
FILE: plugin/federation/testdata/explicitrequires/generated/models.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package generated
type Gender interface {
IsGender()
}
type Female struct {
Description string `json:"description"`
}
func (Female) IsGender() {}
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 Male struct {
Description string `json:"description"`
}
func (Male) IsGender() {}
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"`
Worlds []*World `json:"worlds,omitempty"`
Size int `json:"size"`
Sizes []int `json:"sizes,omitempty"`
}
func (MultiPlanetRequiresNested) IsEntity() {}
type MultiPlanetRequiresNestedByNamesInput struct {
Name string `json:"Name"`
}
type Person struct {
Name string `json:"name"`
Gender Gender `json:"gender"`
WelcomeMessage *string `json:"welcomeMessage,omitempty"`
}
func (Person) IsEntity() {}
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"`
Worlds []*World `json:"worlds,omitempty"`
Size int `json:"size"`
Sizes []int `json:"sizes,omitempty"`
}
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() {}
================================================
FILE: plugin/federation/testdata/explicitrequires/gqlgen.yml
================================================
schema:
- "testdata/explicitrequires/schema.graphql"
exec:
filename: testdata/explicitrequires/generated/exec.go
federation:
filename: testdata/explicitrequires/generated/federation.go
options:
explicit_requires: true
model:
filename: testdata/explicitrequires/generated/models.go
resolver:
filename: testdata/explicitrequires/resolver.go
layout: follow-schema
dir: testdata/explicitrequires
package: explicitrequires
omit_complexity: true
================================================
FILE: plugin/federation/testdata/explicitrequires/resolver.go
================================================
package explicitrequires
// This file will not be regenerated automatically.
//
// It serves as dependency injection for your app, add any dependencies you require here.
type Resolver struct{}
================================================
FILE: plugin/federation/testdata/explicitrequires/schema.graphql
================================================
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 Person @key(fields: "name"){
name: String!
gender: Gender!
welcomeMessage: String @requires(fields:"gender { ... on Male {description} ... on Female {description}}")
}
union Gender = Male | Female
type Male {
description: String!
}
type Female {
description: String!
}
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
worlds: [World!] @external
size: Int! @requires(fields: "world{ foo }")
sizes: [Int!] @requires(fields: "worlds{ foo }")
}
type MultiPlanetRequiresNested @key(fields: "name") @entityResolver(multi: true) {
name: String! @external
world: World! @external
worlds: [World!] @external
size: Int! @requires(fields: "world{ foo }")
sizes: [Int!] @requires(fields: "worlds{ 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")
}
================================================
FILE: plugin/federation/testdata/explicitrequires/schema.resolvers.go
================================================
package explicitrequires
// 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.
================================================
FILE: plugin/federation/testdata/federation2/federation2.graphql
================================================
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.7",
import: ["@key", "@shareable", "@provides", "@external", "@tag", "@extends", "@override", "@inaccessible", "@interfaceObject", "@policy"])
schema {
query: CustomQuery
}
type Hello @key(fields:"name", resolvable: false) {
name: String! @override(from: "old-service", label: "percent(5)")
}
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!
}
================================================
FILE: plugin/federation/testdata/federation2/federation2.yml
================================================
schema:
- "testdata/federation2/federation2.graphql"
exec:
filename: testdata/federation2/generated/exec.go
federation:
filename: testdata/federation2/generated/federation.go
version: 2
autobind:
- "github.com/99designs/gqlgen/plugin/federation/test_data/model2"
================================================
FILE: plugin/federation/testdata/federation2/generated/federation.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package generated
import (
"context"
"errors"
"fmt"
"strings"
"sync"
"github.com/99designs/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]any) []fedruntime.Entity {
list := make([]fedruntime.Entity, len(representations))
repsMap := ec.buildRepresentationGroups(ctx, representations)
switch len(repsMap) {
case 0:
return list
case 1:
for typeName, reps := range repsMap {
ec.resolveEntityGroup(ctx, typeName, reps, list)
}
return list
default:
var g sync.WaitGroup
g.Add(len(repsMap))
for typeName, reps := range repsMap {
go func(typeName string, reps []EntityWithIndex) {
ec.resolveEntityGroup(ctx, typeName, reps, list)
g.Done()
}(typeName, reps)
}
g.Wait()
return list
}
}
type EntityWithIndex struct {
// The index in the original representation array
index int
entity EntityRepresentation
}
// EntityRepresentation is the JSON representation of an entity sent by the Router
// used as the inputs for us to resolve.
//
// We make it a map because we know the top level JSON is always an object.
type EntityRepresentation map[string]any
// We group entities by typename so that we can parallelize their resolution.
// This is particularly helpful when there are entity groups in multi mode.
func (ec *executionContext) buildRepresentationGroups(
ctx context.Context,
representations []map[string]any,
) map[string][]EntityWithIndex {
repsMap := make(map[string][]EntityWithIndex)
for i, rep := range representations {
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
}
repsMap[typeName] = append(repsMap[typeName], EntityWithIndex{
index: i,
entity: rep,
})
}
return repsMap
}
func (ec *executionContext) resolveEntityGroup(
ctx context.Context,
typeName string,
reps []EntityWithIndex,
list []fedruntime.Entity,
) {
if isMulti(typeName) {
err := ec.resolveManyEntities(ctx, typeName, reps, list)
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 EntityWithIndex) {
entity, err := ec.resolveEntity(ctx, typeName, rep.entity)
if err != nil {
ec.Error(ctx, err)
} else {
list[rep.index] = entity
}
e.Done()
}(i, rep)
}
e.Wait()
}
}
func isMulti(typeName string) bool {
switch typeName {
default:
return false
}
}
func (ec *executionContext) resolveEntity(
ctx context.Context,
typeName string,
rep EntityRepresentation,
) (e fedruntime.Entity, 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 nil, fmt.Errorf(`finding resolver for Entity "ExternalExtension": %w`, err)
}
switch resolverName {
case "findExternalExtensionByUpc":
id0, err := ec.unmarshalNString2string(ctx, rep["upc"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findExternalExtensionByUpc(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindExternalExtensionByUpc(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "ExternalExtension": %w`, err)
}
return entity, nil
}
}
return nil, fmt.Errorf("%w: %s", ErrUnknownType, typeName)
}
func (ec *executionContext) resolveManyEntities(
ctx context.Context,
typeName string,
reps []EntityWithIndex,
list []fedruntime.Entity,
) (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)
}
}
func entityResolverNameForExternalExtension(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["upc"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"upc\" for ExternalExtension", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for ExternalExtension", ErrTypeNotFound))
break
}
return "findExternalExtensionByUpc", nil
}
return "", fmt.Errorf("%w for ExternalExtension due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
================================================
FILE: plugin/federation/testdata/interfaces/extends.graphqls
================================================
interface Hello @extends {
name: String!
secondary: String!
}
extend type World implements Hello @key(fields: "name") {
name: String! @external
secondary: String!
tertiary: String!
}
================================================
FILE: plugin/federation/testdata/interfaces/extends.yml
================================================
schema:
- "testdata/interfaces/extends.graphqls"
exec:
filename: testdata/interfaces/generated/exec.go
federation:
filename: testdata/interfaces/generated/federation.go
================================================
FILE: plugin/federation/testdata/interfaces/key.graphqls
================================================
extend interface Hello @key(fields: "name") {
name: String!
secondary: String!
}
type World implements Hello @key(fields: "name") {
name: String!
secondary: String!
}
================================================
FILE: plugin/federation/testdata/interfaces/key.yml
================================================
schema:
- "testdata/interfaces/key.graphqls"
exec:
filename: testdata/interfaces/generated/exec.go
federation:
filename: testdata/interfaces/generated/federation.go
================================================
FILE: plugin/federation/testdata/interfaces/unused_key.graphqls
================================================
extend interface Hello @key(fields: "name") {
name: String!
secondary: String!
}
================================================
FILE: plugin/federation/testdata/interfaces/unused_key.yml
================================================
schema:
- "testdata/interfaces/unused_key.graphqls"
exec:
filename: testdata/interfaces/generated/exec.go
federation:
filename: testdata/interfaces/generated/federation.go
================================================
FILE: plugin/federation/testdata/multi/multi.graphqls
================================================
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.7",
import: ["@key"])
directive @entityResolver(multi: Boolean) on OBJECT
type Hello @key(fields: "name") @entityResolver(multi: true) {
name: String!
secondary: String!
}
================================================
FILE: plugin/federation/testdata/multi/multi.yml
================================================
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
================================================
FILE: plugin/federation/testdata/schema/customquerytype.graphql
================================================
schema {
query: CustomQuery
}
type Hello {
name: String!
}
type CustomQuery {
hello: Hello!
}
================================================
FILE: plugin/federation/testdata/schema/customquerytype.yml
================================================
schema:
- "testdata/schema/customquerytype.graphql"
exec:
filename: testdata/schema/generated/exec.go
federation:
filename: testdata/schema/generated/federation.go
autobind:
- "github.com/99designs/gqlgen/plugin/federation/test_data/model"
================================================
FILE: plugin/federation/testdata/usefunctionsyntaxforexecutioncontext/entity.resolvers.go
================================================
package usefunctionsyntaxforexecutioncontext
// 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/99designs/gqlgen version v0.17.88-dev
import (
"context"
"fmt"
"github.com/99designs/gqlgen/plugin/federation/testdata/usefunctionsyntaxforexecutioncontext/generated"
"github.com/99designs/gqlgen/plugin/federation/testdata/usefunctionsyntaxforexecutioncontext/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,
Bar: FindWorldWithMultipleKeysByHelloNameAndFooBarValue,
}, 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 }
================================================
FILE: plugin/federation/testdata/usefunctionsyntaxforexecutioncontext/generated/errors.go
================================================
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")
)
================================================
FILE: plugin/federation/testdata/usefunctionsyntaxforexecutioncontext/generated/exec.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package generated
import (
"bytes"
"context"
"errors"
"fmt"
"strconv"
"sync/atomic"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/introspection"
"github.com/99designs/gqlgen/plugin/federation/fedruntime"
"github.com/99designs/gqlgen/plugin/federation/testdata/usefunctionsyntaxforexecutioncontext/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{SchemaData: cfg.Schema, Resolvers: cfg.Resolvers, Directives: cfg.Directives, ComplexityRoot: cfg.Complexity}
}
type Config = graphql.Config[ResolverRoot, DirectiveRoot, ComplexityRoot]
type ResolverRoot interface {
Entity() EntityResolver
}
type DirectiveRoot struct {
}
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]any) 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 graphql.ExecutableSchemaState[ResolverRoot, DirectiveRoot, ComplexityRoot]
func (e *executableSchema) Schema() *ast.Schema {
if e.SchemaData != nil {
return e.SchemaData
}
return parsedSchema
}
func (e *executableSchema) Complexity(ctx context.Context, typeName, field string, childComplexity int, rawArgs map[string]any) (int, bool) {
ec := newExecutionContext(nil, e, nil)
_ = ec
switch typeName + "." + field {
case "Entity.findHelloByName":
if e.ComplexityRoot.Entity.FindHelloByName == nil {
break
}
args, err := field_Entity_findHelloByName_args(ctx, &ec, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindHelloByName(childComplexity, args["name"].(string)), true
case "Entity.findHelloMultiSingleKeysByKey1AndKey2":
if e.ComplexityRoot.Entity.FindHelloMultiSingleKeysByKey1AndKey2 == nil {
break
}
args, err := field_Entity_findHelloMultiSingleKeysByKey1AndKey2_args(ctx, &ec, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindHelloMultiSingleKeysByKey1AndKey2(childComplexity, args["key1"].(string), args["key2"].(string)), true
case "Entity.findHelloWithErrorsByName":
if e.ComplexityRoot.Entity.FindHelloWithErrorsByName == nil {
break
}
args, err := field_Entity_findHelloWithErrorsByName_args(ctx, &ec, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindHelloWithErrorsByName(childComplexity, args["name"].(string)), true
case "Entity.findManyMultiHelloByNames":
if e.ComplexityRoot.Entity.FindManyMultiHelloByNames == nil {
break
}
args, err := field_Entity_findManyMultiHelloByNames_args(ctx, &ec, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindManyMultiHelloByNames(childComplexity, args["reps"].([]*model.MultiHelloByNamesInput)), true
case "Entity.findManyMultiHelloMultipleRequiresByNames":
if e.ComplexityRoot.Entity.FindManyMultiHelloMultipleRequiresByNames == nil {
break
}
args, err := field_Entity_findManyMultiHelloMultipleRequiresByNames_args(ctx, &ec, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindManyMultiHelloMultipleRequiresByNames(childComplexity, args["reps"].([]*model.MultiHelloMultipleRequiresByNamesInput)), true
case "Entity.findManyMultiHelloRequiresByNames":
if e.ComplexityRoot.Entity.FindManyMultiHelloRequiresByNames == nil {
break
}
args, err := field_Entity_findManyMultiHelloRequiresByNames_args(ctx, &ec, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindManyMultiHelloRequiresByNames(childComplexity, args["reps"].([]*model.MultiHelloRequiresByNamesInput)), true
case "Entity.findManyMultiHelloWithErrorByNames":
if e.ComplexityRoot.Entity.FindManyMultiHelloWithErrorByNames == nil {
break
}
args, err := field_Entity_findManyMultiHelloWithErrorByNames_args(ctx, &ec, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindManyMultiHelloWithErrorByNames(childComplexity, args["reps"].([]*model.MultiHelloWithErrorByNamesInput)), true
case "Entity.findManyMultiPlanetRequiresNestedByNames":
if e.ComplexityRoot.Entity.FindManyMultiPlanetRequiresNestedByNames == nil {
break
}
args, err := field_Entity_findManyMultiPlanetRequiresNestedByNames_args(ctx, &ec, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindManyMultiPlanetRequiresNestedByNames(childComplexity, args["reps"].([]*model.MultiPlanetRequiresNestedByNamesInput)), true
case "Entity.findPlanetMultipleRequiresByName":
if e.ComplexityRoot.Entity.FindPlanetMultipleRequiresByName == nil {
break
}
args, err := field_Entity_findPlanetMultipleRequiresByName_args(ctx, &ec, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindPlanetMultipleRequiresByName(childComplexity, args["name"].(string)), true
case "Entity.findPlanetRequiresByName":
if e.ComplexityRoot.Entity.FindPlanetRequiresByName == nil {
break
}
args, err := field_Entity_findPlanetRequiresByName_args(ctx, &ec, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindPlanetRequiresByName(childComplexity, args["name"].(string)), true
case "Entity.findPlanetRequiresNestedByName":
if e.ComplexityRoot.Entity.FindPlanetRequiresNestedByName == nil {
break
}
args, err := field_Entity_findPlanetRequiresNestedByName_args(ctx, &ec, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindPlanetRequiresNestedByName(childComplexity, args["name"].(string)), true
case "Entity.findWorldByHelloNameAndFoo":
if e.ComplexityRoot.Entity.FindWorldByHelloNameAndFoo == nil {
break
}
args, err := field_Entity_findWorldByHelloNameAndFoo_args(ctx, &ec, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindWorldByHelloNameAndFoo(childComplexity, args["helloName"].(string), args["foo"].(string)), true
case "Entity.findWorldNameByName":
if e.ComplexityRoot.Entity.FindWorldNameByName == nil {
break
}
args, err := field_Entity_findWorldNameByName_args(ctx, &ec, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindWorldNameByName(childComplexity, args["name"].(string)), true
case "Entity.findWorldWithMultipleKeysByBar":
if e.ComplexityRoot.Entity.FindWorldWithMultipleKeysByBar == nil {
break
}
args, err := field_Entity_findWorldWithMultipleKeysByBar_args(ctx, &ec, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindWorldWithMultipleKeysByBar(childComplexity, args["bar"].(int)), true
case "Entity.findWorldWithMultipleKeysByHelloNameAndFoo":
if e.ComplexityRoot.Entity.FindWorldWithMultipleKeysByHelloNameAndFoo == nil {
break
}
args, err := field_Entity_findWorldWithMultipleKeysByHelloNameAndFoo_args(ctx, &ec, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Entity.FindWorldWithMultipleKeysByHelloNameAndFoo(childComplexity, args["helloName"].(string), args["foo"].(string)), true
case "Hello.name":
if e.ComplexityRoot.Hello.Name == nil {
break
}
return e.ComplexityRoot.Hello.Name(childComplexity), true
case "Hello.secondary":
if e.ComplexityRoot.Hello.Secondary == nil {
break
}
return e.ComplexityRoot.Hello.Secondary(childComplexity), true
case "HelloMultiSingleKeys.key1":
if e.ComplexityRoot.HelloMultiSingleKeys.Key1 == nil {
break
}
return e.ComplexityRoot.HelloMultiSingleKeys.Key1(childComplexity), true
case "HelloMultiSingleKeys.key2":
if e.ComplexityRoot.HelloMultiSingleKeys.Key2 == nil {
break
}
return e.ComplexityRoot.HelloMultiSingleKeys.Key2(childComplexity), true
case "HelloWithErrors.name":
if e.ComplexityRoot.HelloWithErrors.Name == nil {
break
}
return e.ComplexityRoot.HelloWithErrors.Name(childComplexity), true
case "MultiHello.name":
if e.ComplexityRoot.MultiHello.Name == nil {
break
}
return e.ComplexityRoot.MultiHello.Name(childComplexity), true
case "MultiHelloMultipleRequires.key1":
if e.ComplexityRoot.MultiHelloMultipleRequires.Key1 == nil {
break
}
return e.ComplexityRoot.MultiHelloMultipleRequires.Key1(childComplexity), true
case "MultiHelloMultipleRequires.key2":
if e.ComplexityRoot.MultiHelloMultipleRequires.Key2 == nil {
break
}
return e.ComplexityRoot.MultiHelloMultipleRequires.Key2(childComplexity), true
case "MultiHelloMultipleRequires.key3":
if e.ComplexityRoot.MultiHelloMultipleRequires.Key3 == nil {
break
}
return e.ComplexityRoot.MultiHelloMultipleRequires.Key3(childComplexity), true
case "MultiHelloMultipleRequires.name":
if e.ComplexityRoot.MultiHelloMultipleRequires.Name == nil {
break
}
return e.ComplexityRoot.MultiHelloMultipleRequires.Name(childComplexity), true
case "MultiHelloRequires.key1":
if e.ComplexityRoot.MultiHelloRequires.Key1 == nil {
break
}
return e.ComplexityRoot.MultiHelloRequires.Key1(childComplexity), true
case "MultiHelloRequires.key2":
if e.ComplexityRoot.MultiHelloRequires.Key2 == nil {
break
}
return e.ComplexityRoot.MultiHelloRequires.Key2(childComplexity), true
case "MultiHelloRequires.name":
if e.ComplexityRoot.MultiHelloRequires.Name == nil {
break
}
return e.ComplexityRoot.MultiHelloRequires.Name(childComplexity), true
case "MultiHelloWithError.name":
if e.ComplexityRoot.MultiHelloWithError.Name == nil {
break
}
return e.ComplexityRoot.MultiHelloWithError.Name(childComplexity), true
case "MultiPlanetRequiresNested.name":
if e.ComplexityRoot.MultiPlanetRequiresNested.Name == nil {
break
}
return e.ComplexityRoot.MultiPlanetRequiresNested.Name(childComplexity), true
case "MultiPlanetRequiresNested.size":
if e.ComplexityRoot.MultiPlanetRequiresNested.Size == nil {
break
}
return e.ComplexityRoot.MultiPlanetRequiresNested.Size(childComplexity), true
case "MultiPlanetRequiresNested.world":
if e.ComplexityRoot.MultiPlanetRequiresNested.World == nil {
break
}
return e.ComplexityRoot.MultiPlanetRequiresNested.World(childComplexity), true
case "PlanetMultipleRequires.density":
if e.ComplexityRoot.PlanetMultipleRequires.Density == nil {
break
}
return e.ComplexityRoot.PlanetMultipleRequires.Density(childComplexity), true
case "PlanetMultipleRequires.diameter":
if e.ComplexityRoot.PlanetMultipleRequires.Diameter == nil {
break
}
return e.ComplexityRoot.PlanetMultipleRequires.Diameter(childComplexity), true
case "PlanetMultipleRequires.name":
if e.ComplexityRoot.PlanetMultipleRequires.Name == nil {
break
}
return e.ComplexityRoot.PlanetMultipleRequires.Name(childComplexity), true
case "PlanetMultipleRequires.weight":
if e.ComplexityRoot.PlanetMultipleRequires.Weight == nil {
break
}
return e.ComplexityRoot.PlanetMultipleRequires.Weight(childComplexity), true
case "PlanetRequires.diameter":
if e.ComplexityRoot.PlanetRequires.Diameter == nil {
break
}
return e.ComplexityRoot.PlanetRequires.Diameter(childComplexity), true
case "PlanetRequires.name":
if e.ComplexityRoot.PlanetRequires.Name == nil {
break
}
return e.ComplexityRoot.PlanetRequires.Name(childComplexity), true
case "PlanetRequires.size":
if e.ComplexityRoot.PlanetRequires.Size == nil {
break
}
return e.ComplexityRoot.PlanetRequires.Size(childComplexity), true
case "PlanetRequiresNested.name":
if e.ComplexityRoot.PlanetRequiresNested.Name == nil {
break
}
return e.ComplexityRoot.PlanetRequiresNested.Name(childComplexity), true
case "PlanetRequiresNested.size":
if e.ComplexityRoot.PlanetRequiresNested.Size == nil {
break
}
return e.ComplexityRoot.PlanetRequiresNested.Size(childComplexity), true
case "PlanetRequiresNested.world":
if e.ComplexityRoot.PlanetRequiresNested.World == nil {
break
}
return e.ComplexityRoot.PlanetRequiresNested.World(childComplexity), true
case "Query._service":
if e.ComplexityRoot.Query.__resolve__service == nil {
break
}
return e.ComplexityRoot.Query.__resolve__service(childComplexity), true
case "Query._entities":
if e.ComplexityRoot.Query.__resolve_entities == nil {
break
}
args, err := field_Query__entities_args(ctx, &ec, rawArgs)
if err != nil {
return 0, false
}
return e.ComplexityRoot.Query.__resolve_entities(childComplexity, args["representations"].([]map[string]any)), true
case "World.bar":
if e.ComplexityRoot.World.Bar == nil {
break
}
return e.ComplexityRoot.World.Bar(childComplexity), true
case "World.foo":
if e.ComplexityRoot.World.Foo == nil {
break
}
return e.ComplexityRoot.World.Foo(childComplexity), true
case "World.hello":
if e.ComplexityRoot.World.Hello == nil {
break
}
return e.ComplexityRoot.World.Hello(childComplexity), true
case "WorldName.name":
if e.ComplexityRoot.WorldName.Name == nil {
break
}
return e.ComplexityRoot.WorldName.Name(childComplexity), true
case "WorldWithMultipleKeys.bar":
if e.ComplexityRoot.WorldWithMultipleKeys.Bar == nil {
break
}
return e.ComplexityRoot.WorldWithMultipleKeys.Bar(childComplexity), true
case "WorldWithMultipleKeys.foo":
if e.ComplexityRoot.WorldWithMultipleKeys.Foo == nil {
break
}
return e.ComplexityRoot.WorldWithMultipleKeys.Foo(childComplexity), true
case "WorldWithMultipleKeys.hello":
if e.ComplexityRoot.WorldWithMultipleKeys.Hello == nil {
break
}
return e.ComplexityRoot.WorldWithMultipleKeys.Hello(childComplexity), true
case "_Service.sdl":
if e.ComplexityRoot._Service.SDL == nil {
break
}
return e.ComplexityRoot._Service.SDL(childComplexity), true
}
return 0, false
}
func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
opCtx := graphql.GetOperationContext(ctx)
ec := newExecutionContext(opCtx, e, make(chan graphql.DeferredResult))
inputUnmarshalMap := graphql.BuildUnmarshalerMap(
unmarshalInputMultiHelloByNamesInput,
unmarshalInputMultiHelloMultipleRequiresByNamesInput,
unmarshalInputMultiHelloRequiresByNamesInput,
unmarshalInputMultiHelloWithErrorByNamesInput,
unmarshalInputMultiPlanetRequiresNestedByNamesInput,
)
first := true
switch opCtx.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 = _Query(ctx, &ec, opCtx.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.ExecutionContextState[ResolverRoot, DirectiveRoot, ComplexityRoot]
}
func newExecutionContext(
opCtx *graphql.OperationContext,
execSchema *executableSchema,
deferredResults chan graphql.DeferredResult,
) executionContext {
return executionContext{
ExecutionContextState: graphql.NewExecutionContextState[ResolverRoot, DirectiveRoot, ComplexityRoot](
opCtx,
(*graphql.ExecutableSchemaState[ResolverRoot, DirectiveRoot, ComplexityRoot])(execSchema),
parsedSchema,
deferredResults,
),
}
}
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 field_Entity_findHelloByName_args(ctx context.Context, ec *executionContext, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgFieldWithEC(ctx, ec, rawArgs, "name", unmarshalNString2string)
if err != nil {
return nil, err
}
args["name"] = arg0
return args, nil
}
func field_Entity_findHelloMultiSingleKeysByKey1AndKey2_args(ctx context.Context, ec *executionContext, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgFieldWithEC(ctx, ec, rawArgs, "key1", unmarshalNString2string)
if err != nil {
return nil, err
}
args["key1"] = arg0
arg1, err := graphql.ProcessArgFieldWithEC(ctx, ec, rawArgs, "key2", unmarshalNString2string)
if err != nil {
return nil, err
}
args["key2"] = arg1
return args, nil
}
func field_Entity_findHelloWithErrorsByName_args(ctx context.Context, ec *executionContext, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgFieldWithEC(ctx, ec, rawArgs, "name", unmarshalNString2string)
if err != nil {
return nil, err
}
args["name"] = arg0
return args, nil
}
func field_Entity_findManyMultiHelloByNames_args(ctx context.Context, ec *executionContext, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgFieldWithEC(ctx, ec, rawArgs, "reps", unmarshalNMultiHelloByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloByNamesInput)
if err != nil {
return nil, err
}
args["reps"] = arg0
return args, nil
}
func field_Entity_findManyMultiHelloMultipleRequiresByNames_args(ctx context.Context, ec *executionContext, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgFieldWithEC(ctx, ec, rawArgs, "reps", unmarshalNMultiHelloMultipleRequiresByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloMultipleRequiresByNamesInput)
if err != nil {
return nil, err
}
args["reps"] = arg0
return args, nil
}
func field_Entity_findManyMultiHelloRequiresByNames_args(ctx context.Context, ec *executionContext, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgFieldWithEC(ctx, ec, rawArgs, "reps", unmarshalNMultiHelloRequiresByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloRequiresByNamesInput)
if err != nil {
return nil, err
}
args["reps"] = arg0
return args, nil
}
func field_Entity_findManyMultiHelloWithErrorByNames_args(ctx context.Context, ec *executionContext, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgFieldWithEC(ctx, ec, rawArgs, "reps", unmarshalNMultiHelloWithErrorByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloWithErrorByNamesInput)
if err != nil {
return nil, err
}
args["reps"] = arg0
return args, nil
}
func field_Entity_findManyMultiPlanetRequiresNestedByNames_args(ctx context.Context, ec *executionContext, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgFieldWithEC(ctx, ec, rawArgs, "reps", unmarshalNMultiPlanetRequiresNestedByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiPlanetRequiresNestedByNamesInput)
if err != nil {
return nil, err
}
args["reps"] = arg0
return args, nil
}
func field_Entity_findPlanetMultipleRequiresByName_args(ctx context.Context, ec *executionContext, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgFieldWithEC(ctx, ec, rawArgs, "name", unmarshalNString2string)
if err != nil {
return nil, err
}
args["name"] = arg0
return args, nil
}
func field_Entity_findPlanetRequiresByName_args(ctx context.Context, ec *executionContext, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgFieldWithEC(ctx, ec, rawArgs, "name", unmarshalNString2string)
if err != nil {
return nil, err
}
args["name"] = arg0
return args, nil
}
func field_Entity_findPlanetRequiresNestedByName_args(ctx context.Context, ec *executionContext, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgFieldWithEC(ctx, ec, rawArgs, "name", unmarshalNString2string)
if err != nil {
return nil, err
}
args["name"] = arg0
return args, nil
}
func field_Entity_findWorldByHelloNameAndFoo_args(ctx context.Context, ec *executionContext, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgFieldWithEC(ctx, ec, rawArgs, "helloName", unmarshalNString2string)
if err != nil {
return nil, err
}
args["helloName"] = arg0
arg1, err := graphql.ProcessArgFieldWithEC(ctx, ec, rawArgs, "foo", unmarshalNString2string)
if err != nil {
return nil, err
}
args["foo"] = arg1
return args, nil
}
func field_Entity_findWorldNameByName_args(ctx context.Context, ec *executionContext, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgFieldWithEC(ctx, ec, rawArgs, "name", unmarshalNString2string)
if err != nil {
return nil, err
}
args["name"] = arg0
return args, nil
}
func field_Entity_findWorldWithMultipleKeysByBar_args(ctx context.Context, ec *executionContext, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgFieldWithEC(ctx, ec, rawArgs, "bar", unmarshalNInt2int)
if err != nil {
return nil, err
}
args["bar"] = arg0
return args, nil
}
func field_Entity_findWorldWithMultipleKeysByHelloNameAndFoo_args(ctx context.Context, ec *executionContext, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgFieldWithEC(ctx, ec, rawArgs, "helloName", unmarshalNString2string)
if err != nil {
return nil, err
}
args["helloName"] = arg0
arg1, err := graphql.ProcessArgFieldWithEC(ctx, ec, rawArgs, "foo", unmarshalNString2string)
if err != nil {
return nil, err
}
args["foo"] = arg1
return args, nil
}
func field_Query___type_args(ctx context.Context, ec *executionContext, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgFieldWithEC(ctx, ec, rawArgs, "name", unmarshalNString2string)
if err != nil {
return nil, err
}
args["name"] = arg0
return args, nil
}
func field_Query__entities_args(ctx context.Context, ec *executionContext, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgFieldWithEC(ctx, ec, rawArgs, "representations", unmarshalN_Any2ᚕmapᚄ)
if err != nil {
return nil, err
}
args["representations"] = arg0
return args, nil
}
func field___Directive_args_args(ctx context.Context, ec *executionContext, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgFieldWithEC(ctx, ec, rawArgs, "includeDeprecated", unmarshalOBoolean2ᚖbool)
if err != nil {
return nil, err
}
args["includeDeprecated"] = arg0
return args, nil
}
func field___Field_args_args(ctx context.Context, ec *executionContext, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgFieldWithEC(ctx, ec, rawArgs, "includeDeprecated", unmarshalOBoolean2ᚖbool)
if err != nil {
return nil, err
}
args["includeDeprecated"] = arg0
return args, nil
}
func field___Type_enumValues_args(ctx context.Context, ec *executionContext, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgFieldWithEC(ctx, ec, rawArgs, "includeDeprecated", unmarshalOBoolean2bool)
if err != nil {
return nil, err
}
args["includeDeprecated"] = arg0
return args, nil
}
func field___Type_fields_args(ctx context.Context, ec *executionContext, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgFieldWithEC(ctx, ec, rawArgs, "includeDeprecated", unmarshalOBoolean2bool)
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 _Entity_findHelloByName(ctx context.Context, ec *executionContext, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_Entity_findHelloByName(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindHelloByName(ctx, fc.Args["name"].(string))
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *model.Hello) graphql.Marshaler {
return marshalNHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐHello(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_Entity_findHelloByName(ctx context.Context, ec *executionContext, 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 fieldContext_Hello_name(ctx, ec, field)
case "secondary":
return fieldContext_Hello_secondary(ctx, ec, 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 = field_Entity_findHelloByName_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func _Entity_findHelloMultiSingleKeysByKey1AndKey2(ctx context.Context, ec *executionContext, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_Entity_findHelloMultiSingleKeysByKey1AndKey2(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindHelloMultiSingleKeysByKey1AndKey2(ctx, fc.Args["key1"].(string), fc.Args["key2"].(string))
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *model.HelloMultiSingleKeys) graphql.Marshaler {
return marshalNHelloMultiSingleKeys2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐHelloMultiSingleKeys(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_Entity_findHelloMultiSingleKeysByKey1AndKey2(ctx context.Context, ec *executionContext, 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 fieldContext_HelloMultiSingleKeys_key1(ctx, ec, field)
case "key2":
return fieldContext_HelloMultiSingleKeys_key2(ctx, ec, 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 = field_Entity_findHelloMultiSingleKeysByKey1AndKey2_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func _Entity_findHelloWithErrorsByName(ctx context.Context, ec *executionContext, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_Entity_findHelloWithErrorsByName(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindHelloWithErrorsByName(ctx, fc.Args["name"].(string))
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *model.HelloWithErrors) graphql.Marshaler {
return marshalNHelloWithErrors2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐHelloWithErrors(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_Entity_findHelloWithErrorsByName(ctx context.Context, ec *executionContext, 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 fieldContext_HelloWithErrors_name(ctx, ec, 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 = field_Entity_findHelloWithErrorsByName_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func _Entity_findManyMultiHelloByNames(ctx context.Context, ec *executionContext, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_Entity_findManyMultiHelloByNames(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindManyMultiHelloByNames(ctx, fc.Args["reps"].([]*model.MultiHelloByNamesInput))
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v []*model.MultiHello) graphql.Marshaler {
return marshalOMultiHello2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHello(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext_Entity_findManyMultiHelloByNames(ctx context.Context, ec *executionContext, 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 fieldContext_MultiHello_name(ctx, ec, 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 = field_Entity_findManyMultiHelloByNames_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func _Entity_findManyMultiHelloMultipleRequiresByNames(ctx context.Context, ec *executionContext, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_Entity_findManyMultiHelloMultipleRequiresByNames(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindManyMultiHelloMultipleRequiresByNames(ctx, fc.Args["reps"].([]*model.MultiHelloMultipleRequiresByNamesInput))
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v []*model.MultiHelloMultipleRequires) graphql.Marshaler {
return marshalOMultiHelloMultipleRequires2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloMultipleRequires(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext_Entity_findManyMultiHelloMultipleRequiresByNames(ctx context.Context, ec *executionContext, 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 fieldContext_MultiHelloMultipleRequires_name(ctx, ec, field)
case "key1":
return fieldContext_MultiHelloMultipleRequires_key1(ctx, ec, field)
case "key2":
return fieldContext_MultiHelloMultipleRequires_key2(ctx, ec, field)
case "key3":
return fieldContext_MultiHelloMultipleRequires_key3(ctx, ec, 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 = field_Entity_findManyMultiHelloMultipleRequiresByNames_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func _Entity_findManyMultiHelloRequiresByNames(ctx context.Context, ec *executionContext, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_Entity_findManyMultiHelloRequiresByNames(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindManyMultiHelloRequiresByNames(ctx, fc.Args["reps"].([]*model.MultiHelloRequiresByNamesInput))
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v []*model.MultiHelloRequires) graphql.Marshaler {
return marshalOMultiHelloRequires2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloRequires(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext_Entity_findManyMultiHelloRequiresByNames(ctx context.Context, ec *executionContext, 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 fieldContext_MultiHelloRequires_name(ctx, ec, field)
case "key1":
return fieldContext_MultiHelloRequires_key1(ctx, ec, field)
case "key2":
return fieldContext_MultiHelloRequires_key2(ctx, ec, 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 = field_Entity_findManyMultiHelloRequiresByNames_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func _Entity_findManyMultiHelloWithErrorByNames(ctx context.Context, ec *executionContext, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_Entity_findManyMultiHelloWithErrorByNames(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindManyMultiHelloWithErrorByNames(ctx, fc.Args["reps"].([]*model.MultiHelloWithErrorByNamesInput))
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v []*model.MultiHelloWithError) graphql.Marshaler {
return marshalOMultiHelloWithError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloWithError(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext_Entity_findManyMultiHelloWithErrorByNames(ctx context.Context, ec *executionContext, 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 fieldContext_MultiHelloWithError_name(ctx, ec, 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 = field_Entity_findManyMultiHelloWithErrorByNames_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func _Entity_findManyMultiPlanetRequiresNestedByNames(ctx context.Context, ec *executionContext, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_Entity_findManyMultiPlanetRequiresNestedByNames(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindManyMultiPlanetRequiresNestedByNames(ctx, fc.Args["reps"].([]*model.MultiPlanetRequiresNestedByNamesInput))
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v []*model.MultiPlanetRequiresNested) graphql.Marshaler {
return marshalOMultiPlanetRequiresNested2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiPlanetRequiresNested(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext_Entity_findManyMultiPlanetRequiresNestedByNames(ctx context.Context, ec *executionContext, 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 fieldContext_MultiPlanetRequiresNested_name(ctx, ec, field)
case "world":
return fieldContext_MultiPlanetRequiresNested_world(ctx, ec, field)
case "size":
return fieldContext_MultiPlanetRequiresNested_size(ctx, ec, 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 = field_Entity_findManyMultiPlanetRequiresNestedByNames_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func _Entity_findPlanetMultipleRequiresByName(ctx context.Context, ec *executionContext, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_Entity_findPlanetMultipleRequiresByName(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindPlanetMultipleRequiresByName(ctx, fc.Args["name"].(string))
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *model.PlanetMultipleRequires) graphql.Marshaler {
return marshalNPlanetMultipleRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐPlanetMultipleRequires(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_Entity_findPlanetMultipleRequiresByName(ctx context.Context, ec *executionContext, 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 fieldContext_PlanetMultipleRequires_name(ctx, ec, field)
case "diameter":
return fieldContext_PlanetMultipleRequires_diameter(ctx, ec, field)
case "density":
return fieldContext_PlanetMultipleRequires_density(ctx, ec, field)
case "weight":
return fieldContext_PlanetMultipleRequires_weight(ctx, ec, 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 = field_Entity_findPlanetMultipleRequiresByName_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func _Entity_findPlanetRequiresByName(ctx context.Context, ec *executionContext, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_Entity_findPlanetRequiresByName(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindPlanetRequiresByName(ctx, fc.Args["name"].(string))
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *model.PlanetRequires) graphql.Marshaler {
return marshalNPlanetRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐPlanetRequires(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_Entity_findPlanetRequiresByName(ctx context.Context, ec *executionContext, 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 fieldContext_PlanetRequires_name(ctx, ec, field)
case "size":
return fieldContext_PlanetRequires_size(ctx, ec, field)
case "diameter":
return fieldContext_PlanetRequires_diameter(ctx, ec, 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 = field_Entity_findPlanetRequiresByName_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func _Entity_findPlanetRequiresNestedByName(ctx context.Context, ec *executionContext, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_Entity_findPlanetRequiresNestedByName(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindPlanetRequiresNestedByName(ctx, fc.Args["name"].(string))
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *model.PlanetRequiresNested) graphql.Marshaler {
return marshalNPlanetRequiresNested2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐPlanetRequiresNested(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_Entity_findPlanetRequiresNestedByName(ctx context.Context, ec *executionContext, 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 fieldContext_PlanetRequiresNested_name(ctx, ec, field)
case "world":
return fieldContext_PlanetRequiresNested_world(ctx, ec, field)
case "size":
return fieldContext_PlanetRequiresNested_size(ctx, ec, 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 = field_Entity_findPlanetRequiresNestedByName_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func _Entity_findWorldByHelloNameAndFoo(ctx context.Context, ec *executionContext, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_Entity_findWorldByHelloNameAndFoo(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindWorldByHelloNameAndFoo(ctx, fc.Args["helloName"].(string), fc.Args["foo"].(string))
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *model.World) graphql.Marshaler {
return marshalNWorld2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐWorld(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_Entity_findWorldByHelloNameAndFoo(ctx context.Context, ec *executionContext, 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 fieldContext_World_foo(ctx, ec, field)
case "bar":
return fieldContext_World_bar(ctx, ec, field)
case "hello":
return fieldContext_World_hello(ctx, ec, 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 = field_Entity_findWorldByHelloNameAndFoo_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func _Entity_findWorldNameByName(ctx context.Context, ec *executionContext, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_Entity_findWorldNameByName(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindWorldNameByName(ctx, fc.Args["name"].(string))
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *model.WorldName) graphql.Marshaler {
return marshalNWorldName2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐWorldName(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_Entity_findWorldNameByName(ctx context.Context, ec *executionContext, 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 fieldContext_WorldName_name(ctx, ec, 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 = field_Entity_findWorldNameByName_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func _Entity_findWorldWithMultipleKeysByHelloNameAndFoo(ctx context.Context, ec *executionContext, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_Entity_findWorldWithMultipleKeysByHelloNameAndFoo(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindWorldWithMultipleKeysByHelloNameAndFoo(ctx, fc.Args["helloName"].(string), fc.Args["foo"].(string))
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *model.WorldWithMultipleKeys) graphql.Marshaler {
return marshalNWorldWithMultipleKeys2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐWorldWithMultipleKeys(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_Entity_findWorldWithMultipleKeysByHelloNameAndFoo(ctx context.Context, ec *executionContext, 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 fieldContext_WorldWithMultipleKeys_foo(ctx, ec, field)
case "bar":
return fieldContext_WorldWithMultipleKeys_bar(ctx, ec, field)
case "hello":
return fieldContext_WorldWithMultipleKeys_hello(ctx, ec, 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 = field_Entity_findWorldWithMultipleKeysByHelloNameAndFoo_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func _Entity_findWorldWithMultipleKeysByBar(ctx context.Context, ec *executionContext, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_Entity_findWorldWithMultipleKeysByBar(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.Resolvers.Entity().FindWorldWithMultipleKeysByBar(ctx, fc.Args["bar"].(int))
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *model.WorldWithMultipleKeys) graphql.Marshaler {
return marshalNWorldWithMultipleKeys2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐWorldWithMultipleKeys(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_Entity_findWorldWithMultipleKeysByBar(ctx context.Context, ec *executionContext, 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 fieldContext_WorldWithMultipleKeys_foo(ctx, ec, field)
case "bar":
return fieldContext_WorldWithMultipleKeys_bar(ctx, ec, field)
case "hello":
return fieldContext_WorldWithMultipleKeys_hello(ctx, ec, 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 = field_Entity_findWorldWithMultipleKeysByBar_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func _Hello_name(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.Hello) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_Hello_name(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalNString2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_Hello_name(_ context.Context, ec *executionContext, 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 _Hello_secondary(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.Hello) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_Hello_secondary(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Secondary, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalNString2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_Hello_secondary(_ context.Context, ec *executionContext, 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 _HelloMultiSingleKeys_key1(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.HelloMultiSingleKeys) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_HelloMultiSingleKeys_key1(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Key1, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalNString2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_HelloMultiSingleKeys_key1(_ context.Context, ec *executionContext, 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 _HelloMultiSingleKeys_key2(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.HelloMultiSingleKeys) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_HelloMultiSingleKeys_key2(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Key2, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalNString2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_HelloMultiSingleKeys_key2(_ context.Context, ec *executionContext, 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 _HelloWithErrors_name(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.HelloWithErrors) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_HelloWithErrors_name(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalNString2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_HelloWithErrors_name(_ context.Context, ec *executionContext, 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 _MultiHello_name(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.MultiHello) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_MultiHello_name(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalNString2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_MultiHello_name(_ context.Context, ec *executionContext, 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 _MultiHelloMultipleRequires_name(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.MultiHelloMultipleRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_MultiHelloMultipleRequires_name(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalNString2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_MultiHelloMultipleRequires_name(_ context.Context, ec *executionContext, 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 _MultiHelloMultipleRequires_key1(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.MultiHelloMultipleRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_MultiHelloMultipleRequires_key1(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Key1, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalNString2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_MultiHelloMultipleRequires_key1(_ context.Context, ec *executionContext, 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 _MultiHelloMultipleRequires_key2(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.MultiHelloMultipleRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_MultiHelloMultipleRequires_key2(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Key2, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalNString2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_MultiHelloMultipleRequires_key2(_ context.Context, ec *executionContext, 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 _MultiHelloMultipleRequires_key3(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.MultiHelloMultipleRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_MultiHelloMultipleRequires_key3(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Key3, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalNString2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_MultiHelloMultipleRequires_key3(_ context.Context, ec *executionContext, 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 _MultiHelloRequires_name(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.MultiHelloRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_MultiHelloRequires_name(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalNString2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_MultiHelloRequires_name(_ context.Context, ec *executionContext, 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 _MultiHelloRequires_key1(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.MultiHelloRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_MultiHelloRequires_key1(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Key1, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalNString2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_MultiHelloRequires_key1(_ context.Context, ec *executionContext, 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 _MultiHelloRequires_key2(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.MultiHelloRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_MultiHelloRequires_key2(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Key2, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalNString2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_MultiHelloRequires_key2(_ context.Context, ec *executionContext, 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 _MultiHelloWithError_name(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.MultiHelloWithError) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_MultiHelloWithError_name(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalNString2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_MultiHelloWithError_name(_ context.Context, ec *executionContext, 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 _MultiPlanetRequiresNested_name(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.MultiPlanetRequiresNested) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_MultiPlanetRequiresNested_name(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalNString2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_MultiPlanetRequiresNested_name(_ context.Context, ec *executionContext, 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 _MultiPlanetRequiresNested_world(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.MultiPlanetRequiresNested) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_MultiPlanetRequiresNested_world(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.World, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *model.World) graphql.Marshaler {
return marshalNWorld2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐWorld(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_MultiPlanetRequiresNested_world(_ context.Context, ec *executionContext, 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 fieldContext_World_foo(ctx, ec, field)
case "bar":
return fieldContext_World_bar(ctx, ec, field)
case "hello":
return fieldContext_World_hello(ctx, ec, field)
}
return nil, fmt.Errorf("no field named %q was found under type World", field.Name)
},
}
return fc, nil
}
func _MultiPlanetRequiresNested_size(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.MultiPlanetRequiresNested) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_MultiPlanetRequiresNested_size(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Size, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v int) graphql.Marshaler {
return marshalNInt2int(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_MultiPlanetRequiresNested_size(_ context.Context, ec *executionContext, 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 _PlanetMultipleRequires_name(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.PlanetMultipleRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_PlanetMultipleRequires_name(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalNString2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_PlanetMultipleRequires_name(_ context.Context, ec *executionContext, 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 _PlanetMultipleRequires_diameter(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.PlanetMultipleRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_PlanetMultipleRequires_diameter(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Diameter, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v int) graphql.Marshaler {
return marshalNInt2int(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_PlanetMultipleRequires_diameter(_ context.Context, ec *executionContext, 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 _PlanetMultipleRequires_density(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.PlanetMultipleRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_PlanetMultipleRequires_density(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Density, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v int) graphql.Marshaler {
return marshalNInt2int(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_PlanetMultipleRequires_density(_ context.Context, ec *executionContext, 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 _PlanetMultipleRequires_weight(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.PlanetMultipleRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_PlanetMultipleRequires_weight(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Weight, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v int) graphql.Marshaler {
return marshalNInt2int(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_PlanetMultipleRequires_weight(_ context.Context, ec *executionContext, 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 _PlanetRequires_name(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.PlanetRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_PlanetRequires_name(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalNString2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_PlanetRequires_name(_ context.Context, ec *executionContext, 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 _PlanetRequires_size(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.PlanetRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_PlanetRequires_size(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Size, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v int) graphql.Marshaler {
return marshalNInt2int(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_PlanetRequires_size(_ context.Context, ec *executionContext, 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 _PlanetRequires_diameter(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.PlanetRequires) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_PlanetRequires_diameter(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Diameter, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v int) graphql.Marshaler {
return marshalNInt2int(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_PlanetRequires_diameter(_ context.Context, ec *executionContext, 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 _PlanetRequiresNested_name(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.PlanetRequiresNested) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_PlanetRequiresNested_name(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalNString2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_PlanetRequiresNested_name(_ context.Context, ec *executionContext, 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 _PlanetRequiresNested_world(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.PlanetRequiresNested) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_PlanetRequiresNested_world(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.World, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *model.World) graphql.Marshaler {
return marshalNWorld2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐWorld(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_PlanetRequiresNested_world(_ context.Context, ec *executionContext, 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 fieldContext_World_foo(ctx, ec, field)
case "bar":
return fieldContext_World_bar(ctx, ec, field)
case "hello":
return fieldContext_World_hello(ctx, ec, field)
}
return nil, fmt.Errorf("no field named %q was found under type World", field.Name)
},
}
return fc, nil
}
func _PlanetRequiresNested_size(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.PlanetRequiresNested) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_PlanetRequiresNested_size(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Size, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v int) graphql.Marshaler {
return marshalNInt2int(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_PlanetRequiresNested_size(_ context.Context, ec *executionContext, 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 _Query__entities(ctx context.Context, ec *executionContext, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_Query__entities(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.__resolve_entities(ctx, fc.Args["representations"].([]map[string]any)), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v []fedruntime.Entity) graphql.Marshaler {
return marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_Query__entities(ctx context.Context, ec *executionContext, 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 = field_Query__entities_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func _Query__service(ctx context.Context, ec *executionContext, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_Query__service(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return ec.__resolve__service(ctx)
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v fedruntime.Service) graphql.Marshaler {
return marshalN_Service2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_Query__service(_ context.Context, ec *executionContext, 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 fieldContext__Service_sdl(ctx, ec, field)
}
return nil, fmt.Errorf("no field named %q was found under type _Service", field.Name)
},
}
return fc, nil
}
func _Query___type(ctx context.Context, ec *executionContext, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_Query___type(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.IntrospectType(fc.Args["name"].(string))
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
return marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext_Query___type(ctx context.Context, ec *executionContext, 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 fieldContext___Type_kind(ctx, ec, field)
case "name":
return fieldContext___Type_name(ctx, ec, field)
case "description":
return fieldContext___Type_description(ctx, ec, field)
case "specifiedByURL":
return fieldContext___Type_specifiedByURL(ctx, ec, field)
case "fields":
return fieldContext___Type_fields(ctx, ec, field)
case "interfaces":
return fieldContext___Type_interfaces(ctx, ec, field)
case "possibleTypes":
return fieldContext___Type_possibleTypes(ctx, ec, field)
case "enumValues":
return fieldContext___Type_enumValues(ctx, ec, field)
case "inputFields":
return fieldContext___Type_inputFields(ctx, ec, field)
case "ofType":
return fieldContext___Type_ofType(ctx, ec, field)
case "isOneOf":
return fieldContext___Type_isOneOf(ctx, ec, 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 = field_Query___type_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func _Query___schema(ctx context.Context, ec *executionContext, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_Query___schema(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return ec.IntrospectSchema()
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *introspection.Schema) graphql.Marshaler {
return marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext_Query___schema(_ context.Context, ec *executionContext, 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 fieldContext___Schema_description(ctx, ec, field)
case "types":
return fieldContext___Schema_types(ctx, ec, field)
case "queryType":
return fieldContext___Schema_queryType(ctx, ec, field)
case "mutationType":
return fieldContext___Schema_mutationType(ctx, ec, field)
case "subscriptionType":
return fieldContext___Schema_subscriptionType(ctx, ec, field)
case "directives":
return fieldContext___Schema_directives(ctx, ec, field)
}
return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name)
},
}
return fc, nil
}
func _World_foo(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.World) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_World_foo(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Foo, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalNString2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_World_foo(_ context.Context, ec *executionContext, 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 _World_bar(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.World) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_World_bar(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Bar, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v int) graphql.Marshaler {
return marshalNInt2int(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_World_bar(_ context.Context, ec *executionContext, 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 _World_hello(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.World) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_World_hello(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Hello, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *model.Hello) graphql.Marshaler {
return marshalOHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐHello(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext_World_hello(_ context.Context, ec *executionContext, 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 fieldContext_Hello_name(ctx, ec, field)
case "secondary":
return fieldContext_Hello_secondary(ctx, ec, field)
}
return nil, fmt.Errorf("no field named %q was found under type Hello", field.Name)
},
}
return fc, nil
}
func _WorldName_name(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.WorldName) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_WorldName_name(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalNString2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_WorldName_name(_ context.Context, ec *executionContext, 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 _WorldWithMultipleKeys_foo(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.WorldWithMultipleKeys) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_WorldWithMultipleKeys_foo(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Foo, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalNString2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_WorldWithMultipleKeys_foo(_ context.Context, ec *executionContext, 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 _WorldWithMultipleKeys_bar(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.WorldWithMultipleKeys) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_WorldWithMultipleKeys_bar(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Bar, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v int) graphql.Marshaler {
return marshalNInt2int(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext_WorldWithMultipleKeys_bar(_ context.Context, ec *executionContext, 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 _WorldWithMultipleKeys_hello(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *model.WorldWithMultipleKeys) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext_WorldWithMultipleKeys_hello(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Hello, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *model.Hello) graphql.Marshaler {
return marshalOHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐHello(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext_WorldWithMultipleKeys_hello(_ context.Context, ec *executionContext, 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 fieldContext_Hello_name(ctx, ec, field)
case "secondary":
return fieldContext_Hello_secondary(ctx, ec, field)
}
return nil, fmt.Errorf("no field named %q was found under type Hello", field.Name)
},
}
return fc, nil
}
func __Service_sdl(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *fedruntime.Service) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext__Service_sdl(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.SDL, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalOString2string(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext__Service_sdl(_ context.Context, ec *executionContext, 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 ___Directive_name(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Directive_name(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalNString2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext___Directive_name(_ context.Context, ec *executionContext, 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 ___Directive_description(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Directive_description(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *string) graphql.Marshaler {
return marshalOString2ᚖstring(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext___Directive_description(_ context.Context, ec *executionContext, 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 ___Directive_isRepeatable(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Directive_isRepeatable(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.IsRepeatable, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v bool) graphql.Marshaler {
return marshalNBoolean2bool(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext___Directive_isRepeatable(_ context.Context, ec *executionContext, 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 ___Directive_locations(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Directive_locations(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Locations, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v []string) graphql.Marshaler {
return marshalN__DirectiveLocation2ᚕstringᚄ(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext___Directive_locations(_ context.Context, ec *executionContext, 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 ___Directive_args(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Directive_args(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Args, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
return marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext___Directive_args(ctx context.Context, ec *executionContext, 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 fieldContext___InputValue_name(ctx, ec, field)
case "description":
return fieldContext___InputValue_description(ctx, ec, field)
case "type":
return fieldContext___InputValue_type(ctx, ec, field)
case "defaultValue":
return fieldContext___InputValue_defaultValue(ctx, ec, field)
case "isDeprecated":
return fieldContext___InputValue_isDeprecated(ctx, ec, field)
case "deprecationReason":
return fieldContext___InputValue_deprecationReason(ctx, ec, field)
}
return nil, fmt.Errorf("no field named %q was found under type __InputValue", 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 = field___Directive_args_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func ___EnumValue_name(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___EnumValue_name(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalNString2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext___EnumValue_name(_ context.Context, ec *executionContext, 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 ___EnumValue_description(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___EnumValue_description(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *string) graphql.Marshaler {
return marshalOString2ᚖstring(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext___EnumValue_description(_ context.Context, ec *executionContext, 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 ___EnumValue_isDeprecated(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___EnumValue_isDeprecated(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v bool) graphql.Marshaler {
return marshalNBoolean2bool(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext___EnumValue_isDeprecated(_ context.Context, ec *executionContext, 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 ___EnumValue_deprecationReason(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___EnumValue_deprecationReason(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *string) graphql.Marshaler {
return marshalOString2ᚖstring(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext___EnumValue_deprecationReason(_ context.Context, ec *executionContext, 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 ___Field_name(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Field_name(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalNString2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext___Field_name(_ context.Context, ec *executionContext, 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 ___Field_description(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Field_description(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *string) graphql.Marshaler {
return marshalOString2ᚖstring(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext___Field_description(_ context.Context, ec *executionContext, 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 ___Field_args(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Field_args(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Args, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
return marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext___Field_args(ctx context.Context, ec *executionContext, 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 fieldContext___InputValue_name(ctx, ec, field)
case "description":
return fieldContext___InputValue_description(ctx, ec, field)
case "type":
return fieldContext___InputValue_type(ctx, ec, field)
case "defaultValue":
return fieldContext___InputValue_defaultValue(ctx, ec, field)
case "isDeprecated":
return fieldContext___InputValue_isDeprecated(ctx, ec, field)
case "deprecationReason":
return fieldContext___InputValue_deprecationReason(ctx, ec, field)
}
return nil, fmt.Errorf("no field named %q was found under type __InputValue", 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 = field___Field_args_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func ___Field_type(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Field_type(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Type, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
return marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext___Field_type(_ context.Context, ec *executionContext, 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 fieldContext___Type_kind(ctx, ec, field)
case "name":
return fieldContext___Type_name(ctx, ec, field)
case "description":
return fieldContext___Type_description(ctx, ec, field)
case "specifiedByURL":
return fieldContext___Type_specifiedByURL(ctx, ec, field)
case "fields":
return fieldContext___Type_fields(ctx, ec, field)
case "interfaces":
return fieldContext___Type_interfaces(ctx, ec, field)
case "possibleTypes":
return fieldContext___Type_possibleTypes(ctx, ec, field)
case "enumValues":
return fieldContext___Type_enumValues(ctx, ec, field)
case "inputFields":
return fieldContext___Type_inputFields(ctx, ec, field)
case "ofType":
return fieldContext___Type_ofType(ctx, ec, field)
case "isOneOf":
return fieldContext___Type_isOneOf(ctx, ec, field)
}
return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name)
},
}
return fc, nil
}
func ___Field_isDeprecated(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Field_isDeprecated(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v bool) graphql.Marshaler {
return marshalNBoolean2bool(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext___Field_isDeprecated(_ context.Context, ec *executionContext, 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 ___Field_deprecationReason(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Field_deprecationReason(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *string) graphql.Marshaler {
return marshalOString2ᚖstring(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext___Field_deprecationReason(_ context.Context, ec *executionContext, 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 ___InputValue_name(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___InputValue_name(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalNString2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext___InputValue_name(_ context.Context, ec *executionContext, 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 ___InputValue_description(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___InputValue_description(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *string) graphql.Marshaler {
return marshalOString2ᚖstring(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext___InputValue_description(_ context.Context, ec *executionContext, 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 ___InputValue_type(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___InputValue_type(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Type, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
return marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext___InputValue_type(_ context.Context, ec *executionContext, 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 fieldContext___Type_kind(ctx, ec, field)
case "name":
return fieldContext___Type_name(ctx, ec, field)
case "description":
return fieldContext___Type_description(ctx, ec, field)
case "specifiedByURL":
return fieldContext___Type_specifiedByURL(ctx, ec, field)
case "fields":
return fieldContext___Type_fields(ctx, ec, field)
case "interfaces":
return fieldContext___Type_interfaces(ctx, ec, field)
case "possibleTypes":
return fieldContext___Type_possibleTypes(ctx, ec, field)
case "enumValues":
return fieldContext___Type_enumValues(ctx, ec, field)
case "inputFields":
return fieldContext___Type_inputFields(ctx, ec, field)
case "ofType":
return fieldContext___Type_ofType(ctx, ec, field)
case "isOneOf":
return fieldContext___Type_isOneOf(ctx, ec, field)
}
return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name)
},
}
return fc, nil
}
func ___InputValue_defaultValue(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___InputValue_defaultValue(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.DefaultValue, nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *string) graphql.Marshaler {
return marshalOString2ᚖstring(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext___InputValue_defaultValue(_ context.Context, ec *executionContext, 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 ___InputValue_isDeprecated(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___InputValue_isDeprecated(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v bool) graphql.Marshaler {
return marshalNBoolean2bool(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext___InputValue_isDeprecated(_ context.Context, ec *executionContext, 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 Boolean does not have child fields")
},
}
return fc, nil
}
func ___InputValue_deprecationReason(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___InputValue_deprecationReason(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *string) graphql.Marshaler {
return marshalOString2ᚖstring(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext___InputValue_deprecationReason(_ context.Context, ec *executionContext, 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 ___Schema_description(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Schema_description(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *string) graphql.Marshaler {
return marshalOString2ᚖstring(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext___Schema_description(_ context.Context, ec *executionContext, 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 ___Schema_types(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Schema_types(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Types(), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
return marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext___Schema_types(_ context.Context, ec *executionContext, 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 fieldContext___Type_kind(ctx, ec, field)
case "name":
return fieldContext___Type_name(ctx, ec, field)
case "description":
return fieldContext___Type_description(ctx, ec, field)
case "specifiedByURL":
return fieldContext___Type_specifiedByURL(ctx, ec, field)
case "fields":
return fieldContext___Type_fields(ctx, ec, field)
case "interfaces":
return fieldContext___Type_interfaces(ctx, ec, field)
case "possibleTypes":
return fieldContext___Type_possibleTypes(ctx, ec, field)
case "enumValues":
return fieldContext___Type_enumValues(ctx, ec, field)
case "inputFields":
return fieldContext___Type_inputFields(ctx, ec, field)
case "ofType":
return fieldContext___Type_ofType(ctx, ec, field)
case "isOneOf":
return fieldContext___Type_isOneOf(ctx, ec, field)
}
return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name)
},
}
return fc, nil
}
func ___Schema_queryType(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Schema_queryType(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.QueryType(), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
return marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext___Schema_queryType(_ context.Context, ec *executionContext, 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 fieldContext___Type_kind(ctx, ec, field)
case "name":
return fieldContext___Type_name(ctx, ec, field)
case "description":
return fieldContext___Type_description(ctx, ec, field)
case "specifiedByURL":
return fieldContext___Type_specifiedByURL(ctx, ec, field)
case "fields":
return fieldContext___Type_fields(ctx, ec, field)
case "interfaces":
return fieldContext___Type_interfaces(ctx, ec, field)
case "possibleTypes":
return fieldContext___Type_possibleTypes(ctx, ec, field)
case "enumValues":
return fieldContext___Type_enumValues(ctx, ec, field)
case "inputFields":
return fieldContext___Type_inputFields(ctx, ec, field)
case "ofType":
return fieldContext___Type_ofType(ctx, ec, field)
case "isOneOf":
return fieldContext___Type_isOneOf(ctx, ec, field)
}
return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name)
},
}
return fc, nil
}
func ___Schema_mutationType(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Schema_mutationType(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.MutationType(), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
return marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext___Schema_mutationType(_ context.Context, ec *executionContext, 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 fieldContext___Type_kind(ctx, ec, field)
case "name":
return fieldContext___Type_name(ctx, ec, field)
case "description":
return fieldContext___Type_description(ctx, ec, field)
case "specifiedByURL":
return fieldContext___Type_specifiedByURL(ctx, ec, field)
case "fields":
return fieldContext___Type_fields(ctx, ec, field)
case "interfaces":
return fieldContext___Type_interfaces(ctx, ec, field)
case "possibleTypes":
return fieldContext___Type_possibleTypes(ctx, ec, field)
case "enumValues":
return fieldContext___Type_enumValues(ctx, ec, field)
case "inputFields":
return fieldContext___Type_inputFields(ctx, ec, field)
case "ofType":
return fieldContext___Type_ofType(ctx, ec, field)
case "isOneOf":
return fieldContext___Type_isOneOf(ctx, ec, field)
}
return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name)
},
}
return fc, nil
}
func ___Schema_subscriptionType(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Schema_subscriptionType(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.SubscriptionType(), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
return marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext___Schema_subscriptionType(_ context.Context, ec *executionContext, 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 fieldContext___Type_kind(ctx, ec, field)
case "name":
return fieldContext___Type_name(ctx, ec, field)
case "description":
return fieldContext___Type_description(ctx, ec, field)
case "specifiedByURL":
return fieldContext___Type_specifiedByURL(ctx, ec, field)
case "fields":
return fieldContext___Type_fields(ctx, ec, field)
case "interfaces":
return fieldContext___Type_interfaces(ctx, ec, field)
case "possibleTypes":
return fieldContext___Type_possibleTypes(ctx, ec, field)
case "enumValues":
return fieldContext___Type_enumValues(ctx, ec, field)
case "inputFields":
return fieldContext___Type_inputFields(ctx, ec, field)
case "ofType":
return fieldContext___Type_ofType(ctx, ec, field)
case "isOneOf":
return fieldContext___Type_isOneOf(ctx, ec, field)
}
return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name)
},
}
return fc, nil
}
func ___Schema_directives(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Schema_directives(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Directives(), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v []introspection.Directive) graphql.Marshaler {
return marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext___Schema_directives(_ context.Context, ec *executionContext, 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 fieldContext___Directive_name(ctx, ec, field)
case "description":
return fieldContext___Directive_description(ctx, ec, field)
case "isRepeatable":
return fieldContext___Directive_isRepeatable(ctx, ec, field)
case "locations":
return fieldContext___Directive_locations(ctx, ec, field)
case "args":
return fieldContext___Directive_args(ctx, ec, field)
}
return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name)
},
}
return fc, nil
}
func ___Type_kind(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Type_kind(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Kind(), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler {
return marshalN__TypeKind2string(ctx, ec, selections, v)
},
true,
true,
)
}
func fieldContext___Type_kind(_ context.Context, ec *executionContext, 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 ___Type_name(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Type_name(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Name(), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *string) graphql.Marshaler {
return marshalOString2ᚖstring(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext___Type_name(_ context.Context, ec *executionContext, 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 ___Type_description(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Type_description(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *string) graphql.Marshaler {
return marshalOString2ᚖstring(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext___Type_description(_ context.Context, ec *executionContext, 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 ___Type_specifiedByURL(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Type_specifiedByURL(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.SpecifiedByURL(), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *string) graphql.Marshaler {
return marshalOString2ᚖstring(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext___Type_specifiedByURL(_ context.Context, ec *executionContext, 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 ___Type_fields(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Type_fields(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v []introspection.Field) graphql.Marshaler {
return marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext___Type_fields(ctx context.Context, ec *executionContext, 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 fieldContext___Field_name(ctx, ec, field)
case "description":
return fieldContext___Field_description(ctx, ec, field)
case "args":
return fieldContext___Field_args(ctx, ec, field)
case "type":
return fieldContext___Field_type(ctx, ec, field)
case "isDeprecated":
return fieldContext___Field_isDeprecated(ctx, ec, field)
case "deprecationReason":
return fieldContext___Field_deprecationReason(ctx, ec, 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 = field___Type_fields_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func ___Type_interfaces(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Type_interfaces(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.Interfaces(), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
return marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext___Type_interfaces(_ context.Context, ec *executionContext, 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 fieldContext___Type_kind(ctx, ec, field)
case "name":
return fieldContext___Type_name(ctx, ec, field)
case "description":
return fieldContext___Type_description(ctx, ec, field)
case "specifiedByURL":
return fieldContext___Type_specifiedByURL(ctx, ec, field)
case "fields":
return fieldContext___Type_fields(ctx, ec, field)
case "interfaces":
return fieldContext___Type_interfaces(ctx, ec, field)
case "possibleTypes":
return fieldContext___Type_possibleTypes(ctx, ec, field)
case "enumValues":
return fieldContext___Type_enumValues(ctx, ec, field)
case "inputFields":
return fieldContext___Type_inputFields(ctx, ec, field)
case "ofType":
return fieldContext___Type_ofType(ctx, ec, field)
case "isOneOf":
return fieldContext___Type_isOneOf(ctx, ec, field)
}
return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name)
},
}
return fc, nil
}
func ___Type_possibleTypes(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Type_possibleTypes(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.PossibleTypes(), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
return marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext___Type_possibleTypes(_ context.Context, ec *executionContext, 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 fieldContext___Type_kind(ctx, ec, field)
case "name":
return fieldContext___Type_name(ctx, ec, field)
case "description":
return fieldContext___Type_description(ctx, ec, field)
case "specifiedByURL":
return fieldContext___Type_specifiedByURL(ctx, ec, field)
case "fields":
return fieldContext___Type_fields(ctx, ec, field)
case "interfaces":
return fieldContext___Type_interfaces(ctx, ec, field)
case "possibleTypes":
return fieldContext___Type_possibleTypes(ctx, ec, field)
case "enumValues":
return fieldContext___Type_enumValues(ctx, ec, field)
case "inputFields":
return fieldContext___Type_inputFields(ctx, ec, field)
case "ofType":
return fieldContext___Type_ofType(ctx, ec, field)
case "isOneOf":
return fieldContext___Type_isOneOf(ctx, ec, field)
}
return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name)
},
}
return fc, nil
}
func ___Type_enumValues(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Type_enumValues(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler {
return marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext___Type_enumValues(ctx context.Context, ec *executionContext, 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 fieldContext___EnumValue_name(ctx, ec, field)
case "description":
return fieldContext___EnumValue_description(ctx, ec, field)
case "isDeprecated":
return fieldContext___EnumValue_isDeprecated(ctx, ec, field)
case "deprecationReason":
return fieldContext___EnumValue_deprecationReason(ctx, ec, 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 = field___Type_enumValues_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func ___Type_inputFields(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Type_inputFields(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.InputFields(), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
return marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext___Type_inputFields(_ context.Context, ec *executionContext, 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 fieldContext___InputValue_name(ctx, ec, field)
case "description":
return fieldContext___InputValue_description(ctx, ec, field)
case "type":
return fieldContext___InputValue_type(ctx, ec, field)
case "defaultValue":
return fieldContext___InputValue_defaultValue(ctx, ec, field)
case "isDeprecated":
return fieldContext___InputValue_isDeprecated(ctx, ec, field)
case "deprecationReason":
return fieldContext___InputValue_deprecationReason(ctx, ec, field)
}
return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name)
},
}
return fc, nil
}
func ___Type_ofType(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Type_ofType(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.OfType(), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
return marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext___Type_ofType(_ context.Context, ec *executionContext, 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 fieldContext___Type_kind(ctx, ec, field)
case "name":
return fieldContext___Type_name(ctx, ec, field)
case "description":
return fieldContext___Type_description(ctx, ec, field)
case "specifiedByURL":
return fieldContext___Type_specifiedByURL(ctx, ec, field)
case "fields":
return fieldContext___Type_fields(ctx, ec, field)
case "interfaces":
return fieldContext___Type_interfaces(ctx, ec, field)
case "possibleTypes":
return fieldContext___Type_possibleTypes(ctx, ec, field)
case "enumValues":
return fieldContext___Type_enumValues(ctx, ec, field)
case "inputFields":
return fieldContext___Type_inputFields(ctx, ec, field)
case "ofType":
return fieldContext___Type_ofType(ctx, ec, field)
case "isOneOf":
return fieldContext___Type_isOneOf(ctx, ec, field)
}
return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name)
},
}
return fc, nil
}
func ___Type_isOneOf(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return fieldContext___Type_isOneOf(ctx, ec, field)
},
func(ctx context.Context) (any, error) {
return obj.IsOneOf(), nil
},
nil,
func(ctx context.Context, selections ast.SelectionSet, v bool) graphql.Marshaler {
return marshalOBoolean2bool(ctx, ec, selections, v)
},
true,
false,
)
}
func fieldContext___Type_isOneOf(_ context.Context, ec *executionContext, 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 Boolean does not have child fields")
},
}
return fc, nil
}
// endregion **************************** field.gotpl *****************************
// region **************************** input.gotpl *****************************
func unmarshalInputMultiHelloByNamesInput(ctx context.Context, ec *executionContext, obj any) (model.MultiHelloByNamesInput, error) {
var it model.MultiHelloByNamesInput
if obj == nil {
return it, nil
}
asMap := map[string]any{}
for k, v := range obj.(map[string]any) {
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 := unmarshalNString2string(ctx, ec, v)
if err != nil {
return it, err
}
it.Name = data
}
}
return it, nil
}
func unmarshalInputMultiHelloMultipleRequiresByNamesInput(ctx context.Context, ec *executionContext, obj any) (model.MultiHelloMultipleRequiresByNamesInput, error) {
var it model.MultiHelloMultipleRequiresByNamesInput
if obj == nil {
return it, nil
}
asMap := map[string]any{}
for k, v := range obj.(map[string]any) {
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 := unmarshalNString2string(ctx, ec, v)
if err != nil {
return it, err
}
it.Name = data
}
}
return it, nil
}
func unmarshalInputMultiHelloRequiresByNamesInput(ctx context.Context, ec *executionContext, obj any) (model.MultiHelloRequiresByNamesInput, error) {
var it model.MultiHelloRequiresByNamesInput
if obj == nil {
return it, nil
}
asMap := map[string]any{}
for k, v := range obj.(map[string]any) {
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 := unmarshalNString2string(ctx, ec, v)
if err != nil {
return it, err
}
it.Name = data
}
}
return it, nil
}
func unmarshalInputMultiHelloWithErrorByNamesInput(ctx context.Context, ec *executionContext, obj any) (model.MultiHelloWithErrorByNamesInput, error) {
var it model.MultiHelloWithErrorByNamesInput
if obj == nil {
return it, nil
}
asMap := map[string]any{}
for k, v := range obj.(map[string]any) {
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 := unmarshalNString2string(ctx, ec, v)
if err != nil {
return it, err
}
it.Name = data
}
}
return it, nil
}
func unmarshalInputMultiPlanetRequiresNestedByNamesInput(ctx context.Context, ec *executionContext, obj any) (model.MultiPlanetRequiresNestedByNamesInput, error) {
var it model.MultiPlanetRequiresNestedByNamesInput
if obj == nil {
return it, nil
}
asMap := map[string]any{}
for k, v := range obj.(map[string]any) {
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 := unmarshalNString2string(ctx, ec, v)
if err != nil {
return it, err
}
it.Name = data
}
}
return it, nil
}
// endregion **************************** input.gotpl *****************************
// region ************************** interface.gotpl ***************************
func __Entity(ctx context.Context, ec *executionContext, sel ast.SelectionSet, obj fedruntime.Entity) graphql.Marshaler {
switch obj := (obj).(type) {
case nil:
return graphql.Null
case model.WorldWithMultipleKeys:
return _WorldWithMultipleKeys(ctx, ec, sel, &obj)
case *model.WorldWithMultipleKeys:
if obj == nil {
return graphql.Null
}
return _WorldWithMultipleKeys(ctx, ec, sel, obj)
case model.WorldName:
return _WorldName(ctx, ec, sel, &obj)
case *model.WorldName:
if obj == nil {
return graphql.Null
}
return _WorldName(ctx, ec, sel, obj)
case model.World:
return _World(ctx, ec, sel, &obj)
case *model.World:
if obj == nil {
return graphql.Null
}
return _World(ctx, ec, sel, obj)
case model.PlanetRequiresNested:
return _PlanetRequiresNested(ctx, ec, sel, &obj)
case *model.PlanetRequiresNested:
if obj == nil {
return graphql.Null
}
return _PlanetRequiresNested(ctx, ec, sel, obj)
case model.PlanetRequires:
return _PlanetRequires(ctx, ec, sel, &obj)
case *model.PlanetRequires:
if obj == nil {
return graphql.Null
}
return _PlanetRequires(ctx, ec, sel, obj)
case model.PlanetMultipleRequires:
return _PlanetMultipleRequires(ctx, ec, sel, &obj)
case *model.PlanetMultipleRequires:
if obj == nil {
return graphql.Null
}
return _PlanetMultipleRequires(ctx, ec, sel, obj)
case model.MultiPlanetRequiresNested:
return _MultiPlanetRequiresNested(ctx, ec, sel, &obj)
case *model.MultiPlanetRequiresNested:
if obj == nil {
return graphql.Null
}
return _MultiPlanetRequiresNested(ctx, ec, sel, obj)
case model.MultiHelloWithError:
return _MultiHelloWithError(ctx, ec, sel, &obj)
case *model.MultiHelloWithError:
if obj == nil {
return graphql.Null
}
return _MultiHelloWithError(ctx, ec, sel, obj)
case model.MultiHelloRequires:
return _MultiHelloRequires(ctx, ec, sel, &obj)
case *model.MultiHelloRequires:
if obj == nil {
return graphql.Null
}
return _MultiHelloRequires(ctx, ec, sel, obj)
case model.MultiHelloMultipleRequires:
return _MultiHelloMultipleRequires(ctx, ec, sel, &obj)
case *model.MultiHelloMultipleRequires:
if obj == nil {
return graphql.Null
}
return _MultiHelloMultipleRequires(ctx, ec, sel, obj)
case model.MultiHello:
return _MultiHello(ctx, ec, sel, &obj)
case *model.MultiHello:
if obj == nil {
return graphql.Null
}
return _MultiHello(ctx, ec, sel, obj)
case model.HelloWithErrors:
return _HelloWithErrors(ctx, ec, sel, &obj)
case *model.HelloWithErrors:
if obj == nil {
return graphql.Null
}
return _HelloWithErrors(ctx, ec, sel, obj)
case model.HelloMultiSingleKeys:
return _HelloMultiSingleKeys(ctx, ec, sel, &obj)
case *model.HelloMultiSingleKeys:
if obj == nil {
return graphql.Null
}
return _HelloMultiSingleKeys(ctx, ec, sel, obj)
case model.Hello:
return _Hello(ctx, ec, sel, &obj)
case *model.Hello:
if obj == nil {
return graphql.Null
}
return _Hello(ctx, ec, sel, obj)
default:
if typedObj, ok := obj.(graphql.Marshaler); ok {
return typedObj
} else {
panic(fmt.Errorf("unexpected type %T; non-generated variants of _Entity must implement graphql.Marshaler", obj))
}
}
}
// endregion ************************** interface.gotpl ***************************
// region **************************** object.gotpl ****************************
var entityImplementors = []string{"Entity"}
func _Entity(ctx context.Context, ec *executionContext, 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 = _Entity_findHelloByName(ctx, ec, 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 = _Entity_findHelloMultiSingleKeysByKey1AndKey2(ctx, ec, 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 = _Entity_findHelloWithErrorsByName(ctx, ec, 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, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = _Entity_findManyMultiHelloByNames(ctx, ec, 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, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = _Entity_findManyMultiHelloMultipleRequiresByNames(ctx, ec, 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, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = _Entity_findManyMultiHelloRequiresByNames(ctx, ec, 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, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = _Entity_findManyMultiHelloWithErrorByNames(ctx, ec, 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, _ *graphql.FieldSet) (res graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
}
}()
res = _Entity_findManyMultiPlanetRequiresNestedByNames(ctx, ec, 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 = _Entity_findPlanetMultipleRequiresByName(ctx, ec, 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 = _Entity_findPlanetRequiresByName(ctx, ec, 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 = _Entity_findPlanetRequiresNestedByName(ctx, ec, 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 = _Entity_findWorldByHelloNameAndFoo(ctx, ec, 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 = _Entity_findWorldNameByName(ctx, ec, 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 = _Entity_findWorldWithMultipleKeysByHelloNameAndFoo(ctx, ec, 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 = _Entity_findWorldWithMultipleKeysByBar(ctx, ec, 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 _Hello(ctx context.Context, ec *executionContext, 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] = _Hello_name(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "secondary":
out.Values[i] = _Hello_secondary(ctx, ec, 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 _HelloMultiSingleKeys(ctx context.Context, ec *executionContext, 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] = _HelloMultiSingleKeys_key1(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "key2":
out.Values[i] = _HelloMultiSingleKeys_key2(ctx, ec, 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 _HelloWithErrors(ctx context.Context, ec *executionContext, 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] = _HelloWithErrors_name(ctx, ec, 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 _MultiHello(ctx context.Context, ec *executionContext, 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] = _MultiHello_name(ctx, ec, 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 _MultiHelloMultipleRequires(ctx context.Context, ec *executionContext, 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] = _MultiHelloMultipleRequires_name(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "key1":
out.Values[i] = _MultiHelloMultipleRequires_key1(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "key2":
out.Values[i] = _MultiHelloMultipleRequires_key2(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "key3":
out.Values[i] = _MultiHelloMultipleRequires_key3(ctx, ec, 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 _MultiHelloRequires(ctx context.Context, ec *executionContext, 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] = _MultiHelloRequires_name(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "key1":
out.Values[i] = _MultiHelloRequires_key1(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "key2":
out.Values[i] = _MultiHelloRequires_key2(ctx, ec, 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 _MultiHelloWithError(ctx context.Context, ec *executionContext, 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] = _MultiHelloWithError_name(ctx, ec, 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 _MultiPlanetRequiresNested(ctx context.Context, ec *executionContext, 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] = _MultiPlanetRequiresNested_name(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "world":
out.Values[i] = _MultiPlanetRequiresNested_world(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "size":
out.Values[i] = _MultiPlanetRequiresNested_size(ctx, ec, 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 _PlanetMultipleRequires(ctx context.Context, ec *executionContext, 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] = _PlanetMultipleRequires_name(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "diameter":
out.Values[i] = _PlanetMultipleRequires_diameter(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "density":
out.Values[i] = _PlanetMultipleRequires_density(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "weight":
out.Values[i] = _PlanetMultipleRequires_weight(ctx, ec, 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 _PlanetRequires(ctx context.Context, ec *executionContext, 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] = _PlanetRequires_name(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "size":
out.Values[i] = _PlanetRequires_size(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "diameter":
out.Values[i] = _PlanetRequires_diameter(ctx, ec, 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 _PlanetRequiresNested(ctx context.Context, ec *executionContext, 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] = _PlanetRequiresNested_name(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "world":
out.Values[i] = _PlanetRequiresNested_world(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "size":
out.Values[i] = _PlanetRequiresNested_size(ctx, ec, 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 _Query(ctx context.Context, ec *executionContext, 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 = _Query__entities(ctx, ec, 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 = _Query__service(ctx, ec, 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 _Query___type(ctx, ec, field)
})
case "__schema":
out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
return _Query___schema(ctx, ec, 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 _World(ctx context.Context, ec *executionContext, 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] = _World_foo(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "bar":
out.Values[i] = _World_bar(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "hello":
out.Values[i] = _World_hello(ctx, ec, 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 _WorldName(ctx context.Context, ec *executionContext, 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] = _WorldName_name(ctx, ec, 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 _WorldWithMultipleKeys(ctx context.Context, ec *executionContext, 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] = _WorldWithMultipleKeys_foo(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "bar":
out.Values[i] = _WorldWithMultipleKeys_bar(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "hello":
out.Values[i] = _WorldWithMultipleKeys_hello(ctx, ec, 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 __Service(ctx context.Context, ec *executionContext, 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] = __Service_sdl(ctx, ec, 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 ___Directive(ctx context.Context, ec *executionContext, 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] = ___Directive_name(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "description":
out.Values[i] = ___Directive_description(ctx, ec, field, obj)
case "isRepeatable":
out.Values[i] = ___Directive_isRepeatable(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "locations":
out.Values[i] = ___Directive_locations(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "args":
out.Values[i] = ___Directive_args(ctx, ec, 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 ___EnumValue(ctx context.Context, ec *executionContext, 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] = ___EnumValue_name(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "description":
out.Values[i] = ___EnumValue_description(ctx, ec, field, obj)
case "isDeprecated":
out.Values[i] = ___EnumValue_isDeprecated(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "deprecationReason":
out.Values[i] = ___EnumValue_deprecationReason(ctx, ec, 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 ___Field(ctx context.Context, ec *executionContext, 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] = ___Field_name(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "description":
out.Values[i] = ___Field_description(ctx, ec, field, obj)
case "args":
out.Values[i] = ___Field_args(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "type":
out.Values[i] = ___Field_type(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "isDeprecated":
out.Values[i] = ___Field_isDeprecated(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "deprecationReason":
out.Values[i] = ___Field_deprecationReason(ctx, ec, 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 ___InputValue(ctx context.Context, ec *executionContext, 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] = ___InputValue_name(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "description":
out.Values[i] = ___InputValue_description(ctx, ec, field, obj)
case "type":
out.Values[i] = ___InputValue_type(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "defaultValue":
out.Values[i] = ___InputValue_defaultValue(ctx, ec, field, obj)
case "isDeprecated":
out.Values[i] = ___InputValue_isDeprecated(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "deprecationReason":
out.Values[i] = ___InputValue_deprecationReason(ctx, ec, 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 ___Schema(ctx context.Context, ec *executionContext, 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] = ___Schema_description(ctx, ec, field, obj)
case "types":
out.Values[i] = ___Schema_types(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "queryType":
out.Values[i] = ___Schema_queryType(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "mutationType":
out.Values[i] = ___Schema_mutationType(ctx, ec, field, obj)
case "subscriptionType":
out.Values[i] = ___Schema_subscriptionType(ctx, ec, field, obj)
case "directives":
out.Values[i] = ___Schema_directives(ctx, ec, 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 ___Type(ctx context.Context, ec *executionContext, 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] = ___Type_kind(ctx, ec, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "name":
out.Values[i] = ___Type_name(ctx, ec, field, obj)
case "description":
out.Values[i] = ___Type_description(ctx, ec, field, obj)
case "specifiedByURL":
out.Values[i] = ___Type_specifiedByURL(ctx, ec, field, obj)
case "fields":
out.Values[i] = ___Type_fields(ctx, ec, field, obj)
case "interfaces":
out.Values[i] = ___Type_interfaces(ctx, ec, field, obj)
case "possibleTypes":
out.Values[i] = ___Type_possibleTypes(ctx, ec, field, obj)
case "enumValues":
out.Values[i] = ___Type_enumValues(ctx, ec, field, obj)
case "inputFields":
out.Values[i] = ___Type_inputFields(ctx, ec, field, obj)
case "ofType":
out.Values[i] = ___Type_ofType(ctx, ec, field, obj)
case "isOneOf":
out.Values[i] = ___Type_isOneOf(ctx, ec, 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 unmarshalNBoolean2bool(ctx context.Context, ec *executionContext, v any) (bool, error) {
res, err := graphql.UnmarshalBoolean(v)
return res, graphql.ErrorOnPath(ctx, err)
}
func marshalNBoolean2bool(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v bool) graphql.Marshaler {
_ = sel
res := graphql.MarshalBoolean(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func marshalNHello2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐHello(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v model.Hello) graphql.Marshaler {
return _Hello(ctx, ec, sel, &v)
}
func marshalNHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐHello(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v *model.Hello) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return _Hello(ctx, ec, sel, v)
}
func marshalNHelloMultiSingleKeys2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐHelloMultiSingleKeys(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v model.HelloMultiSingleKeys) graphql.Marshaler {
return _HelloMultiSingleKeys(ctx, ec, sel, &v)
}
func marshalNHelloMultiSingleKeys2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐHelloMultiSingleKeys(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v *model.HelloMultiSingleKeys) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return _HelloMultiSingleKeys(ctx, ec, sel, v)
}
func marshalNHelloWithErrors2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐHelloWithErrors(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v model.HelloWithErrors) graphql.Marshaler {
return _HelloWithErrors(ctx, ec, sel, &v)
}
func marshalNHelloWithErrors2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐHelloWithErrors(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v *model.HelloWithErrors) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return _HelloWithErrors(ctx, ec, sel, v)
}
func unmarshalNInt2int(ctx context.Context, ec *executionContext, v any) (int, error) {
res, err := graphql.UnmarshalInt(v)
return res, graphql.ErrorOnPath(ctx, err)
}
func marshalNInt2int(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v int) graphql.Marshaler {
_ = sel
res := graphql.MarshalInt(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func unmarshalNMultiHelloByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloByNamesInput(ctx context.Context, ec *executionContext, v any) ([]*model.MultiHelloByNamesInput, error) {
var vSlice []any
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 = unmarshalOMultiHelloByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloByNamesInput(ctx, ec, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil
}
func unmarshalNMultiHelloMultipleRequiresByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloMultipleRequiresByNamesInput(ctx context.Context, ec *executionContext, v any) ([]*model.MultiHelloMultipleRequiresByNamesInput, error) {
var vSlice []any
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 = unmarshalOMultiHelloMultipleRequiresByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloMultipleRequiresByNamesInput(ctx, ec, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil
}
func unmarshalNMultiHelloRequiresByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloRequiresByNamesInput(ctx context.Context, ec *executionContext, v any) ([]*model.MultiHelloRequiresByNamesInput, error) {
var vSlice []any
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 = unmarshalOMultiHelloRequiresByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloRequiresByNamesInput(ctx, ec, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil
}
func unmarshalNMultiHelloWithErrorByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloWithErrorByNamesInput(ctx context.Context, ec *executionContext, v any) ([]*model.MultiHelloWithErrorByNamesInput, error) {
var vSlice []any
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 = unmarshalOMultiHelloWithErrorByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloWithErrorByNamesInput(ctx, ec, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil
}
func unmarshalNMultiPlanetRequiresNestedByNamesInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiPlanetRequiresNestedByNamesInput(ctx context.Context, ec *executionContext, v any) ([]*model.MultiPlanetRequiresNestedByNamesInput, error) {
var vSlice []any
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 = unmarshalOMultiPlanetRequiresNestedByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiPlanetRequiresNestedByNamesInput(ctx, ec, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil
}
func marshalNPlanetMultipleRequires2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐPlanetMultipleRequires(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v model.PlanetMultipleRequires) graphql.Marshaler {
return _PlanetMultipleRequires(ctx, ec, sel, &v)
}
func marshalNPlanetMultipleRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐPlanetMultipleRequires(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v *model.PlanetMultipleRequires) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return _PlanetMultipleRequires(ctx, ec, sel, v)
}
func marshalNPlanetRequires2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐPlanetRequires(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v model.PlanetRequires) graphql.Marshaler {
return _PlanetRequires(ctx, ec, sel, &v)
}
func marshalNPlanetRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐPlanetRequires(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v *model.PlanetRequires) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return _PlanetRequires(ctx, ec, sel, v)
}
func marshalNPlanetRequiresNested2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐPlanetRequiresNested(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v model.PlanetRequiresNested) graphql.Marshaler {
return _PlanetRequiresNested(ctx, ec, sel, &v)
}
func marshalNPlanetRequiresNested2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐPlanetRequiresNested(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v *model.PlanetRequiresNested) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return _PlanetRequiresNested(ctx, ec, sel, v)
}
func unmarshalNString2string(ctx context.Context, ec *executionContext, v any) (string, error) {
res, err := graphql.UnmarshalString(v)
return res, graphql.ErrorOnPath(ctx, err)
}
func marshalNString2string(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v string) graphql.Marshaler {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func marshalNWorld2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐWorld(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v model.World) graphql.Marshaler {
return _World(ctx, ec, sel, &v)
}
func marshalNWorld2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐWorld(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v *model.World) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return _World(ctx, ec, sel, v)
}
func marshalNWorldName2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐWorldName(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v model.WorldName) graphql.Marshaler {
return _WorldName(ctx, ec, sel, &v)
}
func marshalNWorldName2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐWorldName(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v *model.WorldName) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return _WorldName(ctx, ec, sel, v)
}
func marshalNWorldWithMultipleKeys2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐWorldWithMultipleKeys(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v model.WorldWithMultipleKeys) graphql.Marshaler {
return _WorldWithMultipleKeys(ctx, ec, sel, &v)
}
func marshalNWorldWithMultipleKeys2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐWorldWithMultipleKeys(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v *model.WorldWithMultipleKeys) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return _WorldWithMultipleKeys(ctx, ec, sel, v)
}
func unmarshalN_Any2map(ctx context.Context, ec *executionContext, v any) (map[string]any, error) {
res, err := graphql.UnmarshalMap(v)
return res, graphql.ErrorOnPath(ctx, err)
}
func marshalN_Any2map(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v map[string]any) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
_ = sel
res := graphql.MarshalMap(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func unmarshalN_Any2ᚕmapᚄ(ctx context.Context, ec *executionContext, v any) ([]map[string]any, error) {
var vSlice []any
vSlice = graphql.CoerceList(v)
var err error
res := make([]map[string]any, len(vSlice))
for i := range vSlice {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
res[i], err = unmarshalN_Any2map(ctx, ec, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil
}
func marshalN_Any2ᚕmapᚄ(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v []map[string]any) graphql.Marshaler {
ret := make(graphql.Array, len(v))
for i := range v {
ret[i] = marshalN_Any2map(ctx, ec, sel, v[i])
}
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v []fedruntime.Entity) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return marshalO_Entity2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, ec, sel, v[i])
})
return ret
}
func unmarshalN_FieldSet2string(ctx context.Context, ec *executionContext, v any) (string, error) {
res, err := graphql.UnmarshalString(v)
return res, graphql.ErrorOnPath(ctx, err)
}
func marshalN_FieldSet2string(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v string) graphql.Marshaler {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func marshalN_Service2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v fedruntime.Service) graphql.Marshaler {
return __Service(ctx, ec, sel, &v)
}
func marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler {
return ___Directive(ctx, ec, sel, &v)
}
func marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, ec, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func unmarshalN__DirectiveLocation2string(ctx context.Context, ec *executionContext, v any) (string, error) {
res, err := graphql.UnmarshalString(v)
return res, graphql.ErrorOnPath(ctx, err)
}
func marshalN__DirectiveLocation2string(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v string) graphql.Marshaler {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, ec *executionContext, v any) ([]string, error) {
var vSlice []any
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 = unmarshalN__DirectiveLocation2string(ctx, ec, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil
}
func marshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v []string) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return marshalN__DirectiveLocation2string(ctx, ec, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler {
return ___EnumValue(ctx, ec, sel, &v)
}
func marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler {
return ___Field(ctx, ec, sel, &v)
}
func marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler {
return ___InputValue(ctx, ec, sel, &v)
}
func marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, ec, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler {
return ___Type(ctx, ec, sel, &v)
}
func marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, ec, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return ___Type(ctx, ec, sel, v)
}
func unmarshalN__TypeKind2string(ctx context.Context, ec *executionContext, v any) (string, error) {
res, err := graphql.UnmarshalString(v)
return res, graphql.ErrorOnPath(ctx, err)
}
func marshalN__TypeKind2string(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v string) graphql.Marshaler {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func unmarshalOBoolean2bool(ctx context.Context, ec *executionContext, v any) (bool, error) {
res, err := graphql.UnmarshalBoolean(v)
return res, graphql.ErrorOnPath(ctx, err)
}
func marshalOBoolean2bool(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v bool) graphql.Marshaler {
_ = sel
_ = ctx
res := graphql.MarshalBoolean(v)
return res
}
func unmarshalOBoolean2ᚖbool(ctx context.Context, ec *executionContext, v any) (*bool, error) {
if v == nil {
return nil, nil
}
res, err := graphql.UnmarshalBoolean(v)
return &res, graphql.ErrorOnPath(ctx, err)
}
func marshalOBoolean2ᚖbool(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v *bool) graphql.Marshaler {
if v == nil {
return graphql.Null
}
_ = sel
_ = ctx
res := graphql.MarshalBoolean(*v)
return res
}
func marshalOHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐHello(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v *model.Hello) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return _Hello(ctx, ec, sel, v)
}
func marshalOMultiHello2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHello(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v []*model.MultiHello) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return marshalOMultiHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHello(ctx, ec, sel, v[i])
})
return ret
}
func marshalOMultiHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHello(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v *model.MultiHello) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return _MultiHello(ctx, ec, sel, v)
}
func unmarshalOMultiHelloByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloByNamesInput(ctx context.Context, ec *executionContext, v any) (*model.MultiHelloByNamesInput, error) {
if v == nil {
return nil, nil
}
res, err := unmarshalInputMultiHelloByNamesInput(ctx, ec, v)
return &res, graphql.ErrorOnPath(ctx, err)
}
func marshalOMultiHelloMultipleRequires2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloMultipleRequires(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v []*model.MultiHelloMultipleRequires) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return marshalOMultiHelloMultipleRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloMultipleRequires(ctx, ec, sel, v[i])
})
return ret
}
func marshalOMultiHelloMultipleRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloMultipleRequires(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v *model.MultiHelloMultipleRequires) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return _MultiHelloMultipleRequires(ctx, ec, sel, v)
}
func unmarshalOMultiHelloMultipleRequiresByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloMultipleRequiresByNamesInput(ctx context.Context, ec *executionContext, v any) (*model.MultiHelloMultipleRequiresByNamesInput, error) {
if v == nil {
return nil, nil
}
res, err := unmarshalInputMultiHelloMultipleRequiresByNamesInput(ctx, ec, v)
return &res, graphql.ErrorOnPath(ctx, err)
}
func marshalOMultiHelloRequires2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloRequires(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v []*model.MultiHelloRequires) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return marshalOMultiHelloRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloRequires(ctx, ec, sel, v[i])
})
return ret
}
func marshalOMultiHelloRequires2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloRequires(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v *model.MultiHelloRequires) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return _MultiHelloRequires(ctx, ec, sel, v)
}
func unmarshalOMultiHelloRequiresByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloRequiresByNamesInput(ctx context.Context, ec *executionContext, v any) (*model.MultiHelloRequiresByNamesInput, error) {
if v == nil {
return nil, nil
}
res, err := unmarshalInputMultiHelloRequiresByNamesInput(ctx, ec, v)
return &res, graphql.ErrorOnPath(ctx, err)
}
func marshalOMultiHelloWithError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloWithError(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v []*model.MultiHelloWithError) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return marshalOMultiHelloWithError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloWithError(ctx, ec, sel, v[i])
})
return ret
}
func marshalOMultiHelloWithError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloWithError(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v *model.MultiHelloWithError) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return _MultiHelloWithError(ctx, ec, sel, v)
}
func unmarshalOMultiHelloWithErrorByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiHelloWithErrorByNamesInput(ctx context.Context, ec *executionContext, v any) (*model.MultiHelloWithErrorByNamesInput, error) {
if v == nil {
return nil, nil
}
res, err := unmarshalInputMultiHelloWithErrorByNamesInput(ctx, ec, v)
return &res, graphql.ErrorOnPath(ctx, err)
}
func marshalOMultiPlanetRequiresNested2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiPlanetRequiresNested(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v []*model.MultiPlanetRequiresNested) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return marshalOMultiPlanetRequiresNested2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiPlanetRequiresNested(ctx, ec, sel, v[i])
})
return ret
}
func marshalOMultiPlanetRequiresNested2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiPlanetRequiresNested(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v *model.MultiPlanetRequiresNested) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return _MultiPlanetRequiresNested(ctx, ec, sel, v)
}
func unmarshalOMultiPlanetRequiresNestedByNamesInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋusefunctionsyntaxforexecutioncontextᚋgeneratedᚋmodelᚐMultiPlanetRequiresNestedByNamesInput(ctx context.Context, ec *executionContext, v any) (*model.MultiPlanetRequiresNestedByNamesInput, error) {
if v == nil {
return nil, nil
}
res, err := unmarshalInputMultiPlanetRequiresNestedByNamesInput(ctx, ec, v)
return &res, graphql.ErrorOnPath(ctx, err)
}
func unmarshalOString2string(ctx context.Context, ec *executionContext, v any) (string, error) {
res, err := graphql.UnmarshalString(v)
return res, graphql.ErrorOnPath(ctx, err)
}
func marshalOString2string(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v string) graphql.Marshaler {
_ = sel
_ = ctx
res := graphql.MarshalString(v)
return res
}
func unmarshalOString2ᚖstring(ctx context.Context, ec *executionContext, v any) (*string, error) {
if v == nil {
return nil, nil
}
res, err := graphql.UnmarshalString(v)
return &res, graphql.ErrorOnPath(ctx, err)
}
func marshalOString2ᚖstring(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v *string) graphql.Marshaler {
if v == nil {
return graphql.Null
}
_ = sel
_ = ctx
res := graphql.MarshalString(*v)
return res
}
func marshalO_Entity2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v fedruntime.Entity) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return __Entity(ctx, ec, sel, v)
}
func marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, ec, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, ec, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, ec, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ___Schema(ctx, ec, sel, v)
}
func marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler {
fc := graphql.GetFieldContext(ctx)
fc.Result = &v[i]
return marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, ec, sel, v[i])
})
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ___Type(ctx, ec, sel, v)
}
// endregion ***************************** type.gotpl *****************************
================================================
FILE: plugin/federation/testdata/usefunctionsyntaxforexecutioncontext/generated/federation.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package generated
import (
"context"
"errors"
"fmt"
"strings"
"sync"
"github.com/99designs/gqlgen/plugin/federation/fedruntime"
"github.com/99designs/gqlgen/plugin/federation/testdata/usefunctionsyntaxforexecutioncontext/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]any) []fedruntime.Entity {
list := make([]fedruntime.Entity, len(representations))
repsMap := ec.buildRepresentationGroups(ctx, representations)
switch len(repsMap) {
case 0:
return list
case 1:
for typeName, reps := range repsMap {
ec.resolveEntityGroup(ctx, typeName, reps, list)
}
return list
default:
var g sync.WaitGroup
g.Add(len(repsMap))
for typeName, reps := range repsMap {
go func(typeName string, reps []EntityWithIndex) {
ec.resolveEntityGroup(ctx, typeName, reps, list)
g.Done()
}(typeName, reps)
}
g.Wait()
return list
}
}
type EntityWithIndex struct {
// The index in the original representation array
index int
entity EntityRepresentation
}
// EntityRepresentation is the JSON representation of an entity sent by the Router
// used as the inputs for us to resolve.
//
// We make it a map because we know the top level JSON is always an object.
type EntityRepresentation map[string]any
// We group entities by typename so that we can parallelize their resolution.
// This is particularly helpful when there are entity groups in multi mode.
func (ec *executionContext) buildRepresentationGroups(
ctx context.Context,
representations []map[string]any,
) map[string][]EntityWithIndex {
repsMap := make(map[string][]EntityWithIndex)
for i, rep := range representations {
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
}
repsMap[typeName] = append(repsMap[typeName], EntityWithIndex{
index: i,
entity: rep,
})
}
return repsMap
}
func (ec *executionContext) resolveEntityGroup(
ctx context.Context,
typeName string,
reps []EntityWithIndex,
list []fedruntime.Entity,
) {
if isMulti(typeName) {
err := ec.resolveManyEntities(ctx, typeName, reps, list)
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 EntityWithIndex) {
entity, err := ec.resolveEntity(ctx, typeName, rep.entity)
if err != nil {
ec.Error(ctx, err)
} else {
list[rep.index] = entity
}
e.Done()
}(i, rep)
}
e.Wait()
}
}
func isMulti(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
}
}
func (ec *executionContext) resolveEntity(
ctx context.Context,
typeName string,
rep EntityRepresentation,
) (e fedruntime.Entity, 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 nil, fmt.Errorf(`finding resolver for Entity "Hello": %w`, err)
}
switch resolverName {
case "findHelloByName":
id0, err := unmarshalNString2string(ctx, ec, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findHelloByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindHelloByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "Hello": %w`, err)
}
return entity, nil
}
case "HelloMultiSingleKeys":
resolverName, err := entityResolverNameForHelloMultiSingleKeys(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "HelloMultiSingleKeys": %w`, err)
}
switch resolverName {
case "findHelloMultiSingleKeysByKey1AndKey2":
id0, err := unmarshalNString2string(ctx, ec, rep["key1"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findHelloMultiSingleKeysByKey1AndKey2(): %w`, err)
}
id1, err := unmarshalNString2string(ctx, ec, rep["key2"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 1 for findHelloMultiSingleKeysByKey1AndKey2(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindHelloMultiSingleKeysByKey1AndKey2(ctx, id0, id1)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "HelloMultiSingleKeys": %w`, err)
}
return entity, nil
}
case "HelloWithErrors":
resolverName, err := entityResolverNameForHelloWithErrors(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "HelloWithErrors": %w`, err)
}
switch resolverName {
case "findHelloWithErrorsByName":
id0, err := unmarshalNString2string(ctx, ec, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findHelloWithErrorsByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindHelloWithErrorsByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "HelloWithErrors": %w`, err)
}
return entity, nil
}
case "PlanetMultipleRequires":
resolverName, err := entityResolverNameForPlanetMultipleRequires(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "PlanetMultipleRequires": %w`, err)
}
switch resolverName {
case "findPlanetMultipleRequiresByName":
id0, err := unmarshalNString2string(ctx, ec, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findPlanetMultipleRequiresByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindPlanetMultipleRequiresByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "PlanetMultipleRequires": %w`, err)
}
entity.Diameter, err = unmarshalNInt2int(ctx, ec, rep["diameter"])
if err != nil {
return nil, err
}
entity.Density, err = unmarshalNInt2int(ctx, ec, rep["density"])
if err != nil {
return nil, err
}
return entity, nil
}
case "PlanetRequires":
resolverName, err := entityResolverNameForPlanetRequires(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "PlanetRequires": %w`, err)
}
switch resolverName {
case "findPlanetRequiresByName":
id0, err := unmarshalNString2string(ctx, ec, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findPlanetRequiresByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindPlanetRequiresByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "PlanetRequires": %w`, err)
}
entity.Diameter, err = unmarshalNInt2int(ctx, ec, rep["diameter"])
if err != nil {
return nil, err
}
return entity, nil
}
case "PlanetRequiresNested":
resolverName, err := entityResolverNameForPlanetRequiresNested(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "PlanetRequiresNested": %w`, err)
}
switch resolverName {
case "findPlanetRequiresNestedByName":
id0, err := unmarshalNString2string(ctx, ec, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findPlanetRequiresNestedByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindPlanetRequiresNestedByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "PlanetRequiresNested": %w`, err)
}
entity.World.Foo, err = unmarshalNString2string(ctx, ec, rep["world"].(map[string]any)["foo"])
if err != nil {
return nil, err
}
return entity, nil
}
case "World":
resolverName, err := entityResolverNameForWorld(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "World": %w`, err)
}
switch resolverName {
case "findWorldByHelloNameAndFoo":
id0, err := unmarshalNString2string(ctx, ec, rep["hello"].(map[string]any)["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findWorldByHelloNameAndFoo(): %w`, err)
}
id1, err := unmarshalNString2string(ctx, ec, rep["foo"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 1 for findWorldByHelloNameAndFoo(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindWorldByHelloNameAndFoo(ctx, id0, id1)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "World": %w`, err)
}
return entity, nil
}
case "WorldName":
resolverName, err := entityResolverNameForWorldName(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "WorldName": %w`, err)
}
switch resolverName {
case "findWorldNameByName":
id0, err := unmarshalNString2string(ctx, ec, rep["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findWorldNameByName(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindWorldNameByName(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "WorldName": %w`, err)
}
return entity, nil
}
case "WorldWithMultipleKeys":
resolverName, err := entityResolverNameForWorldWithMultipleKeys(ctx, rep)
if err != nil {
return nil, fmt.Errorf(`finding resolver for Entity "WorldWithMultipleKeys": %w`, err)
}
switch resolverName {
case "findWorldWithMultipleKeysByHelloNameAndFoo":
id0, err := unmarshalNString2string(ctx, ec, rep["hello"].(map[string]any)["name"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findWorldWithMultipleKeysByHelloNameAndFoo(): %w`, err)
}
id1, err := unmarshalNString2string(ctx, ec, rep["foo"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 1 for findWorldWithMultipleKeysByHelloNameAndFoo(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindWorldWithMultipleKeysByHelloNameAndFoo(ctx, id0, id1)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "WorldWithMultipleKeys": %w`, err)
}
return entity, nil
case "findWorldWithMultipleKeysByBar":
id0, err := unmarshalNInt2int(ctx, ec, rep["bar"])
if err != nil {
return nil, fmt.Errorf(`unmarshalling param 0 for findWorldWithMultipleKeysByBar(): %w`, err)
}
entity, err := ec.Resolvers.Entity().FindWorldWithMultipleKeysByBar(ctx, id0)
if err != nil {
return nil, fmt.Errorf(`resolving Entity "WorldWithMultipleKeys": %w`, err)
}
return entity, nil
}
}
return nil, fmt.Errorf("%w: %s", ErrUnknownType, typeName)
}
func (ec *executionContext) resolveManyEntities(
ctx context.Context,
typeName string,
reps []EntityWithIndex,
list []fedruntime.Entity,
) (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].entity)
if err != nil {
return fmt.Errorf(`finding resolver for Entity "MultiHello": %w`, err)
}
switch resolverName {
case "findManyMultiHelloByNames":
typedReps := make([]*model.MultiHelloByNamesInput, len(reps))
for i, rep := range reps {
id0, err := unmarshalNString2string(ctx, ec, rep.entity["name"])
if err != nil {
return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name"))
}
typedReps[i] = &model.MultiHelloByNamesInput{
Name: id0,
}
}
entities, err := ec.Resolvers.Entity().FindManyMultiHelloByNames(ctx, typedReps)
if err != nil {
return err
}
for i, entity := range entities {
list[reps[i].index] = entity
}
return nil
default:
return fmt.Errorf("unknown resolver: %s", resolverName)
}
case "MultiHelloMultipleRequires":
resolverName, err := entityResolverNameForMultiHelloMultipleRequires(ctx, reps[0].entity)
if err != nil {
return fmt.Errorf(`finding resolver for Entity "MultiHelloMultipleRequires": %w`, err)
}
switch resolverName {
case "findManyMultiHelloMultipleRequiresByNames":
typedReps := make([]*model.MultiHelloMultipleRequiresByNamesInput, len(reps))
for i, rep := range reps {
id0, err := unmarshalNString2string(ctx, ec, rep.entity["name"])
if err != nil {
return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name"))
}
typedReps[i] = &model.MultiHelloMultipleRequiresByNamesInput{
Name: id0,
}
}
entities, err := ec.Resolvers.Entity().FindManyMultiHelloMultipleRequiresByNames(ctx, typedReps)
if err != nil {
return err
}
for i, entity := range entities {
entity.Key1, err = unmarshalNString2string(ctx, ec, reps[i].entity["key1"])
if err != nil {
return err
}
entity.Key2, err = unmarshalNString2string(ctx, ec, reps[i].entity["key2"])
if err != nil {
return err
}
list[reps[i].index] = entity
}
return nil
default:
return fmt.Errorf("unknown resolver: %s", resolverName)
}
case "MultiHelloRequires":
resolverName, err := entityResolverNameForMultiHelloRequires(ctx, reps[0].entity)
if err != nil {
return fmt.Errorf(`finding resolver for Entity "MultiHelloRequires": %w`, err)
}
switch resolverName {
case "findManyMultiHelloRequiresByNames":
typedReps := make([]*model.MultiHelloRequiresByNamesInput, len(reps))
for i, rep := range reps {
id0, err := unmarshalNString2string(ctx, ec, rep.entity["name"])
if err != nil {
return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name"))
}
typedReps[i] = &model.MultiHelloRequiresByNamesInput{
Name: id0,
}
}
entities, err := ec.Resolvers.Entity().FindManyMultiHelloRequiresByNames(ctx, typedReps)
if err != nil {
return err
}
for i, entity := range entities {
entity.Key1, err = unmarshalNString2string(ctx, ec, reps[i].entity["key1"])
if err != nil {
return err
}
list[reps[i].index] = entity
}
return nil
default:
return fmt.Errorf("unknown resolver: %s", resolverName)
}
case "MultiHelloWithError":
resolverName, err := entityResolverNameForMultiHelloWithError(ctx, reps[0].entity)
if err != nil {
return fmt.Errorf(`finding resolver for Entity "MultiHelloWithError": %w`, err)
}
switch resolverName {
case "findManyMultiHelloWithErrorByNames":
typedReps := make([]*model.MultiHelloWithErrorByNamesInput, len(reps))
for i, rep := range reps {
id0, err := unmarshalNString2string(ctx, ec, rep.entity["name"])
if err != nil {
return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name"))
}
typedReps[i] = &model.MultiHelloWithErrorByNamesInput{
Name: id0,
}
}
entities, err := ec.Resolvers.Entity().FindManyMultiHelloWithErrorByNames(ctx, typedReps)
if err != nil {
return err
}
for i, entity := range entities {
list[reps[i].index] = entity
}
return nil
default:
return fmt.Errorf("unknown resolver: %s", resolverName)
}
case "MultiPlanetRequiresNested":
resolverName, err := entityResolverNameForMultiPlanetRequiresNested(ctx, reps[0].entity)
if err != nil {
return fmt.Errorf(`finding resolver for Entity "MultiPlanetRequiresNested": %w`, err)
}
switch resolverName {
case "findManyMultiPlanetRequiresNestedByNames":
typedReps := make([]*model.MultiPlanetRequiresNestedByNamesInput, len(reps))
for i, rep := range reps {
id0, err := unmarshalNString2string(ctx, ec, rep.entity["name"])
if err != nil {
return errors.New(fmt.Sprintf("Field %s undefined in schema.", "name"))
}
typedReps[i] = &model.MultiPlanetRequiresNestedByNamesInput{
Name: id0,
}
}
entities, err := ec.Resolvers.Entity().FindManyMultiPlanetRequiresNestedByNames(ctx, typedReps)
if err != nil {
return err
}
for i, entity := range entities {
entity.World.Foo, err = unmarshalNString2string(ctx, ec, reps[i].entity["world"].(map[string]any)["foo"])
if err != nil {
return err
}
list[reps[i].index] = entity
}
return nil
default:
return fmt.Errorf("unknown resolver: %s", resolverName)
}
default:
return errors.New("unknown type: " + typeName)
}
}
func entityResolverNameForHello(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for Hello", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for Hello", ErrTypeNotFound))
break
}
return "findHelloByName", nil
}
return "", fmt.Errorf("%w for Hello due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForHelloMultiSingleKeys(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["key1"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"key1\" for HelloMultiSingleKeys", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
m = rep
val, ok = m["key2"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"key2\" for HelloMultiSingleKeys", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for HelloMultiSingleKeys", ErrTypeNotFound))
break
}
return "findHelloMultiSingleKeysByKey1AndKey2", nil
}
return "", fmt.Errorf("%w for HelloMultiSingleKeys due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForHelloWithErrors(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for HelloWithErrors", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for HelloWithErrors", ErrTypeNotFound))
break
}
return "findHelloWithErrorsByName", nil
}
return "", fmt.Errorf("%w for HelloWithErrors due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForMultiHello(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for MultiHello", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for MultiHello", ErrTypeNotFound))
break
}
return "findManyMultiHelloByNames", nil
}
return "", fmt.Errorf("%w for MultiHello due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForMultiHelloMultipleRequires(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for MultiHelloMultipleRequires", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for MultiHelloMultipleRequires", ErrTypeNotFound))
break
}
return "findManyMultiHelloMultipleRequiresByNames", nil
}
return "", fmt.Errorf("%w for MultiHelloMultipleRequires due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForMultiHelloRequires(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for MultiHelloRequires", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for MultiHelloRequires", ErrTypeNotFound))
break
}
return "findManyMultiHelloRequiresByNames", nil
}
return "", fmt.Errorf("%w for MultiHelloRequires due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForMultiHelloWithError(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for MultiHelloWithError", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for MultiHelloWithError", ErrTypeNotFound))
break
}
return "findManyMultiHelloWithErrorByNames", nil
}
return "", fmt.Errorf("%w for MultiHelloWithError due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForMultiPlanetRequiresNested(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for MultiPlanetRequiresNested", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for MultiPlanetRequiresNested", ErrTypeNotFound))
break
}
return "findManyMultiPlanetRequiresNestedByNames", nil
}
return "", fmt.Errorf("%w for MultiPlanetRequiresNested due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForPlanetMultipleRequires(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for PlanetMultipleRequires", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for PlanetMultipleRequires", ErrTypeNotFound))
break
}
return "findPlanetMultipleRequiresByName", nil
}
return "", fmt.Errorf("%w for PlanetMultipleRequires due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForPlanetRequires(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for PlanetRequires", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for PlanetRequires", ErrTypeNotFound))
break
}
return "findPlanetRequiresByName", nil
}
return "", fmt.Errorf("%w for PlanetRequires due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForPlanetRequiresNested(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for PlanetRequiresNested", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for PlanetRequiresNested", ErrTypeNotFound))
break
}
return "findPlanetRequiresNestedByName", nil
}
return "", fmt.Errorf("%w for PlanetRequiresNested due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForWorld(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["hello"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"hello\" for World", ErrTypeNotFound))
break
}
if m, ok = val.(map[string]any); !ok {
// nested field value is not a map[string]interface so don't use it
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to nested Key Field \"hello\" value not matching map[string]any for World", ErrTypeNotFound))
break
}
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for World", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
m = rep
val, ok = m["foo"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"foo\" for World", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for World", ErrTypeNotFound))
break
}
return "findWorldByHelloNameAndFoo", nil
}
return "", fmt.Errorf("%w for World due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForWorldName(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for WorldName", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for WorldName", ErrTypeNotFound))
break
}
return "findWorldNameByName", nil
}
return "", fmt.Errorf("%w for WorldName due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
func entityResolverNameForWorldWithMultipleKeys(ctx context.Context, rep EntityRepresentation) (string, error) {
// we collect errors because a later entity resolver may work fine
// when an entity has multiple keys
entityResolverErrs := []error{}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["hello"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"hello\" for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
if m, ok = val.(map[string]any); !ok {
// nested field value is not a map[string]interface so don't use it
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to nested Key Field \"hello\" value not matching map[string]any for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
val, ok = m["name"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"name\" for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
m = rep
val, ok = m["foo"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"foo\" for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
return "findWorldWithMultipleKeysByHelloNameAndFoo", nil
}
for {
var (
m EntityRepresentation
val any
ok bool
)
_ = val
// if all of the KeyFields values for this resolver are null,
// we shouldn't use use it
allNull := true
m = rep
val, ok = m["bar"]
if !ok {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to missing Key Field \"bar\" for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
if allNull {
allNull = val == nil
}
if allNull {
entityResolverErrs = append(entityResolverErrs,
fmt.Errorf("%w due to all null value KeyFields for WorldWithMultipleKeys", ErrTypeNotFound))
break
}
return "findWorldWithMultipleKeysByBar", nil
}
return "", fmt.Errorf("%w for WorldWithMultipleKeys due to %v", ErrTypeNotFound,
errors.Join(entityResolverErrs...).Error())
}
================================================
FILE: plugin/federation/testdata/usefunctionsyntaxforexecutioncontext/generated/model/models.go
================================================
// Code generated by github.com/99designs/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() {}
================================================
FILE: plugin/federation/testdata/usefunctionsyntaxforexecutioncontext/gqlgen.yml
================================================
schema:
- "testdata/usefunctionsyntaxforexecutioncontext/schema.graphql"
use_function_syntax_for_execution_context: true
exec:
filename: testdata/usefunctionsyntaxforexecutioncontext/generated/exec.go
federation:
filename: testdata/usefunctionsyntaxforexecutioncontext/generated/federation.go
model:
filename: testdata/usefunctionsyntaxforexecutioncontext/generated/model/models.go
package: model
resolver:
filename: testdata/usefunctionsyntaxforexecutioncontext/resolver.go
layout: follow-schema
dir: testdata/usefunctionsyntaxforexecutioncontext
package: usefunctionsyntaxforexecutioncontext
================================================
FILE: plugin/federation/testdata/usefunctionsyntaxforexecutioncontext/resolver.go
================================================
package usefunctionsyntaxforexecutioncontext
// This file will not be regenerated automatically.
//
// It serves as dependency injection for your app, add any dependencies you require here.
type Resolver struct{}
// FindWorldWithMultipleKeysByHelloNameAndFooBarValue shows we hit the FindWorldWithMultipleKeysByHelloNameAndFoo resolver
const FindWorldWithMultipleKeysByHelloNameAndFooBarValue = 99
================================================
FILE: plugin/federation/testdata/usefunctionsyntaxforexecutioncontext/schema.graphql
================================================
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")
}
================================================
FILE: plugin/federation/testdata/usefunctionsyntaxforexecutioncontext/schema.resolvers.go
================================================
package usefunctionsyntaxforexecutioncontext
// 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.
================================================
FILE: plugin/modelgen/interface_graph.go
================================================
package modelgen
import (
"errors"
"github.com/vektah/gqlparser/v2/ast"
)
// interfaceGraph tracks interface implementation relationships.
type interfaceGraph struct {
schema *ast.Schema
parentInterfaces map[string][]string // interface -> interfaces it implements
childInterfaces map[string][]string // interface -> interfaces that implement it
}
func newInterfaceGraph(schema *ast.Schema) *interfaceGraph {
g := &interfaceGraph{
schema: schema,
parentInterfaces: make(map[string][]string),
childInterfaces: make(map[string][]string),
}
for _, schemaType := range schema.Types {
if schemaType.Kind != ast.Interface {
continue
}
if len(schemaType.Interfaces) == 0 {
g.parentInterfaces[schemaType.Name] = []string{}
} else {
g.parentInterfaces[schemaType.Name] = append([]string{}, schemaType.Interfaces...)
for _, parent := range schemaType.Interfaces {
g.childInterfaces[parent] = append(g.childInterfaces[parent], schemaType.Name)
}
}
}
return g
}
// topologicalSort returns interfaces ordered with parents before children.
// Only considers relationships between interfaces in the provided list.
func (g *interfaceGraph) topologicalSort(interfaces []string) ([]string, error) {
interfaceSet := make(map[string]bool)
for _, iface := range interfaces {
interfaceSet[iface] = true
}
inDegree := make(map[string]int)
for _, iface := range interfaces {
count := 0
for _, parent := range g.parentInterfaces[iface] {
if interfaceSet[parent] {
count++
}
}
inDegree[iface] = count
}
var queue []string
for _, iface := range interfaces {
if inDegree[iface] == 0 {
queue = append(queue, iface)
}
}
var result []string
for len(queue) > 0 {
current := queue[0]
queue = queue[1:]
result = append(result, current)
for _, child := range g.childInterfaces[current] {
if interfaceSet[child] {
inDegree[child]--
if inDegree[child] == 0 {
queue = append(queue, child)
}
}
}
}
if len(result) != len(interfaces) {
return nil, errors.New("cycle detected in interface implementations")
}
return result, nil
}
// embeddingInfo contains information about interface embedding relationships.
type embeddingInfo struct {
Parents []string // embeddable parent interfaces with goEmbedInterface directive
SkippedFields []*ast.FieldDefinition // fields from intermediate parents without the directive
}
// getInterfaceOwnFields returns only the fields that are not inherited from parent interfaces.
func (g *interfaceGraph) getInterfaceOwnFields(interfaceName string) []*ast.FieldDefinition {
schemaInterface := g.schema.Types[interfaceName]
if schemaInterface == nil || schemaInterface.Kind != ast.Interface {
return nil
}
parents := g.parentInterfaces[interfaceName]
if len(parents) == 0 {
return schemaInterface.Fields
}
parentFieldNames := make(map[string]bool)
for _, parentName := range parents {
parentInterface := g.schema.Types[parentName]
if parentInterface == nil {
continue
}
for _, field := range parentInterface.Fields {
parentFieldNames[field.Name] = true
}
}
ownFields := []*ast.FieldDefinition{}
for _, field := range schemaInterface.Fields {
if !parentFieldNames[field.Name] {
ownFields = append(ownFields, field)
}
}
return ownFields
}
// getEmbeddingInfo returns information about embeddable parent interfaces and fields
// from intermediate parents that don't have the goEmbedInterface directive.
func (g *interfaceGraph) getEmbeddingInfo(interfaceName string) embeddingInfo {
info := embeddingInfo{
Parents: []string{},
SkippedFields: []*ast.FieldDefinition{},
}
visited := make(map[string]bool)
var walkParents func(name string)
walkParents = func(name string) {
if visited[name] {
return
}
visited[name] = true
parentDef := g.schema.Types[name]
if parentDef == nil || parentDef.Kind != ast.Interface {
return
}
// Check if this parent has the directive (is embeddable)
if g.isEmbeddable(name) {
info.Parents = append(info.Parents, name)
} else {
// Not embeddable - collect its fields and walk up
info.SkippedFields = append(info.SkippedFields, g.getInterfaceOwnFields(name)...)
for _, grandparent := range parentDef.Interfaces {
walkParents(grandparent)
}
}
}
currentDef := g.schema.Types[interfaceName]
if currentDef != nil {
for _, parent := range currentDef.Interfaces {
walkParents(parent)
}
}
return info
}
// isEmbeddable returns true if the interface has the goEmbedInterface directive.
func (g *interfaceGraph) isEmbeddable(interfaceName string) bool {
iface := g.schema.Types[interfaceName]
if iface == nil || iface.Kind != ast.Interface {
return false
}
return iface.Directives.ForName("goEmbedInterface") != nil
}
================================================
FILE: plugin/modelgen/interface_graph_test.go
================================================
package modelgen
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/vektah/gqlparser/v2/ast"
)
func TestInterfaceGraph(t *testing.T) {
schema := createNodeElementMetalSchema("Node", "Element", "Metal")
t.Run("builds interface graph correctly", func(t *testing.T) {
graph := newInterfaceGraph(schema)
// Check parent relationships
assert.Empty(t, graph.parentInterfaces["Node"])
assert.Equal(t, []string{"Node"}, graph.parentInterfaces["Element"])
assert.Equal(t, []string{"Element"}, graph.parentInterfaces["Metal"])
})
t.Run("topological sort orders parents before children", func(t *testing.T) {
graph := newInterfaceGraph(schema)
sorted, err := graph.topologicalSort([]string{"Metal", "Node", "Element"})
require.NoError(t, err)
// Node should come before Element, Element should come before Metal
nodeIdx := -1
elementIdx := -1
metalIdx := -1
for i, name := range sorted {
switch name {
case "Node":
nodeIdx = i
case "Element":
elementIdx = i
case "Metal":
metalIdx = i
}
}
assert.Less(t, nodeIdx, elementIdx, "Node should come before Element")
assert.Less(t, elementIdx, metalIdx, "Element should come before Metal")
})
t.Run("gets interface own fields correctly", func(t *testing.T) {
graph := newInterfaceGraph(schema)
// Node has all its fields as own fields
nodeFields := graph.getInterfaceOwnFields("Node")
assert.Len(t, nodeFields, 1)
assert.Equal(t, "id", nodeFields[0].Name)
// Element inherits id from Node, only name is own field
elementFields := graph.getInterfaceOwnFields("Element")
assert.Len(t, elementFields, 1)
assert.Equal(t, "name", elementFields[0].Name)
// Metal inherits id and name, only atomicNumber is own field
metalFields := graph.getInterfaceOwnFields("Metal")
assert.Len(t, metalFields, 1)
assert.Equal(t, "atomicNumber", metalFields[0].Name)
})
t.Run("includes all interfaces in graph", func(t *testing.T) {
schemaWithMixed := createNodeElementMetalSchema("Node", "Metal")
graph := newInterfaceGraph(schemaWithMixed)
// All interfaces should be in graph (graph stores all interfaces)
_, nodeExists := graph.parentInterfaces["Node"]
assert.True(t, nodeExists, "Node should be in graph")
_, elementExists := graph.parentInterfaces["Element"]
assert.True(t, elementExists, "Element should be in graph (even without directive)")
_, metalExists := graph.parentInterfaces["Metal"]
assert.True(t, metalExists, "Metal should be in graph")
// But isEmbeddable should filter by directive
assert.True(t, graph.isEmbeddable("Node"), "Node should be embeddable (has directive)")
assert.False(
t,
graph.isEmbeddable("Element"),
"Element should NOT be embeddable (no directive)",
)
assert.True(t, graph.isEmbeddable("Metal"), "Metal should be embeddable (has directive)")
})
t.Run("isEmbeddable returns true for interfaces with directive", func(t *testing.T) {
schema := createNodeElementMetalSchema("Node")
graph := newInterfaceGraph(schema)
assert.True(t, graph.isEmbeddable("Node"), "Node should be embeddable")
})
t.Run("isEmbeddable returns false for interfaces without directive", func(t *testing.T) {
schema := createNodeElementMetalSchema("Node")
graph := newInterfaceGraph(schema)
assert.False(t, graph.isEmbeddable("Element"), "Element should not be embeddable")
})
t.Run("isEmbeddable returns false for non-existent interfaces", func(t *testing.T) {
schema := createNodeElementMetalSchema("Node")
graph := newInterfaceGraph(schema)
assert.False(
t,
graph.isEmbeddable("NonExistent"),
"Non-existent interface should not be embeddable",
)
})
}
func TestInterfaceGraphGetEmbeddableParents(t *testing.T) {
testCases := []struct {
name string
schema *ast.Schema
interfaceName string
expectedParents []string
unexpectedParents []string
expectedSkippedFields []string
shouldHaveSkippedFields bool
}{
{
name: "all parents have directive",
schema: createABCChainSchema("A", "B", "C"),
interfaceName: "C",
expectedParents: []string{"B"},
unexpectedParents: []string{"A"},
shouldHaveSkippedFields: false,
},
{
name: "some parents missing directive",
schema: createABCChainSchema("A", "C"),
interfaceName: "C",
expectedParents: []string{"A"},
unexpectedParents: []string{"B"},
expectedSkippedFields: []string{"fieldB"},
shouldHaveSkippedFields: true,
},
{
name: "deep inheritance chain with mixed directives",
schema: createABCDChainSchema("A", "D"),
interfaceName: "D",
expectedParents: []string{"A"},
unexpectedParents: []string{"B", "C"},
expectedSkippedFields: []string{"fieldB", "fieldC"},
shouldHaveSkippedFields: true,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
graph := newInterfaceGraph(tc.schema)
info := graph.getEmbeddingInfo(tc.interfaceName)
for _, expected := range tc.expectedParents {
assert.Contains(t, info.Parents, expected, "should contain parent %s", expected)
}
for _, unexpected := range tc.unexpectedParents {
assert.NotContains(
t,
info.Parents,
unexpected,
"should not contain parent %s",
unexpected,
)
}
if tc.shouldHaveSkippedFields {
assert.NotEmpty(t, info.SkippedFields, "should have skipped fields")
fieldNames := make(map[string]bool)
for _, field := range info.SkippedFields {
fieldNames[field.Name] = true
}
for _, expectedField := range tc.expectedSkippedFields {
assert.True(
t,
fieldNames[expectedField],
"should contain skipped field %s",
expectedField,
)
}
} else {
assert.Empty(t, info.SkippedFields, "should not have skipped fields")
}
})
}
}
// createNodeElementMetalSchema creates a Node->Element->Metal hierarchy.
// embeddable specifies which interfaces should have the goEmbedInterface directive.
func createNodeElementMetalSchema(embeddable ...string) *ast.Schema {
embeddableSet := make(map[string]bool)
for _, name := range embeddable {
embeddableSet[name] = true
}
hasDirective := func(name string) bool {
return embeddableSet[name]
}
return &ast.Schema{
Types: map[string]*ast.Definition{
"Node": {
Name: "Node",
Kind: ast.Interface,
Interfaces: []string{},
Fields: []*ast.FieldDefinition{{Name: "id"}},
Directives: directives(embeddableSet["Node"]),
},
"Element": {
Name: "Element",
Kind: ast.Interface,
Interfaces: []string{"Node"},
Fields: []*ast.FieldDefinition{{Name: "id"}, {Name: "name"}},
Directives: directives(hasDirective("Element")),
},
"Metal": {
Name: "Metal",
Kind: ast.Interface,
Interfaces: []string{"Element"},
Fields: []*ast.FieldDefinition{
{Name: "id"},
{Name: "name"},
{Name: "atomicNumber"},
},
Directives: directives(hasDirective("Metal")),
},
},
}
}
// createABCChainSchema creates an A->B->C hierarchy.
// embeddable specifies which interfaces should have the goEmbedInterface directive.
func createABCChainSchema(embeddable ...string) *ast.Schema {
embeddableSet := make(map[string]bool)
for _, name := range embeddable {
embeddableSet[name] = true
}
return &ast.Schema{
Types: map[string]*ast.Definition{
"A": {
Name: "A",
Kind: ast.Interface,
Interfaces: []string{},
Fields: []*ast.FieldDefinition{{Name: "fieldA"}},
Directives: directives(embeddableSet["A"]),
},
"B": {
Name: "B",
Kind: ast.Interface,
Interfaces: []string{"A"},
Fields: []*ast.FieldDefinition{{Name: "fieldA"}, {Name: "fieldB"}},
Directives: directives(embeddableSet["B"]),
},
"C": {
Name: "C",
Kind: ast.Interface,
Interfaces: []string{"B"},
Fields: []*ast.FieldDefinition{
{Name: "fieldA"},
{Name: "fieldB"},
{Name: "fieldC"},
},
Directives: directives(embeddableSet["C"]),
},
},
}
}
// createABCDChainSchema creates an A->B->C->D hierarchy.
// embeddable specifies which interfaces should have the goEmbedInterface directive.
func createABCDChainSchema(embeddable ...string) *ast.Schema {
embeddableSet := make(map[string]bool)
for _, name := range embeddable {
embeddableSet[name] = true
}
return &ast.Schema{
Types: map[string]*ast.Definition{
"A": {
Name: "A",
Kind: ast.Interface,
Interfaces: []string{},
Fields: []*ast.FieldDefinition{{Name: "fieldA"}},
Directives: directives(embeddableSet["A"]),
},
"B": {
Name: "B",
Kind: ast.Interface,
Interfaces: []string{"A"},
Fields: []*ast.FieldDefinition{{Name: "fieldA"}, {Name: "fieldB"}},
Directives: directives(embeddableSet["B"]),
},
"C": {
Name: "C",
Kind: ast.Interface,
Interfaces: []string{"B"},
Fields: []*ast.FieldDefinition{
{Name: "fieldA"},
{Name: "fieldB"},
{Name: "fieldC"},
},
Directives: directives(embeddableSet["C"]),
},
"D": {
Name: "D",
Kind: ast.Interface,
Interfaces: []string{"C"},
Fields: []*ast.FieldDefinition{
{Name: "fieldA"},
{Name: "fieldB"},
{Name: "fieldC"},
{Name: "fieldD"},
},
Directives: directives(embeddableSet["D"]),
},
},
}
}
func directives(condition bool) ast.DirectiveList {
if condition {
return ast.DirectiveList{{Name: "goEmbedInterface"}}
}
return ast.DirectiveList{}
}
================================================
FILE: plugin/modelgen/internal/extrafields/types.go
================================================
package extrafields
type Type struct{}
================================================
FILE: plugin/modelgen/models.go
================================================
package modelgen
import (
_ "embed"
"fmt"
"go/types"
"os"
"sort"
"strings"
"text/template"
"github.com/vektah/gqlparser/v2/ast"
"github.com/99designs/gqlgen/codegen/config"
"github.com/99designs/gqlgen/codegen/templates"
"github.com/99designs/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) {
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
IsResolver bool
Omittable bool
ForceGenerate bool
}
type Enum struct {
Description string
Name string
Values []*EnumValue
OmitJSONMarshalers bool
}
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,
}
cfg.Directives["goEmbedInterface"] = config.DirectiveConfig{SkipRuntime: true}
binder := cfg.NewBinder()
// Generate Base structs for interfaces if embedded structs are enabled
embedder := newEmbeddedInterfaceGenerator(cfg, binder, nil, b)
specs, err := embedder.generateAllInterfaceBaseStructs()
if err != nil {
return err
}
for _, spec := range specs {
obj, err := m.buildBaseObjectFromSpec(cfg, binder, spec)
if err != nil {
return err
}
if obj != nil {
b.Models = append(b.Models, obj)
}
}
for _, schemaType := range cfg.Schema.Types {
userDefined := cfg.Models.UserDefined(schemaType.Name)
switch schemaType.Kind {
case ast.Interface, ast.Union:
if !userDefined {
it, err := m.getInterface(cfg, schemaType)
if err != nil {
return err
}
b.Interfaces = append(b.Interfaces, it)
}
}
}
for _, schemaType := range cfg.Schema.Types {
if cfg.Models.UserDefined(schemaType.Name) {
continue
}
switch schemaType.Kind {
case ast.Object, ast.InputObject:
it, err := m.getObject(cfg, schemaType, b)
if err != nil {
return err
}
if it == nil {
continue
}
b.Models = append(b.Models, it)
case ast.Enum:
it := &Enum{
Name: schemaType.Name,
Description: schemaType.Description,
OmitJSONMarshalers: cfg.OmitEnumJSONMarshalers,
}
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.ToGoModelName(it.Name))
}
for _, it := range b.Models {
cfg.Models.Add(it.Name, cfg.Model.ImportPath()+"."+templates.ToGoModelName(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.ToGoModelName(it.Name))
}
for _, it := range b.Scalars {
cfg.Models.Add(it, "github.com/99designs/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.ToGoModelName(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
}
getter := fmt.Sprintf(
"func (this %s) Get%s() %s { return ",
templates.ToGoModelName(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,
PruneOptions: cfg.GetPruneOptions(),
})
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,
model *ModelBuild,
) ([]*Field, error) {
binder := cfg.NewBinder()
embeddedGen := newEmbeddedInterfaceGenerator(cfg, binder, schemaType, model)
fields := make([]*Field, 0)
embeddedFieldMap := embeddedGen.generateEmbeddedFields(schemaType.Fields)
for _, field := range schemaType.Fields {
if embeddedField, isEmbedded := embeddedFieldMap[field.Name]; isEmbedded {
// First field of interface gets the embedded base struct
if embeddedField != nil {
fields = append(fields, embeddedField)
}
// Skip this field (either it's first with embedded field, or subsequent field from same
// interface)
continue
}
f, err := m.generateField(cfg, binder, schemaType, field)
if err != nil {
return nil, err
}
if f == nil {
continue
}
fields = append(fields, f)
}
fields = append(fields, getExtraFields(cfg, schemaType.Name)...)
return fields, nil
}
func (m *Plugin) generateField(
cfg *config.Config,
binder *config.Binder,
schemaType *ast.Definition,
field *ast.FieldDefinition,
) (*Field, error) {
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.ToGoModelName(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 nameOverride := cfg.Models[schemaType.Name].Fields[field.Name].FieldName; nameOverride != "" {
name = nameOverride
}
typ = binder.CopyModifiersFromAst(field.Type, typ)
if cfg.StructFieldsAlwaysPointers {
if isStruct(typ) && (fieldDef.Kind == ast.Object || fieldDef.Kind == ast.InputObject) {
typ = types.NewPointer(typ)
}
}
// Replace to user-defined field type if provided.
if userDefinedType := cfg.Models[schemaType.Name].Fields[field.Name].Type; userDefinedType != "" {
typ = buildType(userDefinedType)
}
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,
IsResolver: cfg.Models[schemaType.Name].Fields[field.Name].Resolver,
ForceGenerate: cfg.Models[schemaType.Name].Fields[field.Name].ForceGenerate,
}
if omittable := cfg.Models[schemaType.Name].Fields[field.Name].Omittable; omittable != nil {
f.Omittable = *omittable
}
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)
}
if mf == nil {
// the field hook wants to omit the field
return nil, nil
}
f = mf
}
if f.IsResolver && cfg.OmitResolverFields && !f.ForceGenerate {
return nil, nil
}
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,
)
}
omittableType, err := binder.FindTypeFromName(
"github.com/99designs/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)
}
}
return f, nil
}
func getExtraFields(cfg *config.Config, modelName string) []*Field {
modelcfg := cfg.Models[modelName]
extraFieldsCount := len(modelcfg.ExtraFields) + len(modelcfg.EmbedExtraFields)
if extraFieldsCount == 0 {
return nil
}
extraFields := make([]*Field, 0, extraFieldsCount)
makeExtraField := func(fname string, fspec config.ModelExtraField) *Field {
ftype := buildType(fspec.Type)
tag := `json:"-"`
if fspec.OverrideTags != "" {
tag = fspec.OverrideTags
}
return &Field{
Name: fname,
GoName: fname,
Type: ftype,
Description: fspec.Description,
Tag: tag,
}
}
if len(modelcfg.ExtraFields) > 0 {
for fname, fspec := range modelcfg.ExtraFields {
extraFields = append(extraFields, makeExtraField(fname, fspec))
}
}
if len(modelcfg.EmbedExtraFields) > 0 {
for _, fspec := range modelcfg.EmbedExtraFields {
extraFields = append(extraFields, makeExtraField("", fspec))
}
}
sort.Slice(extraFields, func(i, j int) bool {
if extraFields[i].Name == "" && extraFields[j].Name == "" {
return extraFields[i].Type.String() < extraFields[j].Type.String()
}
if extraFields[i].Name == "" {
return false
}
if extraFields[j].Name == "" {
return true
}
return extraFields[i].Name < extraFields[j].Name
})
return extraFields
}
func getStructTagFromField(cfg *config.Config, field *ast.FieldDefinition) string {
var tags []string
if !field.Type.NonNull &&
(cfg.EnableModelJsonOmitemptyTag == nil || *cfg.EnableModelJsonOmitemptyTag) {
tags = append(tags, "omitempty")
}
if !field.Type.NonNull &&
(cfg.EnableModelJsonOmitzeroTag == nil || *cfg.EnableModelJsonOmitzeroTag) {
tags = append(tags, "omitzero")
}
if len(tags) > 0 {
return `json:"` + field.Name + `,` + strings.Join(tags, ",") + `"`
}
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.SplitSeq(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.SplitSeq(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 returnTags != "" {
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 is a noop
// TODO: This will be removed in the next breaking release
func GoFieldHook(td *ast.Definition, fd *ast.FieldDefinition, f *Field) (*Field, error) {
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/99designs/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)
}
func (m *Plugin) getInterface(
cfg *config.Config,
schemaType *ast.Definition,
) (*Interface, error) {
var fields []*Field
var err error
if !cfg.OmitGetters {
fields, err = m.generateFields(cfg, schemaType, nil)
if err != nil {
return nil, 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")
}
return it, nil
}
func (m *Plugin) getObject(
cfg *config.Config,
schemaType *ast.Definition,
b *ModelBuild,
) (*Object, error) {
if cfg.IsRoot(schemaType) {
if !cfg.OmitRootModels {
return &Object{
Description: schemaType.Description,
Name: schemaType.Name,
}, nil
}
return nil, nil
}
fields, err := m.generateFields(cfg, schemaType, b)
if err != nil {
return nil, 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
}
}
}
return it, nil
}
func (m *Plugin) buildBaseObjectFromSpec(
cfg *config.Config,
binder *config.Binder,
spec *baseStructSpec,
) (*Object, error) {
fields := make([]*Field, 0)
for _, parentType := range spec.ParentEmbeddings {
fields = append(fields, &Field{
Name: "",
GoName: "", // Empty GoName creates anonymous embedding
Type: parentType,
})
}
// Generate fields from schema definitions
for _, fieldDef := range spec.FieldsToGenerate {
f, err := m.generateField(cfg, binder, spec.SchemaType, fieldDef)
if err != nil {
return nil, err
}
if f != nil {
fields = append(fields, f)
}
}
fields = append(fields, getExtraFields(cfg, spec.SchemaType.Name)...)
return &Object{
Description: spec.SchemaType.Description,
Name: fmt.Sprintf("%s%s", cfg.EmbeddedStructsPrefix, spec.SchemaType.Name),
Fields: fields,
Implements: spec.ImplementsInterfaces,
}, nil
}
================================================
FILE: plugin/modelgen/models.gotpl
================================================
{{ 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/99designs/gqlgen/graphql" }}
{{ reserveImport "github.com/99designs/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}}
{{ if $field.GoName }}{{ $field.GoName }} {{ end }}{{$field.Type | ref}}{{ if $field.Tag }} `{{$field.Tag}}`{{ end }}
{{- 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 any) 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()))
}
{{- if not .OmitJSONMarshalers }}
func (e *{{ goModelName .Name }})UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e {{ goModelName .Name }}) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
{{- end }}
{{- end }}
================================================
FILE: plugin/modelgen/models_interface_embedder.go
================================================
package modelgen
import (
"fmt"
"go/types"
"log"
"sort"
"github.com/vektah/gqlparser/v2/ast"
"github.com/99designs/gqlgen/codegen/config"
"github.com/99designs/gqlgen/codegen/templates"
"github.com/99designs/gqlgen/internal/code"
)
// embeddedInterfaceGenerator generates Base structs for interfaces to enable embedding.
type embeddedInterfaceGenerator struct {
cfg *config.Config
binder *config.Binder
schemaType *ast.Definition
model *ModelBuild
graph *interfaceGraph
}
func newEmbeddedInterfaceGenerator(
cfg *config.Config,
binder *config.Binder,
schemaType *ast.Definition,
model *ModelBuild,
) *embeddedInterfaceGenerator {
return &embeddedInterfaceGenerator{
cfg: cfg,
binder: binder,
schemaType: schemaType,
model: model,
graph: newInterfaceGraph(cfg.Schema),
}
}
// generateAllInterfaceBaseStructs returns Base struct specs ordered with parents before children.
func (g *embeddedInterfaceGenerator) generateAllInterfaceBaseStructs() ([]*baseStructSpec, error) {
// Filter to only embeddable interfaces (have directive) and not bound to external packages
var interfaceNames []string
for name := range g.graph.parentInterfaces {
// Only include interfaces with directive
if g.graph.isEmbeddable(name) {
// Skip interfaces bound to external packages - their Base structs already exist there
if !g.cfg.Models.UserDefined(name) {
interfaceNames = append(interfaceNames, name)
}
}
}
sorted, err := g.graph.topologicalSort(interfaceNames)
if err != nil {
return nil, fmt.Errorf("failed to sort interfaces: %w", err)
}
var specs []*baseStructSpec
for _, name := range sorted {
spec, err := g.generateBaseStructForInterface(g.cfg.Schema.Types[name])
if err != nil {
return nil, err
}
if spec != nil {
specs = append(specs, spec)
}
}
return specs, nil
}
// baseStructSpec defines Base struct structure for an interface
type baseStructSpec struct {
SchemaType *ast.Definition
ParentEmbeddings []types.Type
FieldsToGenerate []*ast.FieldDefinition
ImplementsInterfaces []string
}
func (g *embeddedInterfaceGenerator) generateBaseStructForInterface(
schemaType *ast.Definition,
) (*baseStructSpec, error) {
if schemaType.Kind != ast.Interface {
return nil, fmt.Errorf(
"generateBaseStructForInterface called on non-interface type: %s",
schemaType.Name,
)
}
spec := &baseStructSpec{
SchemaType: schemaType,
FieldsToGenerate: g.graph.getInterfaceOwnFields(schemaType.Name),
ImplementsInterfaces: []string{schemaType.Name},
}
// Get embeddable parents and fields from skipped intermediate parents
embedInfo := g.graph.getEmbeddingInfo(schemaType.Name)
if len(embedInfo.Parents) > 1 {
log.Printf(
"WARN: Base%s: implements %d interfaces %v (potential diamond problem)",
schemaType.Name,
len(embedInfo.Parents),
embedInfo.Parents,
)
}
for _, parent := range embedInfo.Parents {
spec.ParentEmbeddings = append(spec.ParentEmbeddings, g.createParentBaseType(parent))
spec.ImplementsInterfaces = append(spec.ImplementsInterfaces, parent)
}
// Add fields from intermediate parents without the directive
spec.FieldsToGenerate = append(spec.FieldsToGenerate, embedInfo.SkippedFields...)
return spec, nil
}
func (g *embeddedInterfaceGenerator) createParentBaseType(interfaceName string) types.Type {
baseName := templates.ToGo(fmt.Sprintf("%s%s", g.cfg.EmbeddedStructsPrefix, interfaceName))
// Check if interface is bound to external package
if g.cfg.Models.UserDefined(interfaceName) {
if models := g.cfg.Models[interfaceName]; len(models.Model) > 0 {
if extType, err := g.binder.FindTypeFromName(models.Model[0]); err == nil {
if named, ok := extType.(*types.Named); ok {
if pkg := named.Obj().Pkg(); pkg != nil {
if obj := pkg.Scope().Lookup(baseName); obj != nil {
if typeObj, ok := obj.(*types.TypeName); ok {
return typeObj.Type()
}
}
}
}
}
}
}
// Default: reference local package type
return types.NewNamed(
types.NewTypeName(0, g.cfg.Model.Pkg(), baseName, nil),
types.NewStruct(nil, nil),
nil,
)
}
// generateEmbeddedFields returns map: field name -> embedded Base struct (or nil for subsequent
// fields).
// Covariant overrides prevent embedding and require explicit field generation.
func (g *embeddedInterfaceGenerator) generateEmbeddedFields(
fields []*ast.FieldDefinition,
) map[string]*Field {
if g.model == nil || g.schemaType.Kind != ast.Object {
return nil
}
covariantInterfaces := g.findInterfacesWithCovariantOverrides(fields)
result := make(map[string]*Field)
processed := make(map[string]bool)
for _, field := range fields {
interfaceName := g.findInterfaceForField(field)
if interfaceName == "" || covariantInterfaces[interfaceName] {
continue
}
if processed[interfaceName] {
result[field.Name] = nil // subsequent field from same interface
} else {
result[field.Name] = &Field{Type: g.createEmbeddedBaseType(interfaceName)}
processed[interfaceName] = true
}
}
return result
}
func (g *embeddedInterfaceGenerator) findInterfacesWithCovariantOverrides(
fields []*ast.FieldDefinition,
) map[string]bool {
result := make(map[string]bool)
for _, implField := range fields {
for _, interfaceName := range g.schemaType.Interfaces {
if !g.graph.isEmbeddable(interfaceName) {
continue
}
iface := g.cfg.Schema.Types[interfaceName]
if iface == nil {
continue
}
for _, ifaceField := range iface.Fields {
if ifaceField.Name != implField.Name ||
typesMatch(ifaceField.Type, implField.Type) {
continue
}
if !result[interfaceName] {
log.Printf(
"WARN: %s.%s: covariant override %s -> %s (skipping Base%s embedding)",
g.schemaType.Name,
implField.Name,
ifaceField.Type.Name(),
implField.Type.Name(),
interfaceName,
)
}
result[interfaceName] = true
break
}
}
}
return result
}
// findInterfaceForField returns deepest interface containing this field with matching type.
func (g *embeddedInterfaceGenerator) findInterfaceForField(field *ast.FieldDefinition) string {
interfaces := g.schemaType.Interfaces
if len(interfaces) == 0 {
return ""
}
// Sort deepest-first (child interfaces before parent interfaces)
if len(interfaces) > 1 {
sorted := make([]string, len(interfaces))
copy(sorted, interfaces)
sort.Slice(sorted, func(i, j int) bool {
depthI := len(g.cfg.Schema.Types[sorted[i]].Interfaces)
depthJ := len(g.cfg.Schema.Types[sorted[j]].Interfaces)
return depthI > depthJ
})
interfaces = sorted
}
for _, ifaceName := range interfaces {
if iface := g.cfg.Schema.Types[ifaceName]; iface != nil &&
(iface.Kind == ast.Interface || iface.Kind == ast.Union) {
if !g.graph.isEmbeddable(ifaceName) {
continue
}
for _, ifaceField := range iface.Fields {
if ifaceField.Name == field.Name && typesMatch(ifaceField.Type, field.Type) {
return ifaceName
}
}
}
}
return ""
}
// typesMatch checks if two GraphQL types are identical (same base type, nullability, and list
// wrapping).
func typesMatch(a, b *ast.Type) bool {
if a.Name() != b.Name() || a.NonNull != b.NonNull {
return false
}
// Base type reached
if a.NamedType != "" && b.NamedType != "" {
return true
}
// Both must be lists or both must not be lists
if (a.Elem == nil) != (b.Elem == nil) {
return false
}
// Recursively check list element types
if a.Elem != nil {
return typesMatch(a.Elem, b.Elem)
}
return true
}
func (g *embeddedInterfaceGenerator) createEmbeddedBaseType(interfaceName string) types.Type {
baseName := templates.ToGo(fmt.Sprintf("%s%s", g.cfg.EmbeddedStructsPrefix, interfaceName))
// Check if interface is bound to external package
if g.cfg.Models.UserDefined(interfaceName) {
if pkgPath, _ := code.PkgAndType(g.cfg.Models[interfaceName].Model[0]); pkgPath != "" {
if boundType, _ := g.binder.FindTypeFromName(
pkgPath + "." + baseName,
); boundType != nil {
return boundType
}
}
}
// Default: reference local package type
return types.NewNamed(
types.NewTypeName(0, g.cfg.Model.Pkg(), baseName, nil),
types.NewStruct(nil, nil),
nil,
)
}
================================================
FILE: plugin/modelgen/models_interface_embedding_test.go
================================================
package modelgen
import (
"os"
"testing"
"github.com/stretchr/testify/require"
"github.com/99designs/gqlgen/codegen/config"
)
func TestModelGenerationNoDirective(t *testing.T) {
t.Run("generated code does not contains Base structs", func(t *testing.T) {
generated := setupTestGeneration(t,
"testdata/interface_embedding/gqlgen_no_directive_models.yml",
"./out_no_directive_models/",
"./out_no_directive_models/generated_no_directive_models.go",
)
require.NotContains(t, generated, "type Base")
})
t.Run("graph does not have embeddable interfaces", func(t *testing.T) {
cfg, err := config.LoadConfig("testdata/interface_embedding/gqlgen_no_directive_models.yml")
require.NoError(t, err)
require.NoError(t, cfg.Init())
embedder := newEmbeddedInterfaceGenerator(cfg, cfg.NewBinder(), nil, nil)
require.NotEmpty(t, embedder.graph.parentInterfaces, "graph should contain all interfaces")
for name := range embedder.graph.parentInterfaces {
require.False(
t,
embedder.graph.isEmbeddable(name),
"interface %s should not be embeddable",
name,
)
}
})
}
func TestModelGenerationDirectiveEmbedding(t *testing.T) {
testCases := []struct {
name string
configPath string
outputDir string
generatedFile string
expectedBases []string
unexpectedBases []string
structChecks []structCheck
additionalChecks func(*testing.T, string)
}{
{
name: "single package base type embedding",
configPath: "testdata/interface_embedding/gqlgen_directive_embedding_models.yml",
outputDir: "./out_directive_embedding_models/",
generatedFile: "./out_directive_embedding_models/generated_directive_embedding_models.go",
expectedBases: []string{"BaseNode", "BaseElement"},
structChecks: []structCheck{
{"BaseElement", []string{"BaseNode", "Name"}, nil},
{"BaseNode", []string{"ID"}, []string{"Name"}},
{"Carbon", []string{"BaseElement"}, nil},
{"Magnesium", []string{"BaseElement"}, nil},
{"Potassium", []string{"BaseElement"}, nil},
},
},
{
name: "binded package type embedding",
configPath: "testdata/interface_embedding/gqlgen_directive_binding_models.yml",
outputDir: "./out_directive_binding_models/",
generatedFile: "./out_directive_binding_models/generated_directive_binding_models.go",
unexpectedBases: []string{"BaseElement", "BaseNode"},
structChecks: []structCheck{
{"Oxygen", []string{"out_directive_embedding_models.BaseElement", "Purity"}, nil},
{"Molecule", []string{"out_directive_embedding_models.BaseNode"}, nil},
},
additionalChecks: func(t *testing.T, generated string) {
t.Helper()
require.Contains(
t,
generated,
"github.com/99designs/gqlgen/plugin/modelgen/out_directive_embedding_models",
)
},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
generated := setupTestGeneration(t, tc.configPath, tc.outputDir, tc.generatedFile)
assertBaseStructPresence(t, generated, tc.expectedBases, tc.unexpectedBases)
for _, check := range tc.structChecks {
assertStructFields(
t,
generated,
check.structName,
check.mustContain,
check.mustNotContain,
)
}
if tc.additionalChecks != nil {
tc.additionalChecks(t, generated)
}
cfg, err := config.LoadConfig(tc.configPath)
require.NoError(t, err)
require.NoError(t, cfg.Init())
embedder := newEmbeddedInterfaceGenerator(cfg, cfg.NewBinder(), nil, nil)
specs, err := embedder.generateAllInterfaceBaseStructs()
require.NoError(t, err)
require.Len(t, specs, len(tc.expectedBases))
})
}
}
type structCheck struct {
structName string
mustContain []string
mustNotContain []string
}
func TestModelGenerationDirectiveCovariantTypes(t *testing.T) {
generated := setupTestGeneration(t,
"testdata/interface_embedding/gqlgen_directive_covariant_types.yml",
"./out_covariant_types/",
"./out_covariant_types/generated_covariant_types.go",
)
t.Run("ProductNode uses ProductNodeData not embedded BaseNode", func(t *testing.T) {
assertStructFields(t, generated, "ProductNode",
[]string{"ID", "Type", "*ProductNodeData", "ProductTitle"},
[]string{"BaseNode"},
)
})
t.Run("ExtendedProductNode has covariant override for data", func(t *testing.T) {
assertStructFields(t, generated, "ExtendedProductNode",
[]string{"ID", "Type", "*ProductNodeData", "*ProductTags"},
[]string{"BaseNode"},
)
})
t.Run("ProductNodeData also handles covariant overrides", func(t *testing.T) {
assertStructFields(t, generated, "ProductNodeData",
[]string{"BaseNodeData", "ProductSpecificField"},
nil,
)
})
}
func TestModelGenerationSkippedParents(t *testing.T) {
testCases := []struct {
name string
configPath string
outputDir string
generatedFile string
expectedBases []string
unexpectedBases []string
structChecks []structCheck
}{
{
name: "skipped parents with A->B->C hierarchy",
configPath: "testdata/interface_embedding/gqlgen_directive_skipped_parents.yml",
outputDir: "./out_directive_skipped_parents/",
generatedFile: "./out_directive_skipped_parents/generated_directive_skipped_parents.go",
expectedBases: []string{"BaseA", "BaseC"},
unexpectedBases: []string{"BaseB"},
structChecks: []structCheck{
{"BaseC", []string{"BaseA", "FieldB"}, []string{"BaseB"}},
{"ConcreteC", []string{"BaseC"}, nil},
},
},
{
name: "partial directive with Node->Element->Metal hierarchy",
configPath: "testdata/interface_embedding/gqlgen_directive_partial.yml",
outputDir: "./out_directive_partial/",
generatedFile: "./out_directive_partial/generated_directive_partial.go",
expectedBases: []string{"BaseNode", "BaseMetal"},
unexpectedBases: []string{"BaseElement"},
structChecks: []structCheck{
{"BaseMetal", []string{"BaseNode", "Name"}, []string{"BaseElement"}},
{"Gold", []string{"BaseMetal"}, nil},
},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
generated := setupTestGeneration(t, tc.configPath, tc.outputDir, tc.generatedFile)
assertBaseStructPresence(t, generated, tc.expectedBases, tc.unexpectedBases)
for _, check := range tc.structChecks {
assertStructFields(
t,
generated,
check.structName,
check.mustContain,
check.mustNotContain,
)
}
})
}
}
func TestModelGenerationDirectiveDiamond(t *testing.T) {
generated := setupTestGeneration(t,
"testdata/interface_embedding/gqlgen_directive_diamond.yml",
"./out_directive_diamond/",
"./out_directive_diamond/generated_directive_diamond.go",
)
assertBaseStructPresence(t, generated,
[]string{"BaseHasID", "BaseHasIdentifier", "BaseConflicting", "BaseNoConflict"},
[]string{"BaseHasName", "BaseHasTitle"},
)
assertStructFields(t, generated, "BaseConflicting",
[]string{"BaseHasID", "BaseHasIdentifier"},
nil,
)
assertStructFields(t, generated, "BaseNoConflict",
[]string{"Name", "Title"},
nil,
)
}
func setupTestGeneration(t *testing.T, configPath, outputDir, generatedFile string) string {
t.Helper()
cfg, err := config.LoadConfig(configPath)
require.NoError(t, err)
require.NoError(t, cfg.Init())
p := Plugin{
FieldHook: DefaultFieldMutateHook,
}
require.NoError(t, p.MutateConfig(cfg))
require.NoError(t, goBuild(t, outputDir))
generated, err := os.ReadFile(generatedFile)
require.NoError(t, err)
return string(generated)
}
func assertBaseStructPresence(
t *testing.T,
generated string,
expectedBases, unexpectedBases []string,
) {
t.Helper()
for _, base := range expectedBases {
require.Contains(t, generated, "type "+base, "Expected Base struct %s to be present", base)
}
for _, base := range unexpectedBases {
require.NotContains(
t,
generated,
"type "+base,
"Expected Base struct %s to be absent",
base,
)
}
}
func assertStructFields(
t *testing.T,
generated, structName string,
mustContain, mustNotContain []string,
) {
t.Helper()
structStr := getStringInBetween(generated, "type "+structName+" struct {", "}")
require.NotEmpty(t, structStr, "Struct %s should exist", structName)
for _, field := range mustContain {
require.Contains(
t,
structStr,
field,
"Struct %s should contain field %s",
structName,
field,
)
}
for _, field := range mustNotContain {
require.NotContains(
t,
structStr,
field,
"Struct %s should not contain field %s",
structName,
field,
)
}
}
================================================
FILE: plugin/modelgen/models_test.go
================================================
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/99designs/gqlgen/codegen/config"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/plugin/modelgen/internal/extrafields"
"github.com/99designs/gqlgen/plugin/modelgen/out"
"github.com/99designs/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_false"
"github.com/99designs/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_false_omitzero_tag_false"
"github.com/99designs/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_false_omitzero_tag_nil"
"github.com/99designs/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_false_omitzero_tag_true"
"github.com/99designs/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_nil"
"github.com/99designs/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_true"
"github.com/99designs/gqlgen/plugin/modelgen/out_enable_model_json_omitzero_tag_false"
"github.com/99designs/gqlgen/plugin/modelgen/out_enable_model_json_omitzero_tag_nil"
"github.com/99designs/gqlgen/plugin/modelgen/out_enable_model_json_omitzero_tag_true"
"github.com/99designs/gqlgen/plugin/modelgen/out_nullable_input_omittable"
"github.com/99designs/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.Greaterf(
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.Contains(t, 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.Contains(t, 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 {
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, graphql.Omittable[*string]{}, out.MissingInput{}.NullString)
require.IsType(t, graphql.Omittable[*out.MissingEnum]{}, out.MissingInput{}.NullEnum)
require.IsType(t, graphql.Omittable[*out.ExistingInput]{}, out.MissingInput{}.NullObject)
})
t.Run("extra fields are present", func(t *testing.T) {
var m out.ExtraFieldsTest
require.IsType(t, int64(0), m.FieldInt)
require.IsType(t, extrafields.Type{}, m.FieldInternalType)
require.IsType(t, m.FieldStringPtr, new(string))
require.IsType(t, []int64{}, m.FieldIntSlice)
})
}
func TestModelGenerationConflictingTypes(t *testing.T) {
cfg, err := config.LoadConfig("testdata/gqlgen_conflicting_types.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_conflicting_types/"))
generated, err := os.ReadFile("./out_conflicting_types/generated.go")
require.NoError(t, err)
// Depending on the order of the fields in the schema, the generated code will be different
withoutUnderscore := "FooBar0"
withUnderscore := "FooBar"
if strings.Contains(string(generated), `type FooBar struct {
WithoutUnderscore *bool`) {
withoutUnderscore = "FooBar"
withUnderscore = "FooBar0"
}
require.Contains(t, string(generated), "WantWithoutUnderscore *"+withoutUnderscore+" ")
require.Contains(t, string(generated), "WantWithUnderscore *"+withUnderscore+" ")
}
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 TestModelGenerationOmitEnumJSONMarshalers(t *testing.T) {
cfg, err := config.LoadConfig("testdata/gqlgen_omit_json_marshalers.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_omit_json_enum_marshalers/"))
generated, err := os.ReadFile("./out_omit_json_enum_marshalers/generated.go")
require.NoError(t, err)
require.NotContains(t, string(generated), "MarshalJSON")
require.NotContains(t, string(generated), "UnmarshalJSON")
}
func TestModelGenerationOmitResolverFields(t *testing.T) {
cfg, err := config.LoadConfig("testdata/gqlgen_omit_resolver_fields.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_omit_resolver_fields/"))
generated, err := os.ReadFile("./out_omit_resolver_fields/generated.go")
require.NoError(t, err)
require.Contains(t, string(generated), "type Base struct")
require.Contains(t, string(generated), "StandardField")
require.NotContains(t, string(generated), "ResolverField")
// ForceGeneratedField should be present because forceGenerate: true overrides OmitResolverFields
require.Contains(t, string(generated), "ForceGeneratedField")
}
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,
graphql.Omittable[*string]{},
out_nullable_input_omittable.MissingInput{}.Name,
)
require.IsType(
t,
graphql.Omittable[*out_nullable_input_omittable.MissingEnum]{},
out_nullable_input_omittable.MissingInput{}.Enum,
)
require.IsType(
t,
graphql.Omittable[*string]{},
out_nullable_input_omittable.MissingInput{}.NullString,
)
require.IsType(
t,
graphql.Omittable[*out_nullable_input_omittable.MissingEnum]{},
out_nullable_input_omittable.MissingInput{}.NullEnum,
)
require.IsType(
t,
graphql.Omittable[*out_nullable_input_omittable.ExistingInput]{},
out_nullable_input_omittable.MissingInput{}.NullObject,
)
})
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 TestModelGenerationOmitzeroConfig(t *testing.T) {
suites := []struct {
n string
cfg string
expected string
t any
outPath string
}{
{
n: "omitempty nil and omomitzero nil",
cfg: "gqlgen_enable_model_json_omitzero_tag_nil.yml",
expected: "Value,omitempty",
t: out_enable_model_json_omitzero_tag_nil.OmitZeroJSONTagTest{},
outPath: "./out_enable_model_json_omitzero_tag_nil/",
},
{
n: "omitempty nil and omomitzero true",
cfg: "gqlgen_enable_model_json_omitzero_tag_true.yml",
expected: "Value,omitempty,omitzero",
t: out_enable_model_json_omitzero_tag_true.OmitZeroJSONTagTest{},
outPath: "./out_enable_model_json_omitzero_tag_true/",
},
{
n: "omitempty nil and omomitzero false",
cfg: "gqlgen_enable_model_json_omitzero_tag_false.yml",
expected: "Value,omitempty",
t: out_enable_model_json_omitzero_tag_false.OmitZeroJSONTagTest{},
outPath: "./out_enable_model_json_omitzero_tag_false/",
},
{
n: "omitempty false and omomitzero nil",
cfg: "gqlgen_enable_model_json_omitempty_tag_false_omitzero_tag_nil.yml",
expected: "Value",
t: out_enable_model_json_omitempty_tag_false_omitzero_tag_nil.OmitZeroJSONTagTest{},
outPath: "./out_enable_model_json_omitempty_tag_false_omitzero_tag_nil/",
},
{
n: "omitempty false and omomitzero true",
cfg: "gqlgen_enable_model_json_omitempty_tag_false_omitzero_tag_true.yml",
expected: "Value,omitzero",
t: out_enable_model_json_omitempty_tag_false_omitzero_tag_true.OmitZeroJSONTagTest{},
outPath: "./out_enable_model_json_omitempty_tag_false_omitzero_tag_true/",
},
{
n: "omitempty false and omomitzero false",
cfg: "gqlgen_enable_model_json_omitempty_tag_false_omitzero_tag_false.yml",
expected: "Value",
t: out_enable_model_json_omitempty_tag_false_omitzero_tag_false.OmitZeroJSONTagTest{},
outPath: "./out_enable_model_json_omitempty_tag_false_omitzero_tag_false/",
},
}
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))
require.NoError(t, goBuild(t, s.outPath))
rt := reflect.TypeOf(s.t)
// ensure non-nullable fields are never omitzero
sfn, ok := rt.FieldByName("ValueNonNil")
require.True(t, ok)
require.Equal(t, "ValueNonNil", sfn.Tag.Get("json"))
// test nullable fields for configured omitzero
sf, ok := rt.FieldByName("Value")
require.True(t, ok)
require.Equal(t, s.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()
// help wanted to golang.org/x/tools/go/packages
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))
}
func getStringInBetween(str, start, end string) string {
_, after, ok := strings.Cut(str, start)
if !ok {
return ""
}
newStr := after
before, _, ok := strings.Cut(newStr, end)
if !ok {
return ""
}
return before
}
================================================
FILE: plugin/modelgen/out/existing.go
================================================
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()
}
================================================
FILE: plugin/modelgen/out/generated.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out
import (
"fmt"
"io"
"strconv"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/plugin/modelgen/internal/extrafields"
)
// Add any new functions or any additional code/template functionality here
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 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 OmitZeroJSONTagTest struct {
ValueNonNil string `json:"ValueNonNil" database:"OmitZeroJSONTagTestValueNonNil"`
Value *string `json:"Value,omitempty" database:"OmitZeroJSONTagTestValue"`
}
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 {
GOODnaME 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 any) 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 any) 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()))
}
================================================
FILE: plugin/modelgen/out/generated_omit_root_models.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out
import (
"bytes"
"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 any) 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()))
}
func (e *SomeContent) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e SomeContent) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
================================================
FILE: plugin/modelgen/out_conflicting_types/generated.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_conflicting_types
type Baz struct {
WantWithoutUnderscore *FooBar `json:"want_without_underscore" database:"Bazwant_without_underscore"`
}
type Bees struct {
WantWithUnderscore *FooBar0 `json:"want_with_underscore" database:"Beeswant_with_underscore"`
}
type FooBar struct {
WithoutUnderscore *bool `json:"without_underscore,omitempty" database:"FooBarwithout_underscore"`
}
type FooBar0 struct {
WithUnderscore *bool `json:"with_underscore,omitempty" database:"Foo_Barwith_underscore"`
}
type Query struct {
}
================================================
FILE: plugin/modelgen/out_covariant_types/generated_covariant_types.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_covariant_types
type Identifiable interface {
IsIdentifiable()
GetID() string
}
type Node interface {
IsIdentifiable()
IsTypeable()
IsNode()
GetID() string
GetType() string
GetData() NodeData
}
type NodeData interface {
IsNodeData()
GetName() string
GetChildrenIds() []string
}
type Tags interface {
IsTags()
GetData() []string
}
type Typeable interface {
IsTypeable()
GetType() string
}
type BaseIdentifiable struct {
ID string `json:"id"`
}
func (BaseIdentifiable) IsIdentifiable() {}
func (this BaseIdentifiable) GetID() string { return this.ID }
type BaseNode struct {
BaseIdentifiable
BaseTypeable
Data NodeData `json:"data"`
}
func (BaseNode) IsNode() {}
func (this BaseNode) GetID() string { return this.ID }
func (this BaseNode) GetType() string { return this.Type }
func (this BaseNode) GetData() NodeData { return this.Data }
func (BaseNode) IsIdentifiable() {}
func (BaseNode) IsTypeable() {}
type BaseNodeData struct {
Name string `json:"name"`
ChildrenIds []string `json:"childrenIds"`
}
func (BaseNodeData) IsNodeData() {}
func (this BaseNodeData) GetName() string { return this.Name }
func (this BaseNodeData) GetChildrenIds() []string {
if this.ChildrenIds == nil {
return nil
}
interfaceSlice := make([]string, 0, len(this.ChildrenIds))
for _, concrete := range this.ChildrenIds {
interfaceSlice = append(interfaceSlice, concrete)
}
return interfaceSlice
}
type BaseTags struct {
Data []string `json:"data,omitempty"`
}
func (BaseTags) IsTags() {}
func (this BaseTags) GetData() []string {
if this.Data == nil {
return nil
}
interfaceSlice := make([]string, 0, len(this.Data))
for _, concrete := range this.Data {
interfaceSlice = append(interfaceSlice, concrete)
}
return interfaceSlice
}
type BaseTypeable struct {
Type string `json:"type"`
}
func (BaseTypeable) IsTypeable() {}
func (this BaseTypeable) GetType() string { return this.Type }
type ExtendedProductNode struct {
ID string `json:"id"`
Type string `json:"type"`
Data *ProductNodeData `json:"data"`
Tags *ProductTags `json:"tags,omitempty"`
}
func (ExtendedProductNode) IsNode() {}
func (this ExtendedProductNode) GetID() string { return this.ID }
func (this ExtendedProductNode) GetType() string { return this.Type }
func (this ExtendedProductNode) GetData() NodeData { return *this.Data }
func (ExtendedProductNode) IsIdentifiable() {}
func (ExtendedProductNode) IsTypeable() {}
type ProductNode struct {
ID string `json:"id"`
Type string `json:"type"`
Data *ProductNodeData `json:"data"`
ProductTitle string `json:"productTitle"`
}
func (ProductNode) IsNode() {}
func (this ProductNode) GetID() string { return this.ID }
func (this ProductNode) GetType() string { return this.Type }
func (this ProductNode) GetData() NodeData { return *this.Data }
func (ProductNode) IsIdentifiable() {}
func (ProductNode) IsTypeable() {}
type ProductNodeData struct {
BaseNodeData
ProductSpecificField string `json:"productSpecificField"`
}
func (ProductNodeData) IsNodeData() {}
func (this ProductNodeData) GetName() string { return this.Name }
func (this ProductNodeData) GetChildrenIds() []string {
if this.ChildrenIds == nil {
return nil
}
interfaceSlice := make([]string, 0, len(this.ChildrenIds))
for _, concrete := range this.ChildrenIds {
interfaceSlice = append(interfaceSlice, concrete)
}
return interfaceSlice
}
type ProductTags struct {
BaseTags
ProductSpecific *bool `json:"productSpecific,omitempty"`
}
func (ProductTags) IsTags() {}
func (this ProductTags) GetData() []string {
if this.Data == nil {
return nil
}
interfaceSlice := make([]string, 0, len(this.Data))
for _, concrete := range this.Data {
interfaceSlice = append(interfaceSlice, concrete)
}
return interfaceSlice
}
type Query struct {
}
================================================
FILE: plugin/modelgen/out_directive_binding_models/generated_directive_binding_models.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_directive_binding_models
import (
"github.com/99designs/gqlgen/plugin/modelgen/out_directive_embedding_models"
)
type Molecule struct {
out_directive_embedding_models.BaseNode
Elements []out_directive_embedding_models.Element `json:"elements,omitempty"`
}
func (Molecule) IsNode() {}
type Oxygen struct {
out_directive_embedding_models.BaseElement
Purity float64 `json:"purity"`
}
func (Oxygen) IsElement() {}
func (Oxygen) IsNode() {}
================================================
FILE: plugin/modelgen/out_directive_diamond/generated_directive_diamond.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_directive_diamond
type Conflicting interface {
IsHasID()
IsHasIdentifier()
IsConflicting()
GetID() string
GetIdentifier() string
GetName() string
}
type HasID interface {
IsHasID()
GetID() string
}
type HasIdentifier interface {
IsHasIdentifier()
GetIdentifier() string
}
type HasName interface {
IsHasName()
GetName() string
}
type HasTitle interface {
IsHasTitle()
GetTitle() string
}
type NoConflict interface {
IsHasName()
IsHasTitle()
IsNoConflict()
GetName() string
GetTitle() string
}
type BaseConflicting struct {
BaseHasID
BaseHasIdentifier
Name string `json:"name"`
}
func (BaseConflicting) IsConflicting() {}
func (this BaseConflicting) GetID() string { return this.ID }
func (this BaseConflicting) GetIdentifier() string { return this.Identifier }
func (this BaseConflicting) GetName() string { return this.Name }
func (BaseConflicting) IsHasID() {}
func (BaseConflicting) IsHasIdentifier() {}
type BaseHasID struct {
ID string `json:"id"`
}
func (BaseHasID) IsHasID() {}
func (this BaseHasID) GetID() string { return this.ID }
type BaseHasIdentifier struct {
Identifier string `json:"identifier"`
}
func (BaseHasIdentifier) IsHasIdentifier() {}
func (this BaseHasIdentifier) GetIdentifier() string { return this.Identifier }
type BaseNoConflict struct {
Name string `json:"name"`
Title string `json:"title"`
}
func (BaseNoConflict) IsNoConflict() {}
func (this BaseNoConflict) GetName() string { return this.Name }
func (this BaseNoConflict) GetTitle() string { return this.Title }
type ConcreteConflicting struct {
BaseConflicting
Extra string `json:"extra"`
}
func (ConcreteConflicting) IsConflicting() {}
func (this ConcreteConflicting) GetID() string { return this.ID }
func (this ConcreteConflicting) GetIdentifier() string { return this.Identifier }
func (this ConcreteConflicting) GetName() string { return this.Name }
func (ConcreteConflicting) IsHasID() {}
func (ConcreteConflicting) IsHasIdentifier() {}
type ConcreteNoConflict struct {
BaseNoConflict
Extra string `json:"extra"`
}
func (ConcreteNoConflict) IsNoConflict() {}
func (this ConcreteNoConflict) GetName() string { return this.Name }
func (this ConcreteNoConflict) GetTitle() string { return this.Title }
func (ConcreteNoConflict) IsHasName() {}
func (ConcreteNoConflict) IsHasTitle() {}
type Query struct {
}
================================================
FILE: plugin/modelgen/out_directive_embedding_models/generated_directive_embedding_models.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_directive_embedding_models
type Element interface {
IsNode()
IsElement()
GetID() string
GetName() string
}
type Node interface {
IsNode()
GetID() string
}
type BaseElement struct {
BaseNode
Name string `json:"name"`
}
func (BaseElement) IsElement() {}
func (this BaseElement) GetID() string { return this.ID }
func (this BaseElement) GetName() string { return this.Name }
func (BaseElement) IsNode() {}
type BaseNode struct {
ID string `json:"id"`
}
func (BaseNode) IsNode() {}
func (this BaseNode) GetID() string { return this.ID }
type Carbon struct {
BaseElement
Footprint string `json:"footprint"`
}
func (Carbon) IsElement() {}
func (this Carbon) GetID() string { return this.ID }
func (this Carbon) GetName() string { return this.Name }
func (Carbon) IsNode() {}
type Magnesium struct {
BaseElement
Types int `json:"types"`
}
func (Magnesium) IsElement() {}
func (this Magnesium) GetID() string { return this.ID }
func (this Magnesium) GetName() string { return this.Name }
func (Magnesium) IsNode() {}
type Potassium struct {
BaseElement
Price float64 `json:"price"`
}
func (Potassium) IsElement() {}
func (this Potassium) GetID() string { return this.ID }
func (this Potassium) GetName() string { return this.Name }
func (Potassium) IsNode() {}
type Query struct {
}
================================================
FILE: plugin/modelgen/out_directive_partial/generated_directive_partial.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_directive_partial
type Element interface {
IsNode()
IsElement()
GetID() string
GetName() string
}
type Metal interface {
IsElement()
IsNode()
IsMetal()
GetID() string
GetName() string
GetAtomicNumber() int
}
type Node interface {
IsNode()
GetID() string
}
type BaseMetal struct {
BaseNode
AtomicNumber int `json:"atomicNumber"`
Name string `json:"name"`
}
func (BaseMetal) IsMetal() {}
func (this BaseMetal) GetID() string { return this.ID }
func (this BaseMetal) GetName() string { return this.Name }
func (this BaseMetal) GetAtomicNumber() int { return this.AtomicNumber }
func (BaseMetal) IsNode() {}
type BaseNode struct {
ID string `json:"id"`
}
func (BaseNode) IsNode() {}
func (this BaseNode) GetID() string { return this.ID }
type Gold struct {
BaseMetal
Karat int `json:"karat"`
}
func (Gold) IsMetal() {}
func (this Gold) GetID() string { return this.ID }
func (this Gold) GetName() string { return this.Name }
func (this Gold) GetAtomicNumber() int { return this.AtomicNumber }
func (Gold) IsElement() {}
func (Gold) IsNode() {}
type Query struct {
}
type Silver struct {
BaseMetal
Purity float64 `json:"purity"`
}
func (Silver) IsMetal() {}
func (this Silver) GetID() string { return this.ID }
func (this Silver) GetName() string { return this.Name }
func (this Silver) GetAtomicNumber() int { return this.AtomicNumber }
func (Silver) IsElement() {}
func (Silver) IsNode() {}
================================================
FILE: plugin/modelgen/out_directive_skipped_parents/generated_directive_skipped_parents.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_directive_skipped_parents
type A interface {
IsA()
GetID() string
GetFieldA() string
}
type B interface {
IsA()
IsB()
GetID() string
GetFieldA() string
GetFieldB() string
}
type C interface {
IsB()
IsA()
IsC()
GetID() string
GetFieldA() string
GetFieldB() string
GetFieldC() string
}
type BaseA struct {
ID string `json:"id"`
FieldA string `json:"fieldA"`
}
func (BaseA) IsA() {}
func (this BaseA) GetID() string { return this.ID }
func (this BaseA) GetFieldA() string { return this.FieldA }
type BaseC struct {
BaseA
FieldC string `json:"fieldC"`
FieldB string `json:"fieldB"`
}
func (BaseC) IsC() {}
func (this BaseC) GetID() string { return this.ID }
func (this BaseC) GetFieldA() string { return this.FieldA }
func (this BaseC) GetFieldB() string { return this.FieldB }
func (this BaseC) GetFieldC() string { return this.FieldC }
func (BaseC) IsA() {}
type ConcreteC struct {
BaseC
ConcreteField string `json:"concreteField"`
}
func (ConcreteC) IsC() {}
func (this ConcreteC) GetID() string { return this.ID }
func (this ConcreteC) GetFieldA() string { return this.FieldA }
func (this ConcreteC) GetFieldB() string { return this.FieldB }
func (this ConcreteC) GetFieldC() string { return this.FieldC }
func (ConcreteC) IsB() {}
func (ConcreteC) IsA() {}
type Query struct {
}
================================================
FILE: plugin/modelgen/out_embedded_struct_models_with_binding/generated_embedded_structs_models_binding.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_embedded_struct_models_with_binding
import (
"github.com/99designs/gqlgen/plugin/modelgen/out_embedded_structs_models"
)
type Molecule struct {
out_embedded_structs_models.BaseNode
Elements []out_embedded_structs_models.Element `json:"elements,omitempty"`
}
func (Molecule) IsNode() {}
type Oxygen struct {
out_embedded_structs_models.BaseElement
Purity float64 `json:"purity"`
}
func (Oxygen) IsElement() {}
func (Oxygen) IsNode() {}
================================================
FILE: plugin/modelgen/out_embedded_structs_models/generated_embedded_structs_models.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_embedded_structs_models
type Element interface {
IsNode()
IsElement()
GetID() string
GetName() string
}
type Node interface {
IsNode()
GetID() string
}
type BaseElement struct {
BaseNode
Name string `json:"name"`
}
func (BaseElement) IsElement() {}
func (this BaseElement) GetID() string { return this.ID }
func (this BaseElement) GetName() string { return this.Name }
func (BaseElement) IsNode() {}
type BaseNode struct {
ID string `json:"id"`
}
func (BaseNode) IsNode() {}
func (this BaseNode) GetID() string { return this.ID }
type Carbon struct {
BaseElement
Footprint string `json:"footprint"`
}
func (Carbon) IsElement() {}
func (this Carbon) GetID() string { return this.ID }
func (this Carbon) GetName() string { return this.Name }
func (Carbon) IsNode() {}
type Magnesium struct {
BaseElement
Types int `json:"types"`
}
func (Magnesium) IsElement() {}
func (this Magnesium) GetID() string { return this.ID }
func (this Magnesium) GetName() string { return this.Name }
func (Magnesium) IsNode() {}
type Potassium struct {
BaseElement
Price float64 `json:"price"`
}
func (Potassium) IsElement() {}
func (this Potassium) GetID() string { return this.ID }
func (this Potassium) GetName() string { return this.Name }
func (Potassium) IsNode() {}
type Query struct {
}
================================================
FILE: plugin/modelgen/out_enable_model_json_omitempty_tag_false/existing.go
================================================
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()
}
================================================
FILE: plugin/modelgen/out_enable_model_json_omitempty_tag_false/generated.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_enable_model_json_omitempty_tag_false
import (
"bytes"
"fmt"
"io"
"strconv"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/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 OmitZeroJSONTagTest struct {
ValueNonNil string `json:"ValueNonNil" database:"OmitZeroJSONTagTestValueNonNil"`
Value *string `json:"Value" database:"OmitZeroJSONTagTestValue"`
}
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 any) 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()))
}
func (e *EnumWithDescription) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e EnumWithDescription) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
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 any) 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()))
}
func (e *MissingEnum) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e MissingEnum) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
================================================
FILE: plugin/modelgen/out_enable_model_json_omitempty_tag_false_omitempty_tag_false_omitzero_tag_nil/generated.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_enable_model_json_omitempty_tag_false_omitempty_tag_false_omitzero_tag_nil
import (
"fmt"
"io"
"strconv"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/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 OmitZeroJSONTagTest struct {
ValueNonNil string `json:"ValueNonNil" database:"OmitZeroJSONTagTestValueNonNil"`
Value *string `json:"Value" database:"OmitZeroJSONTagTestValue"`
}
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 any) 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 any) 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()))
}
================================================
FILE: plugin/modelgen/out_enable_model_json_omitempty_tag_false_omitempty_tag_false_omitzero_tag_true/generated.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_enable_model_json_omitempty_tag_false_omitempty_tag_false_omitzero_tag_true
import (
"fmt"
"io"
"strconv"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/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,omitzero" 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,omitzero" database:"CyclicalAfield_one"`
FieldTwo *CyclicalB `json:"field_two,omitzero" database:"CyclicalAfield_two"`
FieldThree *CyclicalB `json:"field_three,omitzero" database:"CyclicalAfield_three"`
FieldFour string `json:"field_four" database:"CyclicalAfield_four"`
}
type CyclicalB struct {
FieldOne *CyclicalA `json:"field_one,omitzero" database:"CyclicalBfield_one"`
FieldTwo *CyclicalA `json:"field_two,omitzero" database:"CyclicalBfield_two"`
FieldThree *CyclicalA `json:"field_three,omitzero" database:"CyclicalBfield_three"`
FieldFour *CyclicalA `json:"field_four,omitzero" 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,omitzero" anotherTag:"tag" database:"FieldMutationHookname"`
Enum *out.ExistingEnum `json:"enum,omitzero" yetAnotherTag:"12" database:"FieldMutationHookenum"`
NoVal *string `json:"noVal,omitzero" yaml:"noVal" repeated:"true" database:"FieldMutationHooknoVal"`
Repeated *string `json:"repeated,omitzero" someTag:"value" repeated:"true" database:"FieldMutationHookrepeated"`
}
type ImplArrayOfA struct {
TrickyField []*CDImplemented `json:"trickyField" database:"ImplArrayOfAtrickyField"`
TrickyFieldPointer []*CDImplemented `json:"trickyFieldPointer,omitzero" 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,omitzero" database:"MissingInputname"`
Enum *MissingEnum `json:"enum,omitzero" database:"MissingInputenum"`
NonNullString string `json:"nonNullString" database:"MissingInputnonNullString"`
NullString graphql.Omittable[*string] `json:"nullString,omitzero" database:"MissingInputnullString"`
NullEnum graphql.Omittable[*MissingEnum] `json:"nullEnum,omitzero" database:"MissingInputnullEnum"`
NullObject graphql.Omittable[*out.ExistingInput] `json:"nullObject,omitzero" 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,omitzero" database:"MissingTypeNullablename"`
Enum *MissingEnum `json:"enum,omitzero" database:"MissingTypeNullableenum"`
Int MissingInterface `json:"int,omitzero" database:"MissingTypeNullableint"`
Existing *out.ExistingType `json:"existing,omitzero" database:"MissingTypeNullableexisting"`
Missing2 *MissingTypeNotNull `json:"missing2,omitzero" 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,omitzero" database:"OmitEmptyJsonTagTestValue"`
}
type OmitZeroJSONTagTest struct {
ValueNonNil string `json:"ValueNonNil" database:"OmitZeroJSONTagTestValueNonNil"`
Value *string `json:"Value,omitzero" database:"OmitZeroJSONTagTestValue"`
}
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,omitzero" 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 any) 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 any) 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()))
}
================================================
FILE: plugin/modelgen/out_enable_model_json_omitempty_tag_false_omitzero_tag_false/existing.go
================================================
package out_enable_model_json_omitempty_tag_false_omitzero_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()
}
================================================
FILE: plugin/modelgen/out_enable_model_json_omitempty_tag_false_omitzero_tag_false/generated.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_enable_model_json_omitempty_tag_false_omitzero_tag_false
import (
"bytes"
"fmt"
"io"
"strconv"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/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 OmitZeroJSONTagTest struct {
ValueNonNil string `json:"ValueNonNil" database:"OmitZeroJSONTagTestValueNonNil"`
Value *string `json:"Value" database:"OmitZeroJSONTagTestValue"`
}
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 any) 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()))
}
func (e *EnumWithDescription) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e EnumWithDescription) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
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 any) 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()))
}
func (e *MissingEnum) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e MissingEnum) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
================================================
FILE: plugin/modelgen/out_enable_model_json_omitempty_tag_false_omitzero_tag_nil/existing.go
================================================
package out_enable_model_json_omitempty_tag_false_omitzero_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()
}
================================================
FILE: plugin/modelgen/out_enable_model_json_omitempty_tag_false_omitzero_tag_nil/generated.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_enable_model_json_omitempty_tag_false_omitzero_tag_nil
import (
"bytes"
"fmt"
"io"
"strconv"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/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 OmitZeroJSONTagTest struct {
ValueNonNil string `json:"ValueNonNil" database:"OmitZeroJSONTagTestValueNonNil"`
Value *string `json:"Value" database:"OmitZeroJSONTagTestValue"`
}
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 any) 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()))
}
func (e *EnumWithDescription) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e EnumWithDescription) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
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 any) 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()))
}
func (e *MissingEnum) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e MissingEnum) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
================================================
FILE: plugin/modelgen/out_enable_model_json_omitempty_tag_false_omitzero_tag_true/existing.go
================================================
package out_enable_model_json_omitempty_tag_false_omitzero_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()
}
================================================
FILE: plugin/modelgen/out_enable_model_json_omitempty_tag_false_omitzero_tag_true/generated.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_enable_model_json_omitempty_tag_false_omitzero_tag_true
import (
"bytes"
"fmt"
"io"
"strconv"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/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,omitzero" 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,omitzero" database:"CyclicalAfield_one"`
FieldTwo *CyclicalB `json:"field_two,omitzero" database:"CyclicalAfield_two"`
FieldThree *CyclicalB `json:"field_three,omitzero" database:"CyclicalAfield_three"`
FieldFour string `json:"field_four" database:"CyclicalAfield_four"`
}
type CyclicalB struct {
FieldOne *CyclicalA `json:"field_one,omitzero" database:"CyclicalBfield_one"`
FieldTwo *CyclicalA `json:"field_two,omitzero" database:"CyclicalBfield_two"`
FieldThree *CyclicalA `json:"field_three,omitzero" database:"CyclicalBfield_three"`
FieldFour *CyclicalA `json:"field_four,omitzero" 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,omitzero" anotherTag:"tag" database:"FieldMutationHookname"`
Enum *out.ExistingEnum `json:"enum,omitzero" yetAnotherTag:"12" database:"FieldMutationHookenum"`
NoVal *string `json:"noVal,omitzero" yaml:"noVal" repeated:"true" database:"FieldMutationHooknoVal"`
Repeated *string `json:"repeated,omitzero" someTag:"value" repeated:"true" database:"FieldMutationHookrepeated"`
}
type ImplArrayOfA struct {
TrickyField []*CDImplemented `json:"trickyField" database:"ImplArrayOfAtrickyField"`
TrickyFieldPointer []*CDImplemented `json:"trickyFieldPointer,omitzero" 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,omitzero" database:"MissingInputname"`
Enum *MissingEnum `json:"enum,omitzero" database:"MissingInputenum"`
NonNullString string `json:"nonNullString" database:"MissingInputnonNullString"`
NullString graphql.Omittable[*string] `json:"nullString,omitzero" database:"MissingInputnullString"`
NullEnum graphql.Omittable[*MissingEnum] `json:"nullEnum,omitzero" database:"MissingInputnullEnum"`
NullObject graphql.Omittable[*out.ExistingInput] `json:"nullObject,omitzero" 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,omitzero" database:"MissingTypeNullablename"`
Enum *MissingEnum `json:"enum,omitzero" database:"MissingTypeNullableenum"`
Int MissingInterface `json:"int,omitzero" database:"MissingTypeNullableint"`
Existing *out.ExistingType `json:"existing,omitzero" database:"MissingTypeNullableexisting"`
Missing2 *MissingTypeNotNull `json:"missing2,omitzero" 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,omitzero" database:"OmitEmptyJsonTagTestValue"`
}
type OmitZeroJSONTagTest struct {
ValueNonNil string `json:"ValueNonNil" database:"OmitZeroJSONTagTestValueNonNil"`
Value *string `json:"Value,omitzero" database:"OmitZeroJSONTagTestValue"`
}
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,omitzero" 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 any) 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()))
}
func (e *EnumWithDescription) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e EnumWithDescription) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
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 any) 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()))
}
func (e *MissingEnum) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e MissingEnum) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
================================================
FILE: plugin/modelgen/out_enable_model_json_omitempty_tag_nil/existing.go
================================================
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()
}
================================================
FILE: plugin/modelgen/out_enable_model_json_omitempty_tag_nil/generated.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_enable_model_json_omitempty_tag_nil
import (
"bytes"
"fmt"
"io"
"strconv"
"github.com/99designs/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 OmitZeroJSONTagTest struct {
ValueNonNil string `json:"ValueNonNil" database:"OmitZeroJSONTagTestValueNonNil"`
Value *string `json:"Value,omitempty" database:"OmitZeroJSONTagTestValue"`
}
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 any) 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()))
}
func (e *EnumWithDescription) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e EnumWithDescription) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
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 any) 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()))
}
func (e *MissingEnum) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e MissingEnum) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
================================================
FILE: plugin/modelgen/out_enable_model_json_omitempty_tag_true/existing.go
================================================
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()
}
================================================
FILE: plugin/modelgen/out_enable_model_json_omitempty_tag_true/generated.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_enable_model_json_omitempty_tag_true
import (
"bytes"
"fmt"
"io"
"strconv"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/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 OmitZeroJSONTagTest struct {
ValueNonNil string `json:"ValueNonNil" database:"OmitZeroJSONTagTestValueNonNil"`
Value *string `json:"Value,omitempty" database:"OmitZeroJSONTagTestValue"`
}
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 any) 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()))
}
func (e *EnumWithDescription) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e EnumWithDescription) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
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 any) 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()))
}
func (e *MissingEnum) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e MissingEnum) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
================================================
FILE: plugin/modelgen/out_enable_model_json_omitzero_tag_false/existing.go
================================================
package out_enable_model_json_omitzero_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()
}
================================================
FILE: plugin/modelgen/out_enable_model_json_omitzero_tag_false/generated.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_enable_model_json_omitzero_tag_false
import (
"bytes"
"fmt"
"io"
"strconv"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/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 OmitZeroJSONTagTest struct {
ValueNonNil string `json:"ValueNonNil" database:"OmitZeroJSONTagTestValueNonNil"`
Value *string `json:"Value,omitempty" database:"OmitZeroJSONTagTestValue"`
}
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 any) 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()))
}
func (e *EnumWithDescription) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e EnumWithDescription) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
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 any) 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()))
}
func (e *MissingEnum) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e MissingEnum) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
================================================
FILE: plugin/modelgen/out_enable_model_json_omitzero_tag_nil/existing.go
================================================
package out_enable_model_json_omitzero_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()
}
================================================
FILE: plugin/modelgen/out_enable_model_json_omitzero_tag_nil/generated.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_enable_model_json_omitzero_tag_nil
import (
"bytes"
"fmt"
"io"
"strconv"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/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 OmitZeroJSONTagTest struct {
ValueNonNil string `json:"ValueNonNil" database:"OmitZeroJSONTagTestValueNonNil"`
Value *string `json:"Value,omitempty" database:"OmitZeroJSONTagTestValue"`
}
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 any) 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()))
}
func (e *EnumWithDescription) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e EnumWithDescription) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
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 any) 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()))
}
func (e *MissingEnum) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e MissingEnum) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
================================================
FILE: plugin/modelgen/out_enable_model_json_omitzero_tag_true/existing.go
================================================
package out_enable_model_json_omitzero_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()
}
================================================
FILE: plugin/modelgen/out_enable_model_json_omitzero_tag_true/generated.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_enable_model_json_omitzero_tag_true
import (
"bytes"
"fmt"
"io"
"strconv"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/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,omitzero" 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,omitzero" database:"CyclicalAfield_one"`
FieldTwo *CyclicalB `json:"field_two,omitempty,omitzero" database:"CyclicalAfield_two"`
FieldThree *CyclicalB `json:"field_three,omitempty,omitzero" database:"CyclicalAfield_three"`
FieldFour string `json:"field_four" database:"CyclicalAfield_four"`
}
type CyclicalB struct {
FieldOne *CyclicalA `json:"field_one,omitempty,omitzero" database:"CyclicalBfield_one"`
FieldTwo *CyclicalA `json:"field_two,omitempty,omitzero" database:"CyclicalBfield_two"`
FieldThree *CyclicalA `json:"field_three,omitempty,omitzero" database:"CyclicalBfield_three"`
FieldFour *CyclicalA `json:"field_four,omitempty,omitzero" 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,omitzero" anotherTag:"tag" database:"FieldMutationHookname"`
Enum *out.ExistingEnum `json:"enum,omitempty,omitzero" yetAnotherTag:"12" database:"FieldMutationHookenum"`
NoVal *string `json:"noVal,omitempty,omitzero" yaml:"noVal" repeated:"true" database:"FieldMutationHooknoVal"`
Repeated *string `json:"repeated,omitempty,omitzero" someTag:"value" repeated:"true" database:"FieldMutationHookrepeated"`
}
type ImplArrayOfA struct {
TrickyField []*CDImplemented `json:"trickyField" database:"ImplArrayOfAtrickyField"`
TrickyFieldPointer []*CDImplemented `json:"trickyFieldPointer,omitempty,omitzero" 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,omitzero" database:"MissingInputname"`
Enum *MissingEnum `json:"enum,omitempty,omitzero" database:"MissingInputenum"`
NonNullString string `json:"nonNullString" database:"MissingInputnonNullString"`
NullString graphql.Omittable[*string] `json:"nullString,omitempty,omitzero" database:"MissingInputnullString"`
NullEnum graphql.Omittable[*MissingEnum] `json:"nullEnum,omitempty,omitzero" database:"MissingInputnullEnum"`
NullObject graphql.Omittable[*out.ExistingInput] `json:"nullObject,omitempty,omitzero" 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,omitzero" database:"MissingTypeNullablename"`
Enum *MissingEnum `json:"enum,omitempty,omitzero" database:"MissingTypeNullableenum"`
Int MissingInterface `json:"int,omitempty,omitzero" database:"MissingTypeNullableint"`
Existing *out.ExistingType `json:"existing,omitempty,omitzero" database:"MissingTypeNullableexisting"`
Missing2 *MissingTypeNotNull `json:"missing2,omitempty,omitzero" 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,omitzero" database:"OmitEmptyJsonTagTestValue"`
}
type OmitZeroJSONTagTest struct {
ValueNonNil string `json:"ValueNonNil" database:"OmitZeroJSONTagTestValueNonNil"`
Value *string `json:"Value,omitempty,omitzero" database:"OmitZeroJSONTagTestValue"`
}
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,omitzero" 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 any) 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()))
}
func (e *EnumWithDescription) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e EnumWithDescription) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
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 any) 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()))
}
func (e *MissingEnum) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e MissingEnum) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
================================================
FILE: plugin/modelgen/out_no_directive_models/generated_no_directive_models.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_no_directive_models
type Element interface {
IsNode()
IsElement()
GetID() string
GetName() string
}
type Node interface {
IsNode()
GetID() string
}
type Carbon struct {
ID string `json:"id"`
Name string `json:"name"`
Footprint string `json:"footprint"`
}
func (Carbon) IsElement() {}
func (this Carbon) GetID() string { return this.ID }
func (this Carbon) GetName() string { return this.Name }
func (Carbon) IsNode() {}
type Magnesium struct {
ID string `json:"id"`
Name string `json:"name"`
Types int `json:"types"`
}
func (Magnesium) IsElement() {}
func (this Magnesium) GetID() string { return this.ID }
func (this Magnesium) GetName() string { return this.Name }
func (Magnesium) IsNode() {}
type Potassium struct {
ID string `json:"id"`
Name string `json:"name"`
Price float64 `json:"price"`
}
func (Potassium) IsElement() {}
func (this Potassium) GetID() string { return this.ID }
func (this Potassium) GetName() string { return this.Name }
func (Potassium) IsNode() {}
type Query struct {
}
================================================
FILE: plugin/modelgen/out_nullable_input_omittable/existing.go
================================================
package out_nullable_input_omittable
import (
"github.com/99designs/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()
}
================================================
FILE: plugin/modelgen/out_nullable_input_omittable/generated.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_nullable_input_omittable
import (
"bytes"
"fmt"
"io"
"strconv"
"github.com/99designs/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 OmitZeroJSONTagTest struct {
ValueNonNil string `json:"ValueNonNil" database:"OmitZeroJSONTagTestValueNonNil"`
Value *string `json:"Value,omitempty" database:"OmitZeroJSONTagTestValue"`
}
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 any) 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()))
}
func (e *EnumWithDescription) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e EnumWithDescription) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
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 any) 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()))
}
func (e *MissingEnum) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e MissingEnum) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
================================================
FILE: plugin/modelgen/out_omit_embedded_structs_models/generated_omit_embedded_structs_models.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_omit_embedded_structs_models
type Element interface {
IsNode()
IsElement()
GetID() string
GetName() string
}
type Node interface {
IsNode()
GetID() string
}
type Carbon struct {
ID string `json:"id"`
Name string `json:"name"`
Footprint string `json:"footprint"`
}
func (Carbon) IsElement() {}
func (this Carbon) GetID() string { return this.ID }
func (this Carbon) GetName() string { return this.Name }
func (Carbon) IsNode() {}
type Magnesium struct {
ID string `json:"id"`
Name string `json:"name"`
Types int `json:"types"`
}
func (Magnesium) IsElement() {}
func (this Magnesium) GetID() string { return this.ID }
func (this Magnesium) GetName() string { return this.Name }
func (Magnesium) IsNode() {}
type Potassium struct {
ID string `json:"id"`
Name string `json:"name"`
Price float64 `json:"price"`
}
func (Potassium) IsElement() {}
func (this Potassium) GetID() string { return this.ID }
func (this Potassium) GetName() string { return this.Name }
func (Potassium) IsNode() {}
type Query struct {
}
================================================
FILE: plugin/modelgen/out_omit_json_enum_marshalers/generated.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_omit_json_enum_marshalers
import (
"fmt"
"io"
"strconv"
"github.com/99designs/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 ExistingInterface interface {
IsExistingInterface()
GetName() *string
}
type ExistingUnion interface {
IsExistingUnion()
}
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 ExistingInput struct {
Name *string `json:"name,omitempty" database:"ExistingInputname"`
Enum *ExistingEnum `json:"enum,omitempty" database:"ExistingInputenum"`
}
type ExistingType struct {
Name *string `json:"name,omitempty" database:"ExistingTypename"`
Enum *ExistingEnum `json:"enum,omitempty" database:"ExistingTypeenum"`
Int ExistingInterface `json:"int,omitempty" database:"ExistingTypeint"`
Existing *MissingTypeNullable `json:"existing,omitempty" database:"ExistingTypeexisting"`
}
func (ExistingType) IsMissingUnion() {}
func (ExistingType) IsMissingInterface() {}
func (this ExistingType) GetName() *string { return this.Name }
func (ExistingType) IsExistingInterface() {}
func (ExistingType) IsExistingUnion() {}
func (ExistingType) IsUnionWithDescription() {}
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 OmitZeroJSONTagTest struct {
ValueNonNil string `json:"ValueNonNil" database:"OmitZeroJSONTagTestValueNonNil"`
Value *string `json:"Value,omitempty" database:"OmitZeroJSONTagTestValue"`
}
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 any) 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 ExistingEnum string
const (
ExistingEnumHello ExistingEnum = "Hello"
ExistingEnumGoodbye ExistingEnum = "Goodbye"
)
var AllExistingEnum = []ExistingEnum{
ExistingEnumHello,
ExistingEnumGoodbye,
}
func (e ExistingEnum) IsValid() bool {
switch e {
case ExistingEnumHello, ExistingEnumGoodbye:
return true
}
return false
}
func (e ExistingEnum) String() string {
return string(e)
}
func (e *ExistingEnum) UnmarshalGQL(v any) error {
str, ok := v.(string)
if !ok {
return fmt.Errorf("enums must be strings")
}
*e = ExistingEnum(str)
if !e.IsValid() {
return fmt.Errorf("%s is not a valid ExistingEnum", str)
}
return nil
}
func (e ExistingEnum) 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 any) 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()))
}
================================================
FILE: plugin/modelgen/out_omit_resolver_fields/generated.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_omit_resolver_fields
type Base struct {
StandardField string `json:"StandardField" database:"BaseStandardField"`
ForceGeneratedField string `json:"ForceGeneratedField" database:"BaseForceGeneratedField"`
}
type Query struct {
}
================================================
FILE: plugin/modelgen/out_struct_pointers/existing.go
================================================
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()
}
================================================
FILE: plugin/modelgen/out_struct_pointers/generated.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package out_struct_pointers
import (
"bytes"
"fmt"
"io"
"strconv"
"github.com/99designs/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 OmitZeroJSONTagTest struct {
ValueNonNil string `json:"ValueNonNil" database:"OmitZeroJSONTagTestValueNonNil"`
Value *string `json:"Value,omitempty" database:"OmitZeroJSONTagTestValue"`
}
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 any) 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()))
}
func (e *EnumWithDescription) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e EnumWithDescription) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
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 any) 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()))
}
func (e *MissingEnum) UnmarshalJSON(b []byte) error {
s, err := strconv.Unquote(string(b))
if err != nil {
return err
}
return e.UnmarshalGQL(s)
}
func (e MissingEnum) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
e.MarshalGQL(&buf)
return buf.Bytes(), nil
}
================================================
FILE: plugin/modelgen/testdata/customModelTemplate.gotpl
================================================
{{ 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/99designs/gqlgen/graphql" }}
{{ reserveImport "github.com/99designs/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 any) 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 }}
================================================
FILE: plugin/modelgen/testdata/gqlgen.yml
================================================
schema:
- "testdata/schema.graphql"
exec:
filename: out/ignored.go
model:
filename: out/generated.go
models:
ExistingModel:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingModel
ExistingInput:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingInput
ExistingEnum:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingEnum
ExistingInterface:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingInterface
ExistingUnion:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingUnion
ExistingType:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingType
RenameFieldTest:
fields:
badName:
fieldName: GOODnaME
ExtraFieldsTest:
extraFields:
FieldInternalType:
description: "Internal field"
type: github.com/99designs/gqlgen/plugin/modelgen/internal/extrafields.Type
FieldStringPtr:
type: "*string"
FieldInt:
type: "int64"
overrideTags: 'json:"field_int_tag"'
FieldIntSlice:
type: "[]int64"
================================================
FILE: plugin/modelgen/testdata/gqlgen_conflicting_types.yml
================================================
schema:
- "testdata/schema_conflicting_types.graphql"
exec:
filename: out_conflicting_types/ignored.go
model:
filename: out_conflicting_types/generated.go
================================================
FILE: plugin/modelgen/testdata/gqlgen_custom_model_template.yml
================================================
schema:
- "testdata/schema.graphql"
exec:
filename: out/ignored.go
model:
filename: out/generated.go
model_template: "testdata/customModelTemplate.gotpl"
models:
ExistingModel:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingModel
ExistingInput:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingInput
ExistingEnum:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingEnum
ExistingInterface:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingInterface
ExistingUnion:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingUnion
ExistingType:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingType
RenameFieldTest:
fields:
badName:
fieldName: GOODnaME
ExtraFieldsTest:
extraFields:
FieldInternalType:
description: "Internal field"
type: github.com/99designs/gqlgen/plugin/modelgen/internal/extrafields.Type
FieldStringPtr:
type: "*string"
FieldInt:
type: "int64"
overrideTags: 'json:"field_int_tag"'
FieldIntSlice:
type: "[]int64"
================================================
FILE: plugin/modelgen/testdata/gqlgen_enable_model_json_omitempty_tag_false.yml
================================================
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/99designs/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_false.ExistingModel
ExistingInput:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingInput
ExistingEnum:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingEnum
ExistingInterface:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingInterface
ExistingUnion:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingUnion
ExistingType:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingType
================================================
FILE: plugin/modelgen/testdata/gqlgen_enable_model_json_omitempty_tag_false_omitzero_tag_false.yml
================================================
schema:
- "testdata/schema.graphql"
enable_model_json_omitempty_tag: false
enable_model_json_omitzero_tag: false
exec:
filename: out_enable_model_json_omitempty_tag_false_omitzero_tag_false/ignored.go
model:
filename: out_enable_model_json_omitempty_tag_false_omitzero_tag_false/generated.go
models:
ExistingModel:
model: github.com/99designs/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_false_omitzero_tag_false.ExistingModel
ExistingInput:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingInput
ExistingEnum:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingEnum
ExistingInterface:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingInterface
ExistingUnion:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingUnion
ExistingType:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingType
================================================
FILE: plugin/modelgen/testdata/gqlgen_enable_model_json_omitempty_tag_false_omitzero_tag_nil.yml
================================================
schema:
- "testdata/schema.graphql"
enable_model_json_omitempty_tag: false
exec:
filename: out_enable_model_json_omitempty_tag_false_omitzero_tag_nil/ignored.go
model:
filename: out_enable_model_json_omitempty_tag_false_omitzero_tag_nil/generated.go
models:
ExistingModel:
model: github.com/99designs/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_false_omitzero_tag_nil.ExistingModel
ExistingInput:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingInput
ExistingEnum:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingEnum
ExistingInterface:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingInterface
ExistingUnion:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingUnion
ExistingType:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingType
================================================
FILE: plugin/modelgen/testdata/gqlgen_enable_model_json_omitempty_tag_false_omitzero_tag_true.yml
================================================
schema:
- "testdata/schema.graphql"
enable_model_json_omitempty_tag: false
enable_model_json_omitzero_tag: true
exec:
filename: out_enable_model_json_omitempty_tag_false_omitzero_tag_true/ignored.go
model:
filename: out_enable_model_json_omitempty_tag_false_omitzero_tag_true/generated.go
models:
ExistingModel:
model: github.com/99designs/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_false_omitzero_tag_true.ExistingModel
ExistingInput:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingInput
ExistingEnum:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingEnum
ExistingInterface:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingInterface
ExistingUnion:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingUnion
ExistingType:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingType
================================================
FILE: plugin/modelgen/testdata/gqlgen_enable_model_json_omitempty_tag_nil.yml
================================================
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/99designs/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_nil.ExistingModel
ExistingInput:
model: github.com/99designs/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_nil.ExistingInput
ExistingEnum:
model: github.com/99designs/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_nil.ExistingEnum
ExistingInterface:
model: github.com/99designs/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_nil.ExistingInterface
ExistingUnion:
model: github.com/99designs/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_nil.ExistingUnion
ExistingType:
model: github.com/99designs/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_nil.ExistingType
================================================
FILE: plugin/modelgen/testdata/gqlgen_enable_model_json_omitempty_tag_true.yml
================================================
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/99designs/gqlgen/plugin/modelgen/out_enable_model_json_omitempty_tag_true.ExistingModel
ExistingInput:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingInput
ExistingEnum:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingEnum
ExistingInterface:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingInterface
ExistingUnion:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingUnion
ExistingType:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingType
================================================
FILE: plugin/modelgen/testdata/gqlgen_enable_model_json_omitzero_tag_false.yml
================================================
schema:
- "testdata/schema.graphql"
enable_model_json_omitzero_tag: false
exec:
filename: out_enable_model_json_omitzero_tag_false/ignored.go
model:
filename: out_enable_model_json_omitzero_tag_false/generated.go
models:
ExistingModel:
model: github.com/99designs/gqlgen/plugin/modelgen/out_enable_model_json_omitzero_tag_false.ExistingModel
ExistingInput:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingInput
ExistingEnum:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingEnum
ExistingInterface:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingInterface
ExistingUnion:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingUnion
ExistingType:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingType
================================================
FILE: plugin/modelgen/testdata/gqlgen_enable_model_json_omitzero_tag_nil.yml
================================================
schema:
- "testdata/schema.graphql"
exec:
filename: out_enable_model_json_omitzero_tag_nil/ignored.go
model:
filename: out_enable_model_json_omitzero_tag_nil/generated.go
models:
ExistingModel:
model: github.com/99designs/gqlgen/plugin/modelgen/out_enable_model_json_omitzero_tag_nil.ExistingModel
ExistingInput:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingInput
ExistingEnum:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingEnum
ExistingInterface:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingInterface
ExistingUnion:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingUnion
ExistingType:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingType
================================================
FILE: plugin/modelgen/testdata/gqlgen_enable_model_json_omitzero_tag_true.yml
================================================
schema:
- "testdata/schema.graphql"
enable_model_json_omitzero_tag: true
exec:
filename: out_enable_model_json_omitzero_tag_true/ignored.go
model:
filename: out_enable_model_json_omitzero_tag_true/generated.go
models:
ExistingModel:
model: github.com/99designs/gqlgen/plugin/modelgen/out_enable_model_json_omitzero_tag_true.ExistingModel
ExistingInput:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingInput
ExistingEnum:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingEnum
ExistingInterface:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingInterface
ExistingUnion:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingUnion
ExistingType:
model: github.com/99designs/gqlgen/plugin/modelgen/out.ExistingType
================================================
FILE: plugin/modelgen/testdata/gqlgen_nullable_input_omittable.yml
================================================
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/99designs/gqlgen/plugin/modelgen/out_nullable_input_omittable.ExistingModel
ExistingInput:
model: github.com/99designs/gqlgen/plugin/modelgen/out_nullable_input_omittable.ExistingInput
ExistingEnum:
model: github.com/99designs/gqlgen/plugin/modelgen/out_nullable_input_omittable.ExistingEnum
ExistingInterface:
model: github.com/99designs/gqlgen/plugin/modelgen/out_nullable_input_omittable.ExistingInterface
ExistingUnion:
model: github.com/99designs/gqlgen/plugin/modelgen/out_nullable_input_omittable.ExistingUnion
ExistingType:
model: github.com/99designs/gqlgen/plugin/modelgen/out_nullable_input_omittable.ExistingType
================================================
FILE: plugin/modelgen/testdata/gqlgen_omit_json_marshalers.yml
================================================
schema:
- "testdata/schema.graphql"
omit_enum_json_marshalers: true
model:
filename: out_omit_json_enum_marshalers/generated.go
================================================
FILE: plugin/modelgen/testdata/gqlgen_omit_resolver_fields.yml
================================================
schema:
- "testdata/schema_omit_resolver_fields.graphql"
exec:
filename: out_omit_resolver_fields/ignored.go
model:
filename: out_omit_resolver_fields/generated.go
omit_resolver_fields: true
================================================
FILE: plugin/modelgen/testdata/gqlgen_omit_root_models.yml
================================================
schema:
- "testdata/schema_omit_root_models.graphql"
exec:
filename: out/ignored.go
model:
filename: out/generated_omit_root_models.go
omit_root_models: true
================================================
FILE: plugin/modelgen/testdata/gqlgen_struct_field_pointers.yml
================================================
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/99designs/gqlgen/plugin/modelgen/out_struct_pointers.ExistingModel
ExistingInput:
model: github.com/99designs/gqlgen/plugin/modelgen/out_struct_pointers.ExistingInput
ExistingEnum:
model: github.com/99designs/gqlgen/plugin/modelgen/out_struct_pointers.ExistingEnum
ExistingInterface:
model: github.com/99designs/gqlgen/plugin/modelgen/out_struct_pointers.ExistingInterface
ExistingUnion:
model: github.com/99designs/gqlgen/plugin/modelgen/out_struct_pointers.ExistingUnion
ExistingType:
model: github.com/99designs/gqlgen/plugin/modelgen/out_struct_pointers.ExistingType
================================================
FILE: plugin/modelgen/testdata/interface_embedding/gqlgen_directive_binding_models.yml
================================================
schema:
- "testdata/interface_embedding/schema_directive_basic.graphql"
- "testdata/interface_embedding/schema_directive_binding.graphql"
model:
filename: out_directive_binding_models/generated_directive_binding_models.go
autobind:
- "github.com/99designs/gqlgen/plugin/modelgen/out_directive_embedding_models"
================================================
FILE: plugin/modelgen/testdata/interface_embedding/gqlgen_directive_covariant_types.yml
================================================
schema:
- "testdata/interface_embedding/schema_covariant_types.graphql"
model:
filename: out_covariant_types/generated_covariant_types.go
================================================
FILE: plugin/modelgen/testdata/interface_embedding/gqlgen_directive_diamond.yml
================================================
schema:
- "testdata/interface_embedding/schema_directive_diamond.graphql"
model:
filename: out_directive_diamond/generated_directive_diamond.go
================================================
FILE: plugin/modelgen/testdata/interface_embedding/gqlgen_directive_embedding_models.yml
================================================
schema:
- "testdata/interface_embedding/schema_directive_basic.graphql"
model:
filename: out_directive_embedding_models/generated_directive_embedding_models.go
================================================
FILE: plugin/modelgen/testdata/interface_embedding/gqlgen_directive_partial.yml
================================================
schema:
- "testdata/interface_embedding/schema_directive_partial.graphql"
model:
filename: out_directive_partial/generated_directive_partial.go
================================================
FILE: plugin/modelgen/testdata/interface_embedding/gqlgen_directive_skipped_parents.yml
================================================
schema:
- "testdata/interface_embedding/schema_directive_skipped_parents.graphql"
model:
filename: out_directive_skipped_parents/generated_directive_skipped_parents.go
================================================
FILE: plugin/modelgen/testdata/interface_embedding/gqlgen_no_directive_models.yml
================================================
schema:
- "testdata/interface_embedding/schema_no_directive.graphql"
model:
filename: out_no_directive_models/generated_no_directive_models.go
================================================
FILE: plugin/modelgen/testdata/interface_embedding/schema_covariant_types.graphql
================================================
# Test schema for covariant return types in interface implementations
# GraphQL allows implementations to use more specific types than the interface declares
directive @goEmbedInterface on INTERFACE
interface Identifiable @goEmbedInterface {
id: ID!
}
interface Typeable @goEmbedInterface {
type: String!
}
interface NodeData @goEmbedInterface {
name: String!
childrenIds: [String!]!
}
# Interface implementing multiple interfaces (diamond problem test)
interface Node implements Identifiable & Typeable @goEmbedInterface {
id: ID!
type: String!
data: NodeData!
}
# Specific implementation of NodeData
type ProductNodeData implements NodeData {
name: String!
childrenIds: [String!]!
productSpecificField: String!
}
# Implementation with covariant return type for 'data' field
type ProductNode implements Node & Identifiable & Typeable {
id: ID!
type: String!
# This is a covariant override - using ProductNodeData instead of NodeData
data: ProductNodeData!
productTitle: String!
}
# Another interface for tags
interface Tags @goEmbedInterface {
data: [String!]
}
type ProductTags implements Tags {
data: [String!]
productSpecific: Boolean
}
# Type with multiple covariant overrides
type ExtendedProductNode implements Node & Identifiable & Typeable {
id: ID!
type: String!
# Covariant override
data: ProductNodeData!
tags: ProductTags
}
================================================
FILE: plugin/modelgen/testdata/interface_embedding/schema_directive_basic.graphql
================================================
directive @goEmbedInterface on INTERFACE
interface Node @goEmbedInterface {
id: ID!
}
interface Element implements Node @goEmbedInterface {
id: ID!
name: String!
}
type Magnesium implements Element & Node {
id: ID!
name: String!
types: Int!
}
type Potassium implements Element & Node {
id: ID!
name: String!
price: Float!
}
type Carbon implements Element & Node {
id: ID!
name: String!
footprint: String!
}
================================================
FILE: plugin/modelgen/testdata/interface_embedding/schema_directive_binding.graphql
================================================
type Molecule implements Node {
id: ID!
elements: [Element!]
}
type Oxygen implements Element & Node {
id: ID!
name: String!
purity: Float!
}
================================================
FILE: plugin/modelgen/testdata/interface_embedding/schema_directive_diamond.graphql
================================================
directive @goEmbedInterface on INTERFACE
interface HasID @goEmbedInterface {
id: ID!
}
interface HasIdentifier @goEmbedInterface {
identifier: ID!
}
interface Conflicting implements HasID & HasIdentifier @goEmbedInterface {
id: ID!
identifier: ID!
name: String!
}
interface HasName {
name: String!
}
interface HasTitle {
title: String!
}
interface NoConflict implements HasName & HasTitle @goEmbedInterface {
name: String!
title: String!
}
type ConcreteConflicting implements Conflicting & HasID & HasIdentifier {
id: ID!
identifier: ID!
name: String!
extra: String!
}
type ConcreteNoConflict implements NoConflict & HasName & HasTitle {
name: String!
title: String!
extra: String!
}
================================================
FILE: plugin/modelgen/testdata/interface_embedding/schema_directive_partial.graphql
================================================
directive @goEmbedInterface on INTERFACE
interface Node @goEmbedInterface {
id: ID!
}
interface Element implements Node {
id: ID!
name: String!
}
interface Metal implements Element & Node @goEmbedInterface {
id: ID!
name: String!
atomicNumber: Int!
}
type Gold implements Metal & Element & Node {
id: ID!
name: String!
atomicNumber: Int!
karat: Int!
}
type Silver implements Metal & Element & Node {
id: ID!
name: String!
atomicNumber: Int!
purity: Float!
}
================================================
FILE: plugin/modelgen/testdata/interface_embedding/schema_directive_skipped_parents.graphql
================================================
directive @goEmbedInterface on INTERFACE
interface A @goEmbedInterface {
id: ID!
fieldA: String!
}
interface B implements A {
id: ID!
fieldA: String!
fieldB: String!
}
interface C implements B & A @goEmbedInterface {
id: ID!
fieldA: String!
fieldB: String!
fieldC: String!
}
type ConcreteC implements C & B & A {
id: ID!
fieldA: String!
fieldB: String!
fieldC: String!
concreteField: String!
}
================================================
FILE: plugin/modelgen/testdata/interface_embedding/schema_no_directive.graphql
================================================
interface Node {
id: ID!
}
interface Element implements Node {
id: ID!
name: String!
}
type Magnesium implements Element & Node {
id: ID!
name: String!
types: Int!
}
type Potassium implements Element & Node {
id: ID!
name: String!
price: Float!
}
type Carbon implements Element & Node {
id: ID!
name: String!
footprint: String!
}
================================================
FILE: plugin/modelgen/testdata/schema.graphql
================================================
directive @goTag(
key: String!
value: String
) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION
directive @goField(
forceResolver: Boolean
name: String
omittable: Boolean
type: String
) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION | INTERFACE
type Query {
thisShouldntGetGenerated: Boolean
}
type Mutation {
thisShouldntGetGenerated: Boolean
}
type Subscription {
thisShouldntGetGenerated: 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
}
type OmitZeroJSONTagTest {
ValueNonNil: String!
Value: String
}
================================================
FILE: plugin/modelgen/testdata/schema_conflicting_types.graphql
================================================
directive @goField(
forceResolver: Boolean
name: String
omittable: Boolean
type: String
) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION | INTERFACE
type FooBar {
without_underscore: Boolean
}
type Foo_Bar {
with_underscore: Boolean
}
type Baz {
want_without_underscore: FooBar!
}
type Bees {
want_with_underscore: Foo_Bar!
}
================================================
FILE: plugin/modelgen/testdata/schema_embedded_structs_models_no_embedding.graphql
================================================
directive @goEmbedInterface on INTERFACE
interface Node @goEmbedInterface {
id: ID!
}
interface Element implements Node @goEmbedInterface {
id: ID!
name: String!
}
type Magnesium implements Element & Node {
id: ID!
name: String!
types: Int!
}
type Potassium implements Element & Node {
id: ID!
name: String!
price: Float!
}
type Carbon implements Element & Node {
id: ID!
name: String!
footprint: String!
}
================================================
FILE: plugin/modelgen/testdata/schema_omit_resolver_fields.graphql
================================================
directive @goTag(
key: String!
value: String
) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION
directive @goField(
forceResolver: Boolean
name: String
omittable: Boolean
type: String
forceGenerate: Boolean
) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION | INTERFACE
type Base {
StandardField: String!
ResolverField: String! @goField(forceResolver: true)
ForceGeneratedField: String!
@goField(forceResolver: true, forceGenerate: true)
}
================================================
FILE: plugin/modelgen/testdata/schema_omit_root_models.graphql
================================================
type Query {
thisShoudlntGetGenerated: Boolean
}
type Mutation {
thisShoudlntGetGenerated: Boolean
}
type Subscription {
thisShoudlntGetGenerated: Boolean
}
enum SomeContent {
This
Is
A
Test
}
================================================
FILE: plugin/modelgen/types.go
================================================
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/99designs/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)
}
================================================
FILE: plugin/plugin.go
================================================
// plugin package interfaces are EXPERIMENTAL.
package plugin
import (
"github.com/vektah/gqlparser/v2/ast"
"github.com/99designs/gqlgen/codegen"
"github.com/99designs/gqlgen/codegen/config"
)
type Plugin interface {
Name() string
}
// SchemaMutator is used to modify the schema before it is used to generate code
// Similarly to [ConfigMutator] that is also triggered before code generation, SchemaMutator
// can be used to modify the schema even before the models are generated.
type SchemaMutator interface {
MutateSchema(schema *ast.Schema) error
}
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.
//
// Deprecated: Use EarlySourcesInjector instead
type EarlySourceInjector interface {
InjectSourceEarly() *ast.Source
}
// EarlySourcesInjector is used to inject things that are required for user schema files to compile.
type EarlySourcesInjector interface {
InjectSourcesEarly() ([]*ast.Source, error)
}
// LateSourceInjector is used to inject more sources, after we have loaded the users schema.
// // Deprecated: Use LateSourcesInjector instead
type LateSourceInjector interface {
InjectSourceLate(schema *ast.Schema) *ast.Source
}
// ResolverImplementer is used to generate code inside resolvers
type ResolverImplementer interface {
Implement(prevImplementation string, field *codegen.Field) string
}
// LateSourcesInjector is used to inject more sources, after we have loaded the users schema.
type LateSourcesInjector interface {
InjectSourcesLate(schema *ast.Schema) ([]*ast.Source, error)
}
================================================
FILE: plugin/resolvergen/resolver.go
================================================
package resolvergen
import (
_ "embed"
"errors"
"fmt"
"go/ast"
"os"
"path/filepath"
"strings"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"github.com/99designs/gqlgen/codegen"
"github.com/99designs/gqlgen/codegen/config"
"github.com/99designs/gqlgen/codegen/templates"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/internal/rewrite"
"github.com/99designs/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 fileExists(data.Config.Resolver.Filename) &&
data.Config.Resolver.PreserveResolver {
// file already exists and config says not to update resolver
// so just return
return nil
}
rewriter, err := rewrite.New(data.Config.Resolver.Dir())
if err != nil {
return err
}
for _, o := range data.Objects {
if o.HasResolvers() {
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))
file.Objects = append(file.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 != "" {
resolver := Resolver{
o,
f,
rewriter.GetPrevDecl(structName, f.GoFieldName),
comment,
implementation,
nil,
}
file.Resolvers = append(file.Resolvers, &resolver)
} else {
resolver := Resolver{o, f, nil, "", `panic("not implemented")`, nil}
file.Resolvers = append(file.Resolvers, &resolver)
}
}
}
if fileExists(data.Config.Resolver.Filename) {
file.name = data.Config.Resolver.Filename
file.imports = rewriter.ExistingImports(file.name)
file.RemainingSource = rewriter.RemainingSource(file.name)
}
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)
}
fileNotice := `// THIS CODE WILL BE UPDATED WITH SCHEMA CHANGES. PREVIOUS IMPLEMENTATION FOR SCHEMA CHANGES WILL BE KEPT IN THE COMMENT SECTION. IMPLEMENTATION FOR UNCHANGED SCHEMA WILL BE KEPT.`
if data.Config.Resolver.PreserveResolver {
fileNotice = `// THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES.`
}
return templates.Render(templates.Options{
PackageName: data.Config.Resolver.Package,
FileNotice: fileNotice,
Filename: data.Config.Resolver.Filename,
Data: resolverBuild,
Packages: data.Config.Packages,
Template: newResolverTemplate,
PruneOptions: data.Config.GetPruneOptions(),
})
}
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)
// TODO(steve): Why do we need to trimLeft "\" here? Some bazel thing?
comment := strings.TrimSpace(
strings.TrimLeft(rewriter.GetMethodComment(structName, f.GoFieldName), `\`),
)
implementation := strings.TrimSpace(rewriter.GetMethodBody(structName, f.GoFieldName))
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 errors.New("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)
}
}
var allImports []string
for _, file := range files {
file.imports = rewriter.ExistingImports(file.name)
file.RemainingSource = rewriter.RemainingSource(file.name)
for _, i := range file.imports {
allImports = append(allImports, i.ImportPath)
}
}
data.Config.Packages.LoadAllNames(
allImports...) // Preload all names in one Load call for performance reasons
newResolverTemplate := resolverTemplate
if data.Config.Resolver.ResolverTemplate != "" {
newResolverTemplate = readResolverTemplate(data.Config.Resolver.ResolverTemplate)
}
for _, file := range files {
if fileExists(file.name) &&
data.Config.Resolver.PreserveResolver {
// file already exists and config says not to update resolver
continue
}
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/99designs/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,
PruneOptions: data.Config.GetPruneOptions(),
})
if err != nil {
return err
}
}
if !fileExists(data.Config.Resolver.Filename) {
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,
PruneOptions: data.Config.GetPruneOptions(),
})
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(prevImplementation string, r *codegen.Field) string
}
func (r *Resolver) Implementation() string {
if r.ImplementationRender != nil {
// use custom implementation
return r.ImplementationRender(r.ImplementationStr, r.Field)
}
// if not implementation was previously used, use default implementation
if r.ImplementationStr == "" {
// use default implementation, if no implementation was previously used
return fmt.Sprintf(
"panic(fmt.Errorf(\"not implemented: %v - %v\"))",
r.Field.GoFieldName,
r.Field.Name,
)
}
// use previously used implementation
return r.ImplementationStr
}
func gqlToResolverName(base, 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)
}
func fileExists(fileName string) bool {
if _, err := os.Stat(fileName); err == nil {
return true
}
return false
}
================================================
FILE: plugin/resolvergen/resolver.gotpl
================================================
{{ 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/99designs/gqlgen/graphql" }}
{{ reserveImport "github.com/99designs/gqlgen/graphql/introspection" }}
{{ .Imports }}
{{ if .HasRoot }}
type {{.ResolverType}} struct {}
{{ end }}
{{ range $resolver := .Resolvers -}}
{{- if $resolver.Field.IsBatch }}
{{ if not $.OmitTemplateComment -}}
// {{ $resolver.Field.GoFieldName }} is the batch resolver for the {{ $resolver.Field.Name }} field.
{{- end }}
func (r *{{lcFirst $resolver.Object.Name}}{{ucFirst $.ResolverType}}) {{$resolver.Field.GoFieldName}}{{ $resolver.Field.ShortBatchResolverDeclaration }}{
{{ $resolver.Implementation }}
}
{{- else }}
{{ if $resolver.Comment -}}
{{with $resolver.Comment}}{{.|prefixLines "//"}}{{end}}
{{- 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 }}
{{ 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 }}
================================================
FILE: plugin/resolvergen/resolver_test.go
================================================
package resolvergen
import (
"os"
"strings"
"syscall"
"testing"
"github.com/stretchr/testify/require"
"golang.org/x/tools/go/packages"
"github.com/99designs/gqlgen/codegen"
"github.com/99designs/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)
require.NoError(t, err)
require.NoError(t, p.GenerateCode(data))
assertNoErrors(t, "github.com/99designs/gqlgen/plugin/resolvergen/testdata/singlefile/out")
}
func TestLayoutSingleFileWithEnableRewrite(t *testing.T) {
// Ensure the resolver file exists before running the test
resolverFilePath := "testdata/singlefile_preserve/out/resolver.go"
_, err := os.Stat(resolverFilePath)
if os.IsNotExist(err) {
t.Fatalf("Expected resolver file does not exist: %s", resolverFilePath)
}
require.NoError(t, err)
cfg, err := config.LoadConfig("testdata/singlefile_preserve/gqlgen.yml")
require.NoError(t, err)
p := Plugin{}
require.NoError(t, cfg.Init())
data, err := codegen.BuildData(cfg)
require.NoError(t, err)
require.NoError(t, p.GenerateCode(data))
assertNoErrors(
t,
"github.com/99designs/gqlgen/plugin/resolvergen/testdata/singlefile_preserve/out",
)
}
func TestLayoutFollowSchema(t *testing.T) {
testFollowSchemaPersistence(t, "testdata/followschema")
resolverFilePath := "testdata/followschema/out/schema.resolvers.go"
overWriteFile(t, resolverFilePath+".txt", resolverFilePath)
b, err := os.ReadFile(resolverFilePath)
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")
resolverFilePath := "testdata/filetemplate/out/schema.custom.go"
overWriteFile(t, resolverFilePath+".txt", resolverFilePath)
b, err := os.ReadFile(resolverFilePath)
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)
require.NoError(t, err)
require.NoError(t, p.GenerateCode(data))
assertNoErrors(
t,
"github.com/99designs/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{})
require.NoError(t, err)
require.NoError(t, p.GenerateCode(data))
assertNoErrors(
t,
"github.com/99designs/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)
require.NoError(t, err)
require.NoError(t, p.GenerateCode(data))
}
func TestCommentDirective(t *testing.T) {
_ = syscall.Unlink("testdata/comment_directive/resolver.go")
cfg, err := config.LoadConfig("testdata/comment_directive/gqlgen.yml")
require.NoError(t, err)
p := Plugin{}
require.NoError(t, cfg.Init())
data, err := codegen.BuildData(cfg)
require.NoError(t, err)
require.NoError(t, p.GenerateCode(data))
assertNoErrors(
t,
"github.com/99designs/gqlgen/plugin/resolvergen/testdata/comment_directive/out",
)
b, err := os.ReadFile("testdata/comment_directive/out/schema.resolvers.go")
require.NoError(t, err)
source := string(b)
require.Contains(t, source, "//nolint:test // test")
}
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)
require.NoError(t, err)
require.NoError(t, p.GenerateCode(data))
assertNoErrors(t, "github.com/99designs/gqlgen/plugin/resolvergen/"+dir+"/out")
}
func overWriteFile(t *testing.T, sourceFile, destinationFile string) {
input, err := os.ReadFile(sourceFile)
require.NoError(t, err)
err = os.WriteFile(destinationFile, input, 0o644)
require.NoError(t, err)
}
func assertNoErrors(t *testing.T, pkg string) {
t.Helper()
pkgs, err := packages.Load(&packages.Config{
Mode: packages.NeedName |
packages.NeedFiles |
packages.NeedCompiledGoFiles |
packages.NeedImports |
packages.NeedTypes |
packages.NeedTypesSizes,
}, pkg)
require.NoError(t, err)
var errFilePos []string
var errors []packages.Error
for _, pkg := range pkgs {
errors = append(errors, pkg.Errors...)
for _, err := range pkg.Errors {
errFilePos = append(errFilePos, err.Pos+":"+err.Msg)
}
}
require.Emptyf(t, errors, "There are compilation errors:\n"+
strings.Join(errFilePos, "\n"))
}
type implementorTest struct{}
func (i *implementorTest) Implement(_ string, _ *codegen.Field) string {
return "panic(\"implementor implemented me\")"
}
================================================
FILE: plugin/resolvergen/testdata/comment_directive/gqlgen.yml
================================================
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/comment_directive/out
models:
Resolver:
model: github.com/99designs/gqlgen/plugin/resolvergen/testdata/singlefile/out.Resolver
omit_gqlgen_version_in_file_notice: true
================================================
FILE: plugin/resolvergen/testdata/comment_directive/out/resolver.go
================================================
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{}
================================================
FILE: plugin/resolvergen/testdata/comment_directive/out/schema.resolvers.go
================================================
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/99designs/gqlgen
import (
"context"
"fmt"
customresolver "github.com/99designs/gqlgen/plugin/resolvergen/testdata/singlefile/out"
)
// Resolver is the resolver for the resolver field.
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.
//
//nolint:test // test
func (r *resolverCustomResolverType) Name(ctx context.Context, obj *customresolver.Resolver) (string, error) {
panic(fmt.Errorf("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 }
================================================
FILE: plugin/resolvergen/testdata/filetemplate/gqlgen.yml
================================================
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/99designs/gqlgen/plugin/resolvergen/testdata/singlefile/out.Resolver
omit_gqlgen_version_in_file_notice: true
================================================
FILE: plugin/resolvergen/testdata/filetemplate/out/model.go
================================================
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)
}
================================================
FILE: plugin/resolvergen/testdata/filetemplate/out/resolver.go
================================================
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{}
================================================
FILE: plugin/resolvergen/testdata/filetemplate/out/schema.custom.go
================================================
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/99designs/gqlgen
import (
"context"
customresolver "github.com/99designs/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 }
func AUserHelperFunction() {
// AUserHelperFunction implementation
}
================================================
FILE: plugin/resolvergen/testdata/filetemplate/out/schema.custom.go.txt
================================================
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/99designs/gqlgen
import (
"context"
customresolver "github.com/99designs/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 }
func AUserHelperFunction() {
// AUserHelperFunction implementation
}
================================================
FILE: plugin/resolvergen/testdata/followschema/gqlgen.yml
================================================
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/99designs/gqlgen/plugin/resolvergen/testdata/singlefile/out.Resolver
omit_gqlgen_version_in_file_notice: true
================================================
FILE: plugin/resolvergen/testdata/followschema/out/model.go
================================================
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)
}
================================================
FILE: plugin/resolvergen/testdata/followschema/out/resolver.go
================================================
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{}
================================================
FILE: plugin/resolvergen/testdata/followschema/out/schema.resolvers.go
================================================
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/99designs/gqlgen
import (
"context"
customresolver "github.com/99designs/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.
// This comment is multiline method doc
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.
// This comment is multiline method doc
func (r *CustomResolverType) Resolver() customresolver.ResolverResolver {
return &resolverCustomResolverType{r}
}
type queryCustomResolverType struct{ *CustomResolverType }
type resolverCustomResolverType struct{ *CustomResolverType }
func AUserHelperFunction() {
// AUserHelperFunction implementation
}
================================================
FILE: plugin/resolvergen/testdata/followschema/out/schema.resolvers.go.txt
================================================
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/99designs/gqlgen
import (
"context"
customresolver "github.com/99designs/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.
// This comment is multiline method doc
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.
// This comment is multiline method doc
func (r *CustomResolverType) Resolver() customresolver.ResolverResolver {
return &resolverCustomResolverType{r}
}
type queryCustomResolverType struct{ *CustomResolverType }
type resolverCustomResolverType struct{ *CustomResolverType }
func AUserHelperFunction() {
// AUserHelperFunction implementation
}
================================================
FILE: plugin/resolvergen/testdata/invalid_model_path/gqlgen.yml
================================================
schema:
- "testdata/schema.graphql"
models:
Resolver:
model: github.com/99designs/invalid/invalid/invalid/nope.Resolver
================================================
FILE: plugin/resolvergen/testdata/omit_template_comment/gqlgen.yml
================================================
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/99designs/gqlgen/plugin/resolvergen/testdata/singlefile/out.Resolver
omit_gqlgen_version_in_file_notice: true
================================================
FILE: plugin/resolvergen/testdata/omit_template_comment/out/resolver.go
================================================
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{}
================================================
FILE: plugin/resolvergen/testdata/omit_template_comment/out/schema.resolvers.go
================================================
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/99designs/gqlgen
import (
"context"
"fmt"
customresolver "github.com/99designs/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 }
================================================
FILE: plugin/resolvergen/testdata/resolver_implementor/gqlgen.yml
================================================
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/99designs/gqlgen/plugin/resolvergen/testdata/resolver_implementor/out.Resolver
omit_gqlgen_version_in_file_notice: true
================================================
FILE: plugin/resolvergen/testdata/resolver_implementor/out/model.go
================================================
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)
}
================================================
FILE: plugin/resolvergen/testdata/resolver_implementor/out/resolver.go
================================================
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{}
================================================
FILE: plugin/resolvergen/testdata/resolver_implementor/out/schema.resolvers.go
================================================
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/99designs/gqlgen
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 }
================================================
FILE: plugin/resolvergen/testdata/resolvertemplate/customResolverTemplate.gotpl
================================================
{{ 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/99designs/gqlgen/graphql" }}
{{ reserveImport "github.com/99designs/gqlgen/graphql/introspection" }}
{{ .Imports }}
{{ if .HasRoot }}
type {{.ResolverType}} struct {}
{{ end }}
{{ range $resolver := .Resolvers -}}
{{ if $resolver.Comment -}}
{{with $resolver.Comment}}{{.|prefixLines "// "}}{{end}}
{{- 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 }}
================================================
FILE: plugin/resolvergen/testdata/resolvertemplate/gqlgen.yml
================================================
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/99designs/gqlgen/plugin/resolvergen/testdata/singlefile/out.Resolver
omit_gqlgen_version_in_file_notice: true
================================================
FILE: plugin/resolvergen/testdata/resolvertemplate/out/resolver.go
================================================
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{}
================================================
FILE: plugin/resolvergen/testdata/resolvertemplate/out/schema.resolvers.go
================================================
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/99designs/gqlgen
import (
"context"
"fmt"
customresolver "github.com/99designs/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 }
================================================
FILE: plugin/resolvergen/testdata/return_values/gqlgen.yml
================================================
schema:
- schema.graphqls
exec:
filename: ignored.go
model:
filename: model.go
resolver:
filename: resolvers.go
resolvers_always_return_pointers: false
================================================
FILE: plugin/resolvergen/testdata/return_values/ignored.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package return_values
import (
"bytes"
"context"
"embed"
"errors"
"fmt"
"strconv"
"sync"
"sync/atomic"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/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]any) (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 {
opCtx := graphql.GetOperationContext(ctx)
ec := executionContext{opCtx, e}
inputUnmarshalMap := graphql.BuildUnmarshalerMap()
first := true
switch opCtx.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, opCtx.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]any) (map[string]any, error) {
var err error
args := map[string]any{}
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
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) (any, 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ᚋ99designsᚋ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) (any, 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ᚋ99designsᚋ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) (any, 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ᚋ99designsᚋ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) (any, 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ᚋ99designsᚋ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) (any, 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) (any, 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) (any, 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) (any, 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) (any, 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) (any, 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ᚋ99designsᚋ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) (any, 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) (any, 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) (any, 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) (any, 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) (any, 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) (any, 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) (any, 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) (any, 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ᚋ99designsᚋ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) (any, 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ᚋ99designsᚋ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) (any, 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) (any, 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) (any, 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) (any, 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) (any, 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ᚋ99designsᚋ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) (any, 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) (any, 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) (any, 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ᚋ99designsᚋ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) (any, 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ᚋ99designsᚋ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) (any, 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ᚋ99designsᚋ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) (any, 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ᚋ99designsᚋ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) (any, 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ᚋ99designsᚋ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) (any, 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) (any, 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) (any, 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) (any, 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ᚋ99designsᚋ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) (any, 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ᚋ99designsᚋ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) (any, 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ᚋ99designsᚋ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) (any, 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ᚋ99designsᚋ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) (any, 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ᚋ99designsᚋ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) (any, 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ᚋ99designsᚋ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) (any, 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 any) (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 any) (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 any) (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ᚋ99designsᚋ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ᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler {
return ec.___Directive(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler {
ret := make(graphql.Array, len(v))
var wg sync.WaitGroup
isLen1 := len(v) == 1
if !isLen1 {
wg.Add(len(v))
}
for i := range v {
i := i
fc := &graphql.FieldContext{
Index: &i,
Result: &v[i],
}
ctx := graphql.WithFieldContext(ctx, fc)
f := func(i int) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = nil
}
}()
if !isLen1 {
defer wg.Done()
}
ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i])
}
if isLen1 {
f(i)
} else {
go f(i)
}
}
wg.Wait()
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v any) (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 any) ([]string, error) {
var vSlice []any
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ᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler {
return ec.___EnumValue(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler {
return ec.___Field(ctx, sel, &v)
}
func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler {
return ec.___InputValue(ctx, sel, &v)
}
func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
ret := make(graphql.Array, len(v))
var wg sync.WaitGroup
isLen1 := len(v) == 1
if !isLen1 {
wg.Add(len(v))
}
for i := range v {
i := i
fc := &graphql.FieldContext{
Index: &i,
Result: &v[i],
}
ctx := graphql.WithFieldContext(ctx, fc)
f := func(i int) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = nil
}
}()
if !isLen1 {
defer wg.Done()
}
ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i])
}
if isLen1 {
f(i)
} else {
go f(i)
}
}
wg.Wait()
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler {
return ec.___Type(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
ret := make(graphql.Array, len(v))
var wg sync.WaitGroup
isLen1 := len(v) == 1
if !isLen1 {
wg.Add(len(v))
}
for i := range v {
i := i
fc := &graphql.FieldContext{
Index: &i,
Result: &v[i],
}
ctx := graphql.WithFieldContext(ctx, fc)
f := func(i int) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = nil
}
}()
if !isLen1 {
defer wg.Done()
}
ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i])
}
if isLen1 {
f(i)
} else {
go f(i)
}
}
wg.Wait()
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "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 any) (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 any) (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 any) (*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 any) (*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ᚋ99designsᚋ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ᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := make(graphql.Array, len(v))
var wg sync.WaitGroup
isLen1 := len(v) == 1
if !isLen1 {
wg.Add(len(v))
}
for i := range v {
i := i
fc := &graphql.FieldContext{
Index: &i,
Result: &v[i],
}
ctx := graphql.WithFieldContext(ctx, fc)
f := func(i int) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = nil
}
}()
if !isLen1 {
defer wg.Done()
}
ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i])
}
if isLen1 {
f(i)
} else {
go f(i)
}
}
wg.Wait()
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := make(graphql.Array, len(v))
var wg sync.WaitGroup
isLen1 := len(v) == 1
if !isLen1 {
wg.Add(len(v))
}
for i := range v {
i := i
fc := &graphql.FieldContext{
Index: &i,
Result: &v[i],
}
ctx := graphql.WithFieldContext(ctx, fc)
f := func(i int) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = nil
}
}()
if !isLen1 {
defer wg.Done()
}
ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i])
}
if isLen1 {
f(i)
} else {
go f(i)
}
}
wg.Wait()
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := make(graphql.Array, len(v))
var wg sync.WaitGroup
isLen1 := len(v) == 1
if !isLen1 {
wg.Add(len(v))
}
for i := range v {
i := i
fc := &graphql.FieldContext{
Index: &i,
Result: &v[i],
}
ctx := graphql.WithFieldContext(ctx, fc)
f := func(i int) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = nil
}
}()
if !isLen1 {
defer wg.Done()
}
ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i])
}
if isLen1 {
f(i)
} else {
go f(i)
}
}
wg.Wait()
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec.___Schema(ctx, sel, v)
}
func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := make(graphql.Array, len(v))
var wg sync.WaitGroup
isLen1 := len(v) == 1
if !isLen1 {
wg.Add(len(v))
}
for i := range v {
i := i
fc := &graphql.FieldContext{
Index: &i,
Result: &v[i],
}
ctx := graphql.WithFieldContext(ctx, fc)
f := func(i int) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = nil
}
}()
if !isLen1 {
defer wg.Done()
}
ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i])
}
if isLen1 {
f(i)
} else {
go f(i)
}
}
wg.Wait()
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec.___Type(ctx, sel, v)
}
// endregion ***************************** type.gotpl *****************************
================================================
FILE: plugin/resolvergen/testdata/return_values/model.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package return_values
type User struct {
ID string `json:"id"`
Name string `json:"name"`
}
================================================
FILE: plugin/resolvergen/testdata/return_values/resolvers.go
================================================
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 }
================================================
FILE: plugin/resolvergen/testdata/return_values/return_values_test.go
================================================
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())
}
================================================
FILE: plugin/resolvergen/testdata/return_values/schema.graphqls
================================================
type User {
id: ID!
name: String!
}
type Query {
user: User!
userPointer: User
}
================================================
FILE: plugin/resolvergen/testdata/schema.graphql
================================================
type Query {
resolver: Resolver!
}
type Resolver {
name: String!
}
================================================
FILE: plugin/resolvergen/testdata/singlefile/gqlgen.yml
================================================
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
preserve_resolver: false
models:
Resolver:
model: github.com/99designs/gqlgen/plugin/resolvergen/testdata/singlefile/out.Resolver
omit_gqlgen_version_in_file_notice: true
================================================
FILE: plugin/resolvergen/testdata/singlefile/out/model.go
================================================
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)
}
================================================
FILE: plugin/resolvergen/testdata/singlefile/out/resolver.go
================================================
package customresolver
// THIS CODE WILL BE UPDATED WITH SCHEMA CHANGES. PREVIOUS IMPLEMENTATION FOR SCHEMA CHANGES WILL BE KEPT IN THE COMMENT SECTION. IMPLEMENTATION FOR UNCHANGED SCHEMA WILL BE KEPT.
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 }
================================================
FILE: plugin/resolvergen/testdata/singlefile_preserve/gqlgen.yml
================================================
schema:
- "testdata/schema.graphql"
exec:
filename: testdata/singlefile_preserve/out/ignored.go
model:
filename: testdata/singlefile_preserve/out/generated.go
resolver:
filename: testdata/singlefile_preserve/out/resolver.go
type: CustomResolverType
preserve_resolver: true
models:
Resolver:
model: github.com/99designs/gqlgen/plugin/resolvergen/testdata/singlefile_preserve/out.Resolver
omit_gqlgen_version_in_file_notice: true
================================================
FILE: plugin/resolvergen/testdata/singlefile_preserve/out/model.go
================================================
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)
}
================================================
FILE: plugin/resolvergen/testdata/singlefile_preserve/out/resolver.go
================================================
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 }
================================================
FILE: plugin/servergen/server.go
================================================
package servergen
import (
_ "embed"
"errors"
"io/fs"
"log"
"os"
"github.com/99designs/gqlgen/codegen"
"github.com/99designs/gqlgen/codegen/templates"
"github.com/99designs/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,
PruneOptions: data.Config.GetPruneOptions(),
})
}
log.Printf("Skipped server: %s already exists\n", m.filename)
return nil
}
type ServerBuild struct {
codegen.Data
ExecPackageName string
ResolverPackageName string
}
================================================
FILE: plugin/servergen/server.gotpl
================================================
{{ reserveImport "context" }}
{{ reserveImport "log" }}
{{ reserveImport "net/http" }}
{{ reserveImport "os" }}
{{ reserveImport "github.com/vektah/gqlparser/v2/ast" }}
{{ reserveImport "github.com/99designs/gqlgen/graphql/playground" }}
{{ reserveImport "github.com/99designs/gqlgen/graphql/handler" }}
{{ reserveImport "github.com/99designs/gqlgen/graphql/handler/extension" }}
{{ reserveImport "github.com/99designs/gqlgen/graphql/handler/lru" }}
{{ reserveImport "github.com/99designs/gqlgen/graphql/handler/transport" }}
const defaultPort = "8080"
func main() {
port := os.Getenv("PORT")
if port == "" {
port = defaultPort
}
srv := handler.New({{ lookupImport .ExecPackageName }}.NewExecutableSchema({{ lookupImport .ExecPackageName}}.Config{Resolvers: &{{ lookupImport .ResolverPackageName}}.Resolver{}}))
srv.AddTransport(transport.Options{})
srv.AddTransport(transport.GET{})
srv.AddTransport(transport.POST{})
srv.SetQueryCache(lru.New[*ast.QueryDocument](1000))
srv.Use(extension.Introspection{})
srv.Use(extension.AutomaticPersistedQuery{
Cache: lru.New[string](100),
})
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))
}
================================================
FILE: plugin/stubgen/stubs.go
================================================
package stubgen
import (
_ "embed"
"path/filepath"
"syscall"
"github.com/99designs/gqlgen/codegen"
"github.com/99designs/gqlgen/codegen/config"
"github.com/99designs/gqlgen/codegen/templates"
"github.com/99designs/gqlgen/internal/code"
"github.com/99designs/gqlgen/plugin"
)
//go:embed stubs.gotpl
var stubsTemplate string
func New(filename, 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,
PruneOptions: data.Config.GetPruneOptions(),
})
}
type ResolverBuild struct {
*codegen.Data
TypeName string
}
================================================
FILE: plugin/stubgen/stubs.gotpl
================================================
{{ 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/99designs/gqlgen/graphql" }}
{{ reserveImport "github.com/99designs/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}}{{ if $field.Args }} {{$field.StubCallArgs}}{{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 }}
================================================
FILE: testdata/entitydirectives/generated/exec.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package generated
import (
"bytes"
"context"
"errors"
"fmt"
"strconv"
"sync"
"sync/atomic"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/introspection"
"github.com/99designs/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 {
}
type DirectiveRoot struct {
}
type ComplexityRoot struct {
Query struct {
__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(ctx context.Context, typeName, field string, childComplexity int, rawArgs map[string]any) (int, bool) {
ec := executionContext{nil, e, 0, 0, nil}
_ = ec
switch typeName + "." + field {
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 {
opCtx := graphql.GetOperationContext(ctx)
ec := executionContext{opCtx, e, 0, 0, make(chan graphql.DeferredResult)}
inputUnmarshalMap := graphql.BuildUnmarshalerMap()
first := true
switch opCtx.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, opCtx.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: "../../../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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalNString2string)
if err != nil {
return nil, err
}
args["name"] = arg0
return args, nil
}
func (ec *executionContext) field___Directive_args_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2ᚖbool)
if err != nil {
return nil, err
}
args["includeDeprecated"] = arg0
return args, nil
}
func (ec *executionContext) field___Field_args_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2ᚖbool)
if err != nil {
return nil, err
}
args["includeDeprecated"] = arg0
return args, nil
}
func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2bool)
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]any) (map[string]any, error) {
var err error
args := map[string]any{}
arg0, err := graphql.ProcessArgField(ctx, rawArgs, "includeDeprecated", ec.unmarshalOBoolean2bool)
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__service(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query__service,
func(ctx context.Context) (any, error) {
return ec.__resolve__service(ctx)
},
nil,
ec.marshalN_Service2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService,
true,
true,
)
}
func (ec *executionContext) fieldContext_Query__service(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query___type,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return ec.introspectType(fc.Args["name"].(string))
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext_Query___schema,
func(ctx context.Context) (any, error) {
return ec.introspectSchema()
},
nil,
ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema,
true,
false,
)
}
func (ec *executionContext) fieldContext_Query___schema(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext__Service_sdl,
func(ctx context.Context) (any, error) {
return obj.SDL, nil
},
nil,
ec.marshalOString2string,
true,
false,
)
}
func (ec *executionContext) fieldContext__Service_sdl(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Directive_description(_ 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_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_isRepeatable,
func(ctx context.Context) (any, error) {
return obj.IsRepeatable, nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_isRepeatable(_ 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) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_locations,
func(ctx context.Context) (any, error) {
return obj.Locations, nil
},
nil,
ec.marshalN__DirectiveLocation2ᚕstringᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Directive_locations(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Directive_args,
func(ctx context.Context) (any, error) {
return obj.Args, nil
},
nil,
ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
true,
)
}
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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __InputValue", 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___Directive_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___EnumValue_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___EnumValue_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___EnumValue_isDeprecated(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___EnumValue_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___EnumValue_deprecationReason(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Field_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_args,
func(ctx context.Context) (any, error) {
return obj.Args, nil
},
nil,
ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
true,
)
}
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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __InputValue", 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___Field_args_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_type,
func(ctx context.Context) (any, error) {
return obj.Type, nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_type(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___Field_isDeprecated(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Field_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Field_deprecationReason(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_name,
func(ctx context.Context) (any, error) {
return obj.Name, nil
},
nil,
ec.marshalNString2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_type,
func(ctx context.Context) (any, error) {
return obj.Type, nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_type(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_defaultValue,
func(ctx context.Context) (any, error) {
return obj.DefaultValue, nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_defaultValue(_ 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_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_isDeprecated,
func(ctx context.Context) (any, error) {
return obj.IsDeprecated(), nil
},
nil,
ec.marshalNBoolean2bool,
true,
true,
)
}
func (ec *executionContext) fieldContext___InputValue_isDeprecated(_ 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 Boolean does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) ___InputValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___InputValue_deprecationReason,
func(ctx context.Context) (any, error) {
return obj.DeprecationReason(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___InputValue_deprecationReason(_ 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) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_description(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_types,
func(ctx context.Context) (any, error) {
return obj.Types(), nil
},
nil,
ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_types(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_queryType,
func(ctx context.Context) (any, error) {
return obj.QueryType(), nil
},
nil,
ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_queryType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_mutationType,
func(ctx context.Context) (any, error) {
return obj.MutationType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_mutationType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_subscriptionType,
func(ctx context.Context) (any, error) {
return obj.SubscriptionType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Schema_subscriptionType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Schema_directives,
func(ctx context.Context) (any, error) {
return obj.Directives(), nil
},
nil,
ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ,
true,
true,
)
}
func (ec *executionContext) fieldContext___Schema_directives(_ 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 "isRepeatable":
return ec.fieldContext___Directive_isRepeatable(ctx, field)
case "locations":
return ec.fieldContext___Directive_locations(ctx, field)
case "args":
return ec.fieldContext___Directive_args(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_kind,
func(ctx context.Context) (any, error) {
return obj.Kind(), nil
},
nil,
ec.marshalN__TypeKind2string,
true,
true,
)
}
func (ec *executionContext) fieldContext___Type_kind(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_name,
func(ctx context.Context) (any, error) {
return obj.Name(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_name(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_description,
func(ctx context.Context) (any, error) {
return obj.Description(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_description(_ 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_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_specifiedByURL,
func(ctx context.Context) (any, error) {
return obj.SpecifiedByURL(), nil
},
nil,
ec.marshalOString2ᚖstring,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_specifiedByURL(_ 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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_fields,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil
},
nil,
ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_interfaces,
func(ctx context.Context) (any, error) {
return obj.Interfaces(), nil
},
nil,
ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_interfaces(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_possibleTypes,
func(ctx context.Context) (any, error) {
return obj.PossibleTypes(), nil
},
nil,
ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_possibleTypes(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_enumValues,
func(ctx context.Context) (any, error) {
fc := graphql.GetFieldContext(ctx)
return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil
},
nil,
ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ,
true,
false,
)
}
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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_inputFields,
func(ctx context.Context) (any, error) {
return obj.InputFields(), nil
},
nil,
ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_inputFields(_ 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)
case "isDeprecated":
return ec.fieldContext___InputValue_isDeprecated(ctx, field)
case "deprecationReason":
return ec.fieldContext___InputValue_deprecationReason(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) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_ofType,
func(ctx context.Context) (any, error) {
return obj.OfType(), nil
},
nil,
ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_ofType(_ 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 "specifiedByURL":
return ec.fieldContext___Type_specifiedByURL(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 "isOneOf":
return ec.fieldContext___Type_isOneOf(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name)
},
}
return fc, nil
}
func (ec *executionContext) ___Type_isOneOf(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) {
return graphql.ResolveField(
ctx,
ec.OperationContext,
field,
ec.fieldContext___Type_isOneOf,
func(ctx context.Context) (any, error) {
return obj.IsOneOf(), nil
},
nil,
ec.marshalOBoolean2bool,
true,
false,
)
}
func (ec *executionContext) fieldContext___Type_isOneOf(_ 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 Boolean 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 "_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 "isRepeatable":
out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
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++
}
default:
panic("unknown field " + strconv.Quote(field.Name))
}
}
out.Dispatch(ctx)
if out.Invalids > 0 {
return graphql.Null
}
atomic.AddInt32(&ec.deferred, int32(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)
case "isDeprecated":
out.Values[i] = ec.___InputValue_isDeprecated(ctx, field, obj)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "deprecationReason":
out.Values[i] = ec.___InputValue_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 __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 "specifiedByURL":
out.Values[i] = ec.___Type_specifiedByURL(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 "isOneOf":
out.Values[i] = ec.___Type_isOneOf(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 any) (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 {
_ = sel
res := graphql.MarshalBoolean(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalNString2string(ctx context.Context, v any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalN_FieldSet2string(ctx context.Context, v any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) marshalN_Service2githubᚗcomᚋ99designsᚋ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ᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler {
return ec.___Directive(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler {
ret := make(graphql.Array, len(v))
var wg sync.WaitGroup
isLen1 := len(v) == 1
if !isLen1 {
wg.Add(len(v))
}
for i := range v {
i := i
fc := &graphql.FieldContext{
Index: &i,
Result: &v[i],
}
ctx := graphql.WithFieldContext(ctx, fc)
f := func(i int) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = nil
}
}()
if !isLen1 {
defer wg.Done()
}
ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i])
}
if isLen1 {
f(i)
} else {
go f(i)
}
}
wg.Wait()
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v any) ([]string, error) {
var vSlice []any
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ᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler {
return ec.___EnumValue(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler {
return ec.___Field(ctx, sel, &v)
}
func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler {
return ec.___InputValue(ctx, sel, &v)
}
func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
ret := make(graphql.Array, len(v))
var wg sync.WaitGroup
isLen1 := len(v) == 1
if !isLen1 {
wg.Add(len(v))
}
for i := range v {
i := i
fc := &graphql.FieldContext{
Index: &i,
Result: &v[i],
}
ctx := graphql.WithFieldContext(ctx, fc)
f := func(i int) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = nil
}
}()
if !isLen1 {
defer wg.Done()
}
ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i])
}
if isLen1 {
f(i)
} else {
go f(i)
}
}
wg.Wait()
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler {
return ec.___Type(ctx, sel, &v)
}
func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
ret := make(graphql.Array, len(v))
var wg sync.WaitGroup
isLen1 := len(v) == 1
if !isLen1 {
wg.Add(len(v))
}
for i := range v {
i := i
fc := &graphql.FieldContext{
Index: &i,
Result: &v[i],
}
ctx := graphql.WithFieldContext(ctx, fc)
f := func(i int) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = nil
}
}()
if !isLen1 {
defer wg.Done()
}
ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i])
}
if isLen1 {
f(i)
} else {
go f(i)
}
}
wg.Wait()
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(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 any) (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 {
_ = sel
res := graphql.MarshalString(v)
if res == graphql.Null {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow")
}
}
return res
}
func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v any) (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 {
_ = sel
_ = ctx
res := graphql.MarshalBoolean(v)
return res
}
func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v any) (*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
}
_ = sel
_ = ctx
res := graphql.MarshalBoolean(*v)
return res
}
func (ec *executionContext) unmarshalOString2string(ctx context.Context, v any) (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 {
_ = sel
_ = ctx
res := graphql.MarshalString(v)
return res
}
func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v any) (*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
}
_ = sel
_ = ctx
res := graphql.MarshalString(*v)
return res
}
func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := make(graphql.Array, len(v))
var wg sync.WaitGroup
isLen1 := len(v) == 1
if !isLen1 {
wg.Add(len(v))
}
for i := range v {
i := i
fc := &graphql.FieldContext{
Index: &i,
Result: &v[i],
}
ctx := graphql.WithFieldContext(ctx, fc)
f := func(i int) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = nil
}
}()
if !isLen1 {
defer wg.Done()
}
ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i])
}
if isLen1 {
f(i)
} else {
go f(i)
}
}
wg.Wait()
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := make(graphql.Array, len(v))
var wg sync.WaitGroup
isLen1 := len(v) == 1
if !isLen1 {
wg.Add(len(v))
}
for i := range v {
i := i
fc := &graphql.FieldContext{
Index: &i,
Result: &v[i],
}
ctx := graphql.WithFieldContext(ctx, fc)
f := func(i int) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = nil
}
}()
if !isLen1 {
defer wg.Done()
}
ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i])
}
if isLen1 {
f(i)
} else {
go f(i)
}
}
wg.Wait()
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := make(graphql.Array, len(v))
var wg sync.WaitGroup
isLen1 := len(v) == 1
if !isLen1 {
wg.Add(len(v))
}
for i := range v {
i := i
fc := &graphql.FieldContext{
Index: &i,
Result: &v[i],
}
ctx := graphql.WithFieldContext(ctx, fc)
f := func(i int) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = nil
}
}()
if !isLen1 {
defer wg.Done()
}
ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i])
}
if isLen1 {
f(i)
} else {
go f(i)
}
}
wg.Wait()
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec.___Schema(ctx, sel, v)
}
func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler {
if v == nil {
return graphql.Null
}
ret := make(graphql.Array, len(v))
var wg sync.WaitGroup
isLen1 := len(v) == 1
if !isLen1 {
wg.Add(len(v))
}
for i := range v {
i := i
fc := &graphql.FieldContext{
Index: &i,
Result: &v[i],
}
ctx := graphql.WithFieldContext(ctx, fc)
f := func(i int) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = nil
}
}()
if !isLen1 {
defer wg.Done()
}
ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i])
}
if isLen1 {
f(i)
} else {
go f(i)
}
}
wg.Wait()
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec.___Type(ctx, sel, v)
}
// endregion ***************************** type.gotpl *****************************
================================================
FILE: testdata/entitydirectives/generated/federation.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package generated
import (
"context"
"errors"
"strings"
"github.com/99designs/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
}
================================================
FILE: testdata/entitydirectives/generated/models_gen.go
================================================
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
package generated
type Query struct {
}
================================================
FILE: testdata/gomod-with-leading-comments.mod
================================================
// main module of gqlgen
// and another module to test stripping of comment lines
module github.com/99designs/gqlgen // replace it for new project
go 1.18
================================================
FILE: testdata/gqlgen.go
================================================
package main
import (
"flag"
"fmt"
"io"
"log"
"os"
"time"
"github.com/99designs/gqlgen/api"
"github.com/99designs/gqlgen/codegen/config"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/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())
}