Repository: 99designs/gqlgen Branch: master Commit: 82bf8457f1df Files: 1166 Total size: 9.8 MB Directory structure: gitextract_fuc86lff/ ├── .chglog/ │ ├── CHANGELOG-full-history.tpl.md │ └── config.yml ├── .dockerignore ├── .editorconfig ├── .gitattributes ├── .github/ │ ├── CODEOWNERS │ ├── ISSUE_TEMPLATE.md │ ├── PULL_REQUEST_TEMPLATE.md │ ├── dependabot.yml │ ├── fmt-actions.sh │ ├── fmt-md.sh │ ├── lint-actions.sh │ ├── linters/ │ │ ├── .editorconfig-checker.json │ │ ├── .hadolint.yaml │ │ ├── .markdownlint.json │ │ ├── .markdownlint.yml │ │ ├── .shellcheckrc │ │ ├── .yamlfmt.yaml │ │ ├── .yamllint.yaml │ │ └── actionlint.yaml │ ├── pin-actions.sh │ └── workflows/ │ ├── GOVERSION.txt │ ├── actionlint.yaml │ ├── check-coverage │ ├── check-federation │ ├── check-fmt │ ├── check-generate │ ├── check-gomod.sh │ ├── check-init │ ├── check-integration │ ├── coverage.yml │ ├── fmt-and-generate.yml │ ├── gomod-clean.yml │ ├── integration.yml │ ├── lint.yml │ ├── report.yml │ ├── security.yml │ └── test.yml ├── .gitignore ├── .golangci.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── RELEASE-CHECKLIST.md ├── TESTING.md ├── _examples/ │ ├── batchresolver/ │ │ ├── batchresolver_test.go │ │ ├── generate.go │ │ ├── generated.go │ │ ├── gqlgen.yml │ │ ├── models_gen.go │ │ ├── readme.md │ │ ├── resolver.go │ │ ├── resolver_helpers.go │ │ ├── schema.graphql │ │ └── schema.resolvers.go │ ├── chat/ │ │ ├── .gitignore │ │ ├── .gqlgen.yml │ │ ├── chat_test.go │ │ ├── generated.go │ │ ├── models_gen.go │ │ ├── package.json │ │ ├── public/ │ │ │ └── index.html │ │ ├── readme.md │ │ ├── resolvers.go │ │ ├── schema.graphql │ │ ├── server/ │ │ │ └── server.go │ │ ├── src/ │ │ │ ├── App.js │ │ │ ├── Room.js │ │ │ ├── components/ │ │ │ │ └── room.js │ │ │ ├── graphql-sse.ts │ │ │ ├── graphql-ws.js │ │ │ ├── index.js │ │ │ └── react-app-env.d.ts │ │ └── tsconfig.json │ ├── config/ │ │ ├── .gqlgen.yml │ │ ├── generated.go │ │ ├── model.go │ │ ├── models_gen.go │ │ ├── resolver.go │ │ ├── schema.graphql │ │ ├── schema.resolvers.go │ │ ├── server/ │ │ │ └── server.go │ │ ├── todo.graphql │ │ ├── todo.resolvers.go │ │ ├── user.graphql │ │ └── user.resolvers.go │ ├── contextpropagation/ │ │ ├── generated.go │ │ ├── gqlgen.yml │ │ ├── models_gen.go │ │ ├── schema.graphql │ │ ├── todo.go │ │ └── todo_test.go │ ├── dataloader/ │ │ ├── .gqlgen.yml │ │ ├── addressloader_gen.go │ │ ├── dataloader_test.go │ │ ├── dataloaders.go │ │ ├── generated.go │ │ ├── itemsliceloader_gen.go │ │ ├── models_gen.go │ │ ├── ordersliceloader_gen.go │ │ ├── readme.md │ │ ├── resolvers.go │ │ ├── schema.graphql │ │ └── server/ │ │ └── server.go │ ├── deferexample/ │ │ ├── generated.go │ │ ├── gqlgen.yml │ │ ├── models_gen.go │ │ ├── resolver.go │ │ ├── schema.graphql │ │ ├── schema.resolvers.go │ │ └── server/ │ │ └── server.go │ ├── embedding/ │ │ ├── parent.graphqls │ │ └── subdir/ │ │ ├── cfgdir/ │ │ │ ├── generate_in_gendir.yml │ │ │ └── generate_in_subdir.yml │ │ ├── directives.generated.go │ │ ├── embedding_test.go │ │ ├── entity.generated.go │ │ ├── federation_gen.go │ │ ├── gendir/ │ │ │ ├── federation_gen.go │ │ │ ├── generated.go │ │ │ └── model.go │ │ ├── model.go │ │ ├── prelude.generated.go │ │ ├── resolvers.go │ │ ├── root.generated.go │ │ ├── root_.generated.go │ │ ├── schemadir/ │ │ │ └── root.graphqls │ │ └── subdir.graphqls │ ├── enum/ │ │ ├── api/ │ │ │ ├── enum.go │ │ │ ├── exec.go │ │ │ ├── model.go │ │ │ └── resolver.go │ │ ├── cmd/ │ │ │ └── main.go │ │ ├── enum.graphqls │ │ ├── gen.go │ │ ├── gqlgen.yaml │ │ └── model/ │ │ └── model.go │ ├── federation/ │ │ ├── accounts/ │ │ │ ├── gqlgen.yml │ │ │ ├── graph/ │ │ │ │ ├── entity.resolvers.go │ │ │ │ ├── federation.go │ │ │ │ ├── generated.go │ │ │ │ ├── model/ │ │ │ │ │ ├── model.go │ │ │ │ │ └── models_gen.go │ │ │ │ ├── resolver.go │ │ │ │ ├── schema.graphqls │ │ │ │ └── schema.resolvers.go │ │ │ ├── schema/ │ │ │ │ └── schema.go │ │ │ └── server.go │ │ ├── all/ │ │ │ └── main.go │ │ ├── package.json │ │ ├── products/ │ │ │ ├── gqlgen.yml │ │ │ ├── graph/ │ │ │ │ ├── entity.resolvers.go │ │ │ │ ├── federation.go │ │ │ │ ├── generated.go │ │ │ │ ├── model/ │ │ │ │ │ ├── model.go │ │ │ │ │ └── models_gen.go │ │ │ │ ├── products.go │ │ │ │ ├── resolver.go │ │ │ │ ├── schema.graphqls │ │ │ │ └── schema.resolvers.go │ │ │ ├── schema/ │ │ │ │ └── schema.go │ │ │ └── server.go │ │ ├── readme.md │ │ ├── reviews/ │ │ │ ├── gqlgen.yml │ │ │ ├── graph/ │ │ │ │ ├── entity.resolvers.go │ │ │ │ ├── federation.go │ │ │ │ ├── generated.go │ │ │ │ ├── model/ │ │ │ │ │ ├── models.go │ │ │ │ │ └── models_gen.go │ │ │ │ ├── resolver.go │ │ │ │ ├── reviews.go │ │ │ │ ├── schema.graphqls │ │ │ │ └── schema.resolvers.go │ │ │ ├── schema/ │ │ │ │ └── schema.go │ │ │ └── server.go │ │ ├── src/ │ │ │ ├── __test__/ │ │ │ │ └── integration.spec.ts │ │ │ └── gateway/ │ │ │ └── index.ts │ │ ├── start.sh │ │ ├── subgraphs/ │ │ │ └── subgraphs.go │ │ └── tsconfig.json │ ├── fileupload/ │ │ ├── .gqlgen.yml │ │ ├── fileupload_test.go │ │ ├── generated.go │ │ ├── model/ │ │ │ └── generated.go │ │ ├── readme.md │ │ ├── schema.graphql │ │ ├── server/ │ │ │ └── server.go │ │ ├── stubs.go │ │ └── testfiles/ │ │ ├── a.txt │ │ ├── b.txt │ │ └── c.txt │ ├── go.mod │ ├── go.sum │ ├── large-project-structure/ │ │ ├── integration/ │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── integration.go │ │ │ └── schema.graphqls │ │ ├── main/ │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── gqlgen.yml │ │ │ ├── graph/ │ │ │ │ ├── generated.go │ │ │ │ ├── model/ │ │ │ │ │ └── models_gen.go │ │ │ │ ├── resolver.go │ │ │ │ ├── schema.graphqls │ │ │ │ └── schema.resolvers.go │ │ │ ├── server.go │ │ │ └── tools.go │ │ └── shared/ │ │ ├── go.mod │ │ ├── go.sum │ │ ├── schema.graphqls │ │ └── shared.go │ ├── mini-habr-with-subscriptions/ │ │ ├── Dockerfile │ │ ├── README.md │ │ ├── cmd/ │ │ │ ├── db_connection/ │ │ │ │ ├── cache.go │ │ │ │ └── database.go │ │ │ ├── main.go │ │ │ └── server/ │ │ │ └── server.go │ │ ├── docker-compose.yml │ │ ├── go.mod │ │ ├── go.sum │ │ ├── gqlgen.yml │ │ ├── graph/ │ │ │ ├── generated.go │ │ │ ├── model/ │ │ │ │ └── models_gen.go │ │ │ ├── resolver.go │ │ │ ├── schema.graphqls │ │ │ ├── schema.resolvers.go │ │ │ └── subscription.go │ │ ├── internal/ │ │ │ ├── handlers/ │ │ │ │ ├── comment_mutation/ │ │ │ │ │ ├── interface.go │ │ │ │ │ └── mutations.go │ │ │ │ ├── comment_query/ │ │ │ │ │ ├── interface.go │ │ │ │ │ └── query.go │ │ │ │ ├── post_mutation/ │ │ │ │ │ ├── interface.go │ │ │ │ │ └── mutations.go │ │ │ │ └── post_query/ │ │ │ │ ├── interface.go │ │ │ │ └── query.go │ │ │ ├── model/ │ │ │ │ └── model.go │ │ │ ├── pkg/ │ │ │ │ ├── cursor/ │ │ │ │ │ └── cursor.go │ │ │ │ └── errs/ │ │ │ │ └── errors.go │ │ │ └── storage/ │ │ │ ├── db/ │ │ │ │ └── resolvers.go │ │ │ ├── in-memory/ │ │ │ │ └── resolvers.go │ │ │ └── interface.go │ │ ├── migrations/ │ │ │ └── 001_create_tables.up.sql │ │ └── tools/ │ │ └── tools.go │ ├── readme.md │ ├── scalars/ │ │ ├── .gqlgen.yml │ │ ├── external/ │ │ │ └── model.go │ │ ├── generated.go │ │ ├── model/ │ │ │ ├── generated.go │ │ │ └── model.go │ │ ├── resolvers.go │ │ ├── scalar_test.go │ │ ├── schema.graphql │ │ └── server/ │ │ └── server.go │ ├── selection/ │ │ ├── .gqlgen.yml │ │ ├── generated.go │ │ ├── models_gen.go │ │ ├── readme.md │ │ ├── schema.graphql │ │ ├── selection.go │ │ ├── selection_test.go │ │ └── server/ │ │ └── server.go │ ├── starwars/ │ │ ├── .gqlgen.yml │ │ ├── benchmarks_test.go │ │ ├── generated/ │ │ │ └── exec.go │ │ ├── models/ │ │ │ ├── generated.go │ │ │ └── model.go │ │ ├── readme.md │ │ ├── resolvers.go │ │ ├── schema.graphql │ │ ├── server/ │ │ │ └── server.go │ │ └── starwars_test.go │ ├── todo/ │ │ ├── generated.go │ │ ├── gqlgen.yml │ │ ├── models.go │ │ ├── models_gen.go │ │ ├── readme.md │ │ ├── schema.graphql │ │ ├── server/ │ │ │ └── server.go │ │ ├── todo.go │ │ └── todo_test.go │ ├── tools.go │ ├── type-system-extension/ │ │ ├── README.md │ │ ├── directive.go │ │ ├── generated.go │ │ ├── gqlgen.yml │ │ ├── models_gen.go │ │ ├── resolver.go │ │ ├── schemas/ │ │ │ ├── enum-extension.graphql │ │ │ ├── input-object-extension.graphql │ │ │ ├── interface-extension.graphql │ │ │ ├── object-extension.graphql │ │ │ ├── scalar-extension.graphql │ │ │ ├── schema-extension.graphql │ │ │ ├── schema.graphql │ │ │ ├── type-extension.graphql │ │ │ └── union-extension.graphql │ │ └── server/ │ │ └── server.go │ ├── union-extension/ │ │ ├── .gqlgen.yml │ │ ├── generated.go │ │ ├── models.go │ │ ├── models_gen.go │ │ ├── readme.md │ │ ├── schema.graphql │ │ ├── server/ │ │ │ └── server.go │ │ ├── union_extension.go │ │ └── union_extension_test.go │ ├── uuid/ │ │ ├── gqlgen.yml │ │ ├── graph/ │ │ │ ├── generated.go │ │ │ ├── model/ │ │ │ │ └── models_gen.go │ │ │ ├── resolver.go │ │ │ ├── schema.graphqls │ │ │ └── schema.resolvers.go │ │ └── server.go │ └── websocket-initfunc/ │ ├── graph/ │ │ ├── generated.go │ │ ├── model/ │ │ │ └── models_gen.go │ │ └── resolver.go │ └── server/ │ ├── Makefile │ ├── go.mod │ ├── go.sum │ ├── gqlgen.yml │ ├── graph/ │ │ ├── generated.go │ │ ├── model/ │ │ │ └── models_gen.go │ │ ├── resolver.go │ │ ├── schema.graphqls │ │ └── schema.resolvers.go │ ├── readme.md │ └── server.go ├── api/ │ ├── generate.go │ ├── generate_test.go │ ├── option.go │ ├── option_test.go │ └── testdata/ │ ├── default/ │ │ ├── gqlgen.yml │ │ └── graph/ │ │ ├── model/ │ │ │ └── doc.go │ │ └── schema.graphqls │ ├── federation2/ │ │ ├── gqlgen.yml │ │ └── graph/ │ │ ├── model/ │ │ │ └── doc.go │ │ └── schema.graphqls │ └── workerlimit/ │ ├── gqlgen.yml │ └── graph/ │ ├── model/ │ │ └── doc.go │ └── schema.graphqls ├── bin/ │ ├── _tools/ │ │ ├── apollo-sandbox-sri/ │ │ │ ├── README.md │ │ │ └── main.go │ │ └── go.mod │ ├── fmt.sh │ ├── release │ └── update_gqlparser.sh ├── client/ │ ├── client.go │ ├── client_test.go │ ├── errors.go │ ├── incremental_http.go │ ├── options.go │ ├── readme.md │ ├── sse.go │ ├── websocket.go │ ├── withfilesoption.go │ └── withfilesoption_test.go ├── codegen/ │ ├── args.go │ ├── args.gotpl │ ├── autobind_test.go │ ├── complexity.go │ ├── config/ │ │ ├── binder.go │ │ ├── binder_test.go │ │ ├── config.go │ │ ├── config_directive_test.go │ │ ├── config_schema_json_test.go │ │ ├── config_test.go │ │ ├── exec.go │ │ ├── initialisms.go │ │ ├── initialisms_test.go │ │ ├── package.go │ │ ├── package_test.go │ │ ├── resolver.go │ │ ├── resolver_test.go │ │ └── testdata/ │ │ ├── autobinding/ │ │ │ ├── chat/ │ │ │ │ └── model.go │ │ │ ├── protomodel/ │ │ │ │ └── model.go │ │ │ └── scalars/ │ │ │ └── model/ │ │ │ └── model.go │ │ ├── binding/ │ │ │ └── model.go │ │ ├── cfg/ │ │ │ ├── glob/ │ │ │ │ ├── bar/ │ │ │ │ │ └── bar with spaces.graphql │ │ │ │ └── foo/ │ │ │ │ └── foo.graphql │ │ │ ├── glob.yml │ │ │ ├── goInitialisms.yml │ │ │ ├── gqlgen.yml │ │ │ ├── malformedconfig.yml │ │ │ ├── otherdir/ │ │ │ │ └── .gitkeep │ │ │ ├── outer │ │ │ ├── subdir/ │ │ │ │ ├── gqlgen.yaml │ │ │ │ └── inner │ │ │ ├── unknownkeys.yml │ │ │ └── unwalkable.yml │ │ ├── defaultconfig/ │ │ │ └── schema.graphql │ │ ├── enum/ │ │ │ └── model.go │ │ ├── example.go │ │ └── fuzz/ │ │ └── FuzzReadConfig/ │ │ └── d76a9a281aa1168d │ ├── data.go │ ├── data_test.go │ ├── depgraph.go │ ├── depgraph_test.go │ ├── directive.go │ ├── directive_test.go │ ├── directives.gotpl │ ├── field.go │ ├── field.gotpl │ ├── field_test.go │ ├── generate.go │ ├── generated!.gotpl │ ├── incremental.go │ ├── incremental_test.go │ ├── inline_arguments.go │ ├── inline_arguments_test.go │ ├── input.gotpl │ ├── interface.go │ ├── interface.gotpl │ ├── object.go │ ├── object.gotpl │ ├── root_.gotpl │ ├── templates/ │ │ ├── import.go │ │ ├── import_test.go │ │ ├── templates.go │ │ ├── templates_test.go │ │ ├── test.gotpl │ │ ├── test_.gotpl │ │ └── testdata/ │ │ ├── a/ │ │ │ └── bar/ │ │ │ └── bar.go │ │ ├── b/ │ │ │ └── bar/ │ │ │ └── bar.go │ │ └── pkg_mismatch/ │ │ └── turtles.go │ ├── testserver/ │ │ ├── benchmark/ │ │ │ ├── benchmark_test.go │ │ │ ├── generated/ │ │ │ │ ├── models/ │ │ │ │ │ └── models-gen.go │ │ │ │ ├── prelude.generated.go │ │ │ │ ├── resolvers/ │ │ │ │ │ └── resolver.go │ │ │ │ ├── root_.generated.go │ │ │ │ └── schema.generated.go │ │ │ ├── gqlgen.yml │ │ │ ├── schema.graphql │ │ │ └── stub.go │ │ ├── compliant-int/ │ │ │ ├── compliant_int_test.go │ │ │ ├── generated-compliant-strict/ │ │ │ │ ├── models.go │ │ │ │ ├── resolver.go │ │ │ │ ├── schema.go │ │ │ │ └── stub.go │ │ │ ├── generated-default/ │ │ │ │ ├── models.go │ │ │ │ ├── resolver.go │ │ │ │ ├── schema.go │ │ │ │ └── stub.go │ │ │ ├── gqlgen_compliant_strict.yml │ │ │ ├── gqlgen_default.yml │ │ │ └── schema.graphql │ │ ├── empty.go │ │ ├── followschema/ │ │ │ ├── builtinscalar.generated.go │ │ │ ├── builtinscalar.graphql │ │ │ ├── bytes.go │ │ │ ├── complexity.generated.go │ │ │ ├── complexity.graphql │ │ │ ├── complexity_test.go │ │ │ ├── defaults.generated.go │ │ │ ├── defaults.graphql │ │ │ ├── defaults_test.go │ │ │ ├── defer.generated.go │ │ │ ├── defer.graphql │ │ │ ├── directive.generated.go │ │ │ ├── directive.graphql │ │ │ ├── directive_test.go │ │ │ ├── embedded.generated.go │ │ │ ├── embedded.go │ │ │ ├── embedded.graphql │ │ │ ├── embedded_test.go │ │ │ ├── enum.generated.go │ │ │ ├── enum.graphql │ │ │ ├── enums_test.go │ │ │ ├── fields_order.generated.go │ │ │ ├── fields_order.go │ │ │ ├── fields_order.graphql │ │ │ ├── fields_order_test.go │ │ │ ├── generated_test.go │ │ │ ├── gqlgen.yml │ │ │ ├── inline_arguments_error_test.go │ │ │ ├── inline_arguments_integration_test.go │ │ │ ├── inline_arguments_test.generated.go │ │ │ ├── inline_arguments_test.graphql │ │ │ ├── input_test.go │ │ │ ├── interfaces.generated.go │ │ │ ├── interfaces.go │ │ │ ├── interfaces.graphql │ │ │ ├── interfaces_test.go │ │ │ ├── introspection/ │ │ │ │ └── it.go │ │ │ ├── introspection_test.go │ │ │ ├── invalid-packagename/ │ │ │ │ └── invalid-identifier.go │ │ │ ├── issue4053.generated.go │ │ │ ├── issue4053.go │ │ │ ├── issue4053.graphql │ │ │ ├── issue896.generated.go │ │ │ ├── issue896.graphql │ │ │ ├── loops.generated.go │ │ │ ├── loops.graphql │ │ │ ├── map_nested_map_slice_test.go │ │ │ ├── maps.generated.go │ │ │ ├── maps.go │ │ │ ├── maps.graphql │ │ │ ├── maps_test.go │ │ │ ├── middleware_test.go │ │ │ ├── modelmethod_test.go │ │ │ ├── models-gen.go │ │ │ ├── models.go │ │ │ ├── mutation_with_custom_scalar.generated.go │ │ │ ├── mutation_with_custom_scalar.go │ │ │ ├── mutation_with_custom_scalar.graphql │ │ │ ├── mutation_with_custom_scalar_test.go │ │ │ ├── nulls.generated.go │ │ │ ├── nulls.graphql │ │ │ ├── nulls_test.go │ │ │ ├── otherpkg/ │ │ │ │ └── model.go │ │ │ ├── panics.generated.go │ │ │ ├── panics.graphql │ │ │ ├── panics_test.go │ │ │ ├── prelude.generated.go │ │ │ ├── primitive_objects.generated.go │ │ │ ├── primitive_objects.graphql │ │ │ ├── primitive_objects_test.go │ │ │ ├── ptr_to_any.generated.go │ │ │ ├── ptr_to_any.go │ │ │ ├── ptr_to_any.graphql │ │ │ ├── ptr_to_any_test.go │ │ │ ├── ptr_to_ptr_input.generated.go │ │ │ ├── ptr_to_ptr_input.go │ │ │ ├── ptr_to_ptr_input.graphql │ │ │ ├── ptr_to_ptr_input_test.go │ │ │ ├── ptr_to_slice.generated.go │ │ │ ├── ptr_to_slice.go │ │ │ ├── ptr_to_slice.graphql │ │ │ ├── ptr_to_slice_test.go │ │ │ ├── recursive.go │ │ │ ├── resolver.go │ │ │ ├── response_extension_test.go │ │ │ ├── root_.generated.go │ │ │ ├── scalar_context.generated.go │ │ │ ├── scalar_context.go │ │ │ ├── scalar_context.graphql │ │ │ ├── scalar_context_test.go │ │ │ ├── scalar_default.generated.go │ │ │ ├── scalar_default.graphql │ │ │ ├── scalar_default_test.go │ │ │ ├── schema.generated.go │ │ │ ├── schema.graphql │ │ │ ├── skip-include.generated.go │ │ │ ├── skip-include.graphql │ │ │ ├── slices.generated.go │ │ │ ├── slices.graphql │ │ │ ├── slices_test.go │ │ │ ├── stub.go │ │ │ ├── subscription_test.go │ │ │ ├── thirdparty.go │ │ │ ├── time_test.go │ │ │ ├── typefallback.generated.go │ │ │ ├── typefallback.graphql │ │ │ ├── typefallback_test.go │ │ │ ├── useptr.generated.go │ │ │ ├── useptr.graphql │ │ │ ├── useptr_test.go │ │ │ ├── v-ok.generated.go │ │ │ ├── v-ok.go │ │ │ ├── v-ok.graphql │ │ │ ├── v-ok_test.go │ │ │ ├── validtypes.generated.go │ │ │ ├── validtypes.graphql │ │ │ ├── validtypes_test.go │ │ │ ├── variadic.generated.go │ │ │ ├── variadic.go │ │ │ ├── variadic.graphql │ │ │ ├── weird_type_cases.generated.go │ │ │ ├── weird_type_cases.graphql │ │ │ ├── wrapped_type.generated.go │ │ │ ├── wrapped_type.go │ │ │ ├── wrapped_type.graphql │ │ │ └── wrapped_type_test.go │ │ ├── generated_test.go │ │ ├── nullabledirectives/ │ │ │ ├── directive.graphql │ │ │ ├── directive_test.go │ │ │ ├── generated/ │ │ │ │ ├── directive.generated.go │ │ │ │ ├── models/ │ │ │ │ │ └── models-gen.go │ │ │ │ ├── prelude.generated.go │ │ │ │ ├── resolvers/ │ │ │ │ │ └── resolver.go │ │ │ │ └── root_.generated.go │ │ │ ├── gqlgen.yml │ │ │ └── stub.go │ │ ├── protogetters/ │ │ │ ├── generated.go │ │ │ ├── gqlgen.yml │ │ │ ├── models/ │ │ │ │ └── user.go │ │ │ ├── models_gen.go │ │ │ ├── protogetters_test.go │ │ │ ├── resolver.go │ │ │ ├── schema.graphql │ │ │ ├── schema.resolvers.go │ │ │ └── stub.go │ │ ├── singlefile/ │ │ │ ├── builtinscalar.graphql │ │ │ ├── bytes.go │ │ │ ├── complexity.graphql │ │ │ ├── complexity_test.go │ │ │ ├── defaults.graphql │ │ │ ├── defaults_test.go │ │ │ ├── defer.graphql │ │ │ ├── defer_test.go │ │ │ ├── directive.graphql │ │ │ ├── directive_test.go │ │ │ ├── embedded.go │ │ │ ├── embedded.graphql │ │ │ ├── embedded_test.go │ │ │ ├── enum.graphql │ │ │ ├── enums_test.go │ │ │ ├── fields_order.go │ │ │ ├── fields_order.graphql │ │ │ ├── fields_order_test.go │ │ │ ├── generated.go │ │ │ ├── generated_test.go │ │ │ ├── gqlgen.yml │ │ │ ├── inline_arguments.graphql │ │ │ ├── input_test.go │ │ │ ├── interfaces.go │ │ │ ├── interfaces.graphql │ │ │ ├── interfaces_test.go │ │ │ ├── introspection/ │ │ │ │ └── it.go │ │ │ ├── introspection_test.go │ │ │ ├── invalid-packagename/ │ │ │ │ └── invalid-identifier.go │ │ │ ├── issue4053.go │ │ │ ├── issue4053.graphql │ │ │ ├── issue4053_test.go │ │ │ ├── issue896.graphql │ │ │ ├── loops.graphql │ │ │ ├── map_nested_map_slice_test.go │ │ │ ├── maps.go │ │ │ ├── maps.graphql │ │ │ ├── maps_test.go │ │ │ ├── middleware_test.go │ │ │ ├── modelmethod_test.go │ │ │ ├── models-gen.go │ │ │ ├── models.go │ │ │ ├── mutation_with_custom_scalar.go │ │ │ ├── mutation_with_custom_scalar.graphql │ │ │ ├── mutation_with_custom_scalar_test.go │ │ │ ├── nulls.graphql │ │ │ ├── nulls_test.go │ │ │ ├── otherpkg/ │ │ │ │ └── model.go │ │ │ ├── panics.graphql │ │ │ ├── panics_test.go │ │ │ ├── primitive_objects.graphql │ │ │ ├── primitive_objects_test.go │ │ │ ├── ptr_to_any.go │ │ │ ├── ptr_to_any.graphql │ │ │ ├── ptr_to_any_test.go │ │ │ ├── ptr_to_ptr_input.go │ │ │ ├── ptr_to_ptr_input.graphql │ │ │ ├── ptr_to_ptr_input_test.go │ │ │ ├── ptr_to_slice.go │ │ │ ├── ptr_to_slice.graphql │ │ │ ├── ptr_to_slice_test.go │ │ │ ├── recursive.go │ │ │ ├── resolver.go │ │ │ ├── response_extension_test.go │ │ │ ├── scalar_context.go │ │ │ ├── scalar_context.graphql │ │ │ ├── scalar_context_test.go │ │ │ ├── scalar_default.graphql │ │ │ ├── scalar_default_test.go │ │ │ ├── schema.graphql │ │ │ ├── skip-include.graphql │ │ │ ├── skip_include_test.go │ │ │ ├── slices.graphql │ │ │ ├── slices_test.go │ │ │ ├── stub.go │ │ │ ├── subscription_test.go │ │ │ ├── thirdparty.go │ │ │ ├── time_test.go │ │ │ ├── typefallback.graphql │ │ │ ├── typefallback_test.go │ │ │ ├── useptr.graphql │ │ │ ├── useptr_test.go │ │ │ ├── v-ok.go │ │ │ ├── v-ok.graphql │ │ │ ├── v-ok_test.go │ │ │ ├── validtypes.graphql │ │ │ ├── validtypes_test.go │ │ │ ├── variadic.go │ │ │ ├── variadic.graphql │ │ │ ├── variadic_test.go │ │ │ ├── weird_type_cases.graphql │ │ │ ├── wrapped_type.go │ │ │ ├── wrapped_type.graphql │ │ │ └── wrapped_type_test.go │ │ └── usefunctionsyntaxforexecutioncontext/ │ │ ├── directive.go │ │ ├── generated.go │ │ ├── generated_test.go │ │ ├── gqlgen.yml │ │ ├── models-gen.go │ │ ├── models.go │ │ ├── resolver.go │ │ ├── stub.go │ │ └── test.graphql │ ├── type.go │ ├── type.gotpl │ └── util.go ├── complexity/ │ ├── complexity.go │ ├── complexity_test.go │ └── option.go ├── docs/ │ ├── build.sh │ ├── config.yml │ ├── content/ │ │ ├── config.md │ │ ├── feature-comparison.md │ │ ├── getting-started.md │ │ ├── introduction.md │ │ ├── recipes/ │ │ │ ├── authentication.md │ │ │ ├── cors.md │ │ │ ├── enum.md │ │ │ ├── extra_fields.md │ │ │ ├── federation.md │ │ │ ├── gin.md │ │ │ ├── interfaces.md │ │ │ ├── migration-0.11.md │ │ │ ├── modelgen-hook.md │ │ │ └── subscriptions.md │ │ └── reference/ │ │ ├── apq.md │ │ ├── changesets.md │ │ ├── complexity.md │ │ ├── dataloaders.md │ │ ├── directives.md │ │ ├── errors.md │ │ ├── field-collection.md │ │ ├── file-upload.md │ │ ├── introspection.md │ │ ├── model-generation.md │ │ ├── name-collision.md │ │ ├── plugins.md │ │ ├── resolvers.md │ │ └── scalars.md │ ├── layouts/ │ │ ├── 404.html │ │ ├── _default/ │ │ │ ├── baseof.html │ │ │ └── single.html │ │ ├── index.html │ │ ├── partials/ │ │ │ ├── sidebar.html │ │ │ ├── version-banner.html │ │ │ └── version-switcher.html │ │ └── sitemap.xml │ ├── readme.md │ └── static/ │ ├── main.css │ ├── main.js │ └── syntax.css ├── go.mod ├── go.sum ├── gqlgen.schema.json ├── graphql/ │ ├── any.go │ ├── args.go │ ├── args_test.go │ ├── batch.go │ ├── batch_test.go │ ├── bool.go │ ├── bool_test.go │ ├── cache.go │ ├── cache_test.go │ ├── coercion.go │ ├── coercion_test.go │ ├── collect_fields_cache_integration_test.go │ ├── collect_fields_cache_store.go │ ├── config.go │ ├── context_field.go │ ├── context_field_test.go │ ├── context_operation.go │ ├── context_operation_test.go │ ├── context_path.go │ ├── context_path_test.go │ ├── context_response.go │ ├── context_response_test.go │ ├── context_root_field.go │ ├── context_root_field_test.go │ ├── deferred.go │ ├── duration.go │ ├── duration_test.go │ ├── errcode/ │ │ └── codes.go │ ├── error.go │ ├── executable_schema.go │ ├── executable_schema_mock.go │ ├── executable_schema_state.go │ ├── execution_context_state.go │ ├── execution_context_state_test.go │ ├── executor/ │ │ ├── executor.go │ │ ├── executor_test.go │ │ ├── extensions.go │ │ └── testexecutor/ │ │ └── testexecutor.go │ ├── fieldset.go │ ├── fieldset_test.go │ ├── float.go │ ├── float_test.go │ ├── handler/ │ │ ├── apollofederatedtracingv1/ │ │ │ ├── generated/ │ │ │ │ ├── apollo_trace.pb.go │ │ │ │ └── apollo_trace.proto │ │ │ ├── logger/ │ │ │ │ ├── logger.go │ │ │ │ └── logger_test.go │ │ │ ├── tracing.go │ │ │ ├── tracing_test.go │ │ │ └── tree_builder.go │ │ ├── apollotracing/ │ │ │ ├── tracer.go │ │ │ └── tracer_test.go │ │ ├── debug/ │ │ │ └── tracer.go │ │ ├── extension/ │ │ │ ├── apq.go │ │ │ ├── apq_test.go │ │ │ ├── complexity.go │ │ │ ├── complexity_test.go │ │ │ ├── introspection.go │ │ │ └── introspection_test.go │ │ ├── lru/ │ │ │ └── lru.go │ │ ├── server.go │ │ ├── server_test.go │ │ ├── testserver/ │ │ │ └── testserver.go │ │ └── transport/ │ │ ├── error.go │ │ ├── headers.go │ │ ├── headers_test.go │ │ ├── http_form_multipart.go │ │ ├── http_form_multipart_test.go │ │ ├── http_form_urlencode_test.go │ │ ├── http_form_urlencoded.go │ │ ├── http_get.go │ │ ├── http_get_test.go │ │ ├── http_graphql.go │ │ ├── http_graphql_test.go │ │ ├── http_multipart_mixed.go │ │ ├── http_multipart_mixed_test.go │ │ ├── http_post.go │ │ ├── http_post_test.go │ │ ├── options.go │ │ ├── options_test.go │ │ ├── reader.go │ │ ├── reader_test.go │ │ ├── sse.go │ │ ├── sse_test.go │ │ ├── util.go │ │ ├── websocket.go │ │ ├── websocket_close_reason.go │ │ ├── websocket_graphql_transport_ws.go │ │ ├── websocket_graphqlws.go │ │ ├── websocket_init.go │ │ ├── websocket_resolver_error.go │ │ ├── websocket_subprotocol.go │ │ └── websocket_test.go │ ├── handler.go │ ├── handler_test.go │ ├── id.go │ ├── id_test.go │ ├── input.go │ ├── int.go │ ├── int_test.go │ ├── introspection/ │ │ ├── introspection.go │ │ ├── query.go │ │ ├── schema.go │ │ ├── schema_test.go │ │ ├── type.go │ │ └── type_test.go │ ├── jsonw.go │ ├── jsonw_test.go │ ├── map.go │ ├── omittable.go │ ├── omittable_go124_test.go │ ├── omittable_test.go │ ├── oneshot.go │ ├── playground/ │ │ ├── altair_playground.go │ │ ├── altair_playground_test.go │ │ ├── apollo_sandbox_playground.go │ │ ├── apollo_sandbox_playground_test.go │ │ ├── helper_test.go │ │ ├── playground.go │ │ └── playground_test.go │ ├── recovery.go │ ├── resolve_field.go │ ├── resolve_field_test.go │ ├── response.go │ ├── root.go │ ├── slice.go │ ├── slice_test.go │ ├── stats.go │ ├── string.go │ ├── string_test.go │ ├── time.go │ ├── time_test.go │ ├── uint.go │ ├── uint_test.go │ ├── upload.go │ ├── uuid.go │ ├── uuid_test.go │ └── version.go ├── handler/ │ └── handler.go ├── init-templates/ │ ├── gqlgen.yml.gotmpl │ └── schema.graphqls ├── integration/ │ ├── .gitignore │ ├── README.md │ ├── codegen.ts │ ├── graphql.config.yml │ ├── package.json │ ├── server/ │ │ ├── cmd/ │ │ │ └── integration/ │ │ │ └── server.go │ │ ├── generated.go │ │ ├── gqlgen.yml │ │ ├── models-go/ │ │ │ ├── element.go │ │ │ ├── generated.go │ │ │ └── viewer.go │ │ ├── remote_api/ │ │ │ └── user.go │ │ ├── resolver.go │ │ ├── schema/ │ │ │ ├── schema.graphql │ │ │ ├── testomitempty.graphql │ │ │ └── user.graphql │ │ └── testomitempty/ │ │ └── testmodel.go │ ├── src/ │ │ ├── __test__/ │ │ │ └── integration.spec.ts │ │ ├── generated/ │ │ │ ├── .gitignore │ │ │ ├── fragment-masking.ts │ │ │ ├── gql.ts │ │ │ ├── graphql.ts │ │ │ ├── index.ts │ │ │ └── schema-expected.graphql │ │ └── queries/ │ │ ├── coercion.graphql │ │ ├── complexity.graphql │ │ ├── date.graphql │ │ ├── error.graphql │ │ ├── jsonEncoding.graphql │ │ ├── path.graphql │ │ └── viewer.graphql │ └── tsconfig.json ├── internal/ │ ├── code/ │ │ ├── alias.go │ │ ├── alias_test.go │ │ ├── compare.go │ │ ├── compare_test.go │ │ ├── imports.go │ │ ├── imports_test.go │ │ ├── packages.go │ │ ├── packages_test.go │ │ ├── testdata/ │ │ │ ├── a/ │ │ │ │ └── a.go │ │ │ ├── b/ │ │ │ │ └── b.go │ │ │ ├── c/ │ │ │ │ └── c.go │ │ │ └── p/ │ │ │ └── p.go │ │ ├── util.go │ │ └── util_test.go │ ├── imports/ │ │ ├── prune.go │ │ ├── prune_test.go │ │ └── testdata/ │ │ ├── unused.expected.go │ │ └── unused.go │ ├── rewrite/ │ │ ├── rewriter.go │ │ ├── rewriter_test.go │ │ └── testdata/ │ │ └── example.go │ └── tools.go ├── main.go ├── plugin/ │ ├── federation/ │ │ ├── constants.go │ │ ├── entity.go │ │ ├── entity_directives.go │ │ ├── entity_directives_test.go │ │ ├── federation.go │ │ ├── federation.gotpl │ │ ├── federation_computedrequires_test.go │ │ ├── federation_entitydirectives_test.go │ │ ├── federation_entityresolver_test.go │ │ ├── federation_explicitrequires_test.go │ │ ├── federation_test.go │ │ ├── federation_use_function_syntax_for_execution_context_test.go │ │ ├── fedruntime/ │ │ │ ├── directives.go │ │ │ ├── directives_test.go │ │ │ └── runtime.go │ │ ├── fieldset/ │ │ │ ├── fieldset.go │ │ │ └── fieldset_test.go │ │ ├── readme.md │ │ ├── requires.gotpl │ │ ├── test_data/ │ │ │ ├── model/ │ │ │ │ └── federation.go │ │ │ └── model2/ │ │ │ └── federation.go │ │ └── testdata/ │ │ ├── allthethings/ │ │ │ ├── generated/ │ │ │ │ └── federation.go │ │ │ ├── gqlgen.yml │ │ │ ├── model/ │ │ │ │ └── federation.go │ │ │ └── schema.graphql │ │ ├── computedrequires/ │ │ │ ├── entity.resolvers.go │ │ │ ├── errors.go │ │ │ ├── generated/ │ │ │ │ ├── exec.go │ │ │ │ ├── federation.go │ │ │ │ └── models/ │ │ │ │ └── models.go │ │ │ ├── gqlgen.yml │ │ │ ├── main/ │ │ │ │ └── server.go │ │ │ ├── resolver.go │ │ │ ├── schema.graphql │ │ │ └── schema.resolvers.go │ │ ├── entities/ │ │ │ ├── nokey.graphql │ │ │ └── nokey.yml │ │ ├── entitydirectives/ │ │ │ ├── generated/ │ │ │ │ ├── exec.go │ │ │ │ ├── federation.go │ │ │ │ └── models_gen.go │ │ │ ├── gqlgen.yml │ │ │ └── schema.graphql │ │ ├── entityinterfaces/ │ │ │ ├── generated/ │ │ │ │ ├── exec.go │ │ │ │ ├── federation.go │ │ │ │ └── models_gen.go │ │ │ ├── interface.graphql │ │ │ └── interface.yml │ │ ├── entityresolver/ │ │ │ ├── entity.resolvers.go │ │ │ ├── generated/ │ │ │ │ ├── errors.go │ │ │ │ ├── exec.go │ │ │ │ ├── federation.go │ │ │ │ └── model/ │ │ │ │ └── models.go │ │ │ ├── gqlgen.yml │ │ │ ├── resolver.go │ │ │ ├── schema.graphql │ │ │ └── schema.resolvers.go │ │ ├── explicitrequires/ │ │ │ ├── entity.resolvers.go │ │ │ ├── generated/ │ │ │ │ ├── errors.go │ │ │ │ ├── exec.go │ │ │ │ ├── federation.go │ │ │ │ ├── federation.requires.go │ │ │ │ └── models.go │ │ │ ├── gqlgen.yml │ │ │ ├── resolver.go │ │ │ ├── schema.graphql │ │ │ └── schema.resolvers.go │ │ ├── federation2/ │ │ │ ├── federation2.graphql │ │ │ ├── federation2.yml │ │ │ └── generated/ │ │ │ └── federation.go │ │ ├── interfaces/ │ │ │ ├── extends.graphqls │ │ │ ├── extends.yml │ │ │ ├── key.graphqls │ │ │ ├── key.yml │ │ │ ├── unused_key.graphqls │ │ │ └── unused_key.yml │ │ ├── multi/ │ │ │ ├── multi.graphqls │ │ │ └── multi.yml │ │ ├── schema/ │ │ │ ├── customquerytype.graphql │ │ │ └── customquerytype.yml │ │ └── usefunctionsyntaxforexecutioncontext/ │ │ ├── entity.resolvers.go │ │ ├── generated/ │ │ │ ├── errors.go │ │ │ ├── exec.go │ │ │ ├── federation.go │ │ │ └── model/ │ │ │ └── models.go │ │ ├── gqlgen.yml │ │ ├── resolver.go │ │ ├── schema.graphql │ │ └── schema.resolvers.go │ ├── modelgen/ │ │ ├── interface_graph.go │ │ ├── interface_graph_test.go │ │ ├── internal/ │ │ │ └── extrafields/ │ │ │ └── types.go │ │ ├── models.go │ │ ├── models.gotpl │ │ ├── models_interface_embedder.go │ │ ├── models_interface_embedding_test.go │ │ ├── models_test.go │ │ ├── out/ │ │ │ ├── existing.go │ │ │ ├── generated.go │ │ │ └── generated_omit_root_models.go │ │ ├── out_conflicting_types/ │ │ │ └── generated.go │ │ ├── out_covariant_types/ │ │ │ └── generated_covariant_types.go │ │ ├── out_directive_binding_models/ │ │ │ └── generated_directive_binding_models.go │ │ ├── out_directive_diamond/ │ │ │ └── generated_directive_diamond.go │ │ ├── out_directive_embedding_models/ │ │ │ └── generated_directive_embedding_models.go │ │ ├── out_directive_partial/ │ │ │ └── generated_directive_partial.go │ │ ├── out_directive_skipped_parents/ │ │ │ └── generated_directive_skipped_parents.go │ │ ├── out_embedded_struct_models_with_binding/ │ │ │ └── generated_embedded_structs_models_binding.go │ │ ├── out_embedded_structs_models/ │ │ │ └── generated_embedded_structs_models.go │ │ ├── out_enable_model_json_omitempty_tag_false/ │ │ │ ├── existing.go │ │ │ └── generated.go │ │ ├── out_enable_model_json_omitempty_tag_false_omitempty_tag_false_omitzero_tag_nil/ │ │ │ └── generated.go │ │ ├── out_enable_model_json_omitempty_tag_false_omitempty_tag_false_omitzero_tag_true/ │ │ │ └── generated.go │ │ ├── out_enable_model_json_omitempty_tag_false_omitzero_tag_false/ │ │ │ ├── existing.go │ │ │ └── generated.go │ │ ├── out_enable_model_json_omitempty_tag_false_omitzero_tag_nil/ │ │ │ ├── existing.go │ │ │ └── generated.go │ │ ├── out_enable_model_json_omitempty_tag_false_omitzero_tag_true/ │ │ │ ├── existing.go │ │ │ └── generated.go │ │ ├── out_enable_model_json_omitempty_tag_nil/ │ │ │ ├── existing.go │ │ │ └── generated.go │ │ ├── out_enable_model_json_omitempty_tag_true/ │ │ │ ├── existing.go │ │ │ └── generated.go │ │ ├── out_enable_model_json_omitzero_tag_false/ │ │ │ ├── existing.go │ │ │ └── generated.go │ │ ├── out_enable_model_json_omitzero_tag_nil/ │ │ │ ├── existing.go │ │ │ └── generated.go │ │ ├── out_enable_model_json_omitzero_tag_true/ │ │ │ ├── existing.go │ │ │ └── generated.go │ │ ├── out_no_directive_models/ │ │ │ └── generated_no_directive_models.go │ │ ├── out_nullable_input_omittable/ │ │ │ ├── existing.go │ │ │ └── generated.go │ │ ├── out_omit_embedded_structs_models/ │ │ │ └── generated_omit_embedded_structs_models.go │ │ ├── out_omit_json_enum_marshalers/ │ │ │ └── generated.go │ │ ├── out_omit_resolver_fields/ │ │ │ └── generated.go │ │ ├── out_struct_pointers/ │ │ │ ├── existing.go │ │ │ └── generated.go │ │ ├── testdata/ │ │ │ ├── customModelTemplate.gotpl │ │ │ ├── gqlgen.yml │ │ │ ├── gqlgen_conflicting_types.yml │ │ │ ├── gqlgen_custom_model_template.yml │ │ │ ├── gqlgen_enable_model_json_omitempty_tag_false.yml │ │ │ ├── gqlgen_enable_model_json_omitempty_tag_false_omitzero_tag_false.yml │ │ │ ├── gqlgen_enable_model_json_omitempty_tag_false_omitzero_tag_nil.yml │ │ │ ├── gqlgen_enable_model_json_omitempty_tag_false_omitzero_tag_true.yml │ │ │ ├── gqlgen_enable_model_json_omitempty_tag_nil.yml │ │ │ ├── gqlgen_enable_model_json_omitempty_tag_true.yml │ │ │ ├── gqlgen_enable_model_json_omitzero_tag_false.yml │ │ │ ├── gqlgen_enable_model_json_omitzero_tag_nil.yml │ │ │ ├── gqlgen_enable_model_json_omitzero_tag_true.yml │ │ │ ├── gqlgen_nullable_input_omittable.yml │ │ │ ├── gqlgen_omit_json_marshalers.yml │ │ │ ├── gqlgen_omit_resolver_fields.yml │ │ │ ├── gqlgen_omit_root_models.yml │ │ │ ├── gqlgen_struct_field_pointers.yml │ │ │ ├── interface_embedding/ │ │ │ │ ├── gqlgen_directive_binding_models.yml │ │ │ │ ├── gqlgen_directive_covariant_types.yml │ │ │ │ ├── gqlgen_directive_diamond.yml │ │ │ │ ├── gqlgen_directive_embedding_models.yml │ │ │ │ ├── gqlgen_directive_partial.yml │ │ │ │ ├── gqlgen_directive_skipped_parents.yml │ │ │ │ ├── gqlgen_no_directive_models.yml │ │ │ │ ├── schema_covariant_types.graphql │ │ │ │ ├── schema_directive_basic.graphql │ │ │ │ ├── schema_directive_binding.graphql │ │ │ │ ├── schema_directive_diamond.graphql │ │ │ │ ├── schema_directive_partial.graphql │ │ │ │ ├── schema_directive_skipped_parents.graphql │ │ │ │ └── schema_no_directive.graphql │ │ │ ├── schema.graphql │ │ │ ├── schema_conflicting_types.graphql │ │ │ ├── schema_embedded_structs_models_no_embedding.graphql │ │ │ ├── schema_omit_resolver_fields.graphql │ │ │ └── schema_omit_root_models.graphql │ │ └── types.go │ ├── plugin.go │ ├── resolvergen/ │ │ ├── resolver.go │ │ ├── resolver.gotpl │ │ ├── resolver_test.go │ │ └── testdata/ │ │ ├── comment_directive/ │ │ │ ├── gqlgen.yml │ │ │ └── out/ │ │ │ ├── resolver.go │ │ │ └── schema.resolvers.go │ │ ├── filetemplate/ │ │ │ ├── gqlgen.yml │ │ │ └── out/ │ │ │ ├── model.go │ │ │ ├── resolver.go │ │ │ ├── schema.custom.go │ │ │ └── schema.custom.go.txt │ │ ├── followschema/ │ │ │ ├── gqlgen.yml │ │ │ └── out/ │ │ │ ├── model.go │ │ │ ├── resolver.go │ │ │ ├── schema.resolvers.go │ │ │ └── schema.resolvers.go.txt │ │ ├── invalid_model_path/ │ │ │ └── gqlgen.yml │ │ ├── omit_template_comment/ │ │ │ ├── gqlgen.yml │ │ │ └── out/ │ │ │ ├── resolver.go │ │ │ └── schema.resolvers.go │ │ ├── resolver_implementor/ │ │ │ ├── gqlgen.yml │ │ │ └── out/ │ │ │ ├── model.go │ │ │ ├── resolver.go │ │ │ └── schema.resolvers.go │ │ ├── resolvertemplate/ │ │ │ ├── customResolverTemplate.gotpl │ │ │ ├── gqlgen.yml │ │ │ └── out/ │ │ │ ├── resolver.go │ │ │ └── schema.resolvers.go │ │ ├── return_values/ │ │ │ ├── gqlgen.yml │ │ │ ├── ignored.go │ │ │ ├── model.go │ │ │ ├── resolvers.go │ │ │ ├── return_values_test.go │ │ │ └── schema.graphqls │ │ ├── schema.graphql │ │ ├── singlefile/ │ │ │ ├── gqlgen.yml │ │ │ └── out/ │ │ │ ├── model.go │ │ │ └── resolver.go │ │ └── singlefile_preserve/ │ │ ├── gqlgen.yml │ │ └── out/ │ │ ├── model.go │ │ └── resolver.go │ ├── servergen/ │ │ ├── server.go │ │ └── server.gotpl │ └── stubgen/ │ ├── stubs.go │ └── stubs.gotpl └── testdata/ ├── entitydirectives/ │ └── generated/ │ ├── exec.go │ ├── federation.go │ └── models_gen.go ├── gomod-with-leading-comments.mod └── gqlgen.go ================================================ FILE CONTENTS ================================================ ================================================ FILE: .chglog/CHANGELOG-full-history.tpl.md ================================================ {{- $repourl := $.Info.RepositoryURL -}} # CHANGELOG All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased]({{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD) {{ if .Unreleased.NoteGroups }} {{ range .Unreleased.NoteGroups -}} ### {{ .Title }} {{ range .Notes -}} {{ .Body }} {{ end -}} {{ end -}} {{ end -}} {{ range .Unreleased.CommitGroups }} {{ range .Commits -}} {{- /** Remove markdown urls when there's a pull request linked and replace it with a tag **/ -}} {{- $subject := (regexReplaceAll `URL` (regexReplaceAll `\[#(\d+)\]\(.*?\)` .Subject "#${1}") $repourl) -}} {{- /** Filter out refs mentioned in the title **/ -}} {{- $list := (list) -}} {{- range $idx, $ref := .Refs -}} {{- if not (regexMatch $ref.Ref $subject) -}} {{ $list = append $list $ref }} {{- end -}} {{- end -}} {{- /** end custom variables **/ -}} {{ if .TrimmedBody -}}
{{ else -}}- {{ end -}} {{.Hash.Short}} {{ $subject }} {{- if $list -}} {{ printf " %s " "(closes"}} {{- range $idx, $ref := $list -}}{{ if $idx }}, {{ end -}} #{{ $ref.Ref}}{{ end }}) {{- end -}} {{ if .TrimmedBody -}}{{ printf "\n\n%s\n\n" .TrimmedBody }}
{{ end }} {{ end }} {{ end -}} {{- if .Versions }} {{ range .Versions -}} ## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}[{{ .Tag.Name }}](https://github.com/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 ---------
- 59f0d04c Bump golang.org/x/net 0.29 (#3261)
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 ...
f7bee06f chore(deps-dev): bump [@apollo](https://github.com/apollo)/client in /integration (#3258) - [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.11.5...v3.11.8) --- updated-dependencies: 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 ...
2da2ac36 chore(deps-dev): bump [@apollo](https://github.com/apollo)/client in /integration (#3237) - [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.11.4...v3.11.5) --- updated-dependencies: dependency-type: direct:development 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 ./...
- 3e76e7ee only close websocket once (#3231)
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 ...
- bbc354c6 Add local toolchain for matrix
3fe8329d chore(deps-dev): bump [@apollo](https://github.com/apollo)/client in /integration (#3215) - [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.11.2...v3.11.4) --- updated-dependencies: dependency-type: direct:development 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 ...
5f86c55a chore(deps-dev): bump [@graphql](https://github.com/graphql)-codegen/client-preset in /integration (#3197) - [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 ...
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 ...
1beac8b7 chore(deps-dev): bump [@apollo](https://github.com/apollo)/client in /integration (#3210) - [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.10.8...v3.11.2) --- updated-dependencies: dependency-type: direct:development update-type: version-update:semver-minor ...
- 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 ---------
f2cf11e5 chore(deps-dev): bump [@graphql](https://github.com/graphql)-codegen/client-preset in /integration (#3174) - [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 ...
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 ...
2afa0c22 chore(deps-dev): bump [@apollo](https://github.com/apollo)/client in /integration (#3164) - [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.10.6...v3.10.8) --- updated-dependencies: dependency-type: direct:development update-type: version-update:semver-patch ...
2aeb1518 chore(deps-dev): bump [@graphql](https://github.com/graphql)-codegen/client-preset in /integration (#3165) - [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 ...
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 ...
f82d604a chore(deps-dev): bump [@graphql](https://github.com/graphql)-codegen/schema-ast in /integration (#3167) - [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-minor ...
dd37ea00 chore(deps-dev): bump typescript from 5.4.5 to 5.5.2 in /integration (#3157) Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.4.5 to 5.5.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.4.5...v5.5.2) --- updated-dependencies: - dependency-name: typescript dependency-type: direct:development update-type: version-update:semver-minor ...
7b9c3223 chore(deps-dev): bump graphql from 16.8.2 to 16.9.0 in /integration (#3158) Bumps [graphql](https://github.com/graphql/graphql-js) from 16.8.2 to 16.9.0. - [Release notes](https://github.com/graphql/graphql-js/releases) - [Commits](https://github.com/graphql/graphql-js/compare/v16.8.2...v16.9.0) --- updated-dependencies: - dependency-name: graphql dependency-type: direct:development update-type: version-update:semver-minor ...
b822c2c0 chore(deps): bump mikepenz/action-junit-report from 4.3.0 to 4.3.1 (#3159) Bumps [mikepenz/action-junit-report](https://github.com/mikepenz/action-junit-report) from 4.3.0 to 4.3.1. - [Release notes](https://github.com/mikepenz/action-junit-report/releases) - [Commits](https://github.com/mikepenz/action-junit-report/compare/v4.3.0...v4.3.1) --- updated-dependencies: - dependency-name: mikepenz/action-junit-report dependency-type: direct:production update-type: version-update:semver-patch ...
c1525831 chore(deps-dev): bump [@apollo](https://github.com/apollo)/client in /integration (#3156) - [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.10.5...v3.10.6) --- updated-dependencies: 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 ...
a1ccf971 chore(deps-dev): bump [@apollo](https://github.com/apollo)/client in /integration (#3143) - [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.10.4...v3.10.5) --- updated-dependencies: dependency-type: direct:development update-type: version-update:semver-patch ...
8a59a2c4 chore(deps-dev): bump graphql from 16.8.1 to 16.8.2 in /integration (#3142) Bumps [graphql](https://github.com/graphql/graphql-js) from 16.8.1 to 16.8.2. - [Release notes](https://github.com/graphql/graphql-js/releases) - [Commits](https://github.com/graphql/graphql-js/compare/v16.8.1...v16.8.2) --- updated-dependencies: - dependency-name: graphql dependency-type: direct:development update-type: version-update:semver-patch ...
80098c67 chore(deps-dev): bump [@graphql](https://github.com/graphql)-codegen/client-preset in /integration (#3141) - [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-minor ...
fc90169b chore(deps): bump google.golang.org/protobuf from 1.34.1 to 1.34.2 (#3140) Bumps google.golang.org/protobuf from 1.34.1 to 1.34.2. --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: direct:production update-type: version-update:semver-patch ...
- fb67b709 v0.17.49 postrelease bump ## [v0.17.49](https://github.com/99designs/gqlgen/compare/v0.17.48...v0.17.49) - 2024-06-13 - d093c6e5 release v0.17.49 - a4f997f8 refactor: add missed file.Close() and use t.TempDir() (#3137)
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 ---------
6daceaf3 Linter update + add revive rules (#3127) * Linter update + add revive rules * More revive lints ---------
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 ...
- d9ba3405 v0.17.48 postrelease bump ## [v0.17.48](https://github.com/99designs/gqlgen/compare/v0.17.47...v0.17.48) - 2024-06-06 - 621350a1 release v0.17.48
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 ---------
- 6c83b9ea Remove duplicated return_pointers_in_unmarshalinput explanation (#3109) - d2a6bd5f refactor: fix testifylint.go-require lint issues (#3107)
b18d0287 testifylint v1.3.0 fixes (#3103) * Resolve Merge conflict * Autofixes * Lots more fixes and formatting * Add one more * Apply suggestions from code review ---------
- bbb0c959 chore: fix tests, pin golangci-lint version (#3105) - 57e88b27 Forgot the examples portion (#3101) - ff77f8b2 Some minor test lint (#3102)
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) ---------
0b9e6f9c chore(deps-dev): bump [@apollo](https://github.com/apollo)/client in /integration (#3085) - [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.10.3...v3.10.4) --- updated-dependencies: dependency-type: direct:development update-type: version-update:semver-patch ...
33aad657 chore(deps-dev): bump [@graphql](https://github.com/graphql)-codegen/client-preset in /integration (#3084) - [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 ...
- 58d6978e v0.17.47 postrelease bump ## [v0.17.47](https://github.com/99designs/gqlgen/compare/v0.17.46...v0.17.47) - 2024-05-18 - a9f2b500 release v0.17.47 - 611cbcec Update gqlparser (#3080)
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) ---------
- 8b4df636 Go mod tidy (#3075)
ae9787cb chore(deps): bump github.com/sosodev/duration from 1.3.0 to 1.3.1 (#3070) * chore(deps): bump github.com/sosodev/duration from 1.3.0 to 1.3.1 Bumps [github.com/sosodev/duration](https://github.com/sosodev/duration) from 1.3.0 to 1.3.1. - [Release notes](https://github.com/sosodev/duration/releases) - [Commits](https://github.com/sosodev/duration/compare/v1.3.0...v1.3.1) --- updated-dependencies: - dependency-name: github.com/sosodev/duration dependency-type: direct:production update-type: version-update:semver-patch ... * go mod tidy examples * Pin gorilla to skip 1.5.1 ---------
32014fdb chore(deps): bump golang.org/x/tools from 0.20.0 to 0.21.0 (#3072) Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.20.0 to 0.21.0. - [Release notes](https://github.com/golang/tools/releases) - [Commits](https://github.com/golang/tools/compare/v0.20.0...v0.21.0) --- updated-dependencies: - dependency-name: golang.org/x/tools dependency-type: direct:production update-type: version-update:semver-minor ...
1b5ed7c0 chore(deps-dev): bump urql from 4.0.7 to 4.1.0 in /integration (#3074) Bumps [urql](https://github.com/urql-graphql/urql/tree/HEAD/packages/react-urql) from 4.0.7 to 4.1.0. - [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-minor ...
77ea79a8 chore(deps-dev): bump [@apollo](https://github.com/apollo)/client in /integration (#3073) - [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.10.2...v3.10.3) --- updated-dependencies: dependency-type: direct:development update-type: version-update:semver-patch ...
358c7a2b chore(deps): bump google.golang.org/protobuf from 1.34.0 to 1.34.1 (#3071) Bumps google.golang.org/protobuf from 1.34.0 to 1.34.1. --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: direct:production update-type: version-update:semver-patch ...
5c951f4e chore(deps): bump golangci/golangci-lint-action from 5.3.0 to 6.0.1 (#3069) Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 5.3.0 to 6.0.1. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](https://github.com/golangci/golangci-lint-action/compare/v5.3.0...v6.0.1) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-type: direct:production update-type: version-update:semver-major ...
- 42cae907 chore: remove deprecated errcheck.ignore lint option (#3062) - 1a59d58b Fix typo in error message (#3065) - 39d3d8d0 refactor: simplify test asserts (#3061) - 7421bdfb refactor: compile regex only once (#3063) - a4bf3a7e chore: simplify generating examples in release script (#3064) - 45f6eb56 v0.17.46 postrelease bump ## [v0.17.46](https://github.com/99designs/gqlgen/compare/v0.17.45...v0.17.46) - 2024-05-07 - 90af8bf5 release v0.17.46 - bf49e56a fix: failed to build _examples/websocket-initfunc/server/server.go (#3055) (#3058)
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 ...
a5cb576c chore(deps-dev): bump [@apollo](https://github.com/apollo)/client in /integration (#3049) - [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.10.1...v3.10.2) --- updated-dependencies: dependency-type: direct:development update-type: version-update:semver-patch ...
6b423e51 chore(deps): bump google.golang.org/protobuf from 1.33.0 to 1.34.0 (#3050) Bumps google.golang.org/protobuf from 1.33.0 to 1.34.0. --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: direct:production update-type: version-update:semver-minor ...
c34e246b chore(deps): bump golang.org/x/text from 0.14.0 to 0.15.0 in /_examples (#3053) 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 ...
a3991df0 chore(deps): bump golangci/golangci-lint-action from 5.0.0 to 5.3.0 (#3054) Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 5.0.0 to 5.3.0. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](https://github.com/golangci/golangci-lint-action/compare/v5.0.0...v5.3.0) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-type: direct:production update-type: version-update:semver-minor ...
- 769632a1 chore: simplify go generate in examples (#3033) - f24ae887 enum values binding v2 (#3014)
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 ...
- ada00f78 chore: remove unused lint.txt (#3017)
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 ...
- 6e5a7758 Update `tools.go` url (#2987)
6771a804 Bump [@apollo](https://github.com/apollo)/client from 3.9.9 to 3.9.10 in /integration (#2994) - [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.9...v3.9.10) --- updated-dependencies: dependency-type: direct:development update-type: version-update:semver-patch ...
2ce5fcd1 Bump typescript from 5.4.3 to 5.4.4 in /integration (#2993) Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.4.3 to 5.4.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.4.3...v5.4.4) --- updated-dependencies: - dependency-name: typescript dependency-type: direct:development update-type: version-update:semver-patch ...
- 99d7d887 fix: stop loading package dependencies (#2988) - d0a1aec2 enum values binding (#2982)
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 ...
- 780bf27a Add UintID type binding (#2980)
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 ...
- 0afd63a5 chore: remove repetitive words (#2976)
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 ...
- fa221f64 Update Changelog - f897668b v0.17.45 postrelease bump ## [v0.17.45](https://github.com/99designs/gqlgen/compare/v0.17.44...v0.17.45) - 2024-03-11 - b6d1a8b9 release v0.17.45
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 ...
- 7ca35b11 v0.17.44 postrelease bump ## [v0.17.44](https://github.com/99designs/gqlgen/compare/v0.17.43...v0.17.44) - 2024-02-15 - 296b3c49 release v0.17.44
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 ---------
- 15c05a78 Update changelog - 87a7517a v0.17.42 postrelease bump ## [v0.17.42](https://github.com/99designs/gqlgen/compare/v0.17.41...v0.17.42) - 2023-12-29 - 7bf0c223 release v0.17.42
c811d47e fix: avoid panic from tracing on bad request (#2871) This fixes a panic which arises from the tracing components when a request has some defect which results in an error when creating the operation context. The transports consistently handle this by calling `DispatchError(graphql.WithOperationContext(ctx, rc), err)` where `rc` is the OperationContext which was not correctly constructed. This seems dangerous, because middleware may assume that if there in an `OperationContext` in the `context.Context` than they are being invoked on a normal codepath and can assume their other interceptors have been invoked in the normal order. Also, using a value returned by a function which also returned a non-nil error is very unusual. However, I have no idea what the impact of changing that dangerous behavior in the transports would be, so I opted to make the tracing component more resilient instead.
- 13bb4152 fix for entity interfce code gen with related test (#2868) - 0354649c Remove archived dependency appdash (#2866) - 0d43599c Update examples go.mod with appdash replacements (#2863) - 7dd971c8 Use defer wg.Done() in FieldSet Dispatch (#2861)
24ea195c vikstrous/dataloadgen replaces recommended dataloader package in example docs (#2770) * update example for dataloadgen * improved example with link to example repo * undo unnecessary changes * fix wrong signature * fix creation of loader * Update docs/content/reference/dataloaders.md
42f6e39d Allow fields that return root level definitions (#2858) * generate structs for root level definitions to support fields that return Query, Mutation or Subscription * removed unnecessary comment * re-ran go generate ---------
- 682a58dd Add go generate for examples so contributors never forget (#2859)
e080a96d Modify to prevent unreachable code from occurring (#2846) * fix: 型の数でソートする処理を追加 * 戻し * fix: case文の最初にスーパークラスが来ないようにする * testdata追加 * fix: Added sorting by number of types. * fix: Prevent superclass from appearing at the beginning of case statement
- 68744ad2 Bump changelog - e4cf21d2 v0.17.41 postrelease bump ## [v0.17.41](https://github.com/99designs/gqlgen/compare/v0.17.40...v0.17.41) - 2023-12-03 - fe60938c release v0.17.41
5e98a16a fix fieldset.New bug when prefix slice has len < cap (#2851) * fix fieldset.New bug when prefix slice has len < cap * ignore gocritic warning
bd9657f3 Improve ResolverImplementer.Implment (#2850) * improve resolver implement render * add error when multiple implementors * add initial test
cb3c1c89 Updated apollo sandbox (#2849) Added all supported options to new window.EmbeddedSandbox object
eb5cea72 Small template fix to save space in the generated file (#2841) * Small template fix to save space in the generated file * Re-generate ---------
- c0ca5091 Omittable can now be serialized as json (#2839) - dcb76191 fix: sample program indentation (#2840)
132ec1ce Updated GraphiQL 3.0.1 => 3.0.6 (#2837) * Updated GraphiQL 3.0.1 => 3.0.6 * Added unit tests to cover integrity of playgrounds * Updated vulnerable dependency * Close response body
- 91740700 v0.17.40 postrelease bump ## [v0.17.40](https://github.com/99designs/gqlgen/compare/v0.17.39...v0.17.40) - 2023-10-24 - c5ad14bf release v0.17.40
74e918f9 Map based input types fields are now coerced to the right type (#2830) * Input maps now unmarshals and checks nested fields * Added unit tests * Tested required fields in input maps * Docs updated with disclaimer * Added test for nested inputs
1e5fa72a Bump [@babel](https://github.com/babel)/traverse from 7.22.5 to 7.23.2 in /integration (#2831) - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse) --- updated-dependencies: dependency-type: indirect ...
e5c17d63 resolver: fix case-insensitive file name collision (#2829) for compatibility with Windows/Mac OS X, Go does not allow files with identical case-insensitive names. this commit changes the key of the 'files' map to use the lower case file name, keeping the original file name as a property on the File object.
- 9c5fc302 v0.17.39 postrelease bump ## [v0.17.39](https://github.com/99designs/gqlgen/compare/v0.17.38...v0.17.39) - 2023-10-05 - eed94e8c release v0.17.39
a863d645 Add [@interfaceObject](https://github.com/interfaceObject) and [@composeDirective](https://github.com/composeDirective) at Federation 2 directive lists. (#2821) This commit just adding those directives into the list.
3ff523ba Bump postcss from 8.4.24 to 8.4.31 in /integration (#2819) Bumps [postcss](https://github.com/postcss/postcss) from 8.4.24 to 8.4.31. - [Release notes](https://github.com/postcss/postcss/releases) - [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md) - [Commits](https://github.com/postcss/postcss/compare/8.4.24...8.4.31) --- updated-dependencies: - dependency-name: postcss dependency-type: indirect ...
59258642 Adding duration scalar conforming to ISO8601 standard (#2800) * Adding duration scalar * simple Duration scalar docs * using MarshalString, to add proper double quotes * adding deps and running go mod tidy on _examples * Re-organize imports * Fix test now that imports are sorted ---------
37f8e4eb Add ability to not fail when pong is not received. (#2815) I also changed how the read deadline set works a little, the reason for this is that the protocol allows for pong to be sent without a ping. So setting a read deadline on receiving pong isn't great. Instead we should always set the read deadline on sending ping. Though to do this we need to know whether we have received a pong or not. Because if we set the read deadline when the previous ping still hasn't received the pong. Then it will never hit the deadline.
89ac736f Store parsed Schema on ExecutableSchema rather than use global variable (#2811) * codegen: executableSchema schema configurable * feat * feat * codegen: add schema property on Config and executableSchema * fix: fmt * regenerate ---------
919aded6 Add a pong only keep alive for the new protcol (#2814) The protocol allows for this and this eliminates the potential for over-agressive triggers of the read deadline set for using the ping/pong flow. https://github.com/enisdenjo/graphql-ws/blob/50d5a512d0d7252d41c079e6716b884a191b1ddc/PROTOCOL.md#pong
- 001c296a Update auto-generated files with latest results. (#2813)
f6fa3aae Consider go type name when autobinding (#2812) Currently, generated schema type names are normalized, for instance - SomeTYPE in the schema will be generated as SomeType in the model. When autobinding, however, we only consider the schema type name when searching for it in the relevant package(s), thus type names that differ post normalizations aren't auto-bound properly and are instead re-generated. This commit suggests a fix where we'd try to autobind for both the schema type name (first, to maintain back compat), or the go type name if the former isn't found.
4e8d8c70 Feature: Support Apollo Federation Auth Directives (#2809) * local version working * gofmt * tabs
- 66709d89 feat: update getting-started CreateTodo mutationResolver (#2810)
2c9f9c5f fix: CodeGen for omit_slice_element_pointers and GetMany Entity Resolvers (#2802) * remove ! from reps definition * adding tests * fixing tests * adding documentation * addressing lint * commit after go gonerate * gofmt ---------
3e2393f3 add close flag into wsConnection to avoid duplicate calls of CloseFunc (#2803) * add close flag into wsConnection to avoid duplicate calls of CloseFunc * add test * Fix linter error
af4d3943 Allow WebsocketInitFunc to add payload to Ack (#4) (#2791) * Allow WebsocketInitFunc to add payload to Ack The connection ACK message in the protocol for both graphql-ws and graphql-transport-ws allows for a payload in the connection ack message. We really wanted to use this to establish better telemetry in our use of websockets in graphql. * Fix lint error in test * Switch argument ordering. ---------
- f3b86033 v0.17.38 postrelease bump ## [v0.17.38](https://github.com/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 ---------
- f90ac05e v0.17.37 postrelease bump ## [v0.17.37](https://github.com/99designs/gqlgen/compare/v0.17.36...v0.17.37) - 2023-09-08 - ccae370e release v0.17.37 - 6505f8be Update gqlparser (#2785)
153ec470 add uuid type (#2751) (closes #2749) * add uuid type * add uuid example * add uuid scalar doc * strconv.Quote * Apply suggestions from code review * fix ---------
fa471180 ForceGenerate parameter to [@goModel](https://github.com/goModel) added. (#2780) * forceGenerate to docs added ---------
11bb9b18 codegen: add support for `go_build_tags` option in gqlgen.yaml (#2784) * codegen: support go_build_tags option in gqlgen.yaml * chore: added test * docs/content: update config example * chore: more comment
bee47dcf fix flaky test TestSubscriptions (#2779) * fix flaky test TestSubscriptions * update other copy of the test
- a41f4daa docs: short-lived loader (#2778) - cc4e0ba2 ensure HasOperationContext checks for nil (#2776)
a1ca2204 fix typo in TESTING.md server path (#2774) following TESTING.md instructions, I got an error: "stat ./server/server.go: no such file or directory" server.go path is: integration/server/cmd/integration/server.go
1cde8c3f return internal types in schema introspection (#2773) according to graphql spec: ``` types: return the set of all named types contained within this schema. Any named type which can be found through a field of any introspection type must be included in this set. ``` source: https://github.com/graphql/graphql-spec/blob/main/spec/Section%204%20--%20Introspection.md#the-__schema-type some clients libs (like HotChocolate for C#) depends on this behavior.
- 065aea3e Fix gqlgen truncates tag value with colon (#2759) - d6270e4f Update subsciptions documentation to correctly close channel (#2753) - 2d8673a6 Add Model references to Interface (#2738) - 790d7a75 Allow GraphiQL headers to be set when creating the playground handler (#2740) (closes #2739) - 0eb95dc4 v0.17.36 postrelease bump ## [v0.17.36](https://github.com/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
16c9eb64 Fix docs (#2722) * docs: fix variable names in dataloader sample * fix: request-scoped middleware
b233a01b docs: update dataloader docs (#2719) * docs: update example * docs: update example * fix: import
- cccc7389 Added go mod tidy to quick start guide (#2718) (closes #2717, #2651, #2641, #2614, #2576) - 9adc7b81 Update gqlparser to v2.5.8 (#2716) - b442fbf4 Post v0.17.35 changelog update - 57c12199 v0.17.35 postrelease bump ## [v0.17.35](https://github.com/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`
- 640f3836 Update gqlparser dependency (#2694) - 5ac9fe59 Added flag to omit interface checks (#2689)
abc3c627 feat: always use latest apollo sandbox (#2686) * feat: removeDuplicateTags() validates tags and panic with meaningful error message * Instead of pinning on _latest without subresource integrity check, update both url and integrity to latest * Update graphql/playground/apollo_sandbox_playground.go ---------
3b295bb4 added GoInitialismsConfig which overrides the initialisms to be regarded (#2683) * added GoInitialismsConfig which overrides the initialisms to be regarded * typo * adjusted examples and documentation * removed test with side-effects, adjustend yaml indentations, changed example entry "ID" to "CC" (again? I though I already did that) * comply with linter
- ee6add4b Refactor TypeIdentifier to avoid circular imports (#2682) - 44376e52 fix subscription example in documentation (#2677)
d5080828 Reworked integration testing using vitest (#2675) * Reworked integration using vitest Added SSE client testing Fixed SSE Transport parse errors not being sent as event-stream * Added defer testing using urql * Cleanup unnecessary dependencies
d16f498f fix: issue with extraFields being thrown away (#2674) * fix: issue with extraFields being thrown away * Go fumpt on file ---------
- 71d16aa0 v0.17.33 postrelease bump ## [v0.17.33](https://github.com/99designs/gqlgen/compare/v0.17.32...v0.17.33) - 2023-06-13 - a1e34ca0 release v0.17.33
790a72c1 issue-1372: add custom decode func (#2666) * issue-1372: add custom decode func * issue-1372: add custom decode method * issue-1372: fix lint * issue-1372: add custom decode func * issue-1372: add custom decode method * issue-1372: fix lint * issue-1372: extend functionality by setting up the whole decode config instead of one nested field * issue-1372: rollback generated.go file * issue-1372: fix lint
c63c60eb Update all modules (#2667) * Update all modules * Add gqlparser v2.5.3 ---------
4a78eb0c minor cleaning: fix some stricter lint rule warnings (#2665) * Add Changelog notes * Some spring cleaning * Update golangci-lint to latest ---------
- 1e925f7e v0.17.32 postrelease bump ## [v0.17.32](https://github.com/99designs/gqlgen/compare/v0.17.31...v0.17.32) - 2023-06-06 - 3a81a78b release v0.17.32 - dbb61174 Added unit tests for defer (#2657)
5c19c841 Addressing few issues in defer feature (#2656) And fixed hasNext to only appear in the payload when there is deferred usage * Regenerate * Use go 1.18 compatible atomic operations * Regenerate
8e295024 Update extra fields type definition and plus docs about the feature (#2655) * Update extra fields type definition and plus docs about the feature * Update docs
adf5da27 Make usage of omitempty tag optional (#2649) * Make usage of omitempty tag optional * adding probably good enough test * some kinda docs * lintersssssssssssssssssssssssssssss * removing unnecessary fields from config
- 7ab33176 Extra fields (#2638)
22deb8bd allow binding a GraphQL `Any` field to a struct method returning `*any` (#2644) * allow binding GQL `Any` field to struct method returning `*any` * add singlefile tests for binding to `*any` case * add followschema tests for binding to `*any` case * make ptr_to_any binding tests follow binding conventions better
c313bf3d `[@defer](https://github.com/defer)` initial support (#2642) * support returning errors with deferred fragments. * update integration tests. * fix gotpl indent and pass the correct context to deferred .Dispatch(). * Added hasNext in the tests * Added back root_.gotpl * Regenerate * Regenerate recursively * Updated schema-expected.graphql * Fixed starwars_test.go * Cleanup * Add graphql response hasnext omitempty and update tests to match ---------
4d945da2 feat(federation): update Apollo Federation v2 definitions (#2635) * feat(federation): update Apollo Federation v2 definitions Fix Apollo Federation v2 directive definitions: * `_FieldSet` was renamed `FieldSet` * regenerate examples
- 9796f91d Generate entity resolvers for interfaces with [@key](https://github.com/key) defined (#2634)
33fdd1b5 fix enum capitalization (#2630) * fix enum capitalization * apply suggestion: adding comment
82a110ce Fix uint32 unmarshal (#2631) The string unmarshal for uint32 used ParseInt instead of ParseUint, which would parse the wrong range of valid numbers.
- e62a0277 Add Changelog entries for v0.17.31 - f707aa8d v0.17.31 postrelease bump ## [v0.17.31](https://github.com/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
- 239b97ee Omittable input fields (#2585)
2ad08fff Bugfix: add missing return statements in GRAPHQL and UrlEncodedForm transports. (#2625) Two transports (GRAPHQL and UrlEncodedForm) did not have return statement at the end of `if err` block. Instead of returning a 'could not cleanup body' error, we continued processing. User still got an error. But instead of early 'could not cleanup' error, user gor 'Internal system error' which happened a few lines after the if block. Tests are added.
- a13eca12 update autogenerated gqlgen.yml with new options. (#2622) - f1f63b52 Post Release Changelog entry - 81f3469f v0.17.30 postrelease bump ## [v0.17.30](https://github.com/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
- 498ce3f3 Add Changelog entry - 024430a1 v0.17.29 postrelease bump ## [v0.17.29](https://github.com/99designs/gqlgen/compare/v0.17.28...v0.17.29) - 2023-04-11 - 325405ba release v0.17.29
7bc1f626 Read gqlgen.yml from io.Reader. (#2607) * Update config.go Add ReadConfig * Add tests * Update config_test.go remove extra space to fix lint checks * Update config.go Need to return the config
50c2829c Transport for application/x-www-form-urlencoded content type (#2611) * Renamed 'form' transport to 'form_multipart'. There are multiple ways form data can be encoded. 'multipart' is just one of them - there are also 'application/x-www-form-urlencoded' (which will be added in next commit) and 'text/plain' encodings. Let each encoding have it's own form_xxxx file and tests. * Adds transport for application/x-www-form-urlencoded content type. This commit adds transport that handles form POST with content type set to 'application/x-www-form-urlencoded'. Form body can be json, urlencoded parameters or plain text. Example: ``` curl -X POST 'http://server/query' -d '{name}' -H "Content-Type: application/x-www-form-urlencoded" ``` Enable it in your GQL server with: ``` srv.AddTransport(transport.UrlEncodedForm{}) ``` * golangci-lint: change ifElseChain to switch. No other changes but this rewrite to switch.
8b38c0e9 Add on-close handler for websockets. (#2612) * working without test * test
45488157 Transport for application/graphql contentType (#2592) * Adds application/graphql transport layer This commit adds 'application/graphql' transport. It is based on POST metod and has only the 'query' part in it's body. See: https://graphql.org/learn/serving-over-http/#post-request and it's comment about this content-type. An example of correct application/graphql query is: ``` curl 'http://host/graphql' -d '{time{now}}' -H "Content-Type: application/graphql" ``` Some clients prefix body with 'query=': ``` -d 'query={time{now}}' ``` Some clients html encode body payload: ``` -d 'query=%7Btime%7Bnow%7D%7D' ``` We cleanup both in cleanupBody() method. Tests are in http_graphql_test.go file. * Adds tests for GRAPHQL transport response headers. GRAPHQL transport (like GET, POST and MULTIPART transports) can have specific response headers added. This commit adds tests for it and changes doRequest() method so that we can set inbound Content-Type. Graphql transport uses 'application/graphql' content-type and not 'application/json'. * Adds GRAPHQL transfer to the documentation.
- 21054eba Cleanup only non-gqlgen packages when reloading all packages (#2598) - 1c6bf9bd v0.17.28 postrelease bump ## [v0.17.28](https://github.com/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.
- 65ec8b5a Add Changelog entry for v0.17.27 - a3400ff4 v0.17.27 postrelease bump ## [v0.17.27](https://github.com/99designs/gqlgen/compare/v0.17.26...v0.17.27) - 2023-03-20 - 5bfcdd63 release v0.17.27 - aab9b968 Revert mstephano #2486 #2508 #2528 (#2587)
05500c9d POST transport: missing return and unnecessary logs (#2584) * Add missing return in HTTP POST transport * Remove HTTP POST transport logs
622039cb feat: support ApolloSandbox playground (#2581) * feat: support ApolloSandbox playground * add initialState to be same behavior as others * add docs link of configuration values
- 0bbc7f8c Add omitempty to struct tags for nullable types (#2436) - acbae6f0 Update Changelog for v0.17.26 - fbfa16ea v0.17.26 postrelease bump ## [v0.17.26](https://github.com/99designs/gqlgen/compare/v0.17.25...v0.17.26) - 2023-03-07 - 8ad59302 release v0.17.26
dcd75559 Revert issue 2470 (#2577) (closes #2471, #2523, #2541) This reverts commit 5cb6e3ecb07a292daa37f5ce8e5bcf364e1190af. * misspell lint fix ---------
- cac5f0f4 Post release version bump for examples - 9e9af41a Update Changelog - a8f647cb v0.17.25 postrelease bump ## [v0.17.25](https://github.com/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
- 3087cf3a Fix for #1274. (#2411)
906c0dee optional return pointers in unmarshalInput (#2397) * optional return pointers in unmarshalInput * add docs for return_pointers_in_unmarshalinput
a9d06036 Add json.Number support to UnmarshalString (#2396) * Add json.Number support to UnmarshalString * Add UnmarshalString tests * Remove trailing zeros when calling UnmarshalString with float64
daa44079 Update README.md (#2391) fix: execute gqlgen generate command error. eg: systems failed: unable to build object definition: unable to find type: github.com/99designs/gqlgen/graphql/introspection.InputValue. need import github.com/99designs/gqlgen/graphql/introspection .
419dd96c Bump got and [@graphql](https://github.com/graphql)-codegen/cli in /integration (#2389) Removes `got` - [Release notes](https://github.com/dotansimha/graphql-code-generator/releases) - [Changelog](https://github.com/dotansimha/graphql-code-generator/blob/master/packages/graphql-codegen-cli/CHANGELOG.md) --- updated-dependencies: - dependency-name: got dependency-type: indirect dependency-type: direct:development ...
- b1ca215a Add global typescript (#2390)
265888c6 Bump jsdom and jest in /integration (#2388) Bumps [jsdom](https://github.com/jsdom/jsdom) and [jest](https://github.com/facebook/jest/tree/HEAD/packages/jest). These dependencies needed to be updated together. Removes `jsdom` Updates `jest` from 24.9.0 to 29.0.3 - [Release notes](https://github.com/facebook/jest/releases) - [Changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md) - [Commits](https://github.com/facebook/jest/commits/v29.0.3/packages/jest) --- updated-dependencies: - dependency-name: jsdom dependency-type: indirect - dependency-name: jest dependency-type: direct:development ...
56f6db04 Update module mitchellh/mapstructure to 1.5.0 (#2111) * Update mitchellh/mapstructure * Avoid double pointer
- ea9590a4 update changelog for v0.17.20 - 4c06e6c6 v0.17.20 postrelease bump ## [v0.17.20](https://github.com/99designs/gqlgen/compare/v0.17.19...v0.17.20) - 2022-09-19 - 0e4cbd10 release v0.17.20
12ae8ffa Update go-colorable and x/tools. (#2382) This picks up a new 2022 version of golang.org/x/sys which is caused by https://github.com/golang/go/issues/49219 and is needed to fix building using Go 1.18 on aarch64-darwin.
68136ffb Update diagram in documentation (#2381) The diagram wasn't rendering properly in Go docs, which was a shame because it's a great diagram. This PR fixes that by indenting it another space.
- d29d098f fix field merging behavior for fragments on interfaces (#2380) - 6bb31862 Update changelog for v0.17.19 - bb7fbc0f v0.17.19 postrelease bump ## [v0.17.19](https://github.com/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
- d096fb9b Update directives (#2371) - 1acfea2f Add v0.17.17 changelog - c273adc8 v0.17.17 postrelease bump ## [v0.17.17](https://github.com/99designs/gqlgen/compare/v0.17.16...v0.17.17) - 2022-09-13 - d50bc5ac release v0.17.17
462025b4 nil check error before type assertion follow-up from #2341 (#2368) * Improve errcode.Set safety
59493aff fix: apollo federation tracer was race prone (#2366) The tracer was using a global state across different goroutines Added req headers to operation context to allow it to be fetched in InterceptOperation
- fc018556 Update gqlparser to v2.5.1 (#2363) - 56574a14 feat: make Playground HTML content compatible with UTF-8 charset (#2355)
182b039d Add `subscriptions.md` recipe to docs (#2346) * Add `subscriptions.md` recipe to docs * Fix wrong request type
- b66fff16 Add omit_getters config option (#2348) - 2ba8040f Update changelog for v0.17.16 - 8bef8c80 v0.17.16 postrelease bump ## [v0.17.16](https://github.com/99designs/gqlgen/compare/v0.17.15...v0.17.16) - 2022-08-26 - 9593cead release v0.17.16 - 2390af2d Update gqlparser to v2.5.0 (#2341) - 2a87fe06 feat: update Graphiql to version 2 (#2340)
32e2ccd3 Update yaml to v3 (#2339) * update yaml to v3 * add missing go entry for yaml on _example * add missing sum file
- 7949117a v0.17.15 postrelease bump ## [v0.17.15](https://github.com/99designs/gqlgen/compare/v0.17.14...v0.17.15) - 2022-08-23 - 23cc7492 release v0.17.15 - 577a570c Markdown formatting fixes (#2335)
2b584011 Fix Interface Slice Getter Generation (#2332) * Make modelgen test fail if generated doesn't build Added returning list of interface to modelgen test schema * Implement slice copying when returning interface slices * Re-generate to satisfy the linter
aee57b4c Correct boolean logic (#2330) Correcting boolean logic issue
- da0610e1 Update changelog for v0.17.14 - ddcb524e v0.17.14 postrelease bump ## [v0.17.14](https://github.com/99designs/gqlgen/compare/v0.17.13...v0.17.14) - 2022-08-18 - 581bf6eb release v0.17.14 - d3384377 Update gqlparser - c2d02d35 More descriptive `not implemented` stubs (#2328) (closes #2327)
9f919d2c Avoid GraphQL to Go Naming Collision with "ToGoModelName" func (#2322) (closes #2321) * using ReplaceAllStringLiteral * fixing wordInfo template test * bumping linter timeout to 5m * comment cleanup * some cleanup, adding "ToGoPrivateModelName" func * adding "ToGoPrivateModelName" func * refactoring word walker impl and tests * hopefully making linter happy
- 2304c104 Include docstrings on interface getters (#2317) - f5d60326 Leverage (*Imports).LookupType when generating interface field getters (#2315)
242c3ba2 Generate getters for interface fields (#2314) * Generate getters for interface fields * Changes to make models_test.go pass * Use text/template, not html/template * Re-run go generate ./... * gofmt a few files that were failing lint checks * Another gofmt straggler * Try making the "generated" match the exact whitespace github is disliking
- 0d91c893 Add hackernews graphql api tutorial to other resources (#2305) - c2526ba5 Update gqlparser to v2.4.7 (#2300) - f283124d #2298: fix gqlgen extracting module name from comment line (#2299)
779d7cdd Add support for KeepAlive message in websocket client (#2293) * Add support for KeepAlive message in websocket client * rewrite if-else to switch statement
- 5a37d1dc v0.17.13 postrelease bump ## [v0.17.13](https://github.com/99designs/gqlgen/compare/v0.17.12...v0.17.13) - 2022-07-15 - e82b6bf1 release v0.17.13
f0e9047d Hide dependencies in `tools.go` from importers (#2287) Projects that use `go mod vendor` will vendor `github.com/matryer/moq` despite it not being required at runtime. Moving `tools.go` to `internal` hides this import from downstream users and avoids `github.com/matryer/moq` being vendored. `go generate` of the mocks still works as expected. The assumption behind the import test broke, so I've pointed it at a different path that has no Go code. This seems to match the intent behind the original test for the `internal/code/..` path.
- 6310e6a7 support named interface to Field.CallArgs (#2289)
30493696 fix: return the original error (#2288) * fix: return the original error close https://github.com/99designs/gqlgen/issues/2286 * Update error.go
- fb13091d updated WebSocker InitFunc recipe (#2275) - 770c09fb Update changelog for v0.17.12 - b4c186a7 v0.17.12 postrelease bump ## [v0.17.12](https://github.com/99designs/gqlgen/compare/v0.17.11...v0.17.12) - 2022-07-04 - 94c02b0d release v0.17.12 - 7eb8ba93 Fix CreateTodo (#2256)
0b0e5ce4 Replace use of strings.Title with cases.Title (#2268) * github: Test more go versions * github: Fix ci tests * github: Increase verbosity, sleep * github: Drop bash * github: Test go 1.18 and newer node verisons * github: Pull out node 16 for now * github: Only lint 1.16 for now * cases: Use cases.Title over strings.Title which is deprecated * gqlgen: Remove use of deprecated strings.Title
- 0c11e5fd parse at beginning of do function (#2269) - edb1c585 Update Changelog for v0.17.11 - 5e6b52fd v0.17.11 postrelease bump ## [v0.17.11](https://github.com/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
- 532d46af Make uploads content seekable (#2247)
34bbc450 Use the go:embed API to lookup templates (#2262) * Switch the templates package internally to read from TemplateFS Users are expected to pass in the FS by using the embed API. * Update all usages of templates.Render to use the TemplateFS option * Fix unit tests * Fix linter error * Commit generated changes Doesn't look like anything has changed though. Maybe just a different whitespace character. * Fix test
53ca207a Fix PR links in CHANGELOG.md (#2257) * fix "PR" regex in CHANGELOG-full-history.tpl.md * regenerate CHANGELOG.md
53ada82e Replace deprecated ioutil pkg with os & io (#2254) As of Go 1.16, the same functionality is now provided by package io or package os, and those implementations should be preferred in new code. So replacing all usage of ioutil pkg with io & os.
- a8f112e0 update changelog - 82fbbe41 v0.17.10 postrelease bump ## [v0.17.10](https://github.com/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
- 65e68108 Add config boolean for whether resolvers return pointers (#2175) - ddd825ef Only make cyclical struct fields pointers (#2174) - 5a87fe29 Update websocket.go (#2223) - e2edda5d Update dataloaders.MD (#2221) - 3de7d2cf fix: chat example frontend race condition (#2219) - 11f40572 Update Changelog - caca01fb v0.17.9 postrelease bump ## [v0.17.9](https://github.com/99designs/gqlgen/compare/v0.17.8...v0.17.9) - 2022-05-26 - 7f0611b2 release v0.17.9 - 738209b2 Update gqlparser (#2216)
6855b729 fix: prevent goroutine leak and CPU spinning at websocket transport (#2209) (closes #2168) * Added goroutine leak test for chat example * Improved chat example with proper concurrency This reverts commit eef7bfaad1b524f9e2fc0c1150fdb321c276069e. * Improved subscription channel usage * Regenerated examples and codegen * Add support for subscription keepalives in websocket client * Update chat example test * if else chain to switch * Revert "Add support for subscription keepalives in websocket client" This reverts commits 64b882c3c9901f25edc0684ce2a1f9b63443416b and 670cf22272b490005d46dc2bee1634de1cd06d68. * Fixed chat example race condition * Fixed chatroom#Messages type
5f5bfcb9 fix #2204 - don't try to embed builtin sources (#2214) * dont't try to embed builtins * add test * generated code * fix error message string
- 8d9d3f12 Check only direct dependencies (#2205) - b262e40a v0.17.8 postrelease bump ## [v0.17.8](https://github.com/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)
8825ac46 Fix misprint (#2187) * Fix misprint * Fix misprint * Re-generate
- 41daa5d8 fix #2190 - don't use backslash for "embed" paths on windows (#2191) - 0cce5544 Update Changelog - 26644541 v0.17.6 postrelease bump ## [v0.17.6](https://github.com/99designs/gqlgen/compare/v0.17.5...v0.17.6) - 2022-05-23 - 358d45dc release v0.17.6 - 7c95938c Improve operation error handling (#2184) - 2526f687 Correct identation (#2182)
f7bf453c Bump dset from 3.1.1 to 3.1.2 in /integration (#2176) Bumps [dset](https://github.com/lukeed/dset) from 3.1.1 to 3.1.2. - [Release notes](https://github.com/lukeed/dset/releases) - [Commits](https://github.com/lukeed/dset/compare/v3.1.1...v3.1.2) --- updated-dependencies: - dependency-name: dset dependency-type: indirect ...
4cdf7026 Update getting-started.md (#2157) Fix getting-started missing fields resolver config
- eef7bfaa fix: prevents goroutine leak at websocket transport (#2168) - b8ec51d8 go: update gqlparser to latest (#2149) - ec3e597e Fix docs bug in field collection (#2141)
f6b35231 Add argument to WebsocketErrorFunc (#2124) * Add argument to WebsocketErrorFunc to determine whether the error ocured on read or write to the websocket. * Wrap websocket error
- 0f016df3 Fix invalid query parameter for playground subscription endpoint (#2148)
fb5751ab use "embed" in generated code (#2119) * use "embed" in generated code * don't use embed for builtins * working poc * handle no embeddable sources * fix dir * comment * add test for embedding * improve error handling
d38911f1 Allow absolute https://github.com/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.
- 05bfc1fb Upddate Changelog - 62f694f0 v0.17.5 postrelease bump ## [v0.17.5](https://github.com/99designs/gqlgen/compare/v0.17.4...v0.17.5) - 2022-04-29 - fd97e74e release v0.17.5
9250f9ac Feature: Add FTV1 Support via Handler (#2132) * initial support for ftv1 traces via handler * remove testing json extension * remove binary from commit and add to .gitignore * updating go.mod * updating examples go.sum * rerunning generate within the examples folder
fce3a11a feat: added graphql.UnmarshalInputFromContext (#2131) * feat: added graphql.UnmarshalInputFromContext * chore: run go generate for _examples * fix: apply suggestions from code review * fix: update error cases * fix: fixed unit-test by update root_.gotpl * fix: apply suggestions from code review * fix: update graphql/input.go
6a24e881 update instructions to specify package of Role (#2130) Can't compile with the example unless I also include `model.` for Role.
- ccfa245b Ignore protobuf files in coverage (#2133) - 0465dcb1 Update federation.md (#2129) - 8f0631dc Update Changelog - 41611560 v0.17.4 postrelease bump ## [v0.17.4](https://github.com/99designs/gqlgen/compare/v0.17.3...v0.17.4) - 2022-04-25 - d6de831a release v0.17.4
2a2a3dcb Feature: Adds Federation 2 Support (#2115) * fed2 rough support * autodetection of fed2 * adding basic tests for changes * fixing docs * Update plugin/federation/federation.go * removing custom scalar since it was causing issues * fixing lint test * should fix for real this time * fixing test failures
77260e88 shorten some generated code (#2120) * shorten some generated code * generate examples
4da17e1c update modules except mapstructure (#2118) * Update modules * Update modules except for mapstructure * Try to update to v1.3.1
- cddbf02d Update Changelog file - 8f80f4ef v0.17.3 postrelease bump ## [v0.17.3](https://github.com/99designs/gqlgen/compare/v0.17.2...v0.17.3) - 2022-04-20 - 0bb262d1 release v0.17.3
8d0bd22a Update gqlparser (#2109) * Update gqlparser * Update tests to be NoError
ec0dea88 Fix the ability of websockets to get errors (#2097) Because DispatchOperation creates tempResponseContext, which is passed into Exec, which is then used in _Subscription to generate the next function. Inside the various subscription functions when generating next the context was captured there. Which means later when the returned function from DispatchOperation is called. The responseContext which accumulates the errors is the tempResponseContext which we no longer have access to to read the errors out of it. Instead add a context to next() so that it can be passed through and accumulated the errors as expected. Added a unit test for this as well.
e3f04b42 Change the error message to be consumer targeted (#2096) * Change the error message to be slightly more clear * Rebase on updated origin/master. Fix the test to not be sensitive to array ordering. Re-generate on master as there was a schema change.
5a497649 Fix websocket subscriptions to not double close. (#2095) We were closing at the end of the loop and also in the defer.
- a15a9bfd Update test.yml to be valid
a1538928 Use Github API to update the docs (#2101) * Use Github API to update the docs Instead of a hard-coded version of the docs we want to realease, this uses the Github API to get the last 20 versions and publish those. This will allow any script invoking this to make sure to always have the latest version of the docs * Reinstate set -e
- 3bf437c2 Update golangci-lint (#2103)
12c6d0bf Fix misprint (#2102) * Fix misprint * Update websocket_graphql_transport_ws.go
9f5fad13 Bump minimist from 1.2.5 to 1.2.6 in /integration (#2085) Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6. - [Release notes](https://github.com/substack/minimist/releases) - [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6) --- updated-dependencies: - dependency-name: minimist dependency-type: indirect ...
035e1d6e Add AllowedMethods field to transport.Options (#2080) * Add AllowedMethods field to transport.Options to enable users to specify allowed HTTP methods. * Update graphql/handler/transport/options.go
- f0fdb116 Add instructions for enabling autobinding (#2079)
12b0b385 Bump Playground version (#2078) * update playground * enables tabs * update shas
1324c3ff Merge pull request #2062 from a8m/childfield graphql: add FieldContext.Child field function and enable it in codegen
- bf9caeae graphql: add FieldContext.ChildArgs field and enable it in codegen - 36fb3dc6 codegen: allow binding methods with optional variadic arguments (#2066) - fba5edd4 Update Changelog - 48b2b7e1 v0.17.2 postrelease bump ## [v0.17.2](https://github.com/99designs/gqlgen/compare/v0.17.1...v0.17.2) - 2022-03-21 - 1f04d38a release v0.17.2 - 87fc5f22 Fix #1961 for Go 1.18 (#2052) - f85d59d3 fixed modelgen test schema (#2032) - d873ff8b v0.17.1 postrelease bump ## [v0.17.1](https://github.com/99designs/gqlgen/compare/v0.17.0...v0.17.1) - 2022-03-02 - 5ea50aee release v0.17.1 - a493a423 Prepare for new release
9f520a28 Update golangci-lint and fix resource leak (#2024) * Fix golangci-lint in CI * Fix resource leak
- 74baaa14 fixed model gen for multiple implemented type (#2021) - d31cf6be v0.17.0 postrelease bump ## [v0.17.0](https://github.com/99designs/gqlgen/compare/v0.16.0...v0.17.0) - 2022-03-01 - e4be5651 release v0.17.0
082bbff6 Revert "Update quickstart (#1850)" (#2014) This reverts commit 0ab636144bfc875f86e4d9fd7a2686bc57d5050c.
- a58411b8 Embed templates instead of inlining them (#2019) - 839b50df Test gqlgen generate in CI (#2017) - 00dc14ad Remove ambient imports (#2016)
45e192ea Clean up docs to clarify how to use a particular version (#2015) (closes #1851) This reverts commit 57a148f6d12572fe585ecfcafafbb7441dbf9cab. * Update getting-started.md * Update getting-started.md
- 3a9413f7 Fix issue template
5236fb09 fix introspection for description to be nullable (#2008) * fixed introspection for description to be nullable * regenerated for integration * regenerated * fixed introspection package * regenerated
82fefdb5 support to generate model for intermediate interface (#1982) * support to generate model for intermediate interface * go generate ./... in example * fixed filepath generation
3ec83635 Bump ajv from 6.10.2 to 6.12.6 in /integration (#2007) Bumps [ajv](https://github.com/ajv-validator/ajv) from 6.10.2 to 6.12.6. - [Release notes](https://github.com/ajv-validator/ajv/releases) - [Commits](https://github.com/ajv-validator/ajv/compare/v6.10.2...v6.12.6) --- updated-dependencies: - dependency-name: ajv dependency-type: indirect ...
9546de2c Web Socket initialization message timeout (#2006) * Added an optional timeout to the web socket initialization message read operation. * Added a fail message to a web socket init read timeout test.
f6ea6230 fixed introspection for schema description and specifiedByhttps://github.com/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
- a0543733 remove autobind example (#1949)
06bbca37 docs: migrate dataloaders sample to graph-gophers/dataloader (#1871) * docs: add dataloader sample * finish example * add example * simplify method * replace old example * styling * Update docs/content/reference/dataloaders.md * Update docs/content/reference/dataloaders.md * Update docs/content/reference/dataloaders.md * Update docs/content/reference/dataloaders.md
f9fcfa16 Comment out autobind in the sample config file (#1872) The reason is that many people using it for the first time copy exactly that configuration example and then open the issues to say it doesn't work.
- a30b68de fix: whitelist VERSION and CURRENT_VERSION env vars (#1870)
76a533b8 Bump gopkg.in/yaml.v2 from 2.2.4 to 2.2.8 (#1858) * Bump gopkg.in/yaml.v2 from 2.2.4 to 2.2.8 Bumps [gopkg.in/yaml.v2](https://github.com/go-yaml/yaml) from 2.2.4 to 2.2.8. - [Release notes](https://github.com/go-yaml/yaml/releases) - [Commits](https://github.com/go-yaml/yaml/compare/v2.2.4...v2.2.8) --- updated-dependencies: - dependency-name: gopkg.in/yaml.v2 dependency-type: direct:production ... * Update go sum for example
eed4301c Bump node-fetch from 2.6.1 to 2.6.7 in /integration (#1859) Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.1 to 2.6.7. - [Release notes](https://github.com/node-fetch/node-fetch/releases) - [Commits](https://github.com/node-fetch/node-fetch/compare/v2.6.1...v2.6.7) --- updated-dependencies: - dependency-name: node-fetch dependency-type: direct:development ...
- 7f5dce6d Fix #1776 : Edit and persist headers in GraphiQL (#1856) - e0b42f99 fix requires directive with nested field when entityResolver directive is used (#1863) - 25c2cdcb Fix #1636 by updating gqlparser (#1857) - c161ab38 fix #1770 minor error in getting-started.md (#1771)
57a148f6 Remove outdated version reference so example is always for latest (#1851) * Also update version reference to next * Update getting-started.md
- 0ab63614 Update quickstart (#1850)
a8eba26d Fix #1777 by updating version constant and adding release checklist (#1848) * Revise to use script 🤦
## [v0.16.0](https://github.com/99designs/gqlgen/compare/v0.15.1...v0.16.0) - 2022-01-24 - b90f9750 Merge branch 'master' of github.com:99designs/gqlgen - 99523e44 Prepare for v0.16.0 release (#1842) - 0563146c Prepare for v0.16.0 release
7cefef26 add PrependPlugin (#1839) * add PrependPlugin related: https://github.com/99designs/gqlgen/pull/1838 * added test for PrependPlugin
972878a0 Revert "Fix plugin addition (#1717)" (#1838) This reverts commit f591c8f797e35635fb5eb0e4465c77b6a073896b.
1ed7e050 Fix #1832 [@requires](https://github.com/requires) directive when [@entityResolver](https://github.com/entityResolver) is used (#1833) * fix requires directive for multipleEntity directive * fix lint
fcee4c40 Update README.md (#1836) Corrected a simple grammar typo.
3fb5fd99 Fix #1834: Implement federation correctly (#1835) * Fix federation implementation which does not conform to Apollo Federation subgraph specification * Optimize generated line breaks * Run go generate
98665071 Imporve gqlgen test cases (#1773) (closes #1765) * Imporve test cases for init and generate
5d904d87 Merge pull request #1778 from ipfans/gh-pages-patch Bump gqlgen.com version list
- 196ee13b Bump gqlgen.com version ## [v0.15.1](https://github.com/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.
- 27a2b210 Downgrade to Go 1.16 (#1743)
14cfee70 Support for multiple [@key](https://github.com/key) directives in federation (reworked) (#1723) * address review comments - reworked code generation for federation.go - better checking for missing/incorrect parameters to entity resolver functions - better tests for generated entity resolvers Still missing: - suggested test for autobind vs non-autobind generation - could probably clean up generated code spacing, etc
- 2747bd5f Add CSV and PDF to common initialisms (#1741)
44beadc1 Fix list coercion when using graphql variables (#1740) * fix(codegen): support coercion of lists in graphql variables This was broken by an upstream dependency `gqlparser` coercing variables during validation. this has broken the existing coercion process withing `gqlgen` * test: add list coercion integration tests * chore: regenerate generated code * test: update expected schema for integration tests * chore: run goimports * chore: regenerate examples
bd8938d8 fix: automatically register built-in directive goTag (#1737) * fix: automatically register built-in tag goTag * doc: add directive config documentation
497227fa Close Websocket Connection on Context close/cancel (#1728) * Added code to the web socket so it closes when the context is cancelled (with an optional close reason). * Added a test. * go fmt * Fix linter issues about the cancel function being thrown away.
- 4581fccd Don't loose field arguments when none match (#1725)
213ecd93 Add support for graphql-transport-ws with duplex ping-pong (#1578) * Add support for graphql-transport-ws with duplex ping-pong * Add tests for the duplex ping-pong
- ae92c83d add federation tests (#1719) - f591c8f7 Fix plugin addition (#1717) - 8fa6470f Fix #1704: handle [@required](https://github.com/required) nested fields as in [@key](https://github.com/key) (#1706)
af33b7cd Cleaning up extra return in federation generated code (#1713) In PR 1709, I introduced GetMany semantics for resolving federated entities. But I left a couple of extra return statements in the generated code that are not necessary. So Im just cleaning those up here. Also added `go:generate` in federation entity resolver tests to make it simpler to test. To test: ``` go generate ./... && cd example/ && go generate ./... && cd .. go test -race ./... && cd example && go test -race ./... && cd .. ```
402a2259 Optimize performance for binder, imports and packages (Rebased from sbalabanov/master) (#1711) * Cache go.mod resolution for module name search * Optimize binder.FindObject() for performance by eliminating repeatitive constructs * Optimize allocations in packages.Load() function * Optimize binder.FindObject() by indexing object definitions for each loaded package * goimports to fix linting
- 237a7e6a Separate golangci-lint from other jobs (#1712)
50292e99 Resolve multiple federated entities in a single entityResolve call (#1709) * Resolve multiple federated entities in a single entityResolve call Entity resolver functions can only process one entity at a time. But often we want to resolve all the entities at once so that we can optimize things like database calls. And to do that you need to add you'd need to add batching with abstractions like dataloadgen or batchloader. The drawback here is that the resolver code (the domain logic) gets more complex to implement, test, and debug. An alternative is to have entity resolvers that can process all the representations in a single call so that domain logic can have access to all the representations up front, which is what Im adding in this PR. There are a few moving pieces here: 3. When that's configured, the federation plugin will create an entity resolver that will take a list of representations. Please note that this is very specific to federation and entity resolvers. This does not add support for resolving fields in an entity. Some of the implementation details worth noting. In order to efficiently process batches of entities, I group them by type so that we can process groups of entities at the same time. The resolution of groups of entities run concurrently in Go routines. If there is _only_ one type, then that's just processed without concurrency. Entities that don't have multiget enabled will still continue to resolve concurrently with Go routines, and entities that have multiget enabled just get the entire list of representations. The list of representations that are passed to entity resolvers are strongly types, and the type is generated for you. There are lots of new tests to ensure that there are no regressions and that the new functionality still functions as expected. To test: 1. Go to `plugin/federation` 2. Generate files with `go run github.com/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.
- 41c86765 Revert 1595 (#1658) - 8359f974 Allow custom websocket upgrader (#1595)
1318f127 Update GQLgen test client to work with multipart form data (#1418) * Update GQLgen test client to work with multipart form data Update the GQLgen to support multipart form data, like those present within the fileupload examples. - Add missing space between "unsupported encoding " and failing content-type header error * Add WithFiles client option for fileupload GQLgen client tests Add a `WithFiles` GQLgen client option to support the fileupload input within tests, using the core Golang `os` package and File type, which converts `os.File`s to their appropriate multipart form data within a request. - If there are no files this should just simply convert a `application/json` Content-Type to supported `multipart/form-data` * Update fileupload test to use GQLgen test client Update the fileupload test to use the GQLgen test client and `WithFiles` option to remove the need for `createUploadRequest` helper with raw http posts - Fix setting the Content Type by using the appropriate `http` package function to dectect it + https://godoc.org/net/http#DetectContentType * Update WithFiles option test with multipart Reader * Update file upload tests `WithFiles` option Update the file upload tests to use the GQL test client and its `WithFiles` option to remove the need for a custom raw HTTP post request builder `createUploadRequest`. - Also update `WithFiles` option to group & map identical files; e.g. ``` { "0": ["variables.req.0.file", "variables.req.1.file"] } ``` * Make sure `WithFiles` does not add duplicates to multipart form data * Fix use of byte vs string in `WithFiles` tests
- 6758654c raise panic when nested [@requires](https://github.com/requires) are used on federation (#1655)
f6c35be2 Add ReplacePlugin option to replace a specific plugin (#1657) * Add Helper Option for replacing plugins * Update recipe to use ReplacePlugin instead of NoPlugin and AddPlugin * fix linting issue on comment
f8c46600 fix double indirect bug (#1604) (closes #1587) * invalid code generated * update code generation for pointer-to-pointer updating
- 629c91a2 remove extra WithOperationContext call (#1641) - 35199c49 codegen: ensure Elem present before using (#1317)
bfea93cd Reload config packages after generating models (#1491) If models are generated in a package that has already been loaded, and that package refers to another package that has already been loaded, we can find ourselves in a position where it appears that a GQL `union` is not satisfied. For example, if we have: ``` union Subject = User ``` with this gqlgen.yml in github.com/wendorf/gqlgen-error/gql: ``` schema: - schema.graphql exec: filename: generated.go model: filename: models_gen.go models: User: model: github.com/wendorf/gqlgen-error/gql.User Subject: model: github.com/wendorf/gqlgen-error/models.Subject ``` Note that our User model is in the github.com/wendorf/gqlgen-error.gql package, and our models_gen.go will be generated in that same package. When we try to run gqlgen, we get this error: ``` merging type systems failed: unable to bind to interface: github.com/wendorf/gqlgen-error/gql.User does not satisfy the interface github.com/wendorf/gqlgen-error/models.Subject ``` Digging deeper, it's because we use types.Implements in codegen/interface.go, which does a shallow object comparison. Because the type has been reloaded, it refers to a _different_ interface type object than the one we're comparing against, and get a false negative. By clearing the package cache and repopulating it, the whole package cache is generated at the same time, and comparisons across packages work. To see a demo of this, check out https://github.com/wendorf/gqlgen-error and try the following: 1. Checkout the works-with-v0.10.2 branch and `go generate ./...` to see that it works 2. Checkout the breaks-with-v0.13.0 branch (or run go get to see errors 3. Checkout the works-with-pull-request branch and `go generate ./...` to see that it works again. This branch adds a go.mod replace directive to use the gqlgen code in this PR. The demo starts at v0.10.2 since it is the last release without this problem. https://github.com/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
- a3d9e8ce Remove redundant favicon (#1638) - 210c1aa6 Appropriately Handle Falsy Default Field Values (#1623)
47ce074a Fix example run instructions (closes #1607) Making ./example a separate Go module [1] broke the `go run` invocations listed in a few example readmes [2]. Using relative paths from the respective example directory should be clear enough. [2]: example/todo/server/server.go:10:2: no required module provides package github.com/99designs/gqlgen/example/todo; to add it: go get github.com/99designs/gqlgen/example/todo
- 1a0b19fe Update README.md
d9998283 Merge pull request #1628 from robertmarsal/patch-1 Fix typo in the getting-started docs
- f93f73ac Fix typo in the getting-started docs
2f6919ff Merge pull request #1624 from FlymeDllVa/master Update disabling Introspection
- c53bc0e5 Update disabling Introspection - 880cd73d Update README.md - eec81df0 Update README.md
43b56cba Forward `go mod tidy` stdout/stderr This is a command that can fail (in my case I think for stupid reasons in a hell of my own construction, but nonetheless). Right now we just get ``` $ go run github.com/Khan/webapp/dev/cmd/gqlgen tidy failed: go mod tidy failed: exit status 1 exit status 3 ``` which is not the most informative. Now, instead, we'll forward its output to our own stdout/stderr rather than devnull.
- ce7a8ee4 Fix link in docs - 488cf7e8 Update docs/content/getting-started.md - 73809f69 Update getting started - b938e558 Update README.md - cacd49a6 Update README.md
7d549d64 Merge pull request #1617 from 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
- 00ed6fb1 Also test against 1.16
473f0671 Merge pull request #1613 from 99designs/bump-non-module-deps Clean up non-module deps
- 6960c0c2 Bump non-module deps
bf9b34aa Merge pull request #1612 from 99designs/update-linter Update golangci linter
- 85e7a4a0 Linting fixes - 777dabde Update the linter
85dd47bb Merge pull request #1607 from 99designs/example-module [POC/RFC] Split examples into separate go module
- f93fb248 Split examples into separate go module
890f5f66 Merge pull request #1610 from 99designs/go-1.17 Update to go 1.17
- 9162c53f Fix newlines in error messages - f67a5b26 Update github.com/urfave/cli/v2
1116ea6c Merge pull request #1608 from jjmengze/patch-1 fix Options response header
- 71e57843 Simplify init - a8903ca2 Wrap errors - a644175b Update error checks for go 1.17 - c6b9f292 go mod tidy - 1c63cfff Add missing model package file - 59da23fe Create a temporary file on init so go recognises the directory as a package
682a7d66 fix Options response header operatee the header of ResponseWriter should before WriteHeader called
- ed8054b0 Update to a post-release version - 5216db58 Fix TestAutobinding test failure by checking the module - 90c5eb59 go generate - 402f4495 go fmt - 10bb1ef2 Go mod tidy - ed210385 Update to go 1.17 - 5c7acc1b Fix imports - d7473870 Update plugin/servergen/server.go - a6c6de6b Update plugin/resolvergen/resolver.go - de7d19c8 Update codegen/config/config_test.go - 60d80d4a Update cmd/gen.go - a991e3e7 Update errors to use go1.13 semantics
8f179be9 Merge pull request #1581 from tsh96/master Bypass complexity limit on __Schema queries.
5048f992 Merge pull request #1525 from Code-Hex/fix/support-input-object support input object directive
1e2b303a Merge pull request #1526 from epulze/fix/allow-more-types allow more than 10 different import sources with types
e7df3e5c Merge pull request #1405 from alexsn/subsciption-complete-on-panic subscriptions: send complete message on resolver panic
06e4fe88 Merge pull request #1529 from mathieupost/master Return type loading errors in config.Binder.FindObject
a557c90c Merge pull request #1340 from bickyeric/master serialize ID just like String
522cab59 Merge pull request #1285 from Khan/benkraft.federation Resolve requests for federation entities in parallel
- 5adb73bb add bypass __schema field test case - 54cef3dd Bypass complexity limit on __Schema queries. - f0ccab79 Return type loading errors in config.Binder.FindObject - 91b54787 generated go code - 1efc152e supported INPUT_OBJECT directive - e82b401d allow more than 10 different import sources with types
481a4e44 Marshaling & Unmarshaling time return initial value There was a lack of symmetry that would prevent times for being symmetrical. That is because time.Parse actually parses an RFC3339Nano implicitly, thereby allowing nanosecond resolution on unmarshaling a time. Therefore we now marshal into nanoseconds, getting more information into GraphQL times when querying for a time, and restoring the symmetry
95653193 Resolve requests for federation entities in parallel (closes #1278) In apollo federation, we may be asked for data about a list of entities. These can typically be resolved in parallel, just as with sibling fields in ordinary GraphQL queries. Now we do! I also changed the behavior such that if one lookup fails, we don't cancel the others. This is more consistent with the behavior of other resolvers, and is more natural now that they execute in parallel. This, plus panic handling, required a little refactoring. The examples probably give the clearest picture of the changes. (And the clearest test; the changed functionality is already exercised by `integration-test.js` as watching the test server logs will attest.)
- f00e2c3f subscriptions: send complete message on resolver panic - fa371b9b serialize ID just like String ## [v0.14.0](https://github.com/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
- db6154b9 Update README.md
cecda160 Merge pull request #1464 from frederikhors/patch-1 Add goreportcard badge
- cc957171 Merge branch 'master' into patch-1
023f66df Merge pull request #1465 from frederikhors/patch-2 Add coveralls badge
50c2028a Merge pull request #1497 from polytomic/stable-introspection Return introspection document in stable order
a0232dd2 Merge pull request #1603 from 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
- be9a0791 Update apq.md - 3e45ddc1 Correct minor casing issue - 145101e4 Update apq.md
843edd9e Update apq.md function definition mismatch line 67: cache, err := NewCache(cfg.RedisAddress, 24*time.Hour) line 41: func NewCache(redisAddress string, password string,ttl time.Duration) (*Cache, error) either password should be removed from 41 or added in line 67 Proposed the first one for now.
5ad012e3 Revert "Merge pull request #1511 from a8m/a8m/restore-cwd" This reverts commit f4bf1f591b6a3884041876deb64ce0dd70c3c883, reversing changes made to 3f68ea27a1a9fea2064caf877f7e24d00aa439e6. Reverting this because it will break existing setups, moving where generated files get put.
- bb59cc43 Add a CHANGELOG.md (#1512) - 058a365a Merge pull request #1456 from skaji/issue-1455
bf2fdf44 Merge pull request #1514 from 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)
c920bdeb Merge pull request #1449 from steebchen/feat-prisma-compat feat(codegen): handle (v, ok) methods
3cfc5b14 codegen/config: restore current working directory after changing it Before this commit, a call to config.LoadConfigFromDefaultLocations changed the working directory to the directory that contains the gqlgen config file. This commit changes the implementation to restore the working directory after loading the config.
35b80a72 Merge pull request #1495 from Niennienzz/improve-apq-doc Update apq.md
463debae Merge pull request #1503 from nana4gonta/resolve-vulnerability Resolve indirect dependency vulnerability in example
29e7bccb Merge pull request #1501 from 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
- 02b14003 fomatted query indent - 0e9d9c3a updated sample code for disabling introspection - 478c3f08 feat(codegen): handle (v, ok) methods
5ef5d14f Update cors.md I had problems reading this page and applying it to my project. With these changes it worked on my end
997da421 Merge pull request #1436 from ddouglas/patch-1 Upgrade graphql-playground to 1.7.26
- be4514c6 Upgrade graphql-playground to 1.7.26 - 918801ea Change 'Changeset' doc example to mutation
862762c7 Merge pull request #1409 from zikaeroh/chi-mod Upgrade go-chi to v1.5.1 with module support
- c30ff3dd Upgrade go-chi to v1.5.1 with module support - a9c8fabf int64 support
b484fc27 Merge pull request #1401 from oseifrimpong/patch-1 fix typo
4cc031af Merge pull request #1394 from j2gg0s/fix-default-recover-func bugfix: Default Recover func should return gqlerror.Error
2af51336 Merge pull request #1400 from 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
- 1e8c34e5 Dont export Input
de8af66c Merge pull request #1360 from Captain-K-101/master Update introspection.md
- 09756915 Update introspection docs
651eda40 Merge pull request #1374 from rudylee/docs-file-upload-small-typo Fix small typo in file upload docs
- 94252e04 singleUpload consistency - c9d346f5 Fix small typo in file upload docs - 9f851619 add uint, uint64, uint32 types in graphql
0625525f Update introspection.md updated disabling interospect
- c6a93aa7 split layout components to their own part, makes sample more readable - 7904ef6f channel is switchable too - 13752055 add some layout for demo :)
82ca6e24 Create package declaration to run dataloaden ref: https://github.com/vektah/dataloaden/issues/35
- bf549136 use Apollo docs styling for the gql var uppercase - 36045a37 do not autofocus - 0502228a chore: update example to React hooks and latest Apollo client - e6e64224 update deps
3a31a752 Merge pull request #1345 from abeltay/fix-alignment Fix tab spacing in cors.md
0c68337c Merge pull request #1346 from abeltay/fix-typo Fix typo in migration guide
- 436a88ad Fix typo in migration guide - 3791f71d Fix tab spacing in cors.md
819e751c Merge pull request #1341 from dgraph-io/rajas/fix-gqlgen-1299 Rajas/fix gqlgen 1299
- 789d02f5 Requested changes - 130ed3f7 Fix different alias with same name in inline fragment - f4669ba9 v0.13.0 postrelease bump - 07c06594 Update README.md - 1c9f24b2 remove triming space for schemaDefault ## [v0.13.0](https://github.com/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
- 77aeb477 Point latest docs to v0.12.2
e821b97b Always wrap user errors (closes #1305) Requires use of go 1.13 error unwrapping. On measure I think I prefer this approach, even though it's a bigger BC break: - There's less mutex juggling - It has never felt right to me that we make the user deal with path when overriding the error presenter - The default error presenter is now incredibly simple Questions: - Are we comfortable with supporting 1.13 and up? - Should we change the signature of `ErrorPresenterFunc` to `func(ctx context.Context, err *gqlerror.Error) *gqlerror.Error`? - It always is now, and breaking BC will force users to address the requirement for `errors.As`
51b580de Merge pull request #1324 from bemasher/patch-1 Fix typos in README.md
- 8b2a023c Fix typos in README.md - 3e5dd956 add test for FieldContext.IsResolver - 1524989b go generate - 55951163 add IsResolver to FieldContext
622316e7 Merge pull request #1295 from a-oz/a-oz-patch-1 Update getting-started.md
4c11d9fa Update getting-started.md fix typo
- b4375b04 v0.12.2 postrelease bump ## [v0.12.2](https://github.com/99designs/gqlgen/compare/v0.12.1...v0.12.2) - 2020-08-18 - 03cebf20 release v0.12.2
e3ce560d Merge pull request #1288 from alexsn/nopath-field-noerror avoid computing field path when getting field errors
108975c3 Merge pull request #1284 from dgraph-io/jatin/sameFieldSameTypeGettingIgnored fix same field name in two different fragments
eb424a22 Merge pull request #1294 from 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
- dbbda22e go 1.14
ce964c1f Merge pull request #1115 from bowd/add-input-path-for-unmarshaling Add input path in unmarshaling errors
- bde4291c shadow context to ensure scoped context use - c43990a0 Merge remote-tracking branch 'origin/master' into HEAD - 6be2e9df fix fileupload example
ad675f00 Allow custom resolver filenames using `filename_template` option (closes #1085) resolve merge conflicts.
- fbfdd41c Merge pull request #1262 from sateeshpnv/gqlparser-alias (closes #1258) - 99fafc9f [issue #1258] explicitly add gqlparser alias to vektah/gqlparser/v2 import - 49291f23 fix bug in OBJECT directive
0fbf293f Merge pull request #1248 from sotoslammer/master close the connection when run returns
d7eabafb Merge pull request #1246 from arkhvoid/master Fix typo cause memory problem on upload
- 21b223b8 Fix typo cause memory problem on upload - cc9c520f close the connection when run returns
8494028e Merge pull request #1243 from 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
- d11f6021 Do not use pointers on named map types
acaee361 Merge pull request #1121 from Khan/extern-only Do not require a resolver for "empty" extended types.
555db6d2 Merge pull request #1224 from frederikhors/patch-1 Indentation misprint
- 77b37bb2 Indentation misprint
a3c38c65 Merge pull request #1221 from longngn/patch-1 Update dataloaders.md
- 71182de8 Update dataloaders.md
d81baeed Merge pull request #1218 from StevenACoffman/patch-1 Update feature comparison for federation
- 2c1f2345 Update feature comparison for federation (closes #5) - e19d43bc Adding test - 4a62f012 Adding ContentType header to GET request responses - f5de4731 Add timeout to integration test
a21a6633 Merge pull request #1189 from RichardLindhout/patch-1 Upgrade to OperationContext and remove duplicate fields to fix https:…
543317a2 Merge pull request #1170 from alexsn/apollotracing/nopanic apollotracing: skip field interceptor when on no tracing extension
- d347d972 Update stale.yml
032854bb Merge pull request #1154 from gsgalloway/master Add operation context when dispatching
ccc4eb1d Merge pull request #1188 from k-yomo/update-errors-doc Update outdated examples in errors doc
628b83c1 Merge pull request #1198 from ddevault/pgp codegen: add PGP to common initialisms
d881559b Merge pull request #1202 from whereswaldon/patch-1 doc: fix typo in embedded struct example
b6ce42a7 Merge pull request #1207 from k-yomo/update-gorilla-websocket Update gorilla/websocket to v1.4.2 to resolve vulnerability
- c5bfe9d3 Update gorilla/websocket to v1.4.2 to resolve vulnerability - 55c16e93 doc: fix typo in embedded struct example - 89eb1993 codegen: add PGP to common initialisms - 9ab7294d apollotracing: skip field interceptor when on no tracing extension
40570d1b Merge pull request #1163 from fwojciec/master fix redundant type warning
3f7f60bf Merge pull request #1181 from tmc/patch-1 Update getting-started.md
- 6518d839 Upgrade to OperationContext and remove duplicate fields to fix https://github.com/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.
- 0e2666fb Run `go fmt`
36b5ed83 Actually, we need to check all-external, not all-key. We might well be defining our own type that has only key-fields, but if they're not external then we're the primary provider of the type Test plan: go test ./plugin/federation/
7e3f5844 Do not require a resolver for "empty" extended types. Summary: If our schema has a field with a type defined in another service, then we need to define an "empty extend" of that type in this service, so this service knows what the type is like. But the graphql-server will never ask us to actually resolve this "empty extend", so we don't require a resolver function for it. Example: ``` type MyType { myvar: TypeDefinedInOtherService } // Federation needs this type, but it doesn't need a resolver for // it! graphql-server will never ask *us* to resolve a // TypeDefinedInOtherService; it will ask the other service. extend TypeDefinedInOtherService @key(fields: "id") { id: ID @extends } ``` Test Plan: I manually tested this on a service (`assignments`) that we have that fell afoul of this problem. But I had a hard time adding tests inside gqlgen because the error happens at validation-time, and the federation tests are not set up to go that far down the processing path. Reviewers: benkraft, lizfaubell, dhruv Subscribers: #graphql Differential Revision: https://phabricator.khanacademy.org/D61883
- 9c80bb5b type Person -> type Person struct - ea210929 add test for object directive - 5c3812cb merge object directives to field directives - 8ea5ba2b Fix additional missed tests - 65be2a6e Run generate - fd615cf6 Fix linting - 61fa9903 Add documentation for scalad error handling - 1aa20f25 Add test to highlight usecase - d98ff1b0 Modify templates to include deeper context nesting
a1a02615 Merge pull request #1104 from oshalygin/docs/update-query-complexity-initialization Update Query Complexity Documentation
c68df3c6 Merge pull request #1112 from s-ichikawa/delete-unused-code delete unused code
dfb6558a run CI on PRs PRs from outside the org arent running CI, hopefully this fixes it.
- 5149231c delete unused code
6f81ff92 Update Query Complexity Documentation - This pass at the documentation updates the appropriate section regarding query complexity, specifically in the way that the http.Handler is created. - The deprecated handler.GraphQL calls were replaced with NewDefaultServer. - Instead of passing along the fixed query complexity as a second argument to the now deprecated handler.GraphQL func, extension.FixedComplexityLimit is used instead.
- f0cd7a70 update doc site to point to latest version - 224ff345 v0.11.3 postrelease bump ## [v0.11.3](https://github.com/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
- 5e3cef24 revert #1079
793b0672 Merge pull request #1100 from sonatard/fast Gnerate to fast by exec codegen.GenerateCode before plugin GenerateCode
6ac2d1cd Merge pull request #1097 from 86/86/update-federation-doc Add Enable federation section in federation doc
- 97896eeb exec codegen.GenerateCode before plugin GenerateCode to fast - 44f8ba9f Update licence - 94701fb7 add Enable federation section in federation doc - 64190309 Update upload docs with Apollo usage - a5381191 v0.11.2 postrelease bump ## [v0.11.2](https://github.com/99designs/gqlgen/compare/v0.11.1...v0.11.2) - 2020-03-05 - 2ccc0aa6 release v0.11.2
78f3da22 Merge pull request #1050 from technoweenie/executor Executor
- b82ee517 Fix CI badge
42eff5a9 Merge pull request #1057 from RichardLindhout/master Upgrade to github.com/urfave/cli/v2
bb5cb8a3 Merge pull request #1086 from 99designs/github-actions Use GitHub Actions
- cd2b53f2 remove os.Exits
587bc81c Merge pull request #1074 from yudppp/feature/add_contenttype_for_upload Add ContentType to graphql.Upload
- a84d6577 graphql/handler: revive the existing around func types - f9bb017b graphql/executor_test: ensure operation trace is started before every query - 57dd8d9c graphql/gqlgen: remove unnecessary convenience method - fb86f7b9 graphql/executor: remove the naked return - 9ae6bc0b graphql/executor: reinit all extension values on every Use() call - f3909a8a graphql/executor: make ext funcs private - df9e7ce3 Run CI on push only - ed76bc92 Update badge - 5a1a5446 Coveralls fixes - 41acc753 Fix windows line endings - 390cea4f Replace Appveyor with Github Actions - 85be072f Replace CircleCI with Github Actions - 8d540db3 fix: Add Upload.ContentType test - f21832af fix: Fixed Upload type document
b165568c Merge pull request #1071 from kandros/fix-server-path fix server path
9d7648aa Merge pull request #1072 from wtask/patch-1 Fix a typo in sql example
24400c9b Merge pull request #1079 from sonatard/remove-unused Remove unused code
a7c79891 Merge pull request #1081 from sonatard/fix-plugin-test Fix unlink file path in resolvergen test
e7bf7548 Merge pull request #1080 from sonatard/fix-testdata Fix test data
- 3a61dc00 Fix unlink file path in resolvergen test - df5ac929 Fix test data - b2843f67 Remove unused code - cff73f71 Add ContentType to Upload
f0ebc0df Fix a typo in sql example I think todo is referenced to user by user_id field, not by todo.id
- 22a43d77 fix server path
b788cce5 Merge pull request #1054 from 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
- 2c3853c8 fix whitespace in comparison
07a13861 Merge pull request #1043 from 99designs/ensure-panic-handlers-get-applied Ensure panic handlers get applied
156d306d Merge pull request #1046 from appleboy/patch docs(gin): missing import playground
- 26ee1aa1 docs(gin): missing import playground - 3abe5b32 add test - 6ecdb88d Merge branch 'master' into feat-check-len - 2340f7a7 Ensure panic handlers get applied
25d16761 Merge pull request #1039 from VitaliiLakusta/patch-1 Fix link to examples directory in Federation docs
- 4c47ad16 Fix link to examples directory in Federation docs - 2506dce0 check slice len - 1a68df34 fix origin/master reference in switcher - 199cfedf remove old docs that no longer run with new layout - 556c8484 fix paths - 282100c8 use current layout to build old doc content - 4c38b8b4 v0.11.0 postrelease bump ## [v0.11.0](https://github.com/99designs/gqlgen/compare/v0.10.2...v0.11.0) - 2020-02-17 - 368597aa release v0.11.0
e65d6228 Merge pull request #1036 from 99designs/update-v011-docs Update 0.11 migration docs
- 11f97936 Update 0.11 migration docs
2b3eed30 Merge pull request #1034 from 99designs/strip-underscores-from-entity-interfaces Trim underscores from around go identifiers
- b2d9bfcb Update stale.yml - 1ac8b5ae Update stale.yml - 4b9dfa61 trim underscores from around go identifiers
7cac3610 Merge pull request #1027 from sonatard/response-errors propagate resolver errors to response error in ResponseMiddleware
14dccc57 Merge pull request #1022 from 99designs/feat-gqlparser-117 example about apply https://github.com/vektah/gqlparser/pull/117
- cf6f7683 bump to gqlparser v2
4ece3857 Merge pull request #1028 from abhimanyusinghgaur/master Respect includeDeprecated for EnumValues
- 9638ce0f Fix format - 51b921fa Fix format - 07ffcc82 Respect includeDeprecated for EnuValues - d58434c9 propagate resolver errors to response error in ResponseMiddleware - 59855925 go mod tidy - e4530da6 apply https://github.com/vektah/gqlparser/pull/117
30e23757 Merge pull request #1020 from 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
- 2f0fa0ef handle schema loading error better - aacc9b1f Remove source reprinting
e289aaa0 Merge pull request #1018 from 99designs/federation-docs Federation docs and examples
- 3045b2cf Federation docs and examples
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
- 6bf88417 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)
- db499561 force rebuild - 0985a78e remove debug comments - 7f648425 add preliminary test_data - c9d6d94b add preliminary tests - 2345936e fix integration - aae7486d go generate - 555a9546 go generate + remove directives nil check - 368d546d Apollo Federation MVP - 21e0e676 Fix extra trimspace on nillable Unmarshals - f869f5a8 remove deprected handler call - f0b83cb1 fix merge conflict - cdf96721 update generated code - 21356ce3 markdown cleanup
412a72fe Merge pull request #885 from 99designs/handler-refactor Refactor handler package
- bac79c54 force clean git checkout - dca9e4a5 Add migration docs
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
e747d923 Merge pull request #938 from lulucas/master modelgen hook docs fixed
63be1d5e Merge pull request #1 from lulucas/modelgen-hook-patch-1 modelgen hook docs use plugin poitner
33fc16b1 modelgen hook docs use plugin poitner and add modelgen package to ModelBuild type
- fcfe595e Add a comment
59946087 Add unit test for the interface resolver / typed nil interaction This added test shows that the `_Dog_species` automatically generated resolver will crash unless the extra nil check is added in `interface.gotpl`.
- 201768f0 Regenerate examples
85ca9efe Return graphql.Null in interface resolver when passed a typed nil Go's dreaded _typed nil_ strikes again. Nil pointers of struct types aren't equal to nil interface pointers. See https://golang.org/doc/faq#nil_error
15b30588 Merge pull request #894 from 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
- 7508f4e5 Update to gqlparser-1.2.0
7653a681 Merge pull request #916 from karthikraobr/patch-1 3->4 scalars
8faa0e3a Merge pull request #917 from colelawrence/patch-1 docs: Fix typo in title of "Resolvers"
- f7d888f9 Merge branch 'master' into patch-1 - d722ac66 Update scalars.md
1172128c Merge pull request #904 from cfilby/fix-config-docs Minor Documentation Tweaks
- 935f11ed Fix typo in title - 026d029c 3->4 scalars - 5eb6bef6 Fix weird indending - 756dcf6b Merge pull request #907 from lian-yue/patch-1 (closes #860) - 2a943eed Update directive.go (closes #860)
adbceeea Merge pull request #902 from cfilby/fix-int64-marshalling Add support for int64 IDs
- 13c3d922 Update id function - 37191779 Add more tests - 0968e0cb Fix VSCode Weirdness, validate formatting - a20c96d5 More edits - e9e88b41 Stop double indending - 9f4df68e More minor doc fixes - 7abf0ac3 Fix documentation bug - e9730ab9 gofmt - c3930f57 Remove redundant paren, add test - 395fc85e Add support for int64 ids
dbc88428 Merge pull request #889 from thnt/fix-init-with-schema-arg fix init not use custom schema filename
- fc4e513f add test for https://github.com/vektah/gqlparser/pull/109 - dd98bb13 fix init not use custom schema
4c35356c Merge pull request #883 from 99designs/handle-invalid-types Gracefully handle invalid types from invalid go packages
- 25b70271 Gracefully handle invalid types from invalid go packages
046054db Merge pull request #882 from 99designs/testserver-autobind Use autobinding in testserver
- 12c963a4 Use autobinding in testserver
305116a0 Merge pull request #879 from coderste/patch-1 Fixed broken GitHub link within the APQ page
b4867b3f Fixed broken GitHub link within the APQ page Small documentation change to fix a broken GitHub link.
- 9f6b0ee4 v0.10.1 postrelease bump ## [v0.10.1](https://github.com/99designs/gqlgen/compare/v0.10.0...v0.10.1) - 2019-09-25 - efb6efe0 release v0.10.1
955f3499 Merge pull request #877 from 99designs/fix-websocket-client Fix websocket connections on test client
- ef24a1cc Fix websocket connections on test client - c997ec0c v0.10.0 postrelease bump ## [v0.10.0](https://github.com/99designs/gqlgen/compare/v0.9.3...v0.10.0) - 2019-09-24 - 75a83752 release v0.10.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
ed14cf04 Update playground.go fix formatting
ee8d7a17 Update playground.go fix formatting
- 27389951 fixes shareable link button in playground - 4162d11e Refactor test client - 8ed6ffc7 Fix for nested fields backed by map or interface - 55b21442 Update stale.yml - feebee7d stalebot
7e643fdc Merge pull request #838 from 99designs/fix-directive-nil fix directives return nil handling
- f33e09e8 Merge branch 'master' into fix-directive-nil
8590edef Merge pull request #839 from 99designs/fix-nil-directive refactor unimplemented directive handling
- 1f7ed0d5 refactor unimplemented directive handling - 94ad3f2e fix directives return nil handling - 5c644a6f v0.9.3 postrelease bump - 82758be8 fix error - edde2d03 add OperationName field to RequestContext - 830e466e introduce RequestContext#Validate and use it instead of NewRequestContext function ## [v0.9.3](https://github.com/99designs/gqlgen/compare/v0.9.2...v0.9.3) - 2019-08-16 - a7bc468c release v0.9.3
fc02cfe8 Merge pull request #829 from 99designs/fix-2directives fix go syntax issue when field has 2 directives
924f620c Merge pull request #831 from yudppp/patch-1 Fixed scalar reference documentation
- ca4cc732 Fixed scalar documents - cc9fe145 fix go syntax issue when field has 2 directives - 6b70be03 v0.9.2 postrelease bump ## [v0.9.2](https://github.com/99designs/gqlgen/compare/v0.9.1...v0.9.2) - 2019-08-08 - 4eeacc6e release v0.9.2
5628169d Merge pull request #822 from 99designs/windows-import-path-loop fix for windows infinite loop
- a861aa52 lint fix - 6348a563 fix for windows infinite loop
12893fa4 Merge pull request #821 from 99designs/fix-init Fix config loading during gqlgen init
- 5fafe79c Fix config loading during gqlgen init
2599f560 Merge pull request #820 from 99designs/keepalive-on-init send keepalive on init
- 139e4e8d More directive docs - f93df340 send keepalive on init
8f0d9b48 Merge pull request #816 from nii236/patch-1 Update cors.md to allow CORS for websockets
- 297e09c4 change origin check
410d8322 Merge pull request #805 from andrey1s/golangci enable-all linters on golangci-lint
- 504a96bc set enabled linters - 91966ef4 add example to lint - bcddd7aa fix typo in readme - cce06f1d update lint in circleci
da1c208e Merge pull request #795 from oshalygin/feature/issue-794-resolve-dead-readme-link Update GraphQL Reference Link
8343c32c Merge pull request #784 from y15e/add-missing-header Add a missing "Upload" header
8302463f Merge pull request #797 from muesli/format-fixes Format import order using goimports
f2825e09 Merge pull request #801 from Schparky/patch-1 Documentation: getting-started edits
3db5627f Merge pull request #807 from flrossetto/patch-1 Fix doc
- ab228f1b Update cors.md to allow CORS for websockets
c4ac9347 Fix doc map[string]{interface} -> map[string]interface{}
- fbbed5b8 use alias when invalid pkg name - 2591ea36 fix lint prealloc - 3b0e44fe fix lint misspell - 6ff62b61 fix lint gocritic - cb7f482b fix lint unparam - 620552be fix lint goimports - 477e804e update config golangci - 5b203bcc clarify where the go:generate line should be added - 2a3df24e Replace the -v flag as described below. - f3eeb639 Clarify that the schema file will be generated - 3ac17960 Missing '*' in Todos resolver example - bd598c2c Format import order using goimports
419f966d Update GraphQL Reference Link (closes #794) - The link in the readme has been updated to reference a post by Iván Corrales Solera, "Dive into GraphQL". The previous link does not resolve, likely because the personal site is no longer hosted.
373359de Merge pull request #781 from 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
- b716bfac Autobind models
fc3755f1 Merge pull request #732 from 99designs/schemaconfig-plugin Add a plugin for configuring gqlgen via directives
- c14f8650 Add docs - 64aca616 Merge remote-tracking branch 'origin/master' into schemaconfig-plugin
5e7e94c8 Merge pull request #756 from andrey1s/field generate field defenition and execute field directive
ad2ca304 Merge pull request #759 from 99designs/circle-workflows CircleCI workflows
- 0fc822ca CircleCI workflows
2dc8423b Merge pull request #758 from franxois/patch-1 Update dataloaders.md
d0db28ab Update dataloaders.md Make SQL request use requested IDs
- a58ecfe9 add example and test field directive - 526beecb update generate field - 6e9d7dab generate types directive by location - dfec7b68 define fieldDefinition template - be890ab9 use UnmarshalFunc in args directives implement - dd162f04 define implDirectives template
56f3f92b Merge pull request #755 from 99designs/fix-globbing-windows fix globbing on windows
- a4480fb0 fix globbing on windows
ba176e2e Merge pull request #754 from 99designs/coveralls Add coveralls
- f28ed264 Add coveralls
f4a69ab5 Merge pull request #744 from andrey1s/directive add Execute QUERY/MUTATION/SUBSCRIPTION Directives
- dbd2cc6e simplify resolver test
7fed71b6 Merge pull request #728 from fgallina/make-generated-resolver-dependent-types-follow-configured-type resolvergen: use the resolver type as base name for dependent types
cb284c56 Merge pull request #734 from DBL-Lee/master Automatic Persisted Queries
726a94f4 Merge pull request #750 from 99designs/ws-connection-param-check [websocket] Add a config to reject initial connection
- 69d7e282 move directive to directives.gotpl
090f0bd9 Merge pull request #722 from marwan-at-work/deps resolve all pkg dependencies
- c397be0c Update websocketInitFunc to return error instead of boolean - be18ae1f Add a test - a6508b6d Update typing, function name and small code refactor - e6d791a9 Add websocketOnConnectFunc as a config that can be used to validate websocket init requests
c5acbead resolvergen: use the resolver type as base name for dependent types The template was outputing invalid code since the resolver type was not used in places like the embedding at {query,mutation}Resolver. This change also ensures that objects like {query,mutation}Resolver also use the user provided type name as suffix. Here's the resulting diff on the code generation with `type: GeneratedResolver` in the resolver config: ``` diff -u resolver.go resolvernew.go --- resolver.go 2019-05-26 20:04:15.361969755 -0300 +++ resolvernew.go 2019-05-26 20:04:54.170737786 -0300 @@ -7,20 +7,20 @@ type GeneratedResolver struct{} func (r *GeneratedResolver) Mutation() MutationResolver { - return &mutationResolver{r} + return &mutationGeneratedResolver{r} } func (r *GeneratedResolver) Query() QueryResolver { - return &queryResolver{r} + return &queryGeneratedResolver{r} } -type mutationResolver struct{ *Resolver } +type mutationGeneratedResolver struct{ *GeneratedResolver } -func (r *mutationResolver) CreateTodo(ctx context.Context, input NewTodo) (*Todo, error) { +func (r *mutationGeneratedResolver) CreateTodo(ctx context.Context, input NewTodo) (*Todo, error) { panic("not implemented") } -type queryResolver struct{ *Resolver } +type queryGeneratedResolver struct{ *GeneratedResolver } -func (r *queryResolver) Todos(ctx context.Context) ([]*Todo, error) { +func (r *queryGeneratedResolver) Todos(ctx context.Context) ([]*Todo, error) { panic("not implemented") } ```
- cfdbc39a update QueryDirectives - f32571ee add SUBSCRIPTION Directive - 32462d0f update example todo add directive with location QUERY and MUTATION - 3eec887a add Execute QUERY/MUTATION/SUBSCRIPTION Directives - 8fcc1868 format
e0e1e318 Merge pull request #1 from radev/master Support for external APQ cache
- 9873d998 Add APQ documentation with example - 48292c10 Support pluggable APQ cache implementations. - 694f90aa Merge pull request #717 from cbelsole/schema_file_globbing (closes #631) - 9be5aad0 Don't inject builtins during schema config - 8dc17b47 support GET for apq - d36932c5 support automatic persisted query - de75743c Add plugin for providing config via schema directives - 17a82c37 Provide config to skip generating runtime for a directive
ba7092c5 Merge pull request #724 from saint1991/patch-1 added a missing close bracket
- 9c1f8f2a added a missing close bracket - 3dd8baf5 resolve all pkg dependencies - 1617ff28 Merge pull request #718 from hh/fix-docs (closes #714) - 9d332a7d Fixing getting-started documentation - 39db1477 updated docs - e32c82be cleanup - e9389ef8 added schema file globbing fixes #631
4f163cbc Merge pull request #713 from 99designs/faq Add faq section
- 3a21b369 Add faq section ## [v0.9.0](https://github.com/99designs/gqlgen/compare/v0.8.3...v0.9.0) - 2019-05-15 - ea4652d2 release v0.9.0
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
- 80ebe644 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
- 0b39c445 Fix unset key and comment block
5aa6a20b Merge pull request #673 from marwan-at-work/tpl codegen/templates: allow templates to be passed in options instead of…
- 37fd067e fix typo - e69b7399 add docs to the templates package
8cae895b Merge pull request #676 from jonatasbaldin/gin-context-recipe Add recipe to use gin.Context
- 40c7b952 update test name - 5418a290 Add recipe to use gin.Context - 16f392ee add unit test - a0ee7172 codegen/templates: allow templates to be passed in options instead of os files - 2cf7f452 Fix comments (add request size limit, remove useless comments, improve decoding and function signature, improve documentation)
5ff60925 Merge pull request #665 from ezeql/patch-1 update README.md
b42e1ba6 update README.md fix link
- d3770395 Fix tests. - 2c1f8573 Fix lint errors. - 73b3a536 Fmt graphql.go - 83cde4b6 Fix tests. Improve code format. - 425849a6 Improve fileupload example readme. Update scalars.md. Add file-upload.md - 849d4b1e Make uploadMaxMemory configurable - fc318364 Improve format, inline const. - 662dc337 Move Upload to injected if defined in the schema as scalars - f244442e Fix merge. Remove regexp check.
bf79bc92 Merge branch 'master' into next # Conflicts: # codegen/config/config.go # handler/graphql.go # handler/graphql_test.go
- bd4aeaa6 Merge remote-tracking branch 'upstream/master' - 3a6f2fb7 Improve test code - 239bc46f Add comments - be8d6d12 Improve test - 4d92696b Clean up code and add tests - 2c414edc Improve and add tests - 68446e17 Revert change to websocket_test - 61c1cb9c Improve examples - 493d9375 Improve examples - 3c5f8bb9 Improve some examples - db7a03b1 Improve tests and names - c493d1b9 Revert changing to websocket_test - 998f7674 Revert changing the stub file - a7e95c59 Fix tests. Improve file generation - 10beedb3 Remove not required file - 5afb6b40 Add file upload to default schema - 9c17ce33 Add file upload - b454621d Add support to upload files. ## [v0.8.3](https://github.com/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
a148229c Merge pull request #644 from Sauraus/master Fix Gin installation instruction
52624e53 Fix Gin installation instruction Current `go get gin` instruction results in an error from Go: `package gin: unrecognized import path "gin" (import path does not begin with hostname)`
- 515f2254 Add test case for custom scalar to slice
2284a3eb Improve IsSlice logic to check GQL def Currently TypeReference.IsSlice only looks at the Go type to decide. This should also take into account the GraphQL type as well, to cover cases such as a scalar mapping to []byte
## [v0.8.2](https://github.com/99designs/gqlgen/compare/v0.8.1...v0.8.2) - 2019-03-18 - ee06517c release v0.8.2
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
- f02dabb7 Add test case for union pointer
8257d423 Check Go type rather than GQL type for ptr This is probably a more correct way to check whether we should wrap the type in a pointer or not, rather than looking at the GrapQL definition. There may be use-cases where a GraphQL interface/union might be mapped to a Go stuct.
5df0938f Merge pull request #628 from 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
- 12cf01aa Allow user to supply path to gqlerror
932322b6 Merge pull request #619 from 99designs/nil-slices Support returning nulls from slices
- a48c55b2 Support returning nulls from slices
2b270e4d Merge pull request #618 from codyleyhan/cl/method Adds way to determine if a resolver is a function call or value
- af6dc16d Add test for IsMethod in resolver - 27e97535 Expose IsMethod to resolver context - f52726de Update README.md
ac2422e3 Merge pull request #614 from wesovilabs/master Adding entry for workshop
db4f7255 Merge pull request #613 from icco/patch-2 Upgrade graphql-playground to 1.7.20
163bfc76 Merge pull request #612 from 99designs/maps-changesets Maps as changesets
- 6aa9dfc6 Adding entry for workshop
08f936e1 Upgrade graphql-playground to 1.7.20 CSS didn't change but js did.
8fb1fafd Merge pull request #611 from 99designs/gqlparser-1.1.2 Bump gqlparser to 1.1.2
- 37983a5f remove some invalid test schema - 765ff738 Add some docs on maps - 0a92ca46 Support map[string]interface{} in return types
ac56112b Merge pull request #610 from tgwizard/dynamic-complexity Allow configuring the complexity limit dynamically per request
- a89050aa Bump gqlparser to 1.1.2 - dd288145 Allow configuring the complexity limit dynamically per request
485ddf30 Merge pull request #605 from 99designs/fix-default-scalars Fix default scalars
3ca2599a Merge pull request #606 from jonatasbaldin/add-gin-recipe Add Gin recipe
- 386eede9 Add Gin recipe
22be59d1 Merge pull request #604 from cevou/arg-scalar Fix directives on args with custom type
- d02736dc Added test for fix directives on args with custom type - 30d235bc Fix default scalars
d7b5dc28 Merge pull request #591 from 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
8e66832f Merge pull request #589 from 99designs/fix-autocasing-modelgen-bugs Fix autocasing modelgen bugs
- de3b7cb8 Fix autocasing modelgen bugs
8e00703e Merge pull request #588 from 99designs/fix-default-scalar-implementation-regression Fix default scalar implementation regression
- b27139ed Fix default scalar implementation regression
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
## [v0.8.0](https://github.com/99designs/gqlgen/compare/v0.7.2...v0.8.0) - 2019-03-04 - f24e79d0 release v0.8.0
55df9b8d Merge pull request #574 from 99designs/next v0.8.0
aedcc68a Merge pull request #573 from 99designs/plugin-docs Very rough first pass at plugin docs
- 8f91cf56 Very rough first pass at plugin docs
3d9ad75e Merge pull request #572 from 99designs/handle-nonexistant-directories-when-genreating-packagenames Handle non-existant directories when generating default package names
- 08923334 Handle non-existant directories when generating default package names
2ef4b443 Merge pull request #571 from 99designs/automatically-bind-to-int32-int64 Automatically bind to int32 and int64
2888e96c Merge pull request #570 from 99designs/vendor-packages-workaround Workaround for using packages with vendored code
- fb87dc39 Automatically bind to int32 and int64
f2d9c3f7 Merge pull request #569 from 99designs/improve-introduction Introduction Improvements
- 1e7aab63 Workaround for using packages with vendored code - 5c692e29 User README as canonical introduction - 25bdf3d6 Consolidate Introduction documents - d81670d8 Add initial contributing guidelines - d9a9a532 playground: secure CDN resources with Subresource Integrity
cb38b4be Merge pull request #568 from MichaelMure/secured-playground playground: secure CDN resources with Subresource Integrity
0258e1a2 Merge pull request #565 from steebchen/next Fix cli config getters
- 6ad1d97e Move feature comparison - 37cbbd6d playground: secure CDN resources with Subresource Integrity - da12fd11 Fix cli config getters
51266b8f Merge pull request #554 from 99designs/fix-missing-recover Recover from panics in unlikly places
- 67795c95 Recover from panics in unlikly places
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
- de148d13 Test for #484 - 9a48a007 Merge pull request #538 from 99designs/test-input-marshalling (closes #487) - 7a82ab43 Test for #487
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
- 533b08b6 remove wonky input directives - 60473555 Shared arg unmarshaling logic
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
- f9ee6ce0 return arg in middleware
5c8b1e24 Avoid unnessicary goroutines goos: linux goarch: amd64 pkg: github.com/99designs/gqlgen/example/starwars BenchmarkSimpleQueryNoArgs-8 300000 25093 ns/op 6453 B/op 114 allocs/op PASS ok github.com/99designs/gqlgen/example/starwars 10.807s
b0ffa22a Remove strconv.Quote call in hot path to avoid some allocs go test -benchtime=5s -bench=. -benchmem goos: linux goarch: amd64 pkg: github.com/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.
- d36d3dc5 Add websocket keepalive support
39216361 Merge pull request #476 from svanburen/patch-1 Update config.md
9f6f2bb8 Update config.md Add a missed word and add an apostrophe
- c033f5fc Fix edit link positioning - b3f163d8 Add not about relative generate path - 675ba773 Update errors.md
5c870a48 Merge pull request #461 from ryota548/patch-1 Update getting-started.md
9bcd27c1 Update getting-started.md modify `graph/graph.go` to `resolver.go`
## [v0.7.1](https://github.com/99designs/gqlgen/compare/v0.7.0...v0.7.1) - 2018-11-29
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
- 747c3f9c 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
- 62f0d085 Edit copy for introspection docs
63fc2753 Merge pull request #452 from cemremengu/patch-1 Fix typo in directives.md
da31e8ed Update directives.md Fix small typo
- 83e33c13 Remove a debug print - 6c575914 fix doc indentation - f03b32d3 Use new import handling code - c45546e5 Increase float precision - 77f2e284 Start moving import management to templates - c114346d Decouple loader creation from schema
9d636e78 Merge pull request #448 from 99designs/update-gqlparser Update to latest gqlparser
- d6ce42df Update to latest gqlparser - b0acd078 Add config option to disable introspection
f9c880b6 Merge pull request #446 from 99designs/fix-flakey-test Fix flakey goroutine test
5461e967 Merge pull request #445 from 99designs/remove-graphqlgen Remove graphqlgen link
- 8a5039d8 Fix flakey goroutine test
4b082518 Merge pull request #439 from snormore/pointer-slice Fix type binding validation for slices of pointers like []*foo
- 293b9eaf Remove graphqlgen link
77b27884 Merge pull request #443 from mgutz/patch-1 fix generate stubs sentence
- ae1c7732 fix generate stubs sentence - 827dac5e Fix type binding validation for slices of pointers like []*foo
f7932b40 Merge pull request #435 from matiasanaya/update-readme Update README.md comparison with graph-gophers
- a816208b Update README.md comparison with graph-gophers
d25e3b4b Merge pull request #422 from gracenoah/model-method-context accept an optional ctx parameter on model methods
0ac6fa57 Merge pull request #434 from urakozz/patch-1 Tracer: fixed nil pointer issue
- d4f7c954 Update context.go
4c4ccf47 Update context.go Right now code generated with latest master fails since there are usages of Trace but there is no any single write to this variable
- 5faf3a2b re-generate - 6fed8947 rebase fixes - 4c10ba55 fix generated code - 8066edb7 add tests - 9862c30f mention contexts on model methods in docs - 602a83d6 make ctx method resolvers concurrent - 49755120 accept an optional ctx parameter on model methods
02a19352 Merge pull request #429 from 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
- cac61bb2 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
- a4eaa400 add tests for RequestContext#GetErrors
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
- fd4f5587 fix timing issue - 91e3e88d address comment - a905efa8 fix lint warning - b2ba5f86 address comment - 561be1c0 add Apollo Tracing sample implementation - 83c7b2cb add Start/EndOperationParsing & Start/EndOperationValidation methods to Tracer - b5305d75 address comment - 784dc01f oops... - a027ac21 copy complexity to RequestContext - ececa23c add Tracer for OpenCensus
0d5c65b6 Merge pull request #400 from 99designs/fix-ci fix Circle CI test
- 00d11794 add mutex to logger - 884d35c6 fix race condition - f70cedc2 fix Circle CI test
1b17b5a2 Merge pull request #392 from 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
- a230eb04 Support multiple schemas
20a5b6c7 Merge pull request #369 from vetcher/master reverse errors and data order in response
- f1f043b9 reverse 'data' and 'error' fields order in failure tests
3eab22a3 Merge pull request #370 from rodrigo-brito/fix-underscore Underscore on field name finder
- 0ad3d3ce fix on struct name finder - 42e11045 reverse errors and data order in response ## [v0.6.0](https://github.com/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
- 732be395 Don't let goimports guess import paths
926eb9d8 Merge pull request #364 from 99designs/query-cache-test Add a stress test on query cache
- bab70df5 Add a stress test on query cache
84481761 Merge pull request #362 from 99designs/fix-error-docs fix error docs
- 23b58f6d fix error docs
8f0ef777 Merge pull request #361 from 99designs/revert-360-revert-335-typed-interfaces Revert "Revert "Generate typed interfaces for gql interfaces & unions""
- 77257d1e Revert "Revert "Generate typed interfaces for gql interfaces & unions""
1cae19bb Merge pull request #359 from 99designs/fix-null-arg-error Fix Issue With Argument Pointer Type
ee862717 Merge pull request #360 from 99designs/revert-335-typed-interfaces Revert "Generate typed interfaces for gql interfaces & unions"
- 02658647 Revert "Generate typed interfaces for gql interfaces & unions"
bc35d730 Merge pull request #335 from 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.
- 0c399270 Add test case
b836a976 Merge pull request #358 from 99designs/fix-embedded-pointer Fix Embedded Pointer
- d3e27553 Bump gqlparser to latest master - b8af0c81 Use types.Implements to check if an interface implementor accepts value recievers
2ab05daf Merge pull request #353 from 99designs/resolver-ctx-parenting Parent middleware generated contexts
- faf0416b Parent resolver generated contexts - caa474c6 Check for embedded pointer when finding field on struct - f302b408 Added reproduce test case
14cf46bc Merge pull request #348 from gissleh/feat-websocket-initpayload Added parsing of the websocket init message payload
- 3147d914 Updated example in docs to use handler.GetInitPayload instead of graphql.GetInitPayload - 32f0b843 Moved InitPayload from graphql to handler package, updated test to import it from there. - 01923de6 Moved initPayload to wsConnection member, changed wsConnection.init to return false on invalid payload - 25268ef9 Added information about it under recipes/authentication doc - 575f28e0 Fixed graphql.GetInitPayload panic if payload is nil.
380828fa Added parsing of the websocket init message payload, and making it available via the context passed to resolvers. * Added GetInitPayload(ctx) function to graphql * Added WithInitPayload(ctx) function to graphql * Added WebsocketWithPayload method to client.Client (Websocket calls it with a nil payload for backwards compability) * Added tests for these changes in codegen/testserver/generated_test
2bd1cc2e Merge pull request #334 from 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
- baa99fc5 cleaned up resolver doc
647fbbc9 Merge pull request #340 from chris-ramon/patch-1 README.md: Updates `graphql-go/graphql` features.
729e09c8 README.md: Updates `graphql-go/graphql` features. - Subscription support: https://github.com/graphql-go/graphql/issues/49#issuecomment-404909227 - Concurrency support: https://github.com/graphql-go/graphql/issues/389 - Dataloading support: https://github.com/graphql-go/graphql/pull/388
- 229a81be Fix gouroutine leak when using subscriptions - c15a70ff Adds docs for how resolvers are bound - 35c15c94 Add link to talk by Christopher Biscardi
72edf98a Merge pull request #331 from edsrzf/arg-refactor Refactor arg codegen
- 31505ff4 Use arg function for generated Complexity method - ebdbeba0 Just realized "if not" is allow in templates - 861a805c Regenerate code
639727b6 Refactor arg codegen Now a function is generated for each field and directive that has arguments. This function can be used by both field methods as well as the `Complexity` method. The `args.gotpl` template now generates the code for this function, so its purpose is a little different than it used to be.
8026e63b Merge pull request #330 from edsrzf/string-compare Use built-in less than operator instead of strings.Compare
- c770b4e7 Use built-in less than operator instead of strings.Compare ## [v0.5.0](https://github.com/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
- 14587a5f Add version const
7d44dd6b Merge pull request #315 from edsrzf/query-complexity Query complexity calculation and limits
- 2ab857ee Merge branch 'master' into query-complexity - 6e408d5d Interfaces take max complexity of implementors
d08b9c4a Merge pull request #325 from edsrzf/no-get-mutations Only allow query operations on GET requests
82a28b57 Only allow query operations on GET requests (closes #317) This mitigates the risk of CSRF attacks.
- 239b1d22 Don't emit complexity fields for reserved objects - 8da5d61b Generate complexity for all fields. Fix bugs. Re-generate examples.
40943c6d Merge pull request #322 from 99designs/drop-old-flags Drop old cli flags
8c17eea9 Merge pull request #320 from andrioid/master Description added to generated Model code
988b367a Merge pull request #316 from 99designs/feat-concurrent-each-element use goroutine about processing each array elements
- e5265ac2 Fix complexity template bug - 7c040045 now with field values - 08ab33be starting to look better - e834f6b9 Query complexity docs - a0158a4e Drop old cli flags - bb78d2fa go generate ./.. - 2488e1b3 Merge branch 'master' of https://github.com/99designs/gqlgen
f6a733ae Merge pull request #308 from codyleyhan/tags Finds fields by configurable struct tag
f7aeb88a Merge pull request #321 from 99designs/remove-typemap Remove support for the old json typemap
- d63449b9 Remove support for the old json typemap - fce4c722 address comment - 8c3aed7d Merge branch 'master' into query-complexity
cecd84c6 Add complexity package tests Also some small behavior fixes to complexity calculations.
002ea476 Merge pull request #318 from edsrzf/query-cache Add query cache
- fcd700b6 Panic on lru cache creation error
78c57079 Add query cache This commit adds a query cache with a configurable maximum size. Past this size, queries are evicted from the cache on an LRU basis. The default cache size is 1000, chosen fairly arbitrarily. If the size is configured with a non-positive value, then the cache is disabled. Also ran `dep ensure` to add the new dependency to `Gopkg.lock`.
- 076f9eac removed dirt - 6ae82383 trying to get description with generated models - 7d6f8ed4 fixes case where embeded structs would cause no field to be found - 02873495 use goroutine about processing each array elements - 40f904a6 Merge branch 'master' of github.com: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
- b07736ef Validate gopath when running gqlgen
b082227d fix mapstructure unit test error fix unit test error "mapstructure: result must be a pointer". It appears instead of resolver returned error.
- 25b12cb6 Remove 404s from sitemap
4a6f505d Merge pull request #309 from 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
2c4e6cbf Merge pull request #294 from 99designs/simplfy-concurrent-resolvers Simplfy concurrent resolver logic
- 7926c688 Simplfy concurrent resolver logic ## [v0.4.4](https://github.com/99designs/gqlgen/compare/0.4.3...v0.4.4) - 2018-08-21 - 6f6622c6 Bump gqlparser to latest version
72659af4 Merge pull request #297 from 99designs/fix-dep-pruning Explicitly import ambient imports so dep doesn't prune them
- cac3c729 Explicitly import ambient imports so dep doesn't prune them
e6af26e0 Merge pull request #296 from heww/master sort directives by name when gen
- fd09cd99 sort directives by name when gen
71917267 Merge pull request #292 from m4ppi/fix-doc Fix broken links in docs
- 05c73d9f Fix broken links in docs
5a0b56aa Merge pull request #285 from 99designs/fix-force-type Stop force resolver from picking up types from matching fields
- 31478cf4 Stop force resolver from picking up types from matching fields
ebdcf740 Merge pull request #283 from 99designs/speed-up-tests Speed up tests
- 36e84073 Speed up tests ## [0.4.3](https://github.com/99designs/gqlgen/compare/0.4.2...0.4.3) - 2018-08-10
3575c289 Merge pull request #281 from 99designs/introspection-default-args Fix missing default args on types
- b808253f Fix missing default args on types
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
- a2a7c0e7 Eliminate font resize popin - 8a7ed618 Fix errors docs - 96e6aab2 Add 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
- 7400221c Fix introspection api
b35804ba Merge pull request #254 from oskanberg/patch-1 Fix typo in introduction docs
- 84552437 Fix typo in introduction docs - b5a48e3e Update README.md - c20bb134 update badges ## [0.4.0](https://github.com/99designs/gqlgen/compare/0.3.0...0.4.0) - 2018-08-03
7b5a3d74 Merge pull request #247 from 99designs/next 0.4.0 Release
c0be9c99 Merge pull request #251 from 99designs/rewrite-imports Rewrite import paths
- 4361401a Rewrite import paths
f042328a Merge pull request #252 from 99designs/move-doc-site Move doc site
- 658a24d9 Move doc site
07b7e6ca Merge pull request #248 from 99designs/json-usenumber use json.Decoder.UseNumber() when unmarshalling vars
- 95fe07fe use json.Decoder.UseNumber() when unmarshalling vars
c555f54c Merge pull request #245 from vektah/new-feature-docs New feature docs
825840aa Merge pull request #244 from vektah/array-coercion Add implicit value to array coercion
90b40769 Merge pull request #246 from vektah/fix-introspection Fix introspection
- ef208c76 add docs for resolver generation - e44d798d Add directives docs - 62d4c8aa Ignore __ fields in instrospection - bc204c64 Update getting started guide - b38c580a Return the correct mutation & subscription type - 9397920c Add field name config docs - d2265f3d Add implicit value to array coercion
191c8ba0 Merge pull request #239 from vektah/directive-args Directive args
- 3bef596d regenerate - 4f37d170 Add directive args
f78a6046 Merge pull request #241 from vektah/feat-lintfree Make more golint free generated code
- 19b58175 Merge remote-tracking branch 'origin/master' into HEAD - c3fa1a55 Merge branch 'next' into feat-lintfree
17bfa2cb Merge pull request #240 from vektah/doc-fonts Use fonts from golang styleguide
- 64ef0571 Use fonts from golang styleguide
6b532383 Merge pull request #237 from vektah/feat-fieldmapping Add model field mapping
- 4fb721ae address comment - bf43ab3d Merge branch 'next' into feat-fieldmapping - 353319ca Refactor GoVarName and GoMethodName to GoFieldName etc... - d7e24664 Add method support
17bcb322 Merge pull request #236 from vektah/generate-handler-on-init Generate server on running init
600f4675 Merge pull request #238 from vektah/variable-validation Add missing variable validation
- d6a76254 Add missing variable validation - 121e8db4 Generate server on running init - 108bb6b4 Rename govarname to modelField - f7f6f916 Make more lint friendly - 69eab938 Add model field mapping
ffee020c Merge pull request #235 from vektah/generate-resolver-on-init Generate resolver on init
- df95f003 Generate code after init - 58831ac1 Generate resolver if configured
7031264d Merge pull request #229 from vektah/fix-init-command Fixing init command
078bc985 Fixing init command The init command always return file already exists if there are no configFilename specified This is caused by codegen.LoadDefaultConfig() hiding the loading details and always return the default config with no error while the init command code expects it to tell us if config exists in default locations. To avoid confusion I have splitted the loading config from default locations out into its own method so we can handle different cases better. Additionally I also moved default config into a method so we always generating new a config instead of passing it around and potentially mutating the default config.
803711e9 Merge pull request #221 from vektah/middleware-stack Implement FieldMiddleware Stack
- 0ec918bf Switch GoName to Name|ucFirst - 5dc104eb Add middleware example for Todo - 73a8e3a3 Fix some issues with directive middlewares - 84163247 Regenerate
0e16f1fc Generate FieldMiddleware Moves it off of RequestContext and into generated land. This change has a basic implementation of how directive middlewares might work.
- 2748a19b Require Config object into NewExecutableSchema - 09242061 Add Directives to Build
69e790c2 Add *Field to CollectedField We need the Field Definition so that we can run directive middlewares for this field.
- d6813f6d Generarte
764c6fda Refactor ResolverMiddleware to FieldMiddleware This will allow us to include DirectiveMiddleware in the same middleware setup, that will run after Resolver middlewares.
7226e573 Merge pull request #225 from rongfengliang/patch-1 Update getting-started.md
- 66593ffe Merge remote-tracking branch 'origin/master' into HEAD - 8714f7fb hush metalinter
0dfb92a7 Update getting-started.md CreateTodo UserID input should be UserId not User
0fa7977f Merge pull request #217 from vektah/resolver-middleware-all Run Resolver Middleware For All Fields
7292be78 Rename CastType to AliasedType This field stores a Ref if a type is a builtin that has been aliased. In most cases if this is set, we want to use this as the type signature instead of the named type resolved from the schema.
- ec928cad Regenerate examples
97f13184 Remove comment about ResolverMiddleware Not true anymore!
- b512176c Run resolver middleware for all fields
f67f8390 Merge pull request #218 from vektah/remove-old-resolvers Remove old resolvers
1a3e4e99 Merge pull request #220 from vektah/feat-race turn back -race option
- 40989b19 turn back -race option
1ba61fcb Update test & examples to use new resolver pattern * chat * dataloader * scalar * selection * starwars * todo
38708961 Stop generating two types of resolvers In recent refactor we introduced a new pattern of resolvers which is better structured and more readable. To keep Gqlgen backward compatible we started generate two styles of resolvers side by side. It is now time to sunset the old resolver. This commit removes the old resolver and update the generation code to use the new resolver directly.
- ffe42658 Merge pull request #208 from vektah/directives-skip-include
a69071e3 Pass context to CollectFields instead of RequestContext Internally it can still get to RequestContext as required.
- d02d17ae Add method for generating method name from field - c7ff3208 Update gqlparser version to include default resolution - ce17cd90 Add default value test case
cbfae3d3 Add skip/include test cases Adds a set of test cases for skip and include directives to the todo example. Also now conforms to spec if both are included.
ea0f821c Add skip/include directive implementation This is a snowflake implementation for skip/include directives based on the graphql-js implementation. Skip takes precedence here.
- ebfde103 Pass request context through to CollectFields
bab7abb2 Merge pull request #210 from vektah/feat-init introduce gen & init subcommand
6ba508f9 Merge pull request #214 from vektah/gqlparser-schema-validation Bump gqlparser to get schema validation
- 138b4cea Bump gqlparser to get schema validation - 08d7f7d0 Merge branch 'next' into feat-init - 39f9dbf6 fix error from breaking change - 41147f6f update Gopkg.lock - 87d8fbea remove unused flag - eff49d04 support init subcommand - c5810170 introduce cobra library - c3c20f8f Merge remote-tracking branch 'origin/master' into HEAD
90df37f6 Merge pull request #205 from vektah/forward-credential-to-graphql-endpoint Use original credential for query request in playground
52343745 Merge pull request #206 from vektah/validation-locations Update gqlparser for validation locations
- f4d31aa4 Update gqlparser for validation locations
9d473f8b Merge pull request #203 from vektah/99designs-announcement Announcement: 99designs is now sponsoring gqlgen
c2f1570d Merge pull request #204 from vektah/gqlparser-prelude Use shared prelude
- 004ec6a9 Add 99designs sponsorship news - 548aed14 Use shared prelude
edb3ea4e Use original credential for query request in playg Currently the playground doesn't forward any credentials when making query calls. This can cause problems if your playground requires credential logins.
f855a89c Merge pull request #201 from cocorambo/remove-trailing-println Remove trailing Println
- c41a6c36 Remove trailing Println
2692d3e0 Merge pull request #197 from vektah/new-parser Integrate gqlparser
- 5796d47d Integrate gqlparser - 55179a61 Update badges
01a4c677 Merge pull request #195 from jonstaryuk/master Update playground version
- c52f24af Update playground version to 1.6.2 ## [0.3.0](https://github.com/99designs/gqlgen/compare/0.2.5...0.3.0) - 2018-07-14
381b3469 Merge pull request #194 from vektah/multiline-comments Fix multiline comments
- 112d68a6 only build master branch - 4b3778e3 Fix multiline comments
eb44925c Merge pull request #193 from vektah/validate-method-returns validate method return types
- 164acaed validate method return types
f478f816 Merge pull request #192 from vektah/strict-config Strict config
- a1c02e7b Strict config
533dcba7 Merge pull request #191 from vektah/nullable-list-elements Support nullable list elements
- e0bf6afd Support nullable list elements
0780bf2e Merge pull request #190 from vektah/generated-forced-resolvers Allow forcing resolvers on generated types
- bf1823cd Allow forcing resolvers on generated types
febd0358 Merge pull request #186 from vektah/error-redux Error redux
- b884239a clarify error response ordering - 58e32bbf Drop custom graphql error methods - d390f9c6 Errors redux ## [0.2.5](https://github.com/99designs/gqlgen/compare/0.2.4...0.2.5) - 2018-07-13
0a9709db Merge pull request #188 from vektah/fix-windows-gopath Fix windows gopath issue
- ea4f26c6 more fixes - 1066953d Appveyor config - f08d8b61 Fix windows gopath issue - 9ade6b7a Update gettingstarted to use new resolvers ## [0.2.4](https://github.com/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
- 25cfbf08 Search for config
bff3356b Merge pull request #175 from vektah/lint-all-packages gometalinter should cover all packages
- 61f37173 gometalinter should cover all packages
ce657044 Merge pull request #173 from vvakame/feat-resolver-hint add resolver option support to field
57b8279e Merge pull request #172 from vvakame/feat-newconfig switch to .gqlgen.yml
- fcfceefb add resolver option support to field - c7ce1cbb update docs - 42948153 move to .gqlgen.yml
325c45a4 Merge pull request #171 from vvakame/add-gitignore add .idea/ to .gitignore
- aa4cec9b add .idea/ to .gitignore ## [0.2.2](https://github.com/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.
## [0.2.1](https://github.com/99designs/gqlgen/compare/0.2.0...0.2.1) - 2018-06-26
cb87a2cb Merge pull request #147 from vektah/import-overhaul Improve import handling
9fa3f0fb Merge pull request #134 from mastercactapus/small-interfaces add lint-friendly small interfaces option for resolvers
e8c30acd fix template error on generated defaults (#146) * fix template error on generated defaults * go fmt * add test for default fix * . * add key sort for default values
- 769a97e2 fix race in chat example test - t.Parallel() doesn't guarantee parallel execution - moved goroutine so the test can execute independently - 5b77e4c2 remove deprecation warning for now - 59a5d752 remove trailing S - b04846f6 fix time race in scalar test - a80b720f name updates, deprecation, some code comments - 2bbbe054 Merge branch 'master' into small-interfaces - 4ffa2b24 case insensitive compare to determine self package - c0158f54 make sure colliding imports are stable - abf85a10 get package name from package source - a39c63a5 remove a random json tag from tutorial - f48cbf03 tutorial fixes
0a85d4f2 Update generated headers to match convention. (#139) * Update generated.gotpl * Update models.gotpl * Update data.go * update go generate * revert code changes
- 4a6827bd Update getting started guide - a21f3273 Use recognized `Code generated` header - 038c6fd2 change from `ShortResolver` to `ShortResolvers` - prevents possible collision with an object type named `Short` - 0bc592cd run go generate - db2cec07 fix template formatting - 59ee1b5c from probably makes more sense - 620f7fb4 add "short" resolver interface ## [0.2.0](https://github.com/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
a5f72601 Merge pull request #122 from vektah/json-encoding-fixes Fix json string encoding
- f207c62c review feedback - 578d8415 Fix json string encoding
e9b40666 Merge pull request #123 from vektah/drop-fk-generation BC Break: Stop generating foreign keys in models
a8419e20 Merge pull request #124 from vektah/fix-backtick-escaping Fix backtick escaping
- 47eaff4d Fix backtick escaping - a5c02e6c BC Break: Stop generating foreign keys in models
94d5c89e Merge pull request #120 from andrewmunro/bugfix/fix-panic-on-invalid-array-type Fixing panic when non array value is passed to array type
- 5680ee49 Adding dataloader test to confirm no panic on malformed array query - 55cc161f Fixing panic when non array value is passed to array type - 6b3b338d Add gitter link to readme - 6c823beb add doc publish script
a25232d8 Merge pull request #113 from mikeifomin/patch-1 Fix typo in url dataloaden
- 3a129c77 Fix typo in url dataloaden - e1fd79fe Merge pull request #111 from imiskolee/master (closes #110) - e38cb497 1. fix bug: #110
3990eacf Merge pull request #108 from imiskolee/master generate json tag to model field by gql name.
- abb7502a 1. run go generate - e1f90946 1. add json tag in models_gen.go 2. use gqlname to model filed json tag.
35e09717 Merge pull request #107 from vektah/fix-vendor-normalization Fix vendor normalization
63ee4199 Fix vendor normalization When refering to vendored types in fields a type assertion would fail. This PR makes sure that both paths are normalized to not include the vendor directory.
2a437c23 Merge pull request #105 from vektah/keyword-input-args Automatically add a _ suffix to reserved words
26ac13ff Merge pull request #104 from vektah/new-request-context Add a NewRequestContext method
- 309e5c6d Automatically add a _ suffix to reserved words - a2fb1421 Add a NewRequestContext method
ab6e65bd Merge pull request #97 from vektah/add-input-defaults Default values for input unmarshalers
- 1cd80c4a Default values for input unmarshalers
79c69d15 Merge pull request #96 from vektah/refactor-tests Refactor tests
- 7b1c8198 Refactor tests
0c7bdfc6 Merge pull request #95 from vektah/custom-error-types Custom error types
- 4bdc1e1f regenerate - 20250f18 Add fully customizable resolver errors - a0f66c88 Update README.md - 8f62d505 Update README.md - a1043da6 Add feature comparison table to readme
22128e0e Merge pull request #93 from vektah/input-type-error-handling Input type error handling
- e7539f11 Add an error message when using types inside inputs - a780ce69 Add a better error message when passing a type into an input - 0424f043 Refactor main so tests can execute the generator
ab3803a6 Merge pull request #89 from vektah/opentracing-parent-span Add parent opentracing span around root query/mutation/resolvers
d157ac35 Add context to recover func This makes the request and resolver contexts available during panic so that you can log the incoming query, user info etc with your bug tracker
- 3ceaa189 add request middleware - 877f75a0 remove debugging trace (closes #81)
091d25ab Merge pull request #87 from jon-walton/windows-paths fix package paths on windows
- 53a6e814 fix package paths on windows
546b7b76 Merge pull request #84 from yamitzky/master Fix collectFields to handle aliased fields properly
- ba2ecb16 Add test case for aliased field - 78f3a56c Fix collectFields to handle aliased fields
4d2eece0 Merge pull request #77 from vektah/opentracing Add resolver middleware Add opentracing support
- f0def668 better opentracing tags - 600bff7a bump metalinter deadline - 2e32c121 regenerate code - 5b908507 opentracing middleware - 57adb244 Add resolver middleware - 28d0c81f capture args in map
e266fab9 Merge pull request #75 from mathewbyrne/fix-import-dash Replace Invalid Characters in Package Name with an Underscore
b0d79115 Replace invalid package characters with an underscore This will sanatise local import names to a valid go identifier by replacing any non-word characters with an underscore.
66a91503 Merge pull request #72 from vektah/custom-enum Add support for custom enums
- 61a34a74 Add support for custom enums - 74ac827a move docs to new domain
ebcc94d1 Merge pull request #70 from vektah/models-in-separate-package Allow generated models to go into their own package
- 9a532131 Allow generated models to go into their own package
6129fd26 Merge pull request #69 from vektah/support-options Support OPTIONS requests
- af38cf05 Support OPTIONS requests
893ead12 Merge pull request #67 from vektah/raw-schema-string Use a raw string for schema
- af6178a7 Use a raw string for schema
c0753bed Merge pull request #66 from vektah/generate-enums Generate enums
- 85a51268 Generate enums
71c4e265 Merge pull request #65 from vektah/context Make field selections available in context
- c60336bf regenerate - c5ccfe4e Add an example for getting the selection sets from ctx - e7007746 add fields to resolver context - 40918d52 move request scoped data into context
4e13262e Merge pull request #64 from vektah/vendor-gen-path Fix vendored import paths in generated models
- 2ff9f32f Fix vendored import paths - 630a3cfc failing test - 99dec54c fix missing deps - 652c567e Remove missing field warning and add test for scalar resolvers (closes #63) - 3dc87e1b gtm - c76c3434 Add dataloader tutorial - 449fe8f8 Optimize frontmatter - b90ae60e flatten menus
a508ecb0 Merge pull request #45 from dvic/fix-resolver-public-errors Retain orignal resolver error and support overriding error message
- ab4e7010 Retain orignal resolver error and support overriding error message (closes #38)
a05a18d5 Merge pull request #61 from vektah/import-resolver-collisions Deal with import collisions better
- d81ea2c2 Deal with import collisions better
fb131a94 Merge pull request #59 from vektah/map-support Add map[string]interface{} escape hatch
- 49d92164 Add map[string]interface{} escape hatch
5abdba16 Merge pull request #57 from vektah/null-input-fields Null input fields
- f8add9d2 remove more unneeded whitespace - 84b06617 Allow nulls in input fields
54fbe16a Merge pull request #56 from vektah/getting-started-fixes Getting started fixes
- 17fd17a4 Update the tutorial - e65d2a5a detect correct FK type - b66cfa03 small fixes to entry point - 0b62315a Create ISSUE_TEMPLATE.md
f3a70dac Merge pull request #55 from vektah/fix-input-ptr-unpacking Fix ptr unpacking in input fields
- 10541f19 Fix ptr unpacking in input fields
15b3af2d Fix value receivers for unions too fixes 42
46103bdc Merge pull request #53 from vektah/docs Docs
- d0211a0a Custom scalar docs - e6ed4de5 Update readme link - 51f08a9e start of docs
ac832dea Merge pull request #51 from vektah/support-embedding Support embedding in models
- 9d710712 add embedding support - 0980df0e Embedding example
cb34e6db Merge pull request #50 from vektah/valuer-receiver Don't generate value receivers for types that cant fit the interface
- ec5f5e66 check for valuer receivers before generating type switch - dc898409 add test case
8ef253cb Merge pull request #49 from vektah/default-entrypoints default to Query / Mutation / Subscription if no entry points are specified
- 302058a7 Use default entry points for Query/Mutation/Subscription
13949fdf Merge pull request #37 from vektah/generate-interfaces generate interfaces
- acc45bf0 generate interfaces
e47d5038 Merge pull request #34 from vektah/root-types-only Only bind to types in the root package scope
- ffe972a8 Only bind to types in the root package scope
0e78c0ae Merge pull request #33 from vektah/unset-arguments Allow unset arguments
- bc9e0e54 Allow unset arguments
94718351 Merge pull request #31 from vektah/recover-handler Customizable recover func
- e4e249ea Customizable recover func
69277045 Merge pull request #30 from vektah/complex-input-types Fix complex input types
- 9b64dd22 Fix complex input types
1d074b89 Merge pull request #29 from vektah/multi-stage-model-build Split model generation into its own stage
- cf580c24 Split model generation into its own stage
926384db Merge pull request #28 from vektah/default-args add default args
- 68c54a14 add default args - d63128f6 appease the linting gods
7b6b124e Merge pull request #20 from vektah/codegen-cleanup Codegen cleanup
- 78c34cb3 regenerate - 5ebd157c Only use one gofunc per subscription - 79a70376 Move generated field resolvers into separate methods
e676abe4 Merge pull request #19 from vektah/generate-input-types Generate input models too
- f094e79c Generate input models too - 1634f088 Add a missed error check
4feb1689 Merge pull request #18 from vektah/array-input-args Fix input array processing
- 98176297 Fix input array processing
4880497f Merge pull request #16 from vektah/better-templates Better templates
- 278df9de Better templates
f3731c73 Merge pull request #14 from vektah/autogenerate-models Autogenerate models
- cfe902a0 Autogenerate models - 287bf7f4 more docs
9d896f40 Merge pull request #13 from vektah/autocast Automatically add type conversions around wrapped types
- 85fa63b9 Automatically add type conversions around wrapped types
c8c2e40f Merge pull request #11 from vektah/subscriptions Add support for subscriptions
- d514b829 Add some go tests to the chat app - ec2916d9 chat example for subscriptions using CRA+apollo - 8f93bf8d get arg errors working in both contexts - 62a18ff1 Update generator to build a new ExecutableSchema interface - c082c3a4 prevent concurrent writes in subscriptions - f555aec6 switch to graphql playground for better subscription support - 18219541 add websocket support to the handler - d4c7f3b9 update resolver definition to use channels for subscriptions
d0244d24 Merge pull request #10 from vektah/newtypes User defined custom types
- 5d86eeb6 fix jsonw test - 944ee088 regenerate - 4722a855 add scalar example - 83b001ae rename marshaler methods - e0b7c25f move collectFields out of generated code - 146c6538 generate input object unpackers - d94cfb1f allow primitive scalars to be redefined - 402e0730 rename jsonw to graphql - 3e7d80df Update README.md - 9c77e7a0 Update dataloaden dep - 530f7895 Make gql client work with older versions of mapstructure - 5c04d1ad __typename support
51292db9 Merge pull request #4 from vektah/cleanup-type-binding Cleanup schema binding code
- c89a8774 Cleanup schema binding code
030954a5 Merge pull request #2 from ulrikstrid/patch-1 Fix typo in README
- cb507bd0 Fix typo in README - e3167785 Fix template loading from inside vendor - 261b52ce fix an error handling bug - 1da57f59 Split starwars models out from resolvers - 743b2cf9 fix indenting - fb2d5817 use gorunpkg to vendor go generate binaries - 7f4d0405 encourage dep use - 3276c782 Do not bind to unexported vars or methods - 5fabffaf heading tweaks - e032c1d5 Prior art - 45b79a1e Add a test for multidimensional arrays - ec73a50a fix race - 75a3a05c Dont execute mutations concurrently - 3900a41d tidy up json writing - 0dcf7f6b add circle ci badge - 2c9bf21c get dataloaden - 4fff3241 install dataloaden in ci - 951f41b2 circle ci - 8fa5f628 less whitespace - c76f3b98 clean up template layout - 4a6cea5e readme fixes - b814ad52 rename repo - 9c79a37a Cleanup and add tests - 5afb5caa update dataloaden - d00fae08 Add dataloader example - 86cdf3a0 Fix package resolution - 41306cba Better readme - ce5e38ed Add GET query param support to handler - dd9a8e4d parallel execution - 4468127e pointer juggling - 9e99c149 Use go templates to generate code - 41f74970 Support go versions earlier than 1.9 - c20ef3d0 add missing nulls - bb753776 Use goimports instead of gofmt on generated code - c2cf3835 coerce types between similar types - 5297dd40 Add support for RFC3339 formatted Time as time.Time - 61291ce9 support vendor - 6d437d7e allow map[string]interface{} arg types - 39a8090a cleanup - a9352e32 gometalinter pass - 9ab81d67 Finish fleshing out the connection example - e04b1e50 inline supporting runtime funcs - 9cedf012 complex arg handling - 0c9c009f Clean up json writer - e7e18c40 much cleaner generated code - 6a76bbf6 Interfaces and starwars example - 29110e76 Generate ESS to remove it interface{} casts completly - 2f358e7d graphiql autocomplete working - 2e2c3135 create separate type objects in prep for fragment support - 22c0ad0a Add basic introspection support - c1c2cb64 Code generation - 4be5ac84 args - bde800e1 imports - 596554da start of code generator - 62fa8184 split generated vs exec code - 0ea104cd remove internal package - f81371e8 Args - 01896b3b Hand written codegen example - 5a756bda Rewrite paths and add readme
b4663703 trace: Log graphql.variables rather than tag According to the OT documentation tag values can be numeric types, strings, or bools. The behavior of other tag value types is undefined at the OpenTracing level. For example `github.com/lightstep/lightstep-tracer-go` generates error events.
- 5d3b13f2 Support context injection in testing
beff0841 Separate literal arg parsing cases (int, float) This change allows the ID scalar implementation to more semantically handle the case for unmarshalling integer IDs.
ab1dd4b5 Add tests for ID scalar input This commit adds two tests cases for ID scalar input: - a string literal - an integer literal Both of these literal types are covered by the GraphQL specification as valid input for the ID scalar. Reference the ID section of the spec for more information: http://facebook.github.io/graphql/October2016/#sec-ID
d8c57437 Extract ID scalar implmentation This change moves the ID scalar implementation out of `graphql.go` and into its own file `id.go` for consistency with the Time scalar implementation.
- 10eb949b cleaned up example to use MustParseSchema
52080e1f Rename friendsConenctionArgs to friendsConnectionArgs Fix spelling error in friendsConnectionArgs type
- 3965041f Update GraphiQL interface (add history)
6b9bc3e2 Add `(*Schema).Validate` (#99) * Add `(*Schema).Validate` This adds a `Validate` method to the schema, which allows you to find out if a query is valid without actually running it. This is valuable when you have a client with static queries and want to statically determine whether they are valid. * Fix Validate doc string
- 7f3f7120 Set content-type header to `application/json` - c76ff4d8 moved packer into separate package - 073edccd updated tests from graphql-js - 3a9ac368 validation: improved overlap check - f86c8b01 allow multiple schemas in tests - 77750960 validation: OverlappingFieldsCanBeMerged - e7ca4fde refactor: remove SelectionSet type - 7aad6ba7 refactor: use schema.NamedType - fddcbcb7 resolves #92: fix processing of negative scalars during parse literals - 48c1a0fb Small fix based on feedback. - e90d1089 allow custom types as input arguments - dd3d39e2 fix panic when variable name not declared - c2bc105f validation: NoUnusedVariables - 4aff2976 refactor - 0933d241 validation: VariablesInAllowedPosition - 83e2f31a validation: NoUndefinedVariables - c39ffeca validation: PossibleFragmentSpreads - 47c5cde7 validation: UniqueInputFieldNames - 94cb2918 big refactoring around literals - 3d63ae80 some refactoring - 969dab9d merged lexer into package "common" - a9de6171 renamed lexer.Literal to lexer.BasicLit - 88c492bb validation: NoFragmentCycles (closes #38) - d39712c8 refactor addErrMultiLoc - ee5e1c3b validation: updated tests - 490ad6b2 validation: NoUnusedFragments - da85f09d add path to errors on resolver error or panic (closes #86) - 04cb2550 allow structs without pointers (closes #78) - 4c40b305 show all locations in error string - 5c26f320 fix limiter - dbc3f0a0 fix composing of fragments (closes #75)
213a5d01 Warn if an interface's resolver has a ToTYPE implementation that does not return two values. Currently this instead crashes fairly inscrutably at runtime here: https://github.com/neelance/graphql-go/blob/master/internal/exec/exec.go#L117 An alternate fix would be to check len(out) there and perhaps rely on out[0] being nil to continue if there's only one return value.
- 00c4c574 Fix panic when resolver is not a pointer - d0df6d8a small cleanup - 036945e2 fix hang on panic (fixes #82) - 01ab5128 Add supports for snake case (#77)
67e6f91d use encoding/json to encode scalars There are some edge cases that are better handled by the proven encoder of encoding/json, for example special characters in strings.
- 3f1cb6f8 implement user defined logger (with sensible defaults) - b357f464 built-in json encoding - 2d828770 refactor: collect fields to resolve - 32f8b6ba refactor: replaced MetaField - b95c566e simplify schema introspection - 4200a584 split internal/exec into multiple packages - c11687a7 refactored internal/exec - bd742d84 WIP - d09dd543 added SchemaOpt - 1dcc5753 fix Schema.ToJSON - 4f07e397 pass variable types to tracer - 36e6c97e readme: remove outdated section about opentracing - 0b143cca refactor: apply before exec
a9920602 pluggable tracer Improved performance while keeping flexibility.
- 58d3d5b8 refactored exec.Request - 9dd714ec refactored execField some more - a43ef241 refactor: meta fields - 48931d17 refactor fieldExec - ee95710d small cleanup - 84baade5 perf: create span label only once - a16ed600 improved concurrency architecture
aef3d9cf Add testing.go into its own package (gqltesting) This is done so that "testing" (and especially its registered cli flags) aren't included in any production builds.
- f78108a3 validation: meta fields - c6ab2374 added empty file to make CI happy - d59c1709 fix introspection of default value - 42608a03 clean up now unnecessary check - e45f26dd validation: UniqueDirectivesPerLocation - dcf7e59f validation: UniqueFragmentNames - eeaa510b validation: UniqueOperationNames - a5a11604 refactor: Loc on Field - b5919db4 validation: UniqueVariableNames - 8632753a validation: ScalarLeafs - 45844984 validation: ProvidedNonNullArguments - c741ea84 validation: VariablesAreInputTypes - 0875d74f validation: UniqueArgumentNames - 1fdab07f validation: LoneAnonymousOperation - 090df527 validation: KnownTypeNames - f99ca95e refactor: validation context - 8aac2817 validation: KnownFragmentNames - eae3efc9 validation: KnownDirectives - 70581168 refactor: separate InlineFragment and FragmentSpread - d6aec0d6 renamed schema.Directive to DirectiveDecl - b616eeca validation: KnownArgumentNames - 885af607 refactor: Location without pointer - 5a40251c tests: filter errors to currently tested rule - 9c054f53 refactor: lexer.Ident - 254afa8a validation: fragment type - b6ef81af added test export script - 95a4ecd8 validation: fields - c387449f validation: default values - 44c6e634 validation: arguments - 30dcc339 directive arguments as slice - d331ac27 input values as slice - 615afd61 fields as slice - 60759904 arguments as slice - f7d9ff4e refactor literals - 2e1fef01 keep track of location of arguments - 29e0b375 added EnumValue type - aa868e8d resolve fragments early - adeb53d6 remove resolver from query package - 2e23573f parse directive decl without arguments - 36f8ba8b fix introspection of default value (closes #65) - e06f5855 support for "deprecated" directive on enum values - 498fe396 support for [@deprecated](https://github.com/deprecated) directive on fields (fixes #64) - 93ddece9 refactor: DirectiveArgs - 8f5605a1 refactor directives - faf5384a simplify parseArguments - b2c2e906 some more docs - f4516523 added some method documentations - 91bd7f88 improved meta schema - 10dc8ee6 added support for directive declarations in schema - 28028f66 readme: more info on current project status - e9afca38 hint in error if method only exists on pointer type (fixes #60) - 356ebd93 nicer error messages (fixes #56) - e413f4ed make gocyclo happy - 6e92795e fix spelling - 306e27ef gofmt -s - 612317b2 fix ToJSON - 728e57a9 improved doc for MaxParallelism - e8590a10 don't execute any further resolvers after context got cancelled - 644435cc added MaxParallelism - 21802a33 readme: add Sourcegraph badge - 5b2978fc added support for recursive input values - 8c84afb1 improved structure of "make exec" code - d5a6ca49 make sure internal types don't get exposed - c9d4d865 fixed some null handling - a336dd4b added request.resolveVar - 943f80f4 added unmarshalerPacker type - f77f7339 refactored non-null handling in packer - ae0f1689 remove hasDefault flag from makePacker - 9cbad485 allow Unmarshaler for all types, not just scalars - f565a119 refactored "make exec" code - 07a09e5d properly check scalar types of result values - ecceddec Add ResolverError field to QueryError for post processing - b7c59ab9 renamed type - 5817d300 moved some introspection code into new package, added Schema.Introspect
cdef8563 removed SchemaBuilder It is not necessary any more. Simpler API wins.
518a5fe7 Merge pull request #45 from nicksrandall/master fix wrong import statement
- 8112e719 fix wrong import statement - 7fafcc6e allow single value as implicit list (fixes #41) - 2b513d7e improved custom types - 191422c4 merged code for value coercion and packing - 232356b3 introspection for "skip" and "include" directives (fixes #30) - 2e10f7b8 readme: spec version and link (fixes #35) - 61eca4c7 pretty print SchemaBuilder.ToJSON - 5e09ced1 fix "null" value for empty descriptions of types - 33cd194f SchemaBuilder.ToJSON instead of SchemaToJSON (fixes #29) - fff173bc proper error message when using non-input type as input (#19) - b94f2afe improved support for null - 4130d540 added support for input object literals - 663e466f moved some code into separate file - 728e071e added support for lists as input values (fixes #19) - 86f0f145 fix Float literals - b07f277b raise error on unexported input field (fixes #24) - 4838c6f3 fix optional input fields (fixes #25) - a15deed4 better way to implement GraphQL interfaces (#23) - 7a66d0e0 add support for description comments (fixes #20) - 0b3be40c improved tracing - da879f4f small improvements to readme - f3f24cf6 added some documentation - 38598d83 added CI badge to readme - bab81332 starwars example: fix pagination panic (#12) - 5ce3ca69 testing: proper error on invalid ExpectedResult - 8f7d2b1e added relay.Handler - fce75a50 properly coerce Int input values (#8) - 0dd38747 star wars example: pass operation name and variables (#8) - 3b7efd5c fix __typename for concrete object types (fixes #9) - 35667eda testing tools - 84571820 only create schema once for tests - de113f96 added MustParseSchema - d5e5f609 improved structure for tests - 947a1a3a added package with tools for Relay - 65f3e2b1 fix SchemaToJSON - cec7cea1 better error handling - e3386b06 improved type coercion and explicit ID type - 2ab9d765 support for custom scalars (fixes #3) - bdfd5ce3 use custom error type less - 0a7a37d1 more flexible API for creating a schema - bd20a165 improved type handling - ffa9fea4 renamed GraphQLError to QueryError - fcfa135a refactor - c28891d8 added support for OpenTracing - 2cf7fcc8 added SchemaToJSON - f6b498ac stricter type mapping for input values - 3c15e177 execute mutations serially - 1faf6661 fix missing error - de9b7fed add support for mutations - 094061d8 improved error handling a bit - cdb088d6 refactor: args as input object - b06d3941 refactor: values - 4fd33958 refactor: improved type system
1d03e667 refactor: new package "common" package "query" does not depend on "schema" any more
- 1a959516 refactor - f8cb11c1 example/starwars: use interface base type to make type assertions nicer - 746da4b8 star wars example: friendsConnection - bec45364 parse type in query - be87a8fa remove unused code - 042e306a simpler way to resolve type refs in schema - 7cbf85fb improved type checking of arguments - 2b6460ae type check for scalars - 17034fe7 improved null handling - e6b6fbca small cleanup - 7b8cd1bc meta schema from graphql-js - 9333c0b3 introspection: inputFields - c4faac56 introspection: ofType - 86da8492 introspection: interfaces and possibleTypes - 20dbb845 proper nil support for lists - 2e3369ae resolve types in schema package - 7da95f4a introspection: enum values - cb423e6e improved handling of scalar types - 5b07780f introspection: original order for fields and args - 1e2d180c introspection: arguments - f21131bb refactored schema to be more in line with introspection - 0152d4f2 introspection: currently no descriptions and deprecations - ad5689bb field introspection - 2749d814 removed query.TypeReference
2eb105ec Revert "resolve scalar types in exec" This reverts commit fb3a6fc969b0c8c286c7d024a108f5696627639c.
- 40682d68 removed exec.typeRefExec - 64ea90fe makeWithType - 2966f213 added nonNilExec - c12a8ad3 added support for ints and floats in query - 0f85412b improved example - 22ce46d1 support for optional error result - 0fe56128 optional context parameter - f1bc9b21 syntax errors with proper line and column - ae299efc proper response format - 9619721b added support for contexts - 267fc631 refactor - 2e56e7ea renamed NewSchema to ParseSchema - 356b6e6b added godoc badge - 03f2e72d added README.md - 1134562a added non-null type - 8fa41551 renamed Input to InputObject - 6f2399aa introspection: type kind - e2c58f2f refactor: schema types for interface and input - 0c8c9436 introspection: __type - 99a37521 refactoring: calculate "implemented by" in schema package - 1cac7e56 introspection: queryType - cc348faf first bit of introspection - fb3a6fc9 resolve scalar types in exec - 4cb8dcc0 panic handlers - c7a528d4 proper error handling when creating schema - ae37381c add support for __typename - 4057080f add support for union types - d304a418 attribute source of star wars schema - 0fcab871 added LICENSE - 0dc0116d support for inline fragments - f5e7d070 support for type assertions - fcb853c6 refactoring: addResultFn - 741343f8 explicit fragment spread exec - 73759258 all missing stubs for star wars example - edc78e2b parallelism - fb633714 collect fields - 08f02a2b execs - d70d16c4 added server example - 6f9a89db separate example/starwars package - e4060db5 added support for directives - 89b06652 added support for variables - 78065ecb added support for enums - 18645e60 added support for query fragments - 84f532b9 added support for aliases - 59d2a619 improved support for arguments - edce4ec8 proper star wars data - d6ffc01d syntax support for full star wars schema - b5824104 support for comments - 2f9ce9b4 support for entry points - 0b3d1038 support for arguments - cff8b302 support for arrays - 565e59f5 schema package - 1ae71ba2 query package - 42c13e7a named types, complex objects - bf64e5da initial commit ================================================ 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://user-images.githubusercontent.com/980499/133180111-d064b38c-6eb9-444b-a60f-7005a6e68222.png) # gqlgen [![Integration](https://github.com/99designs/gqlgen/actions/workflows/integration.yml/badge.svg)](https://github.com/99designs/gqlgen/actions) [![Coverage Status](https://coveralls.io/repos/github/99designs/gqlgen/badge.svg?branch=master)](https://coveralls.io/github/99designs/gqlgen?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/99designs/gqlgen)](https://goreportcard.com/report/github.com/99designs/gqlgen) [![Go Reference](https://pkg.go.dev/badge/github.com/99designs/gqlgen.svg)](https://pkg.go.dev/github.com/99designs/gqlgen) [![Read the Docs](https://badgen.net/badge/docs/available/green)](http://gqlgen.com/) ## What is gqlgen? [gqlgen](https://github.com/99designs/gqlgen) is a Go library for building GraphQL servers without any fuss.
- **gqlgen 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
loading
} if (error) { return
error
} return (<> {data.room.messages.map((msg) => msg.createdBy === name ? {msg.text} : {msg.createdBy} {msg.text} )}
setText(e.target.value)} />

); } const SUBSCRIPTION = gql` subscription MoreMessages($channel: String!) { messageAdded(roomName:$channel) { id text createdBy } } `; const QUERY = gql` query Room($channel: String!) { room(name: $channel) { messages { id text createdBy } } } `; const MUTATION = gql` mutation sendMessage($text: String!, $channel: String!, $name: String!) { post(text:$text, roomName:$channel, username:$name) { id } } `; ================================================ FILE: _examples/chat/src/components/room.js ================================================ import styled from 'styled-components'; export const Chat = styled.div` padding: 4px; margin: 0 0 12px; max-width: 400px; max-height: 400px; border: 1px solid #ccc; background-color: #babdc6; overflow-x: hidden; overflow-y: scroll; position: relative; font: 14px verdana; `; export const ChatContainer = styled.div` &:after { content: ""; display: table; clear: both; } `; const ChatLine = styled.div` color: #000; clear: both; line-height: 120%; padding: 8px; position: relative; margin: 8px 0; max-width: 85%; word-wrap: break-word; z-index: 1; &:after { position: absolute; content: ""; width: 0; height: 0; border-style: solid; } span { display: inline-block; float: right; padding: 0 0 0 7px; position: relative; bottom: -4px; } }`; export const MessageReceived = styled(ChatLine)` background: #fff; border-radius: 0px 5px 5px 5px; float: left; &:after { border-width: 0px 10px 10px 0; border-color: transparent #fff transparent transparent; top: 0; left: -4px; } span { display: block; color: #bbb; font-size: 10px; } `; export const Message = styled(ChatLine)` background: #e1ffc7; border-radius: 5px 0px 5px 5px; float: right; &:after { border-width: 0px 0 10px 10px; border-color: transparent transparent transparent #e1ffc7; top: 0; right: -4px; } `; ================================================ FILE: _examples/chat/src/graphql-sse.ts ================================================ import { ApolloLink, Operation, FetchResult, Observable, } from '@apollo/client/core'; import { print } from 'graphql'; import { createClient, ClientOptions, Client } from 'graphql-sse'; export class SSELink extends ApolloLink { private client: Client; constructor(options: ClientOptions) { super(); this.client = createClient(options); } public request(operation: Operation): Observable { return new Observable((sink) => { return this.client.subscribe( { ...operation, query: print(operation.query) }, { next: sink.next.bind(sink), complete: sink.complete.bind(sink), error: sink.error.bind(sink), }, ); }); } } ================================================ FILE: _examples/chat/src/graphql-ws.js ================================================ import { createClient } from 'graphql-ws'; import { print } from 'graphql'; import { ApolloLink, Observable } from '@apollo/client'; export class WebSocketLink extends ApolloLink { client; constructor(options) { super(); this.client = createClient(options); } request(operation) { return new Observable((sink) => { return this.client.subscribe( { ...operation, query: print(operation.query) }, { next: sink.next.bind(sink), complete: sink.complete.bind(sink), error: (err) => { if (err instanceof Error) { return sink.error(err); } if (err instanceof CloseEvent) { return sink.error( // reason will be available on clean closes new Error( `Socket closed with event ${err.code} ${err.reason || ''}`, ), ); } return sink.error( new Error( err .map(({ message }) => message) .join(', '), ), ); }, }, ); }); } } ================================================ FILE: _examples/chat/src/index.js ================================================ import React from 'react'; import ReactDOM from 'react-dom'; import { ApolloClient, ApolloProvider, HttpLink, split, InMemoryCache, } from '@apollo/client'; import { WebSocketLink as ApolloWebSocketLink} from '@apollo/client/link/ws'; import { getMainDefinition } from 'apollo-utilities'; import { App } from './App'; import { WebSocketLink as GraphQLWSWebSocketLink } from './graphql-ws' import { SSELink } from './graphql-sse'; let subscriptionLink; if (process.env.REACT_APP_SSE_PROTOCOL) { subscriptionLink = new SSELink({ url: 'http://localhost:8085/query' }); } else if (process.env.REACT_APP_WS_PROTOCOL === 'graphql-transport-ws') { subscriptionLink = new GraphQLWSWebSocketLink({ url: `ws://localhost:8085/query` }); } else { subscriptionLink = new ApolloWebSocketLink({ uri: `ws://localhost:8085/query`, options: { reconnect: true } }); } const httpLink = new HttpLink({ uri: 'http://localhost:8085/query' }); // depending on what kind of operation is being sent const link = split( // split based on operation type ({ query }) => { const { kind, operation } = getMainDefinition(query); return kind === 'OperationDefinition' && operation === 'subscription'; }, subscriptionLink, httpLink, ); const apolloClient = new ApolloClient({ link: link, cache: new InMemoryCache(), }); if (module.hot) { module.hot.accept('./App', () => { const NextApp = import('./App').default; render(); }) } function render(component) { ReactDOM.render( {component} , document.getElementById('root')); } render(); ================================================ FILE: _examples/chat/src/react-app-env.d.ts ================================================ /// ================================================ FILE: _examples/chat/tsconfig.json ================================================ { "compilerOptions": { "target": "es5", "lib": [ "dom", "dom.iterable", "esnext" ], "allowJs": true, "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "strict": true, "forceConsistentCasingInFileNames": true, "module": "esnext", "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, "jsx": "preserve" }, "include": [ "src" ] } ================================================ FILE: _examples/config/.gqlgen.yml ================================================ # .gqlgen.yml _examples # # Refer to https://gqlgen.com/config/ # for detailed .gqlgen.yml documentation. schema: "*.graphql" exec: filename: generated.go model: filename: models_gen.go resolver: type: Resolver layout: follow-schema dir: . models: Todo: # Object fields: text: fieldName: Description # Field NewTodo: # Input fields: userId: fieldName: UserID # Field ================================================ FILE: _examples/config/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package config 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 { Mutation() MutationResolver Query() QueryResolver Todo() TodoResolver Role() RoleResolver } type DirectiveRoot struct { } type ComplexityRoot struct { Mutation struct { CreateTodo func(childComplexity int, input NewTodo) int } Query struct { Todos func(childComplexity int) int } Todo struct { DatabaseID func(childComplexity int) int Description func(childComplexity int) int Done func(childComplexity int) int ID func(childComplexity int) int Mutation func(childComplexity int) int Query func(childComplexity int) int User func(childComplexity int) int } User struct { FullName func(childComplexity int) int ID func(childComplexity int) int Role func(childComplexity int) int } Role struct { Name func(childComplexity int) int } } type MutationResolver interface { CreateTodo(ctx context.Context, input NewTodo) (*Todo, error) } type QueryResolver interface { Todos(ctx context.Context) ([]*Todo, error) } type TodoResolver interface { ID(ctx context.Context, obj *Todo) (string, error) } type RoleResolver interface { Name(ctx context.Context, obj *UserRole) (string, error) } type executableSchema 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 "Mutation.createTodo": if e.ComplexityRoot.Mutation.CreateTodo == nil { break } args, err := ec.field_Mutation_createTodo_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Mutation.CreateTodo(childComplexity, args["input"].(NewTodo)), true case "Query.todos": if e.ComplexityRoot.Query.Todos == nil { break } return e.ComplexityRoot.Query.Todos(childComplexity), true case "Todo.databaseId": if e.ComplexityRoot.Todo.DatabaseID == nil { break } return e.ComplexityRoot.Todo.DatabaseID(childComplexity), true case "Todo.text": if e.ComplexityRoot.Todo.Description == nil { break } return e.ComplexityRoot.Todo.Description(childComplexity), true case "Todo.done": if e.ComplexityRoot.Todo.Done == nil { break } return e.ComplexityRoot.Todo.Done(childComplexity), true case "Todo.id": if e.ComplexityRoot.Todo.ID == nil { break } return e.ComplexityRoot.Todo.ID(childComplexity), true case "Todo.mutation": if e.ComplexityRoot.Todo.Mutation == nil { break } return e.ComplexityRoot.Todo.Mutation(childComplexity), true case "Todo.query": if e.ComplexityRoot.Todo.Query == nil { break } return e.ComplexityRoot.Todo.Query(childComplexity), true case "Todo.user": if e.ComplexityRoot.Todo.User == nil { break } return e.ComplexityRoot.Todo.User(childComplexity), true case "User.name": if e.ComplexityRoot.User.FullName == nil { break } return e.ComplexityRoot.User.FullName(childComplexity), true case "User.id": if e.ComplexityRoot.User.ID == nil { break } return e.ComplexityRoot.User.ID(childComplexity), true case "User.role": if e.ComplexityRoot.User.Role == nil { break } return e.ComplexityRoot.User.Role(childComplexity), true case "role.name": if e.ComplexityRoot.Role.Name == nil { break } return e.ComplexityRoot.Role.Name(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.unmarshalInputNewTodo, ) 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(), } } 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" "todo.graphql" "user.graphql" var sourcesFS embed.FS func sourceData(filename string) string { data, err := sourcesFS.ReadFile(filename) if err != nil { panic(fmt.Sprintf("codegen problem: %s not available", filename)) } return string(data) } var sources = []*ast.Source{ {Name: "schema.graphql", Input: sourceData("schema.graphql"), BuiltIn: false}, {Name: "todo.graphql", Input: sourceData("todo.graphql"), BuiltIn: false}, {Name: "user.graphql", Input: sourceData("user.graphql"), BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) field_Mutation_createTodo_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalNNewTodo2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋconfigᚐNewTodo) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]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) _Mutation_createTodo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Mutation_createTodo, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Mutation().CreateTodo(ctx, fc.Args["input"].(NewTodo)) }, nil, ec.marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋconfigᚐTodo, true, true, ) } func (ec *executionContext) fieldContext_Mutation_createTodo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Todo_id(ctx, field) case "databaseId": return ec.fieldContext_Todo_databaseId(ctx, field) case "text": return ec.fieldContext_Todo_text(ctx, field) case "done": return ec.fieldContext_Todo_done(ctx, field) case "user": return ec.fieldContext_Todo_user(ctx, field) case "query": return ec.fieldContext_Todo_query(ctx, field) case "mutation": return ec.fieldContext_Todo_mutation(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_createTodo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_todos, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Todos(ctx) }, nil, ec.marshalNTodo2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋconfigᚐTodoᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_todos(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Todo_id(ctx, field) case "databaseId": return ec.fieldContext_Todo_databaseId(ctx, field) case "text": return ec.fieldContext_Todo_text(ctx, field) case "done": return ec.fieldContext_Todo_done(ctx, field) case "user": return ec.fieldContext_Todo_user(ctx, field) case "query": return ec.fieldContext_Todo_query(ctx, field) case "mutation": return ec.fieldContext_Todo_mutation(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) }, } return fc, nil } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 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) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Todo_id, func(ctx context.Context) (any, error) { return ec.Resolvers.Todo().ID(ctx, obj) }, nil, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_Todo_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _Todo_databaseId(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Todo_databaseId, func(ctx context.Context) (any, error) { return obj.DatabaseID, nil }, nil, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_Todo_databaseId(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Todo_text, func(ctx context.Context) (any, error) { return obj.Description, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Todo_text(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Todo_done, func(ctx context.Context) (any, error) { return obj.Done, nil }, nil, ec.marshalNBoolean2bool, true, true, ) } func (ec *executionContext) fieldContext_Todo_done(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Todo_user, func(ctx context.Context) (any, error) { return obj.User, nil }, nil, ec.marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋconfigᚐUser, true, true, ) } func (ec *executionContext) fieldContext_Todo_user(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_User_id(ctx, field) case "name": return ec.fieldContext_User_name(ctx, field) case "role": return ec.fieldContext_User_role(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } func (ec *executionContext) _Todo_query(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Todo_query(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() res := &Query{} fc.Result = res return ec.marshalNQuery2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋconfigᚐQuery(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_query(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "todos": return ec.fieldContext_Query_todos(ctx, field) case "__schema": return ec.fieldContext_Query___schema(ctx, field) case "__type": return ec.fieldContext_Query___type(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Query", field.Name) }, } return fc, nil } func (ec *executionContext) _Todo_mutation(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Todo_mutation(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() res := &Mutation{} fc.Result = res return ec.marshalNMutation2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋconfigᚐMutation(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_mutation(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "createTodo": return ec.fieldContext_Mutation_createTodo(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Mutation", field.Name) }, } return fc, nil } func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, nil, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_User_id(_ 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) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_name, func(ctx context.Context) (any, error) { return obj.FullName(), 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: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _User_role(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_role, func(ctx context.Context) (any, error) { return obj.Role, nil }, nil, ec.marshalNrole2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋconfigᚐUserRole, true, true, ) } func (ec *executionContext) fieldContext_User_role(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "name": return ec.fieldContext_role_name(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type role", field.Name) }, } return fc, nil } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 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 } func (ec *executionContext) _role_name(ctx context.Context, field graphql.CollectedField, obj *UserRole) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_role_name, func(ctx context.Context) (any, error) { return ec.Resolvers.Role().Name(ctx, obj) }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_role_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "role", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** func (ec *executionContext) unmarshalInputNewTodo(ctx context.Context, obj any) (NewTodo, error) { var it NewTodo if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"text", "userId"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "text": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Text = data case "userId": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userId")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.UserID = data } } return it, nil } // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var mutationImplementors = []string{"Mutation"} func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Mutation", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Mutation") case "createTodo": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_createTodo(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "todos": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_todos(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) case "__schema": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var todoImplementors = []string{"Todo"} func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, todoImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Todo") case "id": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Todo_id(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "databaseId": out.Values[i] = ec._Todo_databaseId(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "text": out.Values[i] = ec._Todo_text(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "done": out.Values[i] = ec._Todo_done(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "user": out.Values[i] = ec._Todo_user(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "query": out.Values[i] = ec._Todo_query(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "mutation": out.Values[i] = ec._Todo_mutation(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var userImplementors = []string{"User"} func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *User) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("User") case "id": out.Values[i] = ec._User_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "name": out.Values[i] = ec._User_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "role": out.Values[i] = ec._User_role(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": out.Values[i] = ec.___Directive_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "description": out.Values[i] = ec.___Directive_description(ctx, field, obj) case "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 } var roleImplementors = []string{"role"} func (ec *executionContext) _role(ctx context.Context, sel ast.SelectionSet, obj *UserRole) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, roleImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("role") case "name": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._role_name(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v 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) marshalNMutation2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋconfigᚐMutation(ctx context.Context, sel ast.SelectionSet, v *Mutation) 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._Mutation(ctx, sel) } func (ec *executionContext) unmarshalNNewTodo2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋconfigᚐNewTodo(ctx context.Context, v any) (NewTodo, error) { res, err := ec.unmarshalInputNewTodo(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNQuery2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋconfigᚐQuery(ctx context.Context, sel ast.SelectionSet, v *Query) 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._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) marshalNTodo2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋconfigᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { return ec._Todo(ctx, sel, &v) } func (ec *executionContext) marshalNTodo2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋconfigᚐTodoᚄ(ctx context.Context, sel ast.SelectionSet, v []*Todo) 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.marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋconfigᚐTodo(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋconfigᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) 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._Todo(ctx, sel, v) } func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋconfigᚐ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 { 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) marshalNrole2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋconfigᚐUserRole(ctx context.Context, sel ast.SelectionSet, v UserRole) graphql.Marshaler { return ec._role(ctx, sel, &v) } func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v 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) 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__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/config/model.go ================================================ package config import "fmt" type User struct { ID string FirstName, LastName string Role UserRole } func (user *User) FullName() string { return fmt.Sprintf("%s %s", user.FirstName, user.LastName) } type UserRole struct { RoleName string } ================================================ FILE: _examples/config/models_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package config type Mutation struct { } type NewTodo struct { Text string `json:"text"` UserID string `json:"userId"` } type Query struct { } type Todo struct { ID string `json:"id"` DatabaseID int `json:"databaseId"` Description string `json:"text"` Done bool `json:"done"` User *User `json:"user"` Query *Query `json:"query"` Mutation *Mutation `json:"mutation"` } ================================================ FILE: _examples/config/resolver.go ================================================ //go:generate go run ../../testdata/gqlgen.go package config func New() Config { c := Config{ Resolvers: &Resolver{ todos: []*Todo{ {DatabaseID: 1, Description: "A todo not to forget", Done: false}, {DatabaseID: 2, Description: "This is the most important", Done: false}, {DatabaseID: 3, Description: "Please do this or else", Done: false}, }, nextID: 3, }, } return c } type Resolver struct { todos []*Todo nextID int } ================================================ FILE: _examples/config/schema.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 ) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION type Query { todos: [Todo!]! } type Mutation { createTodo(input: NewTodo!): Todo! } ================================================ FILE: _examples/config/schema.resolvers.go ================================================ package config // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. // Code generated by github.com/99designs/gqlgen version v0.17.88-dev import ( "context" ) // CreateTodo is the resolver for the createTodo field. func (r *mutationResolver) CreateTodo(ctx context.Context, input NewTodo) (*Todo, error) { newID := r.nextID r.nextID++ newTodo := &Todo{ DatabaseID: newID, Description: input.Text, } r.todos = append(r.todos, newTodo) return newTodo, nil } // Todos is the resolver for the todos field. func (r *queryResolver) Todos(ctx context.Context) ([]*Todo, error) { return r.todos, nil } // Mutation returns MutationResolver implementation. func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } // Query returns QueryResolver implementation. func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } type mutationResolver struct{ *Resolver } type queryResolver struct{ *Resolver } ================================================ FILE: _examples/config/server/server.go ================================================ package main import ( "log" "net/http" todo "github.com/99designs/gqlgen/_examples/config" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/playground" ) func main() { srv := handler.New( todo.NewExecutableSchema(todo.New()), ) srv.AddTransport(transport.GET{}) srv.AddTransport(transport.POST{}) http.Handle("/", playground.Handler("Todo", "/query")) http.Handle("/query", srv) log.Fatal(http.ListenAndServe(":8081", nil)) } ================================================ FILE: _examples/config/todo.graphql ================================================ type Todo { id: ID! @goField(forceResolver: true) databaseId: Int! text: String! done: Boolean! user: User! query: Query! mutation: Mutation! } input NewTodo { text: String! userId: String! } ================================================ FILE: _examples/config/todo.resolvers.go ================================================ package config // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. // Code generated by github.com/99designs/gqlgen version v0.17.88-dev import ( "context" "fmt" ) // ID is the resolver for the id field. func (r *todoResolver) ID(ctx context.Context, obj *Todo) (string, error) { if obj.ID != "" { return obj.ID, nil } obj.ID = fmt.Sprintf("TODO:%d", obj.DatabaseID) return obj.ID, nil } // Todo returns TodoResolver implementation. func (r *Resolver) Todo() TodoResolver { return &todoResolver{r} } type todoResolver struct{ *Resolver } ================================================ FILE: _examples/config/user.graphql ================================================ type User @goModel(model:"github.com/99designs/gqlgen/_examples/config.User") { id: ID! name: String! @goField(name:"FullName") role: role! } type role @goModel(model:"github.com/99designs/gqlgen/_examples/config.UserRole") { name: String! } ================================================ FILE: _examples/config/user.resolvers.go ================================================ package config // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. // Code generated by github.com/99designs/gqlgen version v0.17.88-dev import ( "context" ) // Name is the resolver for the name field. func (r *roleResolver) Name(ctx context.Context, obj *UserRole) (string, error) { if obj == nil { return "", nil } return obj.RoleName, nil } // Role returns RoleResolver implementation. func (r *Resolver) Role() RoleResolver { return &roleResolver{r} } type roleResolver struct{ *Resolver } ================================================ FILE: _examples/contextpropagation/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package contextpropagation 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 { Query() QueryResolver TodoContext() TodoContextResolver } type DirectiveRoot struct { WithContext func(ctx context.Context, obj any, next graphql.Resolver, value string) (res any, err error) } type ComplexityRoot struct { Query struct { TestTodo func(childComplexity int) int } Todo struct { Context func(childComplexity int) int Text func(childComplexity int) int } TodoContext struct { Value func(childComplexity int) int } } type QueryResolver interface { TestTodo(ctx context.Context) (*Todo, error) } type TodoContextResolver interface { Value(ctx context.Context, obj *TodoContext) (*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 "Query.testTodo": if e.ComplexityRoot.Query.TestTodo == nil { break } return e.ComplexityRoot.Query.TestTodo(childComplexity), true case "Todo.context": if e.ComplexityRoot.Todo.Context == nil { break } return e.ComplexityRoot.Todo.Context(childComplexity), true case "Todo.text": if e.ComplexityRoot.Todo.Text == nil { break } return e.ComplexityRoot.Todo.Text(childComplexity), true case "TodoContext.value": if e.ComplexityRoot.TodoContext.Value == nil { break } return e.ComplexityRoot.TodoContext.Value(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) dir_withContext_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.unmarshalNString2string) if err != nil { return nil, err } args["value"] = 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___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_testTodo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_testTodo, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().TestTodo(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { value, err := ec.unmarshalNString2string(ctx, "Some value") if err != nil { var zeroVal *Todo return zeroVal, err } if ec.Directives.WithContext == nil { var zeroVal *Todo return zeroVal, errors.New("directive withContext is not implemented") } return ec.Directives.WithContext(ctx, nil, directive0, value) } next = directive1 return next }, ec.marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋcontextpropagationᚐTodo, true, true, ) } func (ec *executionContext) fieldContext_Query_testTodo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "text": return ec.fieldContext_Todo_text(ctx, field) case "context": return ec.fieldContext_Todo_context(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) }, } return fc, nil } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 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) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Todo_text, func(ctx context.Context) (any, error) { return obj.Text, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Todo_text(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Todo_context(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Todo_context, func(ctx context.Context) (any, error) { return obj.Context, nil }, nil, ec.marshalNTodoContext2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋcontextpropagationᚐTodoContext, true, true, ) } func (ec *executionContext) fieldContext_Todo_context(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "value": return ec.fieldContext_TodoContext_value(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type TodoContext", field.Name) }, } return fc, nil } func (ec *executionContext) _TodoContext_value(ctx context.Context, field graphql.CollectedField, obj *TodoContext) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_TodoContext_value, func(ctx context.Context) (any, error) { return ec.Resolvers.TodoContext().Value(ctx, obj) }, nil, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_TodoContext_value(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "TodoContext", 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) ___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 "testTodo": field := field innerFunc := func(ctx 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_testTodo(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) case "__schema": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var todoImplementors = []string{"Todo"} func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, todoImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Todo") case "text": out.Values[i] = ec._Todo_text(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "context": out.Values[i] = ec._Todo_context(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 todoContextImplementors = []string{"TodoContext"} func (ec *executionContext) _TodoContext(ctx context.Context, sel ast.SelectionSet, obj *TodoContext) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, todoContextImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("TodoContext") case "value": 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._TodoContext_value(ctx, field, obj) return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var __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) marshalNTodo2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋcontextpropagationᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { return ec._Todo(ctx, sel, &v) } func (ec *executionContext) marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋcontextpropagationᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) 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._Todo(ctx, sel, v) } func (ec *executionContext) marshalNTodoContext2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋcontextpropagationᚐTodoContext(ctx context.Context, sel ast.SelectionSet, v *TodoContext) 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._TodoContext(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) 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/contextpropagation/gqlgen.yml ================================================ exec: filename: generated.go model: filename: models_gen.go ================================================ FILE: _examples/contextpropagation/models_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package contextpropagation type Query struct { } type Todo struct { Text string `json:"text"` Context *TodoContext `json:"context"` } type TodoContext struct { Value *string `json:"value,omitempty"` } ================================================ FILE: _examples/contextpropagation/schema.graphql ================================================ directive @goField( forceResolver: Boolean name: String omittable: Boolean type: String ) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION directive @withContext(value: String!) on FIELD_DEFINITION type Query { testTodo: Todo! @withContext(value: "Some value") } type Todo { text: String! context: TodoContext! } type TodoContext { value: String @goField(forceResolver: true) } ================================================ FILE: _examples/contextpropagation/todo.go ================================================ //go:generate go run ../../testdata/gqlgen.go package contextpropagation import ( "context" "github.com/99designs/gqlgen/graphql" ) type ctxKey string func getTodoContext(ctx context.Context) *string { if value, ok := ctx.Value(ctxKey("todoContext")).(string); ok { return &value } return nil } func New() Config { c := Config{ Resolvers: new(Resolver), } c.Directives.WithContext = func(ctx context.Context, obj any, next graphql.Resolver, value string) (any, error) { return next(context.WithValue(ctx, ctxKey("todoContext"), value)) } return c } type Resolver struct{} func (r *Resolver) Query() QueryResolver { return r } func (r *Resolver) TodoContext() TodoContextResolver { return r } func (r *Resolver) TestTodo(ctx context.Context) (*Todo, error) { return &Todo{Text: "Test", Context: new(TodoContext)}, nil } func (r *Resolver) Value(ctx context.Context, obj *TodoContext) (*string, error) { return getTodoContext(ctx), nil } ================================================ FILE: _examples/contextpropagation/todo_test.go ================================================ package contextpropagation import ( "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/extension" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestTodo(t *testing.T) { srv := handler.New(NewExecutableSchema(New())) srv.AddTransport(transport.POST{}) srv.Use(extension.Introspection{}) c := client.New(srv) var resp struct { TestTodo struct { Text string Context struct { Value *string } } } c.MustPost(`{ testTodo { text context { value } } }`, &resp) require.Equal(t, "Test", resp.TestTodo.Text) require.NotNil(t, resp.TestTodo.Context.Value) require.Equal(t, "Some value", *resp.TestTodo.Context.Value) } ================================================ FILE: _examples/dataloader/.gqlgen.yml ================================================ models: Order: model: github.com/99designs/gqlgen/_examples/dataloader.Order Customer: model: github.com/99designs/gqlgen/_examples/dataloader.Customer ================================================ FILE: _examples/dataloader/addressloader_gen.go ================================================ // Code generated by github.com/vektah/dataloaden, DO NOT EDIT. package dataloader import ( "sync" "time" ) // AddressLoaderConfig captures the config to create a new AddressLoader type AddressLoaderConfig struct { // Fetch is a method that provides the data for the loader Fetch func(keys []int) ([]*Address, []error) // Wait is how long wait before sending a batch Wait time.Duration // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit MaxBatch int } // NewAddressLoader creates a new AddressLoader given a fetch, wait, and maxBatch func NewAddressLoader(config AddressLoaderConfig) *AddressLoader { return &AddressLoader{ fetch: config.Fetch, wait: config.Wait, maxBatch: config.MaxBatch, } } // AddressLoader batches and caches requests type AddressLoader struct { // this method provides the data for the loader fetch func(keys []int) ([]*Address, []error) // how long to done before sending a batch wait time.Duration // this will limit the maximum number of keys to send in one batch, 0 = no limit maxBatch int // INTERNAL // lazily created cache cache map[int]*Address // the current batch. keys will continue to be collected until timeout is hit, // then everything will be sent to the fetch method and out to the listeners batch *addressLoaderBatch // mutex to prevent races mu sync.Mutex } type addressLoaderBatch struct { keys []int data []*Address error []error closing bool done chan struct{} } // Load a Address by key, batching and caching will be applied automatically func (l *AddressLoader) Load(key int) (*Address, error) { return l.LoadThunk(key)() } // LoadThunk returns a function that when called will block waiting for a Address. // This method should be used if you want one goroutine to make requests to many // different data loaders without blocking until the thunk is called. func (l *AddressLoader) LoadThunk(key int) func() (*Address, error) { l.mu.Lock() if it, ok := l.cache[key]; ok { l.mu.Unlock() return func() (*Address, error) { return it, nil } } if l.batch == nil { l.batch = &addressLoaderBatch{done: make(chan struct{})} } batch := l.batch pos := batch.keyIndex(l, key) l.mu.Unlock() return func() (*Address, error) { <-batch.done var data *Address if pos < len(batch.data) { data = batch.data[pos] } var err error // its convenient to be able to return a single error for everything if len(batch.error) == 1 { err = batch.error[0] } else if batch.error != nil { err = batch.error[pos] } if err == nil { l.mu.Lock() l.unsafeSet(key, data) l.mu.Unlock() } return data, err } } // LoadAll fetches many keys at once. It will be broken into appropriate sized // sub batches depending on how the loader is configured func (l *AddressLoader) LoadAll(keys []int) ([]*Address, []error) { results := make([]func() (*Address, error), len(keys)) for i, key := range keys { results[i] = l.LoadThunk(key) } addresss := make([]*Address, len(keys)) errors := make([]error, len(keys)) for i, thunk := range results { addresss[i], errors[i] = thunk() } return addresss, errors } // LoadAllThunk returns a function that when called will block waiting for a Addresss. // This method should be used if you want one goroutine to make requests to many // different data loaders without blocking until the thunk is called. func (l *AddressLoader) LoadAllThunk(keys []int) func() ([]*Address, []error) { results := make([]func() (*Address, error), len(keys)) for i, key := range keys { results[i] = l.LoadThunk(key) } return func() ([]*Address, []error) { addresss := make([]*Address, len(keys)) errors := make([]error, len(keys)) for i, thunk := range results { addresss[i], errors[i] = thunk() } return addresss, errors } } // Prime the cache with the provided key and value. If the key already exists, no change is made // and false is returned. // (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).) func (l *AddressLoader) Prime(key int, value *Address) bool { l.mu.Lock() var found bool if _, found = l.cache[key]; !found { // make a copy when writing to the cache, its easy to pass a pointer in from a loop var // and end up with the whole cache pointing to the same value. cpy := *value l.unsafeSet(key, &cpy) } l.mu.Unlock() return !found } // Clear the value at key from the cache, if it exists func (l *AddressLoader) Clear(key int) { l.mu.Lock() delete(l.cache, key) l.mu.Unlock() } func (l *AddressLoader) unsafeSet(key int, value *Address) { if l.cache == nil { l.cache = map[int]*Address{} } l.cache[key] = value } // keyIndex will return the location of the key in the batch, if its not found // it will add the key to the batch func (b *addressLoaderBatch) keyIndex(l *AddressLoader, key int) int { for i, existingKey := range b.keys { if key == existingKey { return i } } pos := len(b.keys) b.keys = append(b.keys, key) if pos == 0 { go b.startTimer(l) } if l.maxBatch != 0 && pos >= l.maxBatch-1 { if !b.closing { b.closing = true l.batch = nil go b.end(l) } } return pos } func (b *addressLoaderBatch) startTimer(l *AddressLoader) { time.Sleep(l.wait) l.mu.Lock() // we must have hit a batch limit and are already finalizing this batch if b.closing { l.mu.Unlock() return } l.batch = nil l.mu.Unlock() b.end(l) } func (b *addressLoaderBatch) end(l *AddressLoader) { b.data, b.error = l.fetch(b.keys) close(b.done) } ================================================ FILE: _examples/dataloader/dataloader_test.go ================================================ package dataloader import ( "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "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/introspection" ) func TestTodo(t *testing.T) { srv := handler.New(NewExecutableSchema(Config{Resolvers: &Resolver{}})) srv.AddTransport(transport.POST{}) srv.Use(extension.Introspection{}) c := client.New(LoaderMiddleware(srv)) t.Run("create a new todo", func(t *testing.T) { var resp any c.MustPost(`{ customers { name address { street } orders { id amount items { name } } } }`, &resp) }) t.Run("2d array marshaling", func(t *testing.T) { var resp struct { Torture2d [][]Customer } c.MustPost(`{ torture2d(customerIds:[[1,2],[3,4,5]]) { id name } }`, &resp) require.EqualValues(t, [][]Customer{ {{ID: 1, Name: "0 0"}, {ID: 2, Name: "0 1"}}, {{ID: 3, Name: "1 0"}, {ID: 4, Name: "1 1"}, {ID: 5, Name: "1 2"}}, }, resp.Torture2d) }) // Input coercion on arrays should convert non array values into an array of the appropriate // depth // http://facebook.github.io/graphql/June2018/#sec-Type-System.List t.Run("array coercion", func(t *testing.T) { t.Run("1d", func(t *testing.T) { var resp struct { Torture1d []Customer } c.MustPost(`{ torture1d(customerIds: 1) { id name } }`, &resp) require.EqualValues(t, []Customer{ {ID: 1, Name: "0"}, }, resp.Torture1d) }) t.Run("2d", func(t *testing.T) { var resp struct { Torture2d [][]Customer } c.MustPost(`{ torture2d(customerIds: 1) { id name } }`, &resp) require.EqualValues(t, [][]Customer{ {{ID: 1, Name: "0 0"}}, }, resp.Torture2d) }) }) t.Run("introspection", func(t *testing.T) { // Make sure we can run the graphiql introspection query without errors var resp any c.MustPost(introspection.Query, &resp) }) t.Run("customer array torture malformed array query", func(t *testing.T) { var resp struct { Torture [][]Customer } err := c.Post(`{ torture2d(customerIds:{}) { id name } }`, &resp) require.EqualError( t, err, "[{\"message\":\"map[string]interface {} is not an int\",\"path\":[\"torture2d\",\"customerIds\",0,0]}]", ) }) } ================================================ FILE: _examples/dataloader/dataloaders.go ================================================ //go:generate go run github.com/vektah/dataloaden AddressLoader int *github.com/99designs/gqlgen/_examples/dataloader.Address //go:generate go run github.com/vektah/dataloaden OrderSliceLoader int []*github.com/99designs/gqlgen/_examples/dataloader.Order //go:generate go run github.com/vektah/dataloaden ItemSliceLoader int []*github.com/99designs/gqlgen/_examples/dataloader.Item package dataloader import ( "context" "fmt" "math/rand" "net/http" "strconv" "strings" "time" ) type ctxKeyType struct{ name string } var ctxKey = ctxKeyType{"userCtx"} type loaders struct { addressByID *AddressLoader ordersByCustomer *OrderSliceLoader itemsByOrder *ItemSliceLoader } //nolint:gosec func LoaderMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ldrs := loaders{} // set this to zero what happens without dataloading wait := 250 * time.Microsecond // simple 1:1 loader, fetch an address by its primary key ldrs.addressByID = &AddressLoader{ wait: wait, maxBatch: 100, fetch: func(keys []int) ([]*Address, []error) { var keySql []string for _, key := range keys { keySql = append(keySql, strconv.Itoa(key)) } fmt.Printf("SELECT * FROM address WHERE id IN (%s)\n", strings.Join(keySql, ",")) time.Sleep(5 * time.Millisecond) addresses := make([]*Address, len(keys)) errors := make([]error, len(keys)) for i, key := range keys { addresses[i] = &Address{ Street: "home street", Country: "hometon " + strconv.Itoa(key), } } return addresses, errors }, } // 1:M loader ldrs.ordersByCustomer = &OrderSliceLoader{ wait: wait, maxBatch: 100, fetch: func(keys []int) ([][]*Order, []error) { var keySql []string for _, key := range keys { keySql = append(keySql, strconv.Itoa(key)) } fmt.Printf( "SELECT * FROM orders WHERE customer_id IN (%s)\n", strings.Join(keySql, ","), ) time.Sleep(5 * time.Millisecond) orders := make([][]*Order, len(keys)) errors := make([]error, len(keys)) for i, key := range keys { id := 10 + rand.Int()%3 orders[i] = []*Order{ { ID: id, Amount: rand.Float64(), Date: time.Now().Add(-time.Duration(key) * time.Hour), }, { ID: id + 1, Amount: rand.Float64(), Date: time.Now().Add(-time.Duration(key) * time.Hour), }, } // if you had another customer loader you would prime its cache here // by calling `ldrs.ordersByID.Prime(id, orders[i])` } return orders, errors }, } // M:M loader ldrs.itemsByOrder = &ItemSliceLoader{ wait: wait, maxBatch: 100, fetch: func(keys []int) ([][]*Item, []error) { var keySql []string for _, key := range keys { keySql = append(keySql, strconv.Itoa(key)) } fmt.Printf( "SELECT * FROM items JOIN item_order WHERE item_order.order_id IN (%s)\n", strings.Join(keySql, ","), ) time.Sleep(5 * time.Millisecond) items := make([][]*Item, len(keys)) errors := make([]error, len(keys)) for i := range keys { items[i] = []*Item{ {Name: "item " + strconv.Itoa(rand.Int()%20+20)}, {Name: "item " + strconv.Itoa(rand.Int()%20+20)}, } } return items, errors }, } dlCtx := context.WithValue(r.Context(), ctxKey, ldrs) next.ServeHTTP(w, r.WithContext(dlCtx)) }) } func ctxLoaders(ctx context.Context) loaders { return ctx.Value(ctxKey).(loaders) } ================================================ FILE: _examples/dataloader/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package dataloader 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 { Customer() CustomerResolver Order() OrderResolver Query() QueryResolver } type DirectiveRoot struct { } type ComplexityRoot struct { Address struct { Country func(childComplexity int) int ID func(childComplexity int) int Street func(childComplexity int) int } Customer struct { Address func(childComplexity int) int ID func(childComplexity int) int Name func(childComplexity int) int Orders func(childComplexity int) int } Item struct { Name func(childComplexity int) int } Order struct { Amount func(childComplexity int) int Date func(childComplexity int) int ID func(childComplexity int) int Items func(childComplexity int) int } Query struct { Customers func(childComplexity int) int Torture1d func(childComplexity int, customerIds []int) int Torture2d func(childComplexity int, customerIds [][]int) int } } type CustomerResolver interface { Address(ctx context.Context, obj *Customer) (*Address, error) Orders(ctx context.Context, obj *Customer) ([]*Order, error) } type OrderResolver interface { Items(ctx context.Context, obj *Order) ([]*Item, error) } type QueryResolver interface { Customers(ctx context.Context) ([]*Customer, error) Torture1d(ctx context.Context, customerIds []int) ([]*Customer, error) Torture2d(ctx context.Context, customerIds [][]int) ([][]*Customer, error) } type executableSchema 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 "Address.country": if e.ComplexityRoot.Address.Country == nil { break } return e.ComplexityRoot.Address.Country(childComplexity), true case "Address.id": if e.ComplexityRoot.Address.ID == nil { break } return e.ComplexityRoot.Address.ID(childComplexity), true case "Address.street": if e.ComplexityRoot.Address.Street == nil { break } return e.ComplexityRoot.Address.Street(childComplexity), true case "Customer.address": if e.ComplexityRoot.Customer.Address == nil { break } return e.ComplexityRoot.Customer.Address(childComplexity), true case "Customer.id": if e.ComplexityRoot.Customer.ID == nil { break } return e.ComplexityRoot.Customer.ID(childComplexity), true case "Customer.name": if e.ComplexityRoot.Customer.Name == nil { break } return e.ComplexityRoot.Customer.Name(childComplexity), true case "Customer.orders": if e.ComplexityRoot.Customer.Orders == nil { break } return e.ComplexityRoot.Customer.Orders(childComplexity), true case "Item.name": if e.ComplexityRoot.Item.Name == nil { break } return e.ComplexityRoot.Item.Name(childComplexity), true case "Order.amount": if e.ComplexityRoot.Order.Amount == nil { break } return e.ComplexityRoot.Order.Amount(childComplexity), true case "Order.date": if e.ComplexityRoot.Order.Date == nil { break } return e.ComplexityRoot.Order.Date(childComplexity), true case "Order.id": if e.ComplexityRoot.Order.ID == nil { break } return e.ComplexityRoot.Order.ID(childComplexity), true case "Order.items": if e.ComplexityRoot.Order.Items == nil { break } return e.ComplexityRoot.Order.Items(childComplexity), true case "Query.customers": if e.ComplexityRoot.Query.Customers == nil { break } return e.ComplexityRoot.Query.Customers(childComplexity), true case "Query.torture1d": if e.ComplexityRoot.Query.Torture1d == nil { break } args, err := ec.field_Query_torture1d_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.Torture1d(childComplexity, args["customerIds"].([]int)), true case "Query.torture2d": if e.ComplexityRoot.Query.Torture2d == nil { break } args, err := ec.field_Query_torture2d_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.Torture2d(childComplexity, args["customerIds"].([][]int)), 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_Query_torture1d_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, "customerIds", ec.unmarshalOInt2ᚕintᚄ) if err != nil { return nil, err } args["customerIds"] = arg0 return args, nil } func (ec *executionContext) field_Query_torture2d_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "customerIds", ec.unmarshalOInt2ᚕᚕint) if err != nil { return nil, err } args["customerIds"] = 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) _Address_id(ctx context.Context, field graphql.CollectedField, obj *Address) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Address_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, nil, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_Address_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Address", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _Address_street(ctx context.Context, field graphql.CollectedField, obj *Address) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Address_street, func(ctx context.Context) (any, error) { return obj.Street, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Address_street(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Address", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Address_country(ctx context.Context, field graphql.CollectedField, obj *Address) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Address_country, func(ctx context.Context) (any, error) { return obj.Country, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Address_country(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Address", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Customer_id(ctx context.Context, field graphql.CollectedField, obj *Customer) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Customer_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, nil, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_Customer_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Customer", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _Customer_name(ctx context.Context, field graphql.CollectedField, obj *Customer) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Customer_name, func(ctx context.Context) (any, error) { return obj.Name, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Customer_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Customer", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Customer_address(ctx context.Context, field graphql.CollectedField, obj *Customer) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Customer_address, func(ctx context.Context) (any, error) { return ec.Resolvers.Customer().Address(ctx, obj) }, nil, ec.marshalOAddress2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdataloaderᚐAddress, true, false, ) } func (ec *executionContext) fieldContext_Customer_address(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Customer", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Address_id(ctx, field) case "street": return ec.fieldContext_Address_street(ctx, field) case "country": return ec.fieldContext_Address_country(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Address", field.Name) }, } return fc, nil } func (ec *executionContext) _Customer_orders(ctx context.Context, field graphql.CollectedField, obj *Customer) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Customer_orders, func(ctx context.Context) (any, error) { return ec.Resolvers.Customer().Orders(ctx, obj) }, nil, ec.marshalOOrder2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdataloaderᚐOrderᚄ, true, false, ) } func (ec *executionContext) fieldContext_Customer_orders(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Customer", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Order_id(ctx, field) case "date": return ec.fieldContext_Order_date(ctx, field) case "amount": return ec.fieldContext_Order_amount(ctx, field) case "items": return ec.fieldContext_Order_items(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Order", field.Name) }, } return fc, nil } func (ec *executionContext) _Item_name(ctx context.Context, field graphql.CollectedField, obj *Item) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Item_name, func(ctx context.Context) (any, error) { return obj.Name, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Item_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Item", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Order_id(ctx context.Context, field graphql.CollectedField, obj *Order) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Order_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, nil, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_Order_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Order", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _Order_date(ctx context.Context, field graphql.CollectedField, obj *Order) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Order_date, func(ctx context.Context) (any, error) { return obj.Date, nil }, nil, ec.marshalNTime2timeᚐTime, true, true, ) } func (ec *executionContext) fieldContext_Order_date(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Order", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } func (ec *executionContext) _Order_amount(ctx context.Context, field graphql.CollectedField, obj *Order) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Order_amount, func(ctx context.Context) (any, error) { return obj.Amount, nil }, nil, ec.marshalNFloat2float64, true, true, ) } func (ec *executionContext) fieldContext_Order_amount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Order", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Float does not have child fields") }, } return fc, nil } func (ec *executionContext) _Order_items(ctx context.Context, field graphql.CollectedField, obj *Order) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Order_items, func(ctx context.Context) (any, error) { return ec.Resolvers.Order().Items(ctx, obj) }, nil, ec.marshalOItem2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdataloaderᚐItemᚄ, true, false, ) } func (ec *executionContext) fieldContext_Order_items(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Order", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "name": return ec.fieldContext_Item_name(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Item", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_customers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_customers, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Customers(ctx) }, nil, ec.marshalOCustomer2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdataloaderᚐCustomerᚄ, true, false, ) } func (ec *executionContext) fieldContext_Query_customers(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Customer_id(ctx, field) case "name": return ec.fieldContext_Customer_name(ctx, field) case "address": return ec.fieldContext_Customer_address(ctx, field) case "orders": return ec.fieldContext_Customer_orders(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Customer", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_torture1d(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_torture1d, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().Torture1d(ctx, fc.Args["customerIds"].([]int)) }, nil, ec.marshalOCustomer2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdataloaderᚐCustomerᚄ, true, false, ) } func (ec *executionContext) fieldContext_Query_torture1d(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Customer_id(ctx, field) case "name": return ec.fieldContext_Customer_name(ctx, field) case "address": return ec.fieldContext_Customer_address(ctx, field) case "orders": return ec.fieldContext_Customer_orders(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Customer", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_torture1d_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_torture2d(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_torture2d, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().Torture2d(ctx, fc.Args["customerIds"].([][]int)) }, nil, ec.marshalOCustomer2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdataloaderᚐCustomer, true, false, ) } func (ec *executionContext) fieldContext_Query_torture2d(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Customer_id(ctx, field) case "name": return ec.fieldContext_Customer_name(ctx, field) case "address": return ec.fieldContext_Customer_address(ctx, field) case "orders": return ec.fieldContext_Customer_orders(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Customer", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_torture2d_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 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) ___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 addressImplementors = []string{"Address"} func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, obj *Address) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, addressImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Address") case "id": out.Values[i] = ec._Address_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "street": out.Values[i] = ec._Address_street(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "country": out.Values[i] = ec._Address_country(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var customerImplementors = []string{"Customer"} func (ec *executionContext) _Customer(ctx context.Context, sel ast.SelectionSet, obj *Customer) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, customerImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Customer") case "id": out.Values[i] = ec._Customer_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "name": out.Values[i] = ec._Customer_name(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "address": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Customer_address(ctx, field, obj) return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "orders": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Customer_orders(ctx, field, obj) return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var itemImplementors = []string{"Item"} func (ec *executionContext) _Item(ctx context.Context, sel ast.SelectionSet, obj *Item) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, itemImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Item") case "name": out.Values[i] = ec._Item_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var orderImplementors = []string{"Order"} func (ec *executionContext) _Order(ctx context.Context, sel ast.SelectionSet, obj *Order) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, orderImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Order") case "id": out.Values[i] = ec._Order_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "date": out.Values[i] = ec._Order_date(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "amount": out.Values[i] = ec._Order_amount(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "items": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Order_items(ctx, field, obj) return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "customers": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_customers(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "torture1d": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_torture1d(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "torture2d": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_torture2d(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) case "__schema": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": out.Values[i] = ec.___Directive_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "description": out.Values[i] = ec.___Directive_description(ctx, field, obj) case "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) marshalNCustomer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v *Customer) 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._Customer(ctx, sel, v) } 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) 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) marshalNItem2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdataloaderᚐItem(ctx context.Context, sel ast.SelectionSet, v *Item) 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._Item(ctx, sel, v) } func (ec *executionContext) marshalNOrder2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdataloaderᚐOrder(ctx context.Context, sel ast.SelectionSet, v *Order) 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._Order(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) 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) marshalOAddress2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdataloaderᚐAddress(ctx context.Context, sel ast.SelectionSet, v *Address) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Address(ctx, sel, v) } func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v 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) marshalOCustomer2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdataloaderᚐCustomer(ctx context.Context, sel ast.SelectionSet, v [][]*Customer) 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.marshalOCustomer2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdataloaderᚐCustomerᚄ(ctx, sel, v[i]) }) return ret } func (ec *executionContext) marshalOCustomer2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdataloaderᚐCustomerᚄ(ctx context.Context, sel ast.SelectionSet, v []*Customer) 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.marshalNCustomer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdataloaderᚐCustomer(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) unmarshalOInt2ᚕintᚄ(ctx context.Context, v 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) 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) marshalOItem2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdataloaderᚐItemᚄ(ctx context.Context, sel ast.SelectionSet, v []*Item) 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.marshalNItem2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdataloaderᚐItem(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalOOrder2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdataloaderᚐOrderᚄ(ctx context.Context, sel ast.SelectionSet, v []*Order) 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.marshalNOrder2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdataloaderᚐOrder(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__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/dataloader/itemsliceloader_gen.go ================================================ // Code generated by github.com/vektah/dataloaden, DO NOT EDIT. package dataloader import ( "sync" "time" ) // ItemSliceLoaderConfig captures the config to create a new ItemSliceLoader type ItemSliceLoaderConfig struct { // Fetch is a method that provides the data for the loader Fetch func(keys []int) ([][]*Item, []error) // Wait is how long wait before sending a batch Wait time.Duration // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit MaxBatch int } // NewItemSliceLoader creates a new ItemSliceLoader given a fetch, wait, and maxBatch func NewItemSliceLoader(config ItemSliceLoaderConfig) *ItemSliceLoader { return &ItemSliceLoader{ fetch: config.Fetch, wait: config.Wait, maxBatch: config.MaxBatch, } } // ItemSliceLoader batches and caches requests type ItemSliceLoader struct { // this method provides the data for the loader fetch func(keys []int) ([][]*Item, []error) // how long to done before sending a batch wait time.Duration // this will limit the maximum number of keys to send in one batch, 0 = no limit maxBatch int // INTERNAL // lazily created cache cache map[int][]*Item // the current batch. keys will continue to be collected until timeout is hit, // then everything will be sent to the fetch method and out to the listeners batch *itemSliceLoaderBatch // mutex to prevent races mu sync.Mutex } type itemSliceLoaderBatch struct { keys []int data [][]*Item error []error closing bool done chan struct{} } // Load a Item by key, batching and caching will be applied automatically func (l *ItemSliceLoader) Load(key int) ([]*Item, error) { return l.LoadThunk(key)() } // LoadThunk returns a function that when called will block waiting for a Item. // This method should be used if you want one goroutine to make requests to many // different data loaders without blocking until the thunk is called. func (l *ItemSliceLoader) LoadThunk(key int) func() ([]*Item, error) { l.mu.Lock() if it, ok := l.cache[key]; ok { l.mu.Unlock() return func() ([]*Item, error) { return it, nil } } if l.batch == nil { l.batch = &itemSliceLoaderBatch{done: make(chan struct{})} } batch := l.batch pos := batch.keyIndex(l, key) l.mu.Unlock() return func() ([]*Item, error) { <-batch.done var data []*Item if pos < len(batch.data) { data = batch.data[pos] } var err error // its convenient to be able to return a single error for everything if len(batch.error) == 1 { err = batch.error[0] } else if batch.error != nil { err = batch.error[pos] } if err == nil { l.mu.Lock() l.unsafeSet(key, data) l.mu.Unlock() } return data, err } } // LoadAll fetches many keys at once. It will be broken into appropriate sized // sub batches depending on how the loader is configured func (l *ItemSliceLoader) LoadAll(keys []int) ([][]*Item, []error) { results := make([]func() ([]*Item, error), len(keys)) for i, key := range keys { results[i] = l.LoadThunk(key) } items := make([][]*Item, len(keys)) errors := make([]error, len(keys)) for i, thunk := range results { items[i], errors[i] = thunk() } return items, errors } // LoadAllThunk returns a function that when called will block waiting for a Items. // This method should be used if you want one goroutine to make requests to many // different data loaders without blocking until the thunk is called. func (l *ItemSliceLoader) LoadAllThunk(keys []int) func() ([][]*Item, []error) { results := make([]func() ([]*Item, error), len(keys)) for i, key := range keys { results[i] = l.LoadThunk(key) } return func() ([][]*Item, []error) { items := make([][]*Item, len(keys)) errors := make([]error, len(keys)) for i, thunk := range results { items[i], errors[i] = thunk() } return items, errors } } // Prime the cache with the provided key and value. If the key already exists, no change is made // and false is returned. // (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).) func (l *ItemSliceLoader) Prime(key int, value []*Item) bool { l.mu.Lock() var found bool if _, found = l.cache[key]; !found { // make a copy when writing to the cache, its easy to pass a pointer in from a loop var // and end up with the whole cache pointing to the same value. cpy := make([]*Item, len(value)) copy(cpy, value) l.unsafeSet(key, cpy) } l.mu.Unlock() return !found } // Clear the value at key from the cache, if it exists func (l *ItemSliceLoader) Clear(key int) { l.mu.Lock() delete(l.cache, key) l.mu.Unlock() } func (l *ItemSliceLoader) unsafeSet(key int, value []*Item) { if l.cache == nil { l.cache = map[int][]*Item{} } l.cache[key] = value } // keyIndex will return the location of the key in the batch, if its not found // it will add the key to the batch func (b *itemSliceLoaderBatch) keyIndex(l *ItemSliceLoader, key int) int { for i, existingKey := range b.keys { if key == existingKey { return i } } pos := len(b.keys) b.keys = append(b.keys, key) if pos == 0 { go b.startTimer(l) } if l.maxBatch != 0 && pos >= l.maxBatch-1 { if !b.closing { b.closing = true l.batch = nil go b.end(l) } } return pos } func (b *itemSliceLoaderBatch) startTimer(l *ItemSliceLoader) { time.Sleep(l.wait) l.mu.Lock() // we must have hit a batch limit and are already finalizing this batch if b.closing { l.mu.Unlock() return } l.batch = nil l.mu.Unlock() b.end(l) } func (b *itemSliceLoaderBatch) end(l *ItemSliceLoader) { b.data, b.error = l.fetch(b.keys) close(b.done) } ================================================ FILE: _examples/dataloader/models_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package dataloader type Address struct { ID int `json:"id"` Street string `json:"street"` Country string `json:"country"` } type Item struct { Name string `json:"name"` } type Query struct { } ================================================ FILE: _examples/dataloader/ordersliceloader_gen.go ================================================ // Code generated by github.com/vektah/dataloaden, DO NOT EDIT. package dataloader import ( "sync" "time" ) // OrderSliceLoaderConfig captures the config to create a new OrderSliceLoader type OrderSliceLoaderConfig struct { // Fetch is a method that provides the data for the loader Fetch func(keys []int) ([][]*Order, []error) // Wait is how long wait before sending a batch Wait time.Duration // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit MaxBatch int } // NewOrderSliceLoader creates a new OrderSliceLoader given a fetch, wait, and maxBatch func NewOrderSliceLoader(config OrderSliceLoaderConfig) *OrderSliceLoader { return &OrderSliceLoader{ fetch: config.Fetch, wait: config.Wait, maxBatch: config.MaxBatch, } } // OrderSliceLoader batches and caches requests type OrderSliceLoader struct { // this method provides the data for the loader fetch func(keys []int) ([][]*Order, []error) // how long to done before sending a batch wait time.Duration // this will limit the maximum number of keys to send in one batch, 0 = no limit maxBatch int // INTERNAL // lazily created cache cache map[int][]*Order // the current batch. keys will continue to be collected until timeout is hit, // then everything will be sent to the fetch method and out to the listeners batch *orderSliceLoaderBatch // mutex to prevent races mu sync.Mutex } type orderSliceLoaderBatch struct { keys []int data [][]*Order error []error closing bool done chan struct{} } // Load a Order by key, batching and caching will be applied automatically func (l *OrderSliceLoader) Load(key int) ([]*Order, error) { return l.LoadThunk(key)() } // LoadThunk returns a function that when called will block waiting for a Order. // This method should be used if you want one goroutine to make requests to many // different data loaders without blocking until the thunk is called. func (l *OrderSliceLoader) LoadThunk(key int) func() ([]*Order, error) { l.mu.Lock() if it, ok := l.cache[key]; ok { l.mu.Unlock() return func() ([]*Order, error) { return it, nil } } if l.batch == nil { l.batch = &orderSliceLoaderBatch{done: make(chan struct{})} } batch := l.batch pos := batch.keyIndex(l, key) l.mu.Unlock() return func() ([]*Order, error) { <-batch.done var data []*Order if pos < len(batch.data) { data = batch.data[pos] } var err error // its convenient to be able to return a single error for everything if len(batch.error) == 1 { err = batch.error[0] } else if batch.error != nil { err = batch.error[pos] } if err == nil { l.mu.Lock() l.unsafeSet(key, data) l.mu.Unlock() } return data, err } } // LoadAll fetches many keys at once. It will be broken into appropriate sized // sub batches depending on how the loader is configured func (l *OrderSliceLoader) LoadAll(keys []int) ([][]*Order, []error) { results := make([]func() ([]*Order, error), len(keys)) for i, key := range keys { results[i] = l.LoadThunk(key) } orders := make([][]*Order, len(keys)) errors := make([]error, len(keys)) for i, thunk := range results { orders[i], errors[i] = thunk() } return orders, errors } // LoadAllThunk returns a function that when called will block waiting for a Orders. // This method should be used if you want one goroutine to make requests to many // different data loaders without blocking until the thunk is called. func (l *OrderSliceLoader) LoadAllThunk(keys []int) func() ([][]*Order, []error) { results := make([]func() ([]*Order, error), len(keys)) for i, key := range keys { results[i] = l.LoadThunk(key) } return func() ([][]*Order, []error) { orders := make([][]*Order, len(keys)) errors := make([]error, len(keys)) for i, thunk := range results { orders[i], errors[i] = thunk() } return orders, errors } } // Prime the cache with the provided key and value. If the key already exists, no change is made // and false is returned. // (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).) func (l *OrderSliceLoader) Prime(key int, value []*Order) bool { l.mu.Lock() var found bool if _, found = l.cache[key]; !found { // make a copy when writing to the cache, its easy to pass a pointer in from a loop var // and end up with the whole cache pointing to the same value. cpy := make([]*Order, len(value)) copy(cpy, value) l.unsafeSet(key, cpy) } l.mu.Unlock() return !found } // Clear the value at key from the cache, if it exists func (l *OrderSliceLoader) Clear(key int) { l.mu.Lock() delete(l.cache, key) l.mu.Unlock() } func (l *OrderSliceLoader) unsafeSet(key int, value []*Order) { if l.cache == nil { l.cache = map[int][]*Order{} } l.cache[key] = value } // keyIndex will return the location of the key in the batch, if its not found // it will add the key to the batch func (b *orderSliceLoaderBatch) keyIndex(l *OrderSliceLoader, key int) int { for i, existingKey := range b.keys { if key == existingKey { return i } } pos := len(b.keys) b.keys = append(b.keys, key) if pos == 0 { go b.startTimer(l) } if l.maxBatch != 0 && pos >= l.maxBatch-1 { if !b.closing { b.closing = true l.batch = nil go b.end(l) } } return pos } func (b *orderSliceLoaderBatch) startTimer(l *OrderSliceLoader) { time.Sleep(l.wait) l.mu.Lock() // we must have hit a batch limit and are already finalizing this batch if b.closing { l.mu.Unlock() return } l.batch = nil l.mu.Unlock() b.end(l) } func (b *orderSliceLoaderBatch) end(l *OrderSliceLoader) { b.data, b.error = l.fetch(b.keys) close(b.done) } ================================================ FILE: _examples/dataloader/readme.md ================================================ ### dataloader This example uses [dataloaden](https://github.com/vektah/dataloaden) to avoiding n+1 queries. There is also [nicksrandall/dataloader](https://github.com/nicksrandall/dataloader) if you wanted to avoid doing more codegeneration. ================================================ FILE: _examples/dataloader/resolvers.go ================================================ //go:generate go run ../../testdata/gqlgen.go package dataloader import ( "context" "fmt" "math/rand" "strconv" "time" ) type Customer struct { ID int `json:"id"` Name string `json:"name"` AddressID int } type Order struct { ID int `json:"id"` Date time.Time `json:"date"` Amount float64 `json:"amount"` } type Resolver struct{} func (r *Resolver) Customer() CustomerResolver { return &customerResolver{r} } func (r *Resolver) Order() OrderResolver { return &orderResolver{r} } func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } type customerResolver struct{ *Resolver } func (r *customerResolver) Address(ctx context.Context, obj *Customer) (*Address, error) { return ctxLoaders(ctx).addressByID.Load(obj.AddressID) } func (r *customerResolver) Orders(ctx context.Context, obj *Customer) ([]*Order, error) { return ctxLoaders(ctx).ordersByCustomer.Load(obj.ID) } type orderResolver struct{ *Resolver } func (r *orderResolver) Items(ctx context.Context, obj *Order) ([]*Item, error) { return ctxLoaders(ctx).itemsByOrder.Load(obj.ID) } type queryResolver struct{ *Resolver } func (r *queryResolver) Customers(ctx context.Context) ([]*Customer, error) { fmt.Println("SELECT * FROM customer") time.Sleep(5 * time.Millisecond) return []*Customer{ {ID: 1, Name: "Bob", AddressID: 1}, {ID: 2, Name: "Alice", AddressID: 3}, {ID: 3, Name: "Eve", AddressID: 4}, }, nil } // this method is here to test code generation of nested arrays // //nolint:gosec func (r *queryResolver) Torture1d(ctx context.Context, customerIds []int) ([]*Customer, error) { result := make([]*Customer, len(customerIds)) for i, id := range customerIds { result[i] = &Customer{ID: id, Name: strconv.Itoa(i), AddressID: rand.Int() % 10} } return result, nil } // this method is here to test code generation of nested arrays // //nolint:gosec func (r *queryResolver) Torture2d(ctx context.Context, customerIds [][]int) ([][]*Customer, error) { result := make([][]*Customer, len(customerIds)) for i := range customerIds { inner := make([]*Customer, len(customerIds[i])) for j := range customerIds[i] { inner[j] = &Customer{ ID: customerIds[i][j], Name: fmt.Sprintf("%d %d", i, j), AddressID: rand.Int() % 10, } } result[i] = inner } return result, nil } ================================================ FILE: _examples/dataloader/schema.graphql ================================================ type Query { customers: [Customer!] # these methods are here to test code generation of nested arrays torture1d(customerIds: [Int!]): [Customer!] torture2d(customerIds: [[Int!]]): [[Customer!]] } type Customer { id: Int! name: String! address: Address orders: [Order!] } type Address { id: Int! street: String! country: String! } type Order { id: Int! date: Time! amount: Float! items: [Item!] } type Item { name: String! } scalar Time ================================================ FILE: _examples/dataloader/server/server.go ================================================ package main import ( "log" "net/http" "github.com/99designs/gqlgen/_examples/dataloader" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/playground" ) func main() { router := http.NewServeMux() srv := handler.New( dataloader.NewExecutableSchema(dataloader.Config{Resolvers: &dataloader.Resolver{}}), ) srv.AddTransport(transport.GET{}) srv.AddTransport(transport.POST{}) router.Handle("/", playground.Handler("Dataloader", "/query")) router.Handle("/query", srv) log.Println("connect to http://localhost:8082/ for graphql playground") log.Fatal(http.ListenAndServe(":8082", dataloader.LoaderMiddleware(router))) } ================================================ FILE: _examples/deferexample/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package deferexample 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{ schema: cfg.Schema, resolvers: cfg.Resolvers, directives: cfg.Directives, complexity: cfg.Complexity, } } type Config struct { Schema *ast.Schema Resolvers ResolverRoot Directives DirectiveRoot Complexity ComplexityRoot } type ResolverRoot interface { Mutation() MutationResolver Query() QueryResolver Todo() TodoResolver } type DirectiveRoot struct { } type ComplexityRoot struct { Mutation struct { CreateTodo func(childComplexity int, input NewTodo) int } Query struct { Todos func(childComplexity int) int } Todo struct { Done func(childComplexity int) int ID func(childComplexity int) int Text func(childComplexity int) int User func(childComplexity int) int } User struct { ID func(childComplexity int) int Name func(childComplexity int) int } } type MutationResolver interface { CreateTodo(ctx context.Context, input NewTodo) (*Todo, error) } type QueryResolver interface { Todos(ctx context.Context) ([]*Todo, error) } type TodoResolver interface { User(ctx context.Context, obj *Todo) (*User, error) } type executableSchema struct { schema *ast.Schema resolvers ResolverRoot directives DirectiveRoot complexity ComplexityRoot } func (e *executableSchema) Schema() *ast.Schema { if e.schema != nil { return e.schema } return parsedSchema } func (e *executableSchema) Complexity(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 "Mutation.createTodo": if e.complexity.Mutation.CreateTodo == nil { break } args, err := ec.field_Mutation_createTodo_args(ctx, rawArgs) if err != nil { return 0, false } return e.complexity.Mutation.CreateTodo(childComplexity, args["input"].(NewTodo)), true case "Query.todos": if e.complexity.Query.Todos == nil { break } return e.complexity.Query.Todos(childComplexity), true case "Todo.done": if e.complexity.Todo.Done == nil { break } return e.complexity.Todo.Done(childComplexity), true case "Todo.id": if e.complexity.Todo.ID == nil { break } return e.complexity.Todo.ID(childComplexity), true case "Todo.text": if e.complexity.Todo.Text == nil { break } return e.complexity.Todo.Text(childComplexity), true case "Todo.user": if e.complexity.Todo.User == nil { break } return e.complexity.Todo.User(childComplexity), true case "User.id": if e.complexity.User.ID == nil { break } return e.complexity.User.ID(childComplexity), true case "User.name": if e.complexity.User.Name == nil { break } return e.complexity.User.Name(childComplexity), true } return 0, false } func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { opCtx := graphql.GetOperationContext(ctx) ec := executionContext{opCtx, e, 0, 0, make(chan graphql.DeferredResult)} inputUnmarshalMap := graphql.BuildUnmarshalerMap( ec.unmarshalInputNewTodo, ) 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(), } } default: return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) } } type executionContext struct { *graphql.OperationContext *executableSchema deferred int32 pendingDeferred int32 deferredResults chan graphql.DeferredResult } func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { atomic.AddInt32(&ec.pendingDeferred, 1) go func() { ctx := graphql.WithFreshResponseContext(dg.Context) dg.FieldSet.Dispatch(ctx) ds := graphql.DeferredResult{ Path: dg.Path, Label: dg.Label, Result: dg.FieldSet, Errors: graphql.GetErrors(ctx), } // null fields should bubble up if dg.FieldSet.Invalids > 0 { ds.Result = graphql.Null } ec.deferredResults <- ds }() } func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } return introspection.WrapSchema(ec.Schema()), nil } func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil } //go:embed "schema.graphql" var sourcesFS embed.FS func sourceData(filename string) string { data, err := sourcesFS.ReadFile(filename) if err != nil { panic(fmt.Sprintf("codegen problem: %s not available", filename)) } return string(data) } var sources = []*ast.Source{ {Name: "schema.graphql", Input: sourceData("schema.graphql"), BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) field_Mutation_createTodo_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Mutation_createTodo_argsInput(ctx, rawArgs) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Mutation_createTodo_argsInput( ctx context.Context, rawArgs map[string]any, ) (NewTodo, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) if tmp, ok := rawArgs["input"]; ok { return ec.unmarshalNNewTodo2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdeferexampleᚐNewTodo(ctx, tmp) } var zeroVal NewTodo return zeroVal, 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 := ec.field_Query___type_argsName(ctx, rawArgs) if err != nil { return nil, err } args["name"] = arg0 return args, nil } func (ec *executionContext) field_Query___type_argsName( ctx context.Context, rawArgs map[string]any, ) (string, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) if tmp, ok := rawArgs["name"]; ok { return ec.unmarshalNString2string(ctx, tmp) } var zeroVal string return zeroVal, 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 := ec.field___Directive_args_argsIncludeDeprecated(ctx, rawArgs) if err != nil { return nil, err } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Directive_args_argsIncludeDeprecated( ctx context.Context, rawArgs map[string]any, ) (*bool, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) if tmp, ok := rawArgs["includeDeprecated"]; ok { return ec.unmarshalOBoolean2ᚖbool(ctx, tmp) } var zeroVal *bool return zeroVal, 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 := ec.field___Field_args_argsIncludeDeprecated(ctx, rawArgs) if err != nil { return nil, err } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Field_args_argsIncludeDeprecated( ctx context.Context, rawArgs map[string]any, ) (*bool, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) if tmp, ok := rawArgs["includeDeprecated"]; ok { return ec.unmarshalOBoolean2ᚖbool(ctx, tmp) } var zeroVal *bool return zeroVal, 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 := ec.field___Type_enumValues_argsIncludeDeprecated(ctx, rawArgs) if err != nil { return nil, err } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Type_enumValues_argsIncludeDeprecated( ctx context.Context, rawArgs map[string]any, ) (bool, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) if tmp, ok := rawArgs["includeDeprecated"]; ok { return ec.unmarshalOBoolean2bool(ctx, tmp) } var zeroVal bool return zeroVal, 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 := ec.field___Type_fields_argsIncludeDeprecated(ctx, rawArgs) if err != nil { return nil, err } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Type_fields_argsIncludeDeprecated( ctx context.Context, rawArgs map[string]any, ) (bool, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) if tmp, ok := rawArgs["includeDeprecated"]; ok { return ec.unmarshalOBoolean2bool(ctx, tmp) } var zeroVal bool return zeroVal, nil } // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _Mutation_createTodo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Mutation_createTodo(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Mutation().CreateTodo(rctx, fc.Args["input"].(NewTodo)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*Todo) fc.Result = res return ec.marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdeferexampleᚐTodo(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Mutation_createTodo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Todo_id(ctx, field) case "text": return ec.fieldContext_Todo_text(ctx, field) case "done": return ec.fieldContext_Todo_done(ctx, field) case "user": return ec.fieldContext_Todo_user(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_createTodo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Query_todos(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Todos(rctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]*Todo) fc.Result = res return ec.marshalNTodo2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdeferexampleᚐTodoᚄ(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Query_todos(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Todo_id(ctx, field) case "text": return ec.fieldContext_Todo_text(ctx, field) case "done": return ec.fieldContext_Todo_done(ctx, field) case "user": return ec.fieldContext_Todo_user(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) }, } return fc, nil } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Query___type(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (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 "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) { 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "description": return ec.fieldContext___Schema_description(ctx, field) case "types": return ec.fieldContext___Schema_types(ctx, field) case "queryType": return ec.fieldContext___Schema_queryType(ctx, field) case "mutationType": return ec.fieldContext___Schema_mutationType(ctx, field) case "subscriptionType": return ec.fieldContext___Schema_subscriptionType(ctx, field) case "directives": return ec.fieldContext___Schema_directives(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) }, } return fc, nil } func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Todo_id(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (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_Todo_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Todo_text(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return obj.Text, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_text(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Todo_done(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return obj.Done, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_done(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Todo_user(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Todo().User(rctx, obj) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*User) fc.Result = res return ec.marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdeferexampleᚐUser(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_user(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_User_id(ctx, field) case "name": return ec.fieldContext_User_name(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *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(_ 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(_ 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(_ 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(_ 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) { 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(_ 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) { 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(_ 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) 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) { 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(_ 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(_ 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(_ 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(_ 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(_ 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(_ 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) 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) { 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(_ 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) { 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(_ 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(_ 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(_ 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(_ 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(_ 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) { 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(_ 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) { fc, err := ec.fieldContext___InputValue_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___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) { fc, err := ec.fieldContext___InputValue_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___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) { 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(_ 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(_ 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) { 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(_ 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) { 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(_ 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) { 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(_ 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) { 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(_ 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) { 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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) { 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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 fc, err } return fc, nil } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { fc, err := ec.fieldContext___Type_interfaces(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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) { 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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) { 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 fc, err } return fc, nil } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { fc, err := ec.fieldContext___Type_inputFields(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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) { 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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) { fc, err := ec.fieldContext___Type_isOneOf(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { 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.IsOneOf(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(bool) fc.Result = res return ec.marshalOBoolean2bool(ctx, field.Selections, res) } 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) unmarshalInputNewTodo(ctx context.Context, obj any) (NewTodo, error) { var it NewTodo asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"text", "userId"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "text": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Text = data case "userId": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userId")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.UserID = data } } return it, nil } // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var mutationImplementors = []string{"Mutation"} func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Mutation", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Mutation") case "createTodo": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_createTodo(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.deferred, int32(len(deferred))) for label, dfs := range deferred { ec.processDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "todos": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_todos(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) case "__schema": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.deferred, int32(len(deferred))) for label, dfs := range deferred { ec.processDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var todoImplementors = []string{"Todo"} func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, todoImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Todo") case "id": out.Values[i] = ec._Todo_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "text": out.Values[i] = ec._Todo_text(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "done": out.Values[i] = ec._Todo_done(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "user": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Todo_user(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 userImplementors = []string{"User"} func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *User) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("User") case "id": out.Values[i] = ec._User_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "name": out.Values[i] = ec._User_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.deferred, int32(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 { 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) unmarshalNNewTodo2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdeferexampleᚐNewTodo(ctx context.Context, v any) (NewTodo, error) { res, err := ec.unmarshalInputNewTodo(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } 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) marshalNTodo2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdeferexampleᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { return ec._Todo(ctx, sel, &v) } func (ec *executionContext) marshalNTodo2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdeferexampleᚐTodoᚄ(ctx context.Context, sel ast.SelectionSet, v []*Todo) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 if !isLen1 { wg.Add(len(v)) } for i := range v { i := i fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = nil } }() if !isLen1 { defer wg.Done() } ret[i] = ec.marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdeferexampleᚐTodo(ctx, sel, v[i]) } if isLen1 { f(i) } else { go f(i) } } wg.Wait() for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdeferexampleᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._Todo(ctx, sel, v) } func (ec *executionContext) marshalNUser2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdeferexampleᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler { return ec._User(ctx, sel, &v) } func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋdeferexampleᚐUser(ctx context.Context, sel ast.SelectionSet, v *User) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._User(ctx, sel, v) } func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ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 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) 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: _examples/deferexample/gqlgen.yml ================================================ schema: "*.graphql" exec: filename: generated.go model: filename: models_gen.go resolver: layout: follow-schema dir: . filename_template: "{name}.resolvers.go" call_argument_directives_with_null: true models: ID: model: - github.com/99designs/gqlgen/graphql.ID Todo: fields: user: resolver: true extraFields: userID: type: "string" ================================================ FILE: _examples/deferexample/models_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package deferexample type Mutation struct { } type NewTodo struct { Text string `json:"text"` UserID string `json:"userId"` } type Query struct { } type Todo struct { ID string `json:"id"` Text string `json:"text"` Done bool `json:"done"` User *User `json:"user"` userID string `json:"-"` } type User struct { ID string `json:"id"` Name string `json:"name"` } ================================================ FILE: _examples/deferexample/resolver.go ================================================ package deferexample import "sync" type Resolver struct { mu sync.RWMutex todos []*Todo } ================================================ FILE: _examples/deferexample/schema.graphql ================================================ # 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: _examples/deferexample/schema.resolvers.go ================================================ package deferexample // 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.70-dev import ( "context" "crypto/rand" "fmt" "math/big" "time" ) // CreateTodo is the resolver for the createTodo field. func (r *mutationResolver) CreateTodo(ctx context.Context, input NewTodo) (*Todo, error) { randNumber, _ := rand.Int(rand.Reader, big.NewInt(100)) todo := &Todo{ Text: input.Text, ID: fmt.Sprintf("T%d", randNumber), userID: input.UserID, } r.mu.Lock() r.todos = append(r.todos, todo) r.mu.Unlock() return todo, nil } // Todos is the resolver for the todos field. func (r *queryResolver) Todos(ctx context.Context) ([]*Todo, error) { r.mu.RLock() defer r.mu.RUnlock() return r.todos, nil } // User is the resolver for the user field on Todos. Having this // separate resolver makes the field "deferrable," ie GQLGen will handle // an operation with an @defer directive applied to the given field as a // separately-delivered response, and depending on the logic applied in // the transport can deliver them in the same response or serially. func (r *todoResolver) User(ctx context.Context, t *Todo) (*User, error) { time.Sleep(time.Millisecond * 10) return &User{ ID: t.userID, Name: fmt.Sprintf("User %v", t.userID), }, nil } // Mutation returns MutationResolver implementation. func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } // Query returns QueryResolver implementation. func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } // Todo returns TodoResolver implementation. func (r *Resolver) Todo() TodoResolver { return &todoResolver{r} } type ( mutationResolver struct{ *Resolver } queryResolver struct{ *Resolver } todoResolver struct{ *Resolver } ) ================================================ FILE: _examples/deferexample/server/server.go ================================================ package main import ( "log" "net/http" "os" "time" "github.com/gorilla/websocket" "github.com/rs/cors" "github.com/99designs/gqlgen/_examples/deferexample" "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" ) const defaultPort = "8080" func main() { port := os.Getenv("PORT") if port == "" { port = defaultPort } c := cors.New(cors.Options{ AllowedOrigins: []string{"*"}, AllowCredentials: true, Debug: false, }) srv := handler.New( deferexample.NewExecutableSchema( deferexample.Config{Resolvers: &deferexample.Resolver{}}, ), ) srv.AddTransport(transport.SSE{}) srv.AddTransport(transport.MultipartMixed{ Boundary: "graphql", DeliveryTimeout: time.Millisecond * 10, }) 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.Printf("connect to http://localhost:%s/ for GraphQL playground", port) log.Fatal(http.ListenAndServe(":"+port, nil)) } ================================================ FILE: _examples/embedding/parent.graphqls ================================================ extend type Query { parentdir: String! } ================================================ FILE: _examples/embedding/subdir/cfgdir/generate_in_gendir.yml ================================================ schema: - schemadir/*.graphqls - ../*.graphqls - '*.graphqls' exec: dir: gendir filename: gendir/generated.go package: gendir federation: filename: gendir/federation_gen.go package: gendir model: filename: gendir/model.go package: gendir ================================================ FILE: _examples/embedding/subdir/cfgdir/generate_in_subdir.yml ================================================ schema: - schemadir/*.graphqls - ../*.graphqls - '*.graphqls' exec: layout: follow-schema dir: . package: subdir federation: filename: federation_gen.go package: subdir model: filename: model.go package: subdir ================================================ FILE: _examples/embedding/subdir/directives.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package subdir import ( "context" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) 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 } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: _examples/embedding/subdir/embedding_test.go ================================================ package subdir import ( "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/_examples/embedding/subdir/gendir" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestEmbeddingWorks(t *testing.T) { srv := handler.New(NewExecutableSchema(Config{Resolvers: &Resolver{}})) srv.AddTransport(transport.POST{}) c := client.New(srv) var resp struct { InSchemadir string Parentdir string Subdir string } c.MustPost(`{ inSchemadir parentdir subdir } `, &resp) require.Equal(t, "example", resp.InSchemadir) require.Equal(t, "example", resp.Parentdir) require.Equal(t, "example", resp.Subdir) } func TestEmbeddingWorksInGendir(t *testing.T) { srv := handler.New(gendir.NewExecutableSchema(gendir.Config{Resolvers: &GendirResolver{}})) srv.AddTransport(transport.POST{}) c := client.New(srv) var resp struct { InSchemadir string Parentdir string Subdir string } c.MustPost(`{ inSchemadir parentdir subdir } `, &resp) require.Equal(t, "example", resp.InSchemadir) require.Equal(t, "example", resp.Parentdir) require.Equal(t, "example", resp.Subdir) } ================================================ FILE: _examples/embedding/subdir/entity.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package subdir import ( "context" "errors" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/plugin/federation/fedruntime" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) __Service_sdl(ctx context.Context, field graphql.CollectedField, obj *fedruntime.Service) (ret graphql.Marshaler) { 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 } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var _ServiceImplementors = []string{"_Service"} func (ec *executionContext) __Service(ctx context.Context, sel ast.SelectionSet, obj *fedruntime.Service) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, _ServiceImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("_Service") case "sdl": out.Values[i] = ec.__Service_sdl(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshalN_Service2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx context.Context, sel ast.SelectionSet, v fedruntime.Service) graphql.Marshaler { return ec.__Service(ctx, sel, &v) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: _examples/embedding/subdir/federation_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package subdir 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: _examples/embedding/subdir/gendir/federation_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package gendir 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: _examples/embedding/subdir/gendir/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package gendir 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 { Query() QueryResolver } type DirectiveRoot struct { } type ComplexityRoot struct { Query struct { InSchemadir func(childComplexity int) int Parentdir func(childComplexity int) int Subdir func(childComplexity int) int __resolve__service func(childComplexity int) int } _Service struct { SDL func(childComplexity int) int } } type QueryResolver interface { InSchemadir(ctx context.Context) (string, error) Parentdir(ctx context.Context) (string, error) Subdir(ctx context.Context) (string, error) } type executableSchema 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 "Query.inSchemadir": if e.ComplexityRoot.Query.InSchemadir == nil { break } return e.ComplexityRoot.Query.InSchemadir(childComplexity), true case "Query.parentdir": if e.ComplexityRoot.Query.Parentdir == nil { break } return e.ComplexityRoot.Query.Parentdir(childComplexity), true case "Query.subdir": if e.ComplexityRoot.Query.Subdir == nil { break } return e.ComplexityRoot.Query.Subdir(childComplexity), true case "Query._service": if e.ComplexityRoot.Query.__resolve__service == nil { break } return e.ComplexityRoot.Query.__resolve__service(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: "../schemadir/root.graphqls", Input: `type Query { inSchemadir: String! } `, BuiltIn: false}, {Name: "../../parent.graphqls", Input: `extend type Query { parentdir: String! } `, BuiltIn: false}, {Name: "../subdir.graphqls", Input: `extend type Query { subdir: String! } `, BuiltIn: false}, {Name: "../federation/directives.graphql", Input: ` directive @key(fields: _FieldSet!) repeatable on OBJECT | INTERFACE directive @requires(fields: _FieldSet!) on FIELD_DEFINITION directive @provides(fields: _FieldSet!) on FIELD_DEFINITION directive @extends on OBJECT | INTERFACE directive @external on FIELD_DEFINITION scalar _Any scalar _FieldSet `, BuiltIn: true}, {Name: "../federation/entity.graphql", Input: ` type _Service { sdl: String } extend type Query { _service: _Service! } `, BuiltIn: true}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]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_inSchemadir(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_inSchemadir, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().InSchemadir(ctx) }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Query_inSchemadir(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_parentdir(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_parentdir, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Parentdir(ctx) }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Query_parentdir(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_subdir(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_subdir, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Subdir(ctx) }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Query_subdir(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query__service(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 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 "inSchemadir": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_inSchemadir(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "parentdir": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_parentdir(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "subdir": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_subdir(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "_service": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query__service(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) case "__schema": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var _ServiceImplementors = []string{"_Service"} func (ec *executionContext) __Service(ctx context.Context, sel ast.SelectionSet, obj *fedruntime.Service) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, _ServiceImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("_Service") case "sdl": out.Values[i] = ec.__Service_sdl(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": out.Values[i] = ec.___Directive_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "description": out.Values[i] = ec.___Directive_description(ctx, field, obj) case "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 := 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) 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 := 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/embedding/subdir/gendir/model.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package gendir type Query struct { } ================================================ FILE: _examples/embedding/subdir/model.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package subdir type Query struct { } ================================================ FILE: _examples/embedding/subdir/prelude.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package subdir import ( "context" "errors" "fmt" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) dir_defer_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, "if", ec.unmarshalOBoolean2ᚖbool) if err != nil { return nil, err } args["if"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "label", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["label"] = arg1 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) ___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 __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) 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) 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 := 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/embedding/subdir/resolvers.go ================================================ //go:generate go run ../../../testdata/gqlgen.go -config cfgdir/generate_in_subdir.yml //go:generate go run ../../../testdata/gqlgen.go -config cfgdir/generate_in_gendir.yml package subdir import ( "context" "github.com/99designs/gqlgen/_examples/embedding/subdir/gendir" ) type Resolver struct{ *Resolver } func (q *Resolver) Query() QueryResolver { return q } func (q *Resolver) InSchemadir(ctx context.Context) (string, error) { return "example", nil } func (q *Resolver) Parentdir(ctx context.Context) (string, error) { return "example", nil } func (q *Resolver) Subdir(ctx context.Context) (string, error) { return "example", nil } type GendirResolver struct{ *Resolver } func (q *GendirResolver) Query() gendir.QueryResolver { return &Resolver{} } ================================================ FILE: _examples/embedding/subdir/root.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package subdir import ( "context" "errors" "fmt" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** type QueryResolver interface { InSchemadir(ctx context.Context) (string, error) Parentdir(ctx context.Context) (string, error) Subdir(ctx context.Context) (string, error) } // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]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 } // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _Query_inSchemadir(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_inSchemadir, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().InSchemadir(ctx) }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Query_inSchemadir(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_parentdir(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_parentdir, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Parentdir(ctx) }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Query_parentdir(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_subdir(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_subdir, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Subdir(ctx) }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Query_subdir(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query__service(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 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 } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "inSchemadir": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_inSchemadir(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "parentdir": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_parentdir(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "subdir": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_subdir(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "_service": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query__service(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) case "__schema": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** // endregion ***************************** type.gotpl ***************************** ================================================ FILE: _examples/embedding/subdir/root_.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package subdir import ( "bytes" "context" "embed" "fmt" "sync/atomic" "github.com/99designs/gqlgen/graphql" gqlparser "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" ) // NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { return &executableSchema{SchemaData: cfg.Schema, Resolvers: cfg.Resolvers, Directives: cfg.Directives, ComplexityRoot: cfg.Complexity} } type Config = graphql.Config[ResolverRoot, DirectiveRoot, ComplexityRoot] type ResolverRoot interface { Query() QueryResolver } type DirectiveRoot struct { } type ComplexityRoot struct { Query struct { InSchemadir func(childComplexity int) int Parentdir func(childComplexity int) int Subdir func(childComplexity int) int __resolve__service func(childComplexity int) int } _Service struct { SDL func(childComplexity int) int } } type executableSchema 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 "Query.inSchemadir": if e.ComplexityRoot.Query.InSchemadir == nil { break } return e.ComplexityRoot.Query.InSchemadir(childComplexity), true case "Query.parentdir": if e.ComplexityRoot.Query.Parentdir == nil { break } return e.ComplexityRoot.Query.Parentdir(childComplexity), true case "Query.subdir": if e.ComplexityRoot.Query.Subdir == nil { break } return e.ComplexityRoot.Query.Subdir(childComplexity), true case "Query._service": if e.ComplexityRoot.Query.__resolve__service == nil { break } return e.ComplexityRoot.Query.__resolve__service(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, ), } } //go:embed "schemadir/root.graphqls" "subdir.graphqls" var sourcesFS embed.FS func sourceData(filename string) string { data, err := sourcesFS.ReadFile(filename) if err != nil { panic(fmt.Sprintf("codegen problem: %s not available", filename)) } return string(data) } var sources = []*ast.Source{ {Name: "schemadir/root.graphqls", Input: sourceData("schemadir/root.graphqls"), BuiltIn: false}, {Name: "../parent.graphqls", Input: `extend type Query { parentdir: String! } `, BuiltIn: false}, {Name: "subdir.graphqls", Input: sourceData("subdir.graphqls"), BuiltIn: false}, {Name: "federation/directives.graphql", Input: ` directive @key(fields: _FieldSet!) repeatable on OBJECT | INTERFACE directive @requires(fields: _FieldSet!) on FIELD_DEFINITION directive @provides(fields: _FieldSet!) on FIELD_DEFINITION directive @extends on OBJECT | INTERFACE directive @external on FIELD_DEFINITION scalar _Any scalar _FieldSet `, BuiltIn: true}, {Name: "federation/entity.graphql", Input: ` type _Service { sdl: String } extend type Query { _service: _Service! } `, BuiltIn: true}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) ================================================ FILE: _examples/embedding/subdir/schemadir/root.graphqls ================================================ type Query { inSchemadir: String! } ================================================ FILE: _examples/embedding/subdir/subdir.graphqls ================================================ extend type Query { subdir: String! } ================================================ FILE: _examples/enum/api/enum.go ================================================ package api // 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" "github.com/99designs/gqlgen/_examples/enum/model" ) // IntTyped is the resolver for the intTyped field. func (r *queryResolver) IntTyped(ctx context.Context, arg model.IntTyped) (model.IntTyped, error) { return arg, nil } // IntUntyped is the resolver for the intUntyped field. func (r *queryResolver) IntUntyped(ctx context.Context, arg int) (int, error) { return arg, nil } // IntTypedN is the resolver for the intTypedN field. func (r *queryResolver) IntTypedN(ctx context.Context, arg *model.IntTyped) (*model.IntTyped, error) { return arg, nil } // IntUntypedN is the resolver for the intUntypedN field. func (r *queryResolver) IntUntypedN(ctx context.Context, arg *int) (*int, error) { return arg, nil } // StringTyped is the resolver for the stringTyped field. func (r *queryResolver) StringTyped(ctx context.Context, arg model.StringTyped) (model.StringTyped, error) { return arg, nil } // StringUntyped is the resolver for the stringUntyped field. func (r *queryResolver) StringUntyped(ctx context.Context, arg string) (string, error) { return arg, nil } // StringTypedN is the resolver for the stringTypedN field. func (r *queryResolver) StringTypedN(ctx context.Context, arg *model.StringTyped) (*model.StringTyped, error) { return arg, nil } // StringUntypedN is the resolver for the stringUntypedN field. func (r *queryResolver) StringUntypedN(ctx context.Context, arg *string) (*string, error) { return arg, nil } // BoolTyped is the resolver for the boolTyped field. func (r *queryResolver) BoolTyped(ctx context.Context, arg model.BoolTyped) (model.BoolTyped, error) { return arg, nil } // BoolUntyped is the resolver for the boolUntyped field. func (r *queryResolver) BoolUntyped(ctx context.Context, arg bool) (bool, error) { return arg, nil } // BoolTypedN is the resolver for the boolTypedN field. func (r *queryResolver) BoolTypedN(ctx context.Context, arg *model.BoolTyped) (*model.BoolTyped, error) { return arg, nil } // BoolUntypedN is the resolver for the boolUntypedN field. func (r *queryResolver) BoolUntypedN(ctx context.Context, arg *bool) (*bool, error) { return arg, nil } // VarTyped is the resolver for the varTyped field. func (r *queryResolver) VarTyped(ctx context.Context, arg model.VarTyped) (model.VarTyped, error) { return arg, nil } // VarUntyped is the resolver for the varUntyped field. func (r *queryResolver) VarUntyped(ctx context.Context, arg bool) (bool, error) { return arg, nil } // InPackage is the resolver for the inPackage field. func (r *queryResolver) InPackage(ctx context.Context, arg InPackage) (InPackage, error) { return arg, nil } // Query returns QueryResolver implementation. func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } type queryResolver struct{ *Resolver } ================================================ FILE: _examples/enum/api/exec.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package api import ( "bytes" "context" "errors" "fmt" "strconv" "sync/atomic" "github.com/99designs/gqlgen/_examples/enum/model" "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 { Query() QueryResolver } type DirectiveRoot struct { } type ComplexityRoot struct { Query struct { BoolTyped func(childComplexity int, arg model.BoolTyped) int BoolTypedN func(childComplexity int, arg *model.BoolTyped) int BoolUntyped func(childComplexity int, arg bool) int BoolUntypedN func(childComplexity int, arg *bool) int InPackage func(childComplexity int, arg InPackage) int IntTyped func(childComplexity int, arg model.IntTyped) int IntTypedN func(childComplexity int, arg *model.IntTyped) int IntUntyped func(childComplexity int, arg int) int IntUntypedN func(childComplexity int, arg *int) int StringTyped func(childComplexity int, arg model.StringTyped) int StringTypedN func(childComplexity int, arg *model.StringTyped) int StringUntyped func(childComplexity int, arg string) int StringUntypedN func(childComplexity int, arg *string) int VarTyped func(childComplexity int, arg model.VarTyped) int VarUntyped func(childComplexity int, arg bool) int } } type QueryResolver interface { IntTyped(ctx context.Context, arg model.IntTyped) (model.IntTyped, error) IntUntyped(ctx context.Context, arg int) (int, error) IntTypedN(ctx context.Context, arg *model.IntTyped) (*model.IntTyped, error) IntUntypedN(ctx context.Context, arg *int) (*int, error) StringTyped(ctx context.Context, arg model.StringTyped) (model.StringTyped, error) StringUntyped(ctx context.Context, arg string) (string, error) StringTypedN(ctx context.Context, arg *model.StringTyped) (*model.StringTyped, error) StringUntypedN(ctx context.Context, arg *string) (*string, error) BoolTyped(ctx context.Context, arg model.BoolTyped) (model.BoolTyped, error) BoolUntyped(ctx context.Context, arg bool) (bool, error) BoolTypedN(ctx context.Context, arg *model.BoolTyped) (*model.BoolTyped, error) BoolUntypedN(ctx context.Context, arg *bool) (*bool, error) VarTyped(ctx context.Context, arg model.VarTyped) (model.VarTyped, error) VarUntyped(ctx context.Context, arg bool) (bool, error) InPackage(ctx context.Context, arg InPackage) (InPackage, 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 "Query.boolTyped": if e.ComplexityRoot.Query.BoolTyped == nil { break } args, err := ec.field_Query_boolTyped_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.BoolTyped(childComplexity, args["arg"].(model.BoolTyped)), true case "Query.boolTypedN": if e.ComplexityRoot.Query.BoolTypedN == nil { break } args, err := ec.field_Query_boolTypedN_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.BoolTypedN(childComplexity, args["arg"].(*model.BoolTyped)), true case "Query.boolUntyped": if e.ComplexityRoot.Query.BoolUntyped == nil { break } args, err := ec.field_Query_boolUntyped_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.BoolUntyped(childComplexity, args["arg"].(bool)), true case "Query.boolUntypedN": if e.ComplexityRoot.Query.BoolUntypedN == nil { break } args, err := ec.field_Query_boolUntypedN_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.BoolUntypedN(childComplexity, args["arg"].(*bool)), true case "Query.inPackage": if e.ComplexityRoot.Query.InPackage == nil { break } args, err := ec.field_Query_inPackage_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.InPackage(childComplexity, args["arg"].(InPackage)), true case "Query.intTyped": if e.ComplexityRoot.Query.IntTyped == nil { break } args, err := ec.field_Query_intTyped_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.IntTyped(childComplexity, args["arg"].(model.IntTyped)), true case "Query.intTypedN": if e.ComplexityRoot.Query.IntTypedN == nil { break } args, err := ec.field_Query_intTypedN_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.IntTypedN(childComplexity, args["arg"].(*model.IntTyped)), true case "Query.intUntyped": if e.ComplexityRoot.Query.IntUntyped == nil { break } args, err := ec.field_Query_intUntyped_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.IntUntyped(childComplexity, args["arg"].(int)), true case "Query.intUntypedN": if e.ComplexityRoot.Query.IntUntypedN == nil { break } args, err := ec.field_Query_intUntypedN_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.IntUntypedN(childComplexity, args["arg"].(*int)), true case "Query.stringTyped": if e.ComplexityRoot.Query.StringTyped == nil { break } args, err := ec.field_Query_stringTyped_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.StringTyped(childComplexity, args["arg"].(model.StringTyped)), true case "Query.stringTypedN": if e.ComplexityRoot.Query.StringTypedN == nil { break } args, err := ec.field_Query_stringTypedN_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.StringTypedN(childComplexity, args["arg"].(*model.StringTyped)), true case "Query.stringUntyped": if e.ComplexityRoot.Query.StringUntyped == nil { break } args, err := ec.field_Query_stringUntyped_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.StringUntyped(childComplexity, args["arg"].(string)), true case "Query.stringUntypedN": if e.ComplexityRoot.Query.StringUntypedN == nil { break } args, err := ec.field_Query_stringUntypedN_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.StringUntypedN(childComplexity, args["arg"].(*string)), true case "Query.varTyped": if e.ComplexityRoot.Query.VarTyped == nil { break } args, err := ec.field_Query_varTyped_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.VarTyped(childComplexity, args["arg"].(model.VarTyped)), true case "Query.varUntyped": if e.ComplexityRoot.Query.VarUntyped == nil { break } args, err := ec.field_Query_varUntyped_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.VarUntyped(childComplexity, args["arg"].(bool)), 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: "../enum.graphqls", Input: `directive @goModel( model: String models: [String!] ) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION directive @goEnum( value: String ) on ENUM_VALUE type Query { intTyped(arg: IntTyped!): IntTyped! intUntyped(arg: IntUntyped!): IntUntyped! intTypedN(arg: IntTyped): IntTyped intUntypedN(arg: IntUntyped): IntUntyped stringTyped(arg: StringTyped!): StringTyped! stringUntyped(arg: StringUntyped!): StringUntyped! stringTypedN(arg: StringTyped): StringTyped stringUntypedN(arg: StringUntyped): StringUntyped boolTyped(arg: BoolTyped!): BoolTyped! boolUntyped(arg: BoolUntyped!): BoolUntyped! boolTypedN(arg: BoolTyped): BoolTyped boolUntypedN(arg: BoolUntyped): BoolUntyped varTyped(arg: VarTyped!): VarTyped! varUntyped(arg: VarUntyped!): VarUntyped! inPackage(arg: InPackage!): InPackage! } enum IntTyped @goModel(model: "github.com/99designs/gqlgen/_examples/enum/model.IntTyped") { ONE @goEnum(value: "github.com/99designs/gqlgen/_examples/enum/model.IntTypedOne") TWO @goEnum(value: "github.com/99designs/gqlgen/_examples/enum/model.IntTypedTwo") } enum IntUntyped @goModel(model: "github.com/99designs/gqlgen/graphql.Int") { ONE @goEnum(value: "github.com/99designs/gqlgen/_examples/enum/model.IntUntypedOne") TWO @goEnum(value: "github.com/99designs/gqlgen/_examples/enum/model.IntUntypedTwo") } enum StringTyped @goModel(model: "github.com/99designs/gqlgen/_examples/enum/model.StringTyped") { ONE @goEnum(value: "github.com/99designs/gqlgen/_examples/enum/model.StringTypedOne") TWO @goEnum(value: "github.com/99designs/gqlgen/_examples/enum/model.StringTypedTwo") } enum StringUntyped @goModel(model: "github.com/99designs/gqlgen/graphql.String") { ONE @goEnum(value: "github.com/99designs/gqlgen/_examples/enum/model.StringUntypedOne") TWO @goEnum(value: "github.com/99designs/gqlgen/_examples/enum/model.StringUntypedTwo") } enum BoolTyped { TRUE FALSE } enum BoolUntyped { TRUE FALSE } enum VarTyped @goModel(model: "github.com/99designs/gqlgen/_examples/enum/model.VarTyped") { TRUE @goEnum(value: "github.com/99designs/gqlgen/_examples/enum/model.VarTypedTrue") FALSE @goEnum(value: "github.com/99designs/gqlgen/_examples/enum/model.VarTypedFalse") } enum VarUntyped @goModel(model: "github.com/99designs/gqlgen/graphql.Boolean") { TRUE @goEnum(value: "github.com/99designs/gqlgen/_examples/enum/model.VarUntypedTrue") FALSE @goEnum(value: "github.com/99designs/gqlgen/_examples/enum/model.VarUntypedFalse") } enum InPackage { TRUE FALSE } `, 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_Query_boolTypedN_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, "arg", ec.unmarshalOBoolTyped2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐBoolTyped) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_boolTyped_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, "arg", ec.unmarshalNBoolTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐBoolTyped) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_boolUntypedN_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, "arg", ec.unmarshalOBoolUntyped2ᚖbool) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_boolUntyped_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, "arg", ec.unmarshalNBoolUntyped2bool) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_inPackage_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, "arg", ec.unmarshalNInPackage2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋapiᚐInPackage) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_intTypedN_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, "arg", ec.unmarshalOIntTyped2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐIntTyped) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_intTyped_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, "arg", ec.unmarshalNIntTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐIntTyped) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_intUntypedN_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, "arg", ec.unmarshalOIntUntyped2ᚖint) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_intUntyped_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, "arg", ec.unmarshalNIntUntyped2int) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_stringTypedN_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, "arg", ec.unmarshalOStringTyped2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐStringTyped) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_stringTyped_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, "arg", ec.unmarshalNStringTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐStringTyped) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_stringUntypedN_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, "arg", ec.unmarshalOStringUntyped2ᚖstring) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_stringUntyped_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, "arg", ec.unmarshalNStringUntyped2string) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_varTyped_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, "arg", ec.unmarshalNVarTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐVarTyped) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_varUntyped_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, "arg", ec.unmarshalNVarUntyped2bool) if err != nil { return nil, err } args["arg"] = 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_intTyped(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_intTyped, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().IntTyped(ctx, fc.Args["arg"].(model.IntTyped)) }, nil, ec.marshalNIntTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐIntTyped, true, true, ) } func (ec *executionContext) fieldContext_Query_intTyped(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 IntTyped 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_intTyped_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_intUntyped(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_intUntyped, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().IntUntyped(ctx, fc.Args["arg"].(int)) }, nil, ec.marshalNIntUntyped2int, true, true, ) } func (ec *executionContext) fieldContext_Query_intUntyped(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 IntUntyped 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_intUntyped_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_intTypedN(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_intTypedN, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().IntTypedN(ctx, fc.Args["arg"].(*model.IntTyped)) }, nil, ec.marshalOIntTyped2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐIntTyped, true, false, ) } func (ec *executionContext) fieldContext_Query_intTypedN(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 IntTyped 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_intTypedN_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_intUntypedN(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_intUntypedN, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().IntUntypedN(ctx, fc.Args["arg"].(*int)) }, nil, ec.marshalOIntUntyped2ᚖint, true, false, ) } func (ec *executionContext) fieldContext_Query_intUntypedN(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 IntUntyped 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_intUntypedN_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_stringTyped(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_stringTyped, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().StringTyped(ctx, fc.Args["arg"].(model.StringTyped)) }, nil, ec.marshalNStringTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐStringTyped, true, true, ) } func (ec *executionContext) fieldContext_Query_stringTyped(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 StringTyped 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_stringTyped_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_stringUntyped(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_stringUntyped, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().StringUntyped(ctx, fc.Args["arg"].(string)) }, nil, ec.marshalNStringUntyped2string, true, true, ) } func (ec *executionContext) fieldContext_Query_stringUntyped(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 StringUntyped 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_stringUntyped_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_stringTypedN(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_stringTypedN, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().StringTypedN(ctx, fc.Args["arg"].(*model.StringTyped)) }, nil, ec.marshalOStringTyped2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐStringTyped, true, false, ) } func (ec *executionContext) fieldContext_Query_stringTypedN(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 StringTyped 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_stringTypedN_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_stringUntypedN(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_stringUntypedN, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().StringUntypedN(ctx, fc.Args["arg"].(*string)) }, nil, ec.marshalOStringUntyped2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_stringUntypedN(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 StringUntyped 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_stringUntypedN_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_boolTyped(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_boolTyped, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().BoolTyped(ctx, fc.Args["arg"].(model.BoolTyped)) }, nil, ec.marshalNBoolTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐBoolTyped, true, true, ) } func (ec *executionContext) fieldContext_Query_boolTyped(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 BoolTyped 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_boolTyped_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_boolUntyped(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_boolUntyped, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().BoolUntyped(ctx, fc.Args["arg"].(bool)) }, nil, ec.marshalNBoolUntyped2bool, true, true, ) } func (ec *executionContext) fieldContext_Query_boolUntyped(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 BoolUntyped 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_boolUntyped_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_boolTypedN(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_boolTypedN, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().BoolTypedN(ctx, fc.Args["arg"].(*model.BoolTyped)) }, nil, ec.marshalOBoolTyped2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐBoolTyped, true, false, ) } func (ec *executionContext) fieldContext_Query_boolTypedN(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 BoolTyped 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_boolTypedN_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_boolUntypedN(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_boolUntypedN, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().BoolUntypedN(ctx, fc.Args["arg"].(*bool)) }, nil, ec.marshalOBoolUntyped2ᚖbool, true, false, ) } func (ec *executionContext) fieldContext_Query_boolUntypedN(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 BoolUntyped 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_boolUntypedN_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_varTyped(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_varTyped, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().VarTyped(ctx, fc.Args["arg"].(model.VarTyped)) }, nil, ec.marshalNVarTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐVarTyped, true, true, ) } func (ec *executionContext) fieldContext_Query_varTyped(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 VarTyped 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_varTyped_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_varUntyped(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_varUntyped, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().VarUntyped(ctx, fc.Args["arg"].(bool)) }, nil, ec.marshalNVarUntyped2bool, true, true, ) } func (ec *executionContext) fieldContext_Query_varUntyped(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 VarUntyped 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_varUntyped_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_inPackage(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_inPackage, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().InPackage(ctx, fc.Args["arg"].(InPackage)) }, nil, ec.marshalNInPackage2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋapiᚐInPackage, true, true, ) } func (ec *executionContext) fieldContext_Query_inPackage(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 InPackage 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_inPackage_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) ___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 "intTyped": field := field innerFunc := func(ctx 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_intTyped(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 "intUntyped": field := field innerFunc := func(ctx 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_intUntyped(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 "intTypedN": 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_intTypedN(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 "intUntypedN": 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_intUntypedN(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 "stringTyped": field := field innerFunc := func(ctx 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_stringTyped(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 "stringUntyped": field := field innerFunc := func(ctx 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_stringUntyped(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 "stringTypedN": 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_stringTypedN(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 "stringUntypedN": 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_stringUntypedN(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 "boolTyped": field := field innerFunc := func(ctx 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_boolTyped(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 "boolUntyped": field := field innerFunc := func(ctx 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_boolUntyped(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 "boolTypedN": 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_boolTypedN(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 "boolUntypedN": 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_boolUntypedN(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 "varTyped": field := field innerFunc := func(ctx 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_varTyped(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 "varUntyped": field := field innerFunc := func(ctx 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_varUntyped(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 "inPackage": field := field innerFunc := func(ctx 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_inPackage(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) case "__schema": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": out.Values[i] = ec.___Directive_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "description": out.Values[i] = ec.___Directive_description(ctx, field, obj) case "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) unmarshalNBoolTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐBoolTyped(ctx context.Context, v any) (model.BoolTyped, error) { tmp, err := graphql.UnmarshalString(v) res := unmarshalNBoolTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐBoolTyped[tmp] return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNBoolTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐBoolTyped(ctx context.Context, sel ast.SelectionSet, v model.BoolTyped) graphql.Marshaler { _ = sel res := graphql.MarshalString(marshalNBoolTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐBoolTyped[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 } var ( unmarshalNBoolTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐBoolTyped = map[string]model.BoolTyped{ "TRUE": model.BoolTypedTrue, "FALSE": model.BoolTypedFalse, } marshalNBoolTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐBoolTyped = map[model.BoolTyped]string{ model.BoolTypedTrue: "TRUE", model.BoolTypedFalse: "FALSE", } ) func (ec *executionContext) unmarshalNBoolUntyped2bool(ctx context.Context, v any) (bool, error) { tmp, err := graphql.UnmarshalString(v) res := unmarshalNBoolUntyped2bool[tmp] return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNBoolUntyped2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { _ = sel res := graphql.MarshalString(marshalNBoolUntyped2bool[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 } var ( unmarshalNBoolUntyped2bool = map[string]bool{ "TRUE": model.BoolUntypedTrue, "FALSE": model.BoolUntypedFalse, } marshalNBoolUntyped2bool = map[bool]string{ model.BoolUntypedTrue: "TRUE", model.BoolUntypedFalse: "FALSE", } ) 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) unmarshalNInPackage2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋapiᚐInPackage(ctx context.Context, v any) (InPackage, error) { tmp, err := graphql.UnmarshalString(v) res := unmarshalNInPackage2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋapiᚐInPackage[tmp] return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNInPackage2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋapiᚐInPackage(ctx context.Context, sel ast.SelectionSet, v InPackage) graphql.Marshaler { _ = sel res := graphql.MarshalString(marshalNInPackage2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋapiᚐInPackage[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 } var ( unmarshalNInPackage2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋapiᚐInPackage = map[string]InPackage{ "TRUE": InPackageTrue, "FALSE": InPackageFalse, } marshalNInPackage2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋapiᚐInPackage = map[InPackage]string{ InPackageTrue: "TRUE", InPackageFalse: "FALSE", } ) func (ec *executionContext) unmarshalNIntTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐIntTyped(ctx context.Context, v any) (model.IntTyped, error) { tmp, err := graphql.UnmarshalString(v) res := unmarshalNIntTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐIntTyped[tmp] return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNIntTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐIntTyped(ctx context.Context, sel ast.SelectionSet, v model.IntTyped) graphql.Marshaler { _ = sel res := graphql.MarshalString(marshalNIntTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐIntTyped[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 } var ( unmarshalNIntTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐIntTyped = map[string]model.IntTyped{ "ONE": model.IntTypedOne, "TWO": model.IntTypedTwo, } marshalNIntTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐIntTyped = map[model.IntTyped]string{ model.IntTypedOne: "ONE", model.IntTypedTwo: "TWO", } ) func (ec *executionContext) unmarshalNIntUntyped2int(ctx context.Context, v any) (int, error) { tmp, err := graphql.UnmarshalString(v) res := unmarshalNIntUntyped2int[tmp] return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNIntUntyped2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { _ = sel res := graphql.MarshalString(marshalNIntUntyped2int[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 } var ( unmarshalNIntUntyped2int = map[string]int{ "ONE": model.IntUntypedOne, "TWO": model.IntUntypedTwo, } marshalNIntUntyped2int = map[int]string{ model.IntUntypedOne: "ONE", model.IntUntypedTwo: "TWO", } ) 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) unmarshalNStringTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐStringTyped(ctx context.Context, v any) (model.StringTyped, error) { tmp, err := graphql.UnmarshalString(v) res := unmarshalNStringTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐStringTyped[tmp] return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNStringTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐStringTyped(ctx context.Context, sel ast.SelectionSet, v model.StringTyped) graphql.Marshaler { _ = sel res := graphql.MarshalString(marshalNStringTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐStringTyped[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 } var ( unmarshalNStringTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐStringTyped = map[string]model.StringTyped{ "ONE": model.StringTypedOne, "TWO": model.StringTypedTwo, } marshalNStringTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐStringTyped = map[model.StringTyped]string{ model.StringTypedOne: "ONE", model.StringTypedTwo: "TWO", } ) func (ec *executionContext) unmarshalNStringUntyped2string(ctx context.Context, v any) (string, error) { tmp, err := graphql.UnmarshalString(v) res := unmarshalNStringUntyped2string[tmp] return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNStringUntyped2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { _ = sel res := graphql.MarshalString(marshalNStringUntyped2string[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 } var ( unmarshalNStringUntyped2string = map[string]string{ "ONE": model.StringUntypedOne, "TWO": model.StringUntypedTwo, } marshalNStringUntyped2string = map[string]string{ model.StringUntypedOne: "ONE", model.StringUntypedTwo: "TWO", } ) func (ec *executionContext) unmarshalNVarTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐVarTyped(ctx context.Context, v any) (model.VarTyped, error) { tmp, err := graphql.UnmarshalString(v) res := unmarshalNVarTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐVarTyped[tmp] return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNVarTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐVarTyped(ctx context.Context, sel ast.SelectionSet, v model.VarTyped) graphql.Marshaler { _ = sel res := graphql.MarshalString(marshalNVarTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐVarTyped[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 } var ( unmarshalNVarTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐVarTyped = map[string]model.VarTyped{ "TRUE": model.VarTypedTrue, "FALSE": model.VarTypedFalse, } marshalNVarTyped2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐVarTyped = map[model.VarTyped]string{ model.VarTypedTrue: "TRUE", model.VarTypedFalse: "FALSE", } ) func (ec *executionContext) unmarshalNVarUntyped2bool(ctx context.Context, v any) (bool, error) { tmp, err := graphql.UnmarshalString(v) res := unmarshalNVarUntyped2bool[tmp] return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNVarUntyped2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { _ = sel res := graphql.MarshalString(marshalNVarUntyped2bool[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 } var ( unmarshalNVarUntyped2bool = map[string]bool{ "TRUE": model.VarUntypedTrue, "FALSE": model.VarUntypedFalse, } marshalNVarUntyped2bool = map[bool]string{ model.VarUntypedTrue: "TRUE", model.VarUntypedFalse: "FALSE", } ) 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) unmarshalOBoolTyped2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐBoolTyped(ctx context.Context, v any) (*model.BoolTyped, error) { if v == nil { return nil, nil } tmp, err := graphql.UnmarshalString(v) res := unmarshalOBoolTyped2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐBoolTyped[tmp] return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOBoolTyped2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐBoolTyped(ctx context.Context, sel ast.SelectionSet, v *model.BoolTyped) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel _ = ctx res := graphql.MarshalString(marshalOBoolTyped2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐBoolTyped[*v]) return res } var ( unmarshalOBoolTyped2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐBoolTyped = map[string]model.BoolTyped{ "TRUE": model.BoolTypedTrue, "FALSE": model.BoolTypedFalse, } marshalOBoolTyped2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐBoolTyped = map[model.BoolTyped]string{ model.BoolTypedTrue: "TRUE", model.BoolTypedFalse: "FALSE", } ) func (ec *executionContext) unmarshalOBoolUntyped2ᚖbool(ctx context.Context, v any) (*bool, error) { if v == nil { return nil, nil } tmp, err := graphql.UnmarshalString(v) res := unmarshalOBoolUntyped2ᚖbool[tmp] return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOBoolUntyped2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel _ = ctx res := graphql.MarshalString(marshalOBoolUntyped2ᚖbool[*v]) return res } var ( unmarshalOBoolUntyped2ᚖbool = map[string]bool{ "TRUE": model.BoolUntypedTrue, "FALSE": model.BoolUntypedFalse, } marshalOBoolUntyped2ᚖbool = map[bool]string{ model.BoolUntypedTrue: "TRUE", model.BoolUntypedFalse: "FALSE", } ) 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) unmarshalOIntTyped2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐIntTyped(ctx context.Context, v any) (*model.IntTyped, error) { if v == nil { return nil, nil } tmp, err := graphql.UnmarshalString(v) res := unmarshalOIntTyped2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐIntTyped[tmp] return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOIntTyped2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐIntTyped(ctx context.Context, sel ast.SelectionSet, v *model.IntTyped) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel _ = ctx res := graphql.MarshalString(marshalOIntTyped2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐIntTyped[*v]) return res } var ( unmarshalOIntTyped2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐIntTyped = map[string]model.IntTyped{ "ONE": model.IntTypedOne, "TWO": model.IntTypedTwo, } marshalOIntTyped2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐIntTyped = map[model.IntTyped]string{ model.IntTypedOne: "ONE", model.IntTypedTwo: "TWO", } ) func (ec *executionContext) unmarshalOIntUntyped2ᚖint(ctx context.Context, v any) (*int, error) { if v == nil { return nil, nil } tmp, err := graphql.UnmarshalString(v) res := unmarshalOIntUntyped2ᚖint[tmp] return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOIntUntyped2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel _ = ctx res := graphql.MarshalString(marshalOIntUntyped2ᚖint[*v]) return res } var ( unmarshalOIntUntyped2ᚖint = map[string]int{ "ONE": model.IntUntypedOne, "TWO": model.IntUntypedTwo, } marshalOIntUntyped2ᚖint = map[int]string{ model.IntUntypedOne: "ONE", model.IntUntypedTwo: "TWO", } ) 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) unmarshalOStringTyped2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐStringTyped(ctx context.Context, v any) (*model.StringTyped, error) { if v == nil { return nil, nil } tmp, err := graphql.UnmarshalString(v) res := unmarshalOStringTyped2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐStringTyped[tmp] return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOStringTyped2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐStringTyped(ctx context.Context, sel ast.SelectionSet, v *model.StringTyped) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel _ = ctx res := graphql.MarshalString(marshalOStringTyped2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐStringTyped[*v]) return res } var ( unmarshalOStringTyped2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐStringTyped = map[string]model.StringTyped{ "ONE": model.StringTypedOne, "TWO": model.StringTypedTwo, } marshalOStringTyped2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋenumᚋmodelᚐStringTyped = map[model.StringTyped]string{ model.StringTypedOne: "ONE", model.StringTypedTwo: "TWO", } ) func (ec *executionContext) unmarshalOStringUntyped2ᚖstring(ctx context.Context, v any) (*string, error) { if v == nil { return nil, nil } tmp, err := graphql.UnmarshalString(v) res := unmarshalOStringUntyped2ᚖstring[tmp] return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOStringUntyped2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel _ = ctx res := graphql.MarshalString(marshalOStringUntyped2ᚖstring[*v]) return res } var ( unmarshalOStringUntyped2ᚖstring = map[string]string{ "ONE": model.StringUntypedOne, "TWO": model.StringUntypedTwo, } marshalOStringUntyped2ᚖstring = map[string]string{ model.StringUntypedOne: "ONE", model.StringUntypedTwo: "TWO", } ) 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/enum/api/model.go ================================================ package api type InPackage bool const ( InPackageTrue InPackage = true InPackageFalse InPackage = false ) ================================================ FILE: _examples/enum/api/resolver.go ================================================ package api // 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: _examples/enum/cmd/main.go ================================================ package main import ( "log" "net/http" "github.com/99designs/gqlgen/_examples/enum/api" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/playground" ) func main() { srv := handler.New( api.NewExecutableSchema(api.Config{Resolvers: &api.Resolver{}}), ) srv.AddTransport(transport.Options{}) srv.AddTransport(transport.GET{}) srv.AddTransport(transport.POST{}) http.Handle("/", playground.Handler("Enum", "/query")) http.Handle("/query", srv) log.Fatal(http.ListenAndServe(":8081", nil)) } ================================================ FILE: _examples/enum/enum.graphqls ================================================ directive @goModel( model: String models: [String!] ) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION directive @goEnum( value: String ) on ENUM_VALUE type Query { intTyped(arg: IntTyped!): IntTyped! intUntyped(arg: IntUntyped!): IntUntyped! intTypedN(arg: IntTyped): IntTyped intUntypedN(arg: IntUntyped): IntUntyped stringTyped(arg: StringTyped!): StringTyped! stringUntyped(arg: StringUntyped!): StringUntyped! stringTypedN(arg: StringTyped): StringTyped stringUntypedN(arg: StringUntyped): StringUntyped boolTyped(arg: BoolTyped!): BoolTyped! boolUntyped(arg: BoolUntyped!): BoolUntyped! boolTypedN(arg: BoolTyped): BoolTyped boolUntypedN(arg: BoolUntyped): BoolUntyped varTyped(arg: VarTyped!): VarTyped! varUntyped(arg: VarUntyped!): VarUntyped! inPackage(arg: InPackage!): InPackage! } enum IntTyped @goModel(model: "github.com/99designs/gqlgen/_examples/enum/model.IntTyped") { ONE @goEnum(value: "github.com/99designs/gqlgen/_examples/enum/model.IntTypedOne") TWO @goEnum(value: "github.com/99designs/gqlgen/_examples/enum/model.IntTypedTwo") } enum IntUntyped @goModel(model: "github.com/99designs/gqlgen/graphql.Int") { ONE @goEnum(value: "github.com/99designs/gqlgen/_examples/enum/model.IntUntypedOne") TWO @goEnum(value: "github.com/99designs/gqlgen/_examples/enum/model.IntUntypedTwo") } enum StringTyped @goModel(model: "github.com/99designs/gqlgen/_examples/enum/model.StringTyped") { ONE @goEnum(value: "github.com/99designs/gqlgen/_examples/enum/model.StringTypedOne") TWO @goEnum(value: "github.com/99designs/gqlgen/_examples/enum/model.StringTypedTwo") } enum StringUntyped @goModel(model: "github.com/99designs/gqlgen/graphql.String") { ONE @goEnum(value: "github.com/99designs/gqlgen/_examples/enum/model.StringUntypedOne") TWO @goEnum(value: "github.com/99designs/gqlgen/_examples/enum/model.StringUntypedTwo") } enum BoolTyped { TRUE FALSE } enum BoolUntyped { TRUE FALSE } enum VarTyped @goModel(model: "github.com/99designs/gqlgen/_examples/enum/model.VarTyped") { TRUE @goEnum(value: "github.com/99designs/gqlgen/_examples/enum/model.VarTypedTrue") FALSE @goEnum(value: "github.com/99designs/gqlgen/_examples/enum/model.VarTypedFalse") } enum VarUntyped @goModel(model: "github.com/99designs/gqlgen/graphql.Boolean") { TRUE @goEnum(value: "github.com/99designs/gqlgen/_examples/enum/model.VarUntypedTrue") FALSE @goEnum(value: "github.com/99designs/gqlgen/_examples/enum/model.VarUntypedFalse") } enum InPackage { TRUE FALSE } ================================================ FILE: _examples/enum/gen.go ================================================ //go:generate go run ../../testdata/gqlgen.go package enum ================================================ FILE: _examples/enum/gqlgen.yaml ================================================ schema: ./*.graphqls exec: filename: ./api/exec.go package: api resolver: layout: follow-schema package: api dir: api filename_template: "{name}.go" omit_slice_element_pointers: true resolvers_always_return_pointers: false struct_fields_always_pointers: false omit_root_models: true models: BoolTyped: model: github.com/99designs/gqlgen/_examples/enum/model.BoolTyped enum_values: "TRUE": value: github.com/99designs/gqlgen/_examples/enum/model.BoolTypedTrue "FALSE": value: github.com/99designs/gqlgen/_examples/enum/model.BoolTypedFalse BoolUntyped: model: github.com/99designs/gqlgen/graphql.Boolean enum_values: "TRUE": value: github.com/99designs/gqlgen/_examples/enum/model.BoolUntypedTrue "FALSE": value: github.com/99designs/gqlgen/_examples/enum/model.BoolUntypedFalse InPackage: model: github.com/99designs/gqlgen/_examples/enum/api.InPackage enum_values: "TRUE": value: github.com/99designs/gqlgen/_examples/enum/api.InPackageTrue "FALSE": value: github.com/99designs/gqlgen/_examples/enum/api.InPackageFalse ================================================ FILE: _examples/enum/model/model.go ================================================ package model import ( "encoding/json" "fmt" ) // this file is provided as an example for int-based enums // but if you instead wanted to support arbitrary // english words for numbers to integers, consider // github.com/will-lol/numberconverter/etoi or a similar library type IntTyped int const ( IntTypedOne IntTyped = iota + 1 IntTypedTwo ) const ( IntUntypedOne = iota + 1 IntUntypedTwo ) func (t IntTyped) String() string { switch t { case IntTypedOne: return "ONE" case IntTypedTwo: return "TWO" default: return "UNKNOWN" } } func (t IntTyped) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, t.String())), nil } func (t *IntTyped) UnmarshalJSON(b []byte) (err error) { var s string if err = json.Unmarshal(b, &s); err != nil { return err } switch s { case "ONE": *t = IntTypedOne case "TWO": *t = IntTypedTwo default: return fmt.Errorf("unexpected enum value %q", s) } return nil } type StringTyped string const ( StringTypedOne StringTyped = "ONE" StringTypedTwo StringTyped = "TWO" ) const ( StringUntypedOne = "ONE" StringUntypedTwo = "TWO" ) type BoolTyped bool const ( BoolTypedTrue BoolTyped = true BoolTypedFalse BoolTyped = false ) const ( BoolUntypedTrue = true BoolUntypedFalse = false ) type VarTyped bool var ( VarTypedTrue VarTyped = true VarTypedFalse VarTyped = false ) var ( VarUntypedTrue = true VarUntypedFalse = false ) ================================================ FILE: _examples/federation/accounts/gqlgen.yml ================================================ # Where are all the schema files located? globs are supported eg src/**/*.graphqls schema: - graph/*.graphqls # Where should the generated server code go? exec: filename: graph/generated.go package: graph federation: filename: graph/federation.go version: 2 package: graph # Where should any generated models go? model: filename: graph/model/models_gen.go package: model # Where should the resolver implementations go? resolver: layout: follow-schema dir: graph package: graph # Optional: turn on use `gqlgen:"fieldName"` tags in your models # struct_tag: json # Optional: turn on to use []Thing instead of []*Thing # omit_slice_element_pointers: false # Optional: turn off to make struct-type struct fields not use pointers # e.g. type Thing struct { FieldA OtherThing } instead of { FieldA *OtherThing } # struct_fields_always_pointers: true # Optional: turn off to make resolvers return values instead of pointers for structs # resolvers_always_return_pointers: true # Optional: turn on to return pointers instead of values in unmarshalInput # return_pointers_in_unmarshalinput: false # Optional: wrap nullable input fields with Omittable # nullable_input_omittable: true # Optional: set to speed up generation time by not performing a final validation pass. # skip_validation: true # gqlgen will search for any type names in the schema in these go packages # if they match it will use them, otherwise it will generate them. autobind: - "github.com/99designs/gqlgen/_examples/federation/accounts/graph/model" # This section declares type mapping between the GraphQL and go type systems # # The first line in each type will be used as defaults for resolver arguments and # modelgen, the others will be allowed when binding to fields. Configure them to # your liking models: ID: model: - github.com/99designs/gqlgen/graphql.ID - github.com/99designs/gqlgen/graphql.Int - github.com/99designs/gqlgen/graphql.Int64 - github.com/99designs/gqlgen/graphql.Int32 Int: model: - github.com/99designs/gqlgen/graphql.Int - github.com/99designs/gqlgen/graphql.Int64 - github.com/99designs/gqlgen/graphql.Int32 ================================================ FILE: _examples/federation/accounts/graph/entity.resolvers.go ================================================ package graph // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. // Code generated by github.com/99designs/gqlgen version v0.17.88-dev import ( "context" "github.com/99designs/gqlgen/_examples/federation/accounts/graph/model" ) // FindEmailHostByID is the resolver for the findEmailHostByID field. func (r *entityResolver) FindEmailHostByID(ctx context.Context, id string) (*model.EmailHost, error) { return r.HostForUserID(id) } // FindUserByID is the resolver for the findUserByID field. func (r *entityResolver) FindUserByID(ctx context.Context, id string) (*model.User, error) { name := "User " + id if id == "1234" { name = "Me" } return &model.User{ ID: id, Username: name, Email: id + "@test.com", }, nil } // Entity returns EntityResolver implementation. func (r *Resolver) Entity() EntityResolver { return &entityResolver{r} } type entityResolver struct{ *Resolver } ================================================ FILE: _examples/federation/accounts/graph/federation.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package graph 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 "EmailHost": resolverName, err := entityResolverNameForEmailHost(ctx, rep) if err != nil { return nil, fmt.Errorf(`finding resolver for Entity "EmailHost": %w`, err) } switch resolverName { case "findEmailHostByID": id0, err := ec.unmarshalNString2string(ctx, rep["id"]) if err != nil { return nil, fmt.Errorf(`unmarshalling param 0 for findEmailHostByID(): %w`, err) } entity, err := ec.Resolvers.Entity().FindEmailHostByID(ctx, id0) if err != nil { return nil, fmt.Errorf(`resolving Entity "EmailHost": %w`, err) } return entity, nil } case "User": resolverName, err := entityResolverNameForUser(ctx, rep) if err != nil { return nil, fmt.Errorf(`finding resolver for Entity "User": %w`, err) } switch resolverName { case "findUserByID": id0, err := ec.unmarshalNID2string(ctx, rep["id"]) if err != nil { return nil, fmt.Errorf(`unmarshalling param 0 for findUserByID(): %w`, err) } entity, err := ec.Resolvers.Entity().FindUserByID(ctx, id0) if err != nil { return nil, fmt.Errorf(`resolving Entity "User": %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 entityResolverNameForEmailHost(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 EmailHost", ErrTypeNotFound)) break } if allNull { allNull = val == nil } if allNull { entityResolverErrs = append(entityResolverErrs, fmt.Errorf("%w due to all null value KeyFields for EmailHost", ErrTypeNotFound)) break } return "findEmailHostByID", nil } return "", fmt.Errorf("%w for EmailHost due to %v", ErrTypeNotFound, errors.Join(entityResolverErrs...).Error()) } func entityResolverNameForUser(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 User", ErrTypeNotFound)) break } if allNull { allNull = val == nil } if allNull { entityResolverErrs = append(entityResolverErrs, fmt.Errorf("%w due to all null value KeyFields for User", ErrTypeNotFound)) break } return "findUserByID", nil } return "", fmt.Errorf("%w for User due to %v", ErrTypeNotFound, errors.Join(entityResolverErrs...).Error()) } ================================================ FILE: _examples/federation/accounts/graph/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package graph import ( "bytes" "context" "embed" "errors" "fmt" "strconv" "sync/atomic" "github.com/99designs/gqlgen/_examples/federation/accounts/graph/model" "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 User() UserResolver } type DirectiveRoot struct { } type ComplexityRoot struct { EmailHost struct { ID func(childComplexity int) int Name func(childComplexity int) int } Entity struct { FindEmailHostByID func(childComplexity int, id string) int FindUserByID func(childComplexity int, id string) int } Query struct { Me func(childComplexity int) int __resolve__service func(childComplexity int) int __resolve_entities func(childComplexity int, representations []map[string]any) int } User struct { Email func(childComplexity int) int Host func(childComplexity int) int ID func(childComplexity int) int Username func(childComplexity int) int } _Service struct { SDL func(childComplexity int) int } } type EntityResolver interface { FindEmailHostByID(ctx context.Context, id string) (*model.EmailHost, error) FindUserByID(ctx context.Context, id string) (*model.User, error) } type QueryResolver interface { Me(ctx context.Context) (*model.User, error) } type UserResolver interface { Host(ctx context.Context, obj *model.User) (*model.EmailHost, 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 "EmailHost.id": if e.ComplexityRoot.EmailHost.ID == nil { break } return e.ComplexityRoot.EmailHost.ID(childComplexity), true case "EmailHost.name": if e.ComplexityRoot.EmailHost.Name == nil { break } return e.ComplexityRoot.EmailHost.Name(childComplexity), true case "Entity.findEmailHostByID": if e.ComplexityRoot.Entity.FindEmailHostByID == nil { break } args, err := ec.field_Entity_findEmailHostByID_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Entity.FindEmailHostByID(childComplexity, args["id"].(string)), true case "Entity.findUserByID": if e.ComplexityRoot.Entity.FindUserByID == nil { break } args, err := ec.field_Entity_findUserByID_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Entity.FindUserByID(childComplexity, args["id"].(string)), true case "Query.me": if e.ComplexityRoot.Query.Me == nil { break } return e.ComplexityRoot.Query.Me(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 "User.email": if e.ComplexityRoot.User.Email == nil { break } return e.ComplexityRoot.User.Email(childComplexity), true case "User.host": if e.ComplexityRoot.User.Host == nil { break } return e.ComplexityRoot.User.Host(childComplexity), true case "User.id": if e.ComplexityRoot.User.ID == nil { break } return e.ComplexityRoot.User.ID(childComplexity), true case "User.username": if e.ComplexityRoot.User.Username == nil { break } return e.ComplexityRoot.User.Username(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, ), } } //go:embed "schema.graphqls" var sourcesFS embed.FS func sourceData(filename string) string { data, err := sourcesFS.ReadFile(filename) if err != nil { panic(fmt.Sprintf("codegen problem: %s not available", filename)) } return string(data) } var sources = []*ast.Source{ {Name: "schema.graphqls", Input: sourceData("schema.graphqls"), BuiltIn: false}, {Name: "../federation/directives.graphql", Input: ` directive @authenticated on FIELD_DEFINITION | OBJECT | INTERFACE | SCALAR | ENUM directive @composeDirective(name: String!) repeatable on SCHEMA directive @extends on OBJECT | INTERFACE directive @external on OBJECT | FIELD_DEFINITION directive @key(fields: FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE directive @inaccessible on | ARGUMENT_DEFINITION | ENUM | ENUM_VALUE | FIELD_DEFINITION | INPUT_FIELD_DEFINITION | INPUT_OBJECT | INTERFACE | OBJECT | SCALAR | UNION directive @interfaceObject on OBJECT directive @link(import: [String!], url: String!) repeatable on SCHEMA directive @override(from: String!, 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 = EmailHost | User # fake type to build resolver interfaces for users to implement type Entity { findEmailHostByID(id: String!,): EmailHost! findUserByID(id: ID!,): User! } type _Service { sdl: String } extend type Query { _entities(representations: [_Any!]!): [_Entity]! _service: _Service! } `, BuiltIn: true}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) field_Entity_findEmailHostByID_args(ctx context.Context, rawArgs map[string]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_findUserByID_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.unmarshalNID2string) 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) _EmailHost_id(ctx context.Context, field graphql.CollectedField, obj *model.EmailHost) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_EmailHost_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_EmailHost_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "EmailHost", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _EmailHost_name(ctx context.Context, field graphql.CollectedField, obj *model.EmailHost) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_EmailHost_name, func(ctx context.Context) (any, error) { return obj.Name, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_EmailHost_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "EmailHost", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Entity_findEmailHostByID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Entity_findEmailHostByID, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Entity().FindEmailHostByID(ctx, fc.Args["id"].(string)) }, nil, ec.marshalNEmailHost2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋaccountsᚋgraphᚋmodelᚐEmailHost, true, true, ) } func (ec *executionContext) fieldContext_Entity_findEmailHostByID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Entity", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_EmailHost_id(ctx, field) case "name": return ec.fieldContext_EmailHost_name(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type EmailHost", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Entity_findEmailHostByID_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Entity_findUserByID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Entity_findUserByID, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Entity().FindUserByID(ctx, fc.Args["id"].(string)) }, nil, ec.marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋaccountsᚋgraphᚋmodelᚐUser, true, true, ) } func (ec *executionContext) fieldContext_Entity_findUserByID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Entity", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_User_id(ctx, field) case "host": return ec.fieldContext_User_host(ctx, field) case "email": return ec.fieldContext_User_email(ctx, field) case "username": return ec.fieldContext_User_username(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Entity_findUserByID_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_me(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_me, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Me(ctx) }, nil, ec.marshalOUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋaccountsᚋgraphᚋmodelᚐUser, true, false, ) } func (ec *executionContext) fieldContext_Query_me(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_User_id(ctx, field) case "host": return ec.fieldContext_User_host(ctx, field) case "email": return ec.fieldContext_User_email(ctx, field) case "username": return ec.fieldContext_User_username(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } func (ec *executionContext) _Query__entities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 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) _User_id(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, nil, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_User_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _User_host(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_host, func(ctx context.Context) (any, error) { return ec.Resolvers.User().Host(ctx, obj) }, nil, ec.marshalNEmailHost2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋaccountsᚋgraphᚋmodelᚐEmailHost, true, true, ) } func (ec *executionContext) fieldContext_User_host(_ 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_EmailHost_id(ctx, field) case "name": return ec.fieldContext_EmailHost_name(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type EmailHost", field.Name) }, } return fc, nil } func (ec *executionContext) _User_email(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_email, func(ctx context.Context) (any, error) { return obj.Email, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_User_email(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _User_username(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_username, func(ctx context.Context) (any, error) { return obj.Username, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_User_username(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) __Service_sdl(ctx context.Context, field graphql.CollectedField, obj *fedruntime.Service) (ret graphql.Marshaler) { 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 model.User: return ec._User(ctx, sel, &obj) case *model.User: if obj == nil { return graphql.Null } return ec._User(ctx, sel, obj) case model.EmailHost: return ec._EmailHost(ctx, sel, &obj) case *model.EmailHost: if obj == nil { return graphql.Null } return ec._EmailHost(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 emailHostImplementors = []string{"EmailHost", "_Entity"} func (ec *executionContext) _EmailHost(ctx context.Context, sel ast.SelectionSet, obj *model.EmailHost) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, emailHostImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("EmailHost") case "id": out.Values[i] = ec._EmailHost_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "name": out.Values[i] = ec._EmailHost_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var entityImplementors = []string{"Entity"} func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, entityImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Entity", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Entity") case "findEmailHostByID": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Entity_findEmailHostByID(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "findUserByID": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Entity_findUserByID(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "me": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_me(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "_entities": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query__entities(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "_service": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query__service(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) case "__schema": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var userImplementors = []string{"User", "_Entity"} func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *model.User) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("User") case "id": out.Values[i] = ec._User_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "host": field := field innerFunc := func(ctx 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_host(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 "email": out.Values[i] = ec._User_email(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "username": out.Values[i] = ec._User_username(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 _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) marshalNEmailHost2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋaccountsᚋgraphᚋmodelᚐEmailHost(ctx context.Context, sel ast.SelectionSet, v model.EmailHost) graphql.Marshaler { return ec._EmailHost(ctx, sel, &v) } func (ec *executionContext) marshalNEmailHost2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋaccountsᚋgraphᚋmodelᚐEmailHost(ctx context.Context, sel ast.SelectionSet, v *model.EmailHost) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._EmailHost(ctx, sel, v) } 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) 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) 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) marshalNUser2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋaccountsᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v model.User) graphql.Marshaler { return ec._User(ctx, sel, &v) } func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋaccountsᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 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) 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) marshalOUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋaccountsᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { if v == nil { return graphql.Null } return ec._User(ctx, sel, v) } func (ec *executionContext) marshalO_Entity2githubᚗcomᚋ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: _examples/federation/accounts/graph/model/model.go ================================================ package model ================================================ FILE: _examples/federation/accounts/graph/model/models_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package model type EmailHost struct { ID string `json:"id"` Name string `json:"name"` } func (EmailHost) IsEntity() {} type Query struct { } type User struct { ID string `json:"id"` Host *EmailHost `json:"host"` Email string `json:"email"` Username string `json:"username"` } func (User) IsEntity() {} ================================================ FILE: _examples/federation/accounts/graph/resolver.go ================================================ // This file will not be regenerated automatically. // // It serves as dependency injection for your app, add any dependencies you require here. package graph import "github.com/99designs/gqlgen/_examples/federation/accounts/graph/model" type Resolver struct{} func (r *Resolver) HostForUserID(id string) (*model.EmailHost, error) { return &model.EmailHost{ ID: id, Name: "Email Host " + id, }, nil } ================================================ FILE: _examples/federation/accounts/graph/schema.graphqls ================================================ directive @goField( forceResolver: Boolean name: String omittable: Boolean type: String ) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION extend type Query { me: User } type EmailHost @key(fields: "id") { id: String! name: String! } type User @key(fields: "id") { id: ID! host: EmailHost! @goField(forceResolver: true) email: String! username: String! } ================================================ FILE: _examples/federation/accounts/graph/schema.resolvers.go ================================================ package graph // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. // Code generated by github.com/99designs/gqlgen version v0.17.88-dev import ( "context" "github.com/99designs/gqlgen/_examples/federation/accounts/graph/model" ) // Me is the resolver for the me field. func (r *queryResolver) Me(ctx context.Context) (*model.User, error) { return &model.User{ ID: "1234", Host: &model.EmailHost{ ID: "4567", Name: "Email Host 4567", }, Email: "me@example.com", Username: "Me", }, nil } // Host is the resolver for the host field. func (r *userResolver) Host(ctx context.Context, obj *model.User) (*model.EmailHost, error) { return r.HostForUserID(obj.ID) } // 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 queryResolver struct{ *Resolver } type userResolver struct{ *Resolver } ================================================ FILE: _examples/federation/accounts/schema/schema.go ================================================ package server import ( "github.com/99designs/gqlgen/_examples/federation/accounts/graph" ) const DefaultPort = "4001" var Schema = graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}}) ================================================ FILE: _examples/federation/accounts/server.go ================================================ //go:generate go run ../../../testdata/gqlgen.go package main import ( "log" "net/http" "os" "github.com/99designs/gqlgen/_examples/federation/accounts/graph" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/debug" "github.com/99designs/gqlgen/graphql/handler/extension" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/playground" ) const defaultPort = "4001" func main() { port := os.Getenv("PORT") if port == "" { port = defaultPort } srv := handler.New( graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}}), ) srv.AddTransport(transport.GET{}) srv.AddTransport(transport.POST{}) srv.Use(extension.Introspection{}) 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: _examples/federation/all/main.go ================================================ package main import ( "context" "log" accounts "github.com/99designs/gqlgen/_examples/federation/accounts/schema" products "github.com/99designs/gqlgen/_examples/federation/products/schema" reviews "github.com/99designs/gqlgen/_examples/federation/reviews/schema" "github.com/99designs/gqlgen/_examples/federation/subgraphs" ) func main() { ctx := context.Background() subgraphs, err := subgraphs.New( ctx, subgraphs.SubgraphConfig{ Name: "accounts", Schema: accounts.Schema, Port: accounts.DefaultPort, }, subgraphs.SubgraphConfig{ Name: "products", Schema: products.Schema, Port: products.DefaultPort, }, subgraphs.SubgraphConfig{ Name: "reviews", Schema: reviews.Schema, Port: reviews.DefaultPort, }, ) if err != nil { log.Fatal(err) } log.Fatal(subgraphs.ListenAndServe(ctx)) } ================================================ FILE: _examples/federation/package.json ================================================ { "name": "gateway", "version": "1.0.1", "description": "", "main": "src/gateway/index.ts", "type": "module", "scripts": { "start-gateway": "node src/gateway/index.ts", "test": "vitest" }, "author": "", "license": "ISC", "dependencies": { "@apollo/gateway": "^2.11.2", "@apollo/server": "^5.0.0", "graphql": "^16.11.0", "rxjs": "^7.8.2" }, "devDependencies": { "@apollo/client": "^4.0.4", "cross-fetch": "^4.1.0", "node-fetch": "^3.3.2", "vitest": "^4.0.3" } } ================================================ FILE: _examples/federation/products/gqlgen.yml ================================================ # Where are all the schema files located? globs are supported eg src/**/*.graphqls schema: - graph/*.graphqls # Where should the generated server code go? exec: filename: graph/generated.go package: graph federation: filename: graph/federation.go version: 2 package: graph # Where should any generated models go? model: filename: graph/model/models_gen.go package: model # Where should the resolver implementations go? resolver: layout: follow-schema dir: graph package: graph # Optional: turn on use `gqlgen:"fieldName"` tags in your models # struct_tag: json # Optional: turn on to use []Thing instead of []*Thing # omit_slice_element_pointers: false # Optional: turn off to make struct-type struct fields not use pointers # e.g. type Thing struct { FieldA OtherThing } instead of { FieldA *OtherThing } # struct_fields_always_pointers: true # Optional: turn off to make resolvers return values instead of pointers for structs # resolvers_always_return_pointers: true # Optional: turn on to return pointers instead of values in unmarshalInput # return_pointers_in_unmarshalinput: false # Optional: wrap nullable input fields with Omittable # nullable_input_omittable: true # Optional: set to speed up generation time by not performing a final validation pass. # skip_validation: true # gqlgen will search for any type names in the schema in these go packages # if they match it will use them, otherwise it will generate them. autobind: - "github.com/99designs/gqlgen/_examples/federation/products/graph/model" # This section declares type mapping between the GraphQL and go type systems # # The first line in each type will be used as defaults for resolver arguments and # modelgen, the others will be allowed when binding to fields. Configure them to # your liking models: ID: model: - github.com/99designs/gqlgen/graphql.ID - github.com/99designs/gqlgen/graphql.Int - github.com/99designs/gqlgen/graphql.Int64 - github.com/99designs/gqlgen/graphql.Int32 Int: model: - github.com/99designs/gqlgen/graphql.Int - github.com/99designs/gqlgen/graphql.Int64 - github.com/99designs/gqlgen/graphql.Int32 omit_complexity: true ================================================ FILE: _examples/federation/products/graph/entity.resolvers.go ================================================ package graph // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. // Code generated by github.com/99designs/gqlgen version v0.17.88-dev import ( "context" "github.com/99designs/gqlgen/_examples/federation/products/graph/model" ) // FindManufacturerByID is the resolver for the findManufacturerByID field. func (r *entityResolver) FindManufacturerByID(ctx context.Context, id string) (*model.Manufacturer, error) { return &model.Manufacturer{ ID: id, Name: "Millinery " + id, }, nil } // FindProductByManufacturerIDAndID is the resolver for the findProductByManufacturerIDAndID field. func (r *entityResolver) FindProductByManufacturerIDAndID(ctx context.Context, manufacturerID string, id string) (*model.Product, error) { for _, hat := range hats { if hat.ID == id && hat.Manufacturer.ID == manufacturerID { return hat, nil } } return nil, nil } // FindProductByUpc is the resolver for the findProductByUpc field. func (r *entityResolver) FindProductByUpc(ctx context.Context, upc string) (*model.Product, error) { for _, hat := range hats { if hat.Upc == upc { return hat, nil } } return nil, nil } // Entity returns EntityResolver implementation. func (r *Resolver) Entity() EntityResolver { return &entityResolver{r} } type entityResolver struct{ *Resolver } ================================================ FILE: _examples/federation/products/graph/federation.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package graph 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 "Manufacturer": resolverName, err := entityResolverNameForManufacturer(ctx, rep) if err != nil { return nil, fmt.Errorf(`finding resolver for Entity "Manufacturer": %w`, err) } switch resolverName { case "findManufacturerByID": id0, err := ec.unmarshalNString2string(ctx, rep["id"]) if err != nil { return nil, fmt.Errorf(`unmarshalling param 0 for findManufacturerByID(): %w`, err) } entity, err := ec.Resolvers.Entity().FindManufacturerByID(ctx, id0) if err != nil { return nil, fmt.Errorf(`resolving Entity "Manufacturer": %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 "findProductByManufacturerIDAndID": id0, err := ec.unmarshalNString2string(ctx, rep["manufacturer"].(map[string]any)["id"]) if err != nil { return nil, fmt.Errorf(`unmarshalling param 0 for findProductByManufacturerIDAndID(): %w`, err) } id1, err := ec.unmarshalNString2string(ctx, rep["id"]) if err != nil { return nil, fmt.Errorf(`unmarshalling param 1 for findProductByManufacturerIDAndID(): %w`, err) } entity, err := ec.Resolvers.Entity().FindProductByManufacturerIDAndID(ctx, id0, id1) if err != nil { return nil, fmt.Errorf(`resolving Entity "Product": %w`, err) } return entity, nil case "findProductByUpc": id0, err := ec.unmarshalNString2string(ctx, rep["upc"]) if err != nil { return nil, fmt.Errorf(`unmarshalling param 0 for findProductByUpc(): %w`, err) } entity, err := ec.Resolvers.Entity().FindProductByUpc(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 entityResolverNameForManufacturer(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 Manufacturer", ErrTypeNotFound)) break } if allNull { allNull = val == nil } if allNull { entityResolverErrs = append(entityResolverErrs, fmt.Errorf("%w due to all null value KeyFields for Manufacturer", ErrTypeNotFound)) break } return "findManufacturerByID", nil } return "", fmt.Errorf("%w for Manufacturer 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["manufacturer"] if !ok { entityResolverErrs = append(entityResolverErrs, fmt.Errorf("%w due to missing Key Field \"manufacturer\" for Product", 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 \"manufacturer\" value not matching map[string]any for Product", ErrTypeNotFound)) break } val, ok = m["id"] if !ok { entityResolverErrs = append(entityResolverErrs, fmt.Errorf("%w due to missing Key Field \"id\" for Product", ErrTypeNotFound)) break } if allNull { allNull = val == nil } m = rep val, ok = m["id"] if !ok { entityResolverErrs = append(entityResolverErrs, fmt.Errorf("%w due to missing Key Field \"id\" 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 "findProductByManufacturerIDAndID", 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["upc"] if !ok { entityResolverErrs = append(entityResolverErrs, fmt.Errorf("%w due to missing Key Field \"upc\" 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 "findProductByUpc", nil } return "", fmt.Errorf("%w for Product due to %v", ErrTypeNotFound, errors.Join(entityResolverErrs...).Error()) } ================================================ FILE: _examples/federation/products/graph/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package graph import ( "bytes" "context" "embed" "errors" "fmt" "strconv" "sync/atomic" "github.com/99designs/gqlgen/_examples/federation/products/graph/model" "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 { } type ComplexityRoot struct { } type EntityResolver interface { FindManufacturerByID(ctx context.Context, id string) (*model.Manufacturer, error) FindProductByManufacturerIDAndID(ctx context.Context, manufacturerID string, id string) (*model.Product, error) FindProductByUpc(ctx context.Context, upc string) (*model.Product, error) } type QueryResolver interface { TopProducts(ctx context.Context, first *int) ([]*model.Product, error) } type executableSchema 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() 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.graphqls" var sourcesFS embed.FS func sourceData(filename string) string { data, err := sourcesFS.ReadFile(filename) if err != nil { panic(fmt.Sprintf("codegen problem: %s not available", filename)) } return string(data) } var sources = []*ast.Source{ {Name: "schema.graphqls", Input: sourceData("schema.graphqls"), BuiltIn: false}, {Name: "../federation/directives.graphql", Input: ` directive @authenticated on FIELD_DEFINITION | OBJECT | INTERFACE | SCALAR | ENUM directive @composeDirective(name: String!) repeatable on SCHEMA directive @extends on OBJECT | INTERFACE directive @external on OBJECT | FIELD_DEFINITION directive @key(fields: FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE directive @inaccessible on | ARGUMENT_DEFINITION | ENUM | ENUM_VALUE | FIELD_DEFINITION | INPUT_FIELD_DEFINITION | INPUT_OBJECT | INTERFACE | OBJECT | SCALAR | UNION directive @interfaceObject on OBJECT directive @link(import: [String!], url: String!) repeatable on SCHEMA directive @override(from: String!, 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 = Manufacturer | Product # fake type to build resolver interfaces for users to implement type Entity { findManufacturerByID(id: String!,): Manufacturer! findProductByManufacturerIDAndID(manufacturerID: String!,id: String!,): Product! findProductByUpc(upc: String!,): Product! } type _Service { sdl: String } extend type Query { _entities(representations: [_Any!]!): [_Entity]! _service: _Service! } `, BuiltIn: true}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) field_Entity_findManufacturerByID_args(ctx context.Context, rawArgs map[string]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_findProductByManufacturerIDAndID_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, "manufacturerID", ec.unmarshalNString2string) if err != nil { return nil, err } args["manufacturerID"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "id", ec.unmarshalNString2string) if err != nil { return nil, err } args["id"] = arg1 return args, nil } func (ec *executionContext) field_Entity_findProductByUpc_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "upc", ec.unmarshalNString2string) if err != nil { return nil, err } args["upc"] = arg0 return args, nil } func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]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_topProducts_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, "first", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["first"] = 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_findManufacturerByID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Entity_findManufacturerByID, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Entity().FindManufacturerByID(ctx, fc.Args["id"].(string)) }, nil, ec.marshalNManufacturer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋproductsᚋgraphᚋmodelᚐManufacturer, true, true, ) } func (ec *executionContext) fieldContext_Entity_findManufacturerByID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Entity", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Manufacturer_id(ctx, field) case "name": return ec.fieldContext_Manufacturer_name(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Manufacturer", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Entity_findManufacturerByID_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Entity_findProductByManufacturerIDAndID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Entity_findProductByManufacturerIDAndID, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Entity().FindProductByManufacturerIDAndID(ctx, fc.Args["manufacturerID"].(string), fc.Args["id"].(string)) }, nil, ec.marshalNProduct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋproductsᚋgraphᚋmodelᚐProduct, true, true, ) } func (ec *executionContext) fieldContext_Entity_findProductByManufacturerIDAndID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Entity", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Product_id(ctx, field) case "manufacturer": return ec.fieldContext_Product_manufacturer(ctx, field) case "upc": return ec.fieldContext_Product_upc(ctx, field) case "name": return ec.fieldContext_Product_name(ctx, field) case "price": return ec.fieldContext_Product_price(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Product", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Entity_findProductByManufacturerIDAndID_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Entity_findProductByUpc(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Entity_findProductByUpc, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Entity().FindProductByUpc(ctx, fc.Args["upc"].(string)) }, nil, ec.marshalNProduct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋproductsᚋgraphᚋmodelᚐProduct, true, true, ) } func (ec *executionContext) fieldContext_Entity_findProductByUpc(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Entity", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Product_id(ctx, field) case "manufacturer": return ec.fieldContext_Product_manufacturer(ctx, field) case "upc": return ec.fieldContext_Product_upc(ctx, field) case "name": return ec.fieldContext_Product_name(ctx, field) case "price": return ec.fieldContext_Product_price(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Product", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Entity_findProductByUpc_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Manufacturer_id(ctx context.Context, field graphql.CollectedField, obj *model.Manufacturer) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Manufacturer_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Manufacturer_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Manufacturer", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Manufacturer_name(ctx context.Context, field graphql.CollectedField, obj *model.Manufacturer) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Manufacturer_name, func(ctx context.Context) (any, error) { return obj.Name, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Manufacturer_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Manufacturer", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Product_id(ctx context.Context, field graphql.CollectedField, obj *model.Product) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Product_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Product_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Product", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Product_manufacturer(ctx context.Context, field graphql.CollectedField, obj *model.Product) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Product_manufacturer, func(ctx context.Context) (any, error) { return obj.Manufacturer, nil }, nil, ec.marshalNManufacturer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋproductsᚋgraphᚋmodelᚐManufacturer, true, true, ) } func (ec *executionContext) fieldContext_Product_manufacturer(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Product", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Manufacturer_id(ctx, field) case "name": return ec.fieldContext_Manufacturer_name(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Manufacturer", field.Name) }, } return fc, nil } func (ec *executionContext) _Product_upc(ctx context.Context, field graphql.CollectedField, obj *model.Product) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Product_upc, func(ctx context.Context) (any, error) { return obj.Upc, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Product_upc(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Product", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Product_name(ctx context.Context, field graphql.CollectedField, obj *model.Product) (ret graphql.Marshaler) { 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 *model.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.marshalNInt2int, 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 Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_topProducts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_topProducts, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().TopProducts(ctx, fc.Args["first"].(*int)) }, nil, ec.marshalOProduct2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋproductsᚋgraphᚋmodelᚐProduct, true, false, ) } func (ec *executionContext) fieldContext_Query_topProducts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Product_id(ctx, field) case "manufacturer": return ec.fieldContext_Product_manufacturer(ctx, field) case "upc": return ec.fieldContext_Product_upc(ctx, field) case "name": return ec.fieldContext_Product_name(ctx, field) case "price": return ec.fieldContext_Product_price(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Product", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_topProducts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query__entities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 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 model.Product: return ec._Product(ctx, sel, &obj) case *model.Product: if obj == nil { return graphql.Null } return ec._Product(ctx, sel, obj) case model.Manufacturer: return ec._Manufacturer(ctx, sel, &obj) case *model.Manufacturer: if obj == nil { return graphql.Null } return ec._Manufacturer(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 "findManufacturerByID": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Entity_findManufacturerByID(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "findProductByManufacturerIDAndID": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Entity_findProductByManufacturerIDAndID(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "findProductByUpc": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Entity_findProductByUpc(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var manufacturerImplementors = []string{"Manufacturer", "_Entity"} func (ec *executionContext) _Manufacturer(ctx context.Context, sel ast.SelectionSet, obj *model.Manufacturer) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, manufacturerImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Manufacturer") case "id": out.Values[i] = ec._Manufacturer_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "name": out.Values[i] = ec._Manufacturer_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var productImplementors = []string{"Product", "_Entity"} func (ec *executionContext) _Product(ctx context.Context, sel ast.SelectionSet, obj *model.Product) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, productImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Product") case "id": out.Values[i] = ec._Product_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "manufacturer": out.Values[i] = ec._Product_manufacturer(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "upc": out.Values[i] = ec._Product_upc(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "name": out.Values[i] = ec._Product_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "price": out.Values[i] = ec._Product_price(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "topProducts": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_topProducts(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "_entities": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query__entities(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "_service": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query__service(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) case "__schema": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var _ServiceImplementors = []string{"_Service"} func (ec *executionContext) __Service(ctx context.Context, sel ast.SelectionSet, obj *fedruntime.Service) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, _ServiceImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("_Service") case "sdl": out.Values[i] = ec.__Service_sdl(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": out.Values[i] = ec.___Directive_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "description": out.Values[i] = ec.___Directive_description(ctx, field, obj) case "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) 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) marshalNManufacturer2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋproductsᚋgraphᚋmodelᚐManufacturer(ctx context.Context, sel ast.SelectionSet, v model.Manufacturer) graphql.Marshaler { return ec._Manufacturer(ctx, sel, &v) } func (ec *executionContext) marshalNManufacturer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋproductsᚋgraphᚋmodelᚐManufacturer(ctx context.Context, sel ast.SelectionSet, v *model.Manufacturer) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._Manufacturer(ctx, sel, v) } func (ec *executionContext) marshalNProduct2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋproductsᚋgraphᚋmodelᚐProduct(ctx context.Context, sel ast.SelectionSet, v model.Product) graphql.Marshaler { return ec._Product(ctx, sel, &v) } func (ec *executionContext) marshalNProduct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋproductsᚋgraphᚋmodelᚐProduct(ctx context.Context, sel ast.SelectionSet, v *model.Product) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 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) 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) 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) marshalOProduct2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋproductsᚋgraphᚋmodelᚐProduct(ctx context.Context, sel ast.SelectionSet, v []*model.Product) graphql.Marshaler { if v == nil { return graphql.Null } ret := 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.marshalOProduct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋproductsᚋgraphᚋmodelᚐProduct(ctx, sel, v[i]) }) return ret } func (ec *executionContext) marshalOProduct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋproductsᚋgraphᚋmodelᚐProduct(ctx context.Context, sel ast.SelectionSet, v *model.Product) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Product(ctx, sel, v) } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v 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: _examples/federation/products/graph/model/model.go ================================================ package model ================================================ FILE: _examples/federation/products/graph/model/models_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package model type Manufacturer struct { ID string `json:"id"` Name string `json:"name"` } func (Manufacturer) IsEntity() {} type Product struct { ID string `json:"id"` Manufacturer *Manufacturer `json:"manufacturer"` Upc string `json:"upc"` Name string `json:"name"` Price int `json:"price"` } func (Product) IsEntity() {} type Query struct { } ================================================ FILE: _examples/federation/products/graph/products.go ================================================ package graph import "github.com/99designs/gqlgen/_examples/federation/products/graph/model" var hats = []*model.Product{ { ID: "111", Manufacturer: &model.Manufacturer{ ID: "1234", Name: "Millinery 1234", }, Upc: "top-1", Name: "Trilby", Price: 11, }, { ID: "222", Manufacturer: &model.Manufacturer{ ID: "2345", Name: "Millinery 2345", }, Upc: "top-2", Name: "Fedora", Price: 22, }, { ID: "333", Manufacturer: &model.Manufacturer{ ID: "2345", Name: "Millinery 2345", }, Upc: "top-3", Name: "Boater", Price: 33, }, } ================================================ FILE: _examples/federation/products/graph/resolver.go ================================================ // This file will not be regenerated automatically. // // It serves as dependency injection for your app, add any dependencies you require here. package graph type Resolver struct{} ================================================ FILE: _examples/federation/products/graph/schema.graphqls ================================================ extend type Query { topProducts(first: Int = 5): [Product] } type Manufacturer @key(fields: "id") { id: String! name: String! } type Product @key(fields: "manufacturer { id } id") @key(fields: "upc") { id: String! manufacturer: Manufacturer! upc: String! name: String! price: Int! } ================================================ FILE: _examples/federation/products/graph/schema.resolvers.go ================================================ package graph // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. // Code generated by github.com/99designs/gqlgen version v0.17.88-dev import ( "context" "github.com/99designs/gqlgen/_examples/federation/products/graph/model" ) // TopProducts is the resolver for the topProducts field. func (r *queryResolver) TopProducts(ctx context.Context, first *int) ([]*model.Product, error) { return hats, nil } // Query returns QueryResolver implementation. func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } type queryResolver struct{ *Resolver } ================================================ FILE: _examples/federation/products/schema/schema.go ================================================ package schema import ( "github.com/99designs/gqlgen/_examples/federation/products/graph" ) const DefaultPort = "4002" var Schema = graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}}) ================================================ FILE: _examples/federation/products/server.go ================================================ //go:generate go run ../../../testdata/gqlgen.go package main import ( "log" "net/http" "os" "github.com/99designs/gqlgen/_examples/federation/products/graph" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/debug" "github.com/99designs/gqlgen/graphql/handler/extension" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/playground" ) const defaultPort = "4002" func main() { port := os.Getenv("PORT") if port == "" { port = defaultPort } srv := handler.New( graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}}), ) srv.AddTransport(transport.GET{}) srv.AddTransport(transport.POST{}) srv.Use(extension.Introspection{}) 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: _examples/federation/readme.md ================================================ ### Federation [Read the docs](https://gqlgen.com/recipes/federation/) ## Testing If you want to set breakpoints and debug the federation example, you can first run the subgraphs using: $ go run ./all/main.go Then start the gateway using $ npm run start-gateway You can then connect your preferred Golang debugger to the Go process as you make requests to the router. ================================================ FILE: _examples/federation/reviews/gqlgen.yml ================================================ # Where are all the schema files located? globs are supported eg src/**/*.graphqls schema: - graph/*.graphqls # Where should the generated server code go? exec: filename: graph/generated.go package: graph federation: filename: graph/federation.go package: graph version: 2 options: computed_requires: true # Where should any generated models go? model: filename: graph/model/models_gen.go package: model # Where should the resolver implementations go? resolver: layout: follow-schema dir: graph package: graph # Optional: turn on use `gqlgen:"fieldName"` tags in your models # struct_tag: json # Optional: turn on to use []Thing instead of []*Thing # omit_slice_element_pointers: false # Optional: turn off to make struct-type struct fields not use pointers # e.g. type Thing struct { FieldA OtherThing } instead of { FieldA *OtherThing } # struct_fields_always_pointers: true # Optional: turn off to make resolvers return values instead of pointers for structs # resolvers_always_return_pointers: true # Optional: turn on to return pointers instead of values in unmarshalInput # return_pointers_in_unmarshalinput: false # Optional: wrap nullable input fields with Omittable # nullable_input_omittable: true # Optional: set to speed up generation time by not performing a final validation pass. # skip_validation: true # gqlgen will search for any type names in the schema in these go packages # if they match it will use them, otherwise it will generate them. autobind: - "github.com/99designs/gqlgen/_examples/federation/reviews/graph/model" # This section declares type mapping between the GraphQL and go type systems # # The first line in each type will be used as defaults for resolver arguments and # modelgen, the others will be allowed when binding to fields. Configure them to # your liking models: ID: model: - github.com/99designs/gqlgen/graphql.ID - github.com/99designs/gqlgen/graphql.Int - github.com/99designs/gqlgen/graphql.Int64 - github.com/99designs/gqlgen/graphql.Int32 Int: model: - github.com/99designs/gqlgen/graphql.Int - github.com/99designs/gqlgen/graphql.Int64 - github.com/99designs/gqlgen/graphql.Int32 omit_complexity: true call_argument_directives_with_null: true ================================================ FILE: _examples/federation/reviews/graph/entity.resolvers.go ================================================ package graph // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. // Code generated by github.com/99designs/gqlgen version v0.17.88-dev import ( "context" "github.com/99designs/gqlgen/_examples/federation/reviews/graph/model" ) // FindManyProductByManufacturerIDAndIDs is the resolver for the // findManyProductByManufacturerIDAndIDs field. func (r *entityResolver) FindManyProductByManufacturerIDAndIDs(ctx context.Context, reps []*model.ProductByManufacturerIDAndIDsInput) ([]*model.Product, error) { products := make([]*model.Product, 0, len(reps)) for idx := range reps { rep := reps[len(reps)-idx-1] product, err := r.FindProductByManufacturerIDAndID(ctx, rep.ManufacturerID, rep.ID) if err != nil { return nil, err } products = append(products, product) } return products, nil } // FindUserByID is the resolver for the findUserByID field. func (r *entityResolver) FindUserByID(ctx context.Context, id string) (*model.User, error) { return &model.User{ ID: id, Host: &model.EmailHost{}, }, nil } // Entity returns EntityResolver implementation. func (r *Resolver) Entity() EntityResolver { return &entityResolver{r} } type entityResolver struct{ *Resolver } ================================================ FILE: _examples/federation/reviews/graph/federation.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package graph import ( "context" "errors" "fmt" "strings" "sync" "github.com/99designs/gqlgen/_examples/federation/reviews/graph/model" "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 "Product": 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 "User": resolverName, err := entityResolverNameForUser(ctx, rep) if err != nil { return nil, fmt.Errorf(`finding resolver for Entity "User": %w`, err) } switch resolverName { case "findUserByID": id0, err := ec.unmarshalNID2string(ctx, rep["id"]) if err != nil { return nil, fmt.Errorf(`unmarshalling param 0 for findUserByID(): %w`, err) } entity, err := ec.Resolvers.Entity().FindUserByID(ctx, id0) if err != nil { return nil, fmt.Errorf(`resolving Entity "User": %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 "Product": resolverName, err := entityResolverNameForProduct(ctx, reps[0].entity) if err != nil { return fmt.Errorf(`finding resolver for Entity "Product": %w`, err) } switch resolverName { case "findManyProductByManufacturerIDAndIDs": typedReps := make([]*model.ProductByManufacturerIDAndIDsInput, len(reps)) for i, rep := range reps { id0, err := ec.unmarshalNString2string(ctx, rep.entity["manufacturer"].(map[string]any)["id"]) if err != nil { return errors.New(fmt.Sprintf("Field %s undefined in schema.", "manufacturerID")) } id1, err := ec.unmarshalNString2string(ctx, rep.entity["id"]) if err != nil { return errors.New(fmt.Sprintf("Field %s undefined in schema.", "id")) } typedReps[i] = &model.ProductByManufacturerIDAndIDsInput{ ManufacturerID: id0, ID: id1, } } entities, err := ec.Resolvers.Entity().FindManyProductByManufacturerIDAndIDs(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 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["manufacturer"] if !ok { entityResolverErrs = append(entityResolverErrs, fmt.Errorf("%w due to missing Key Field \"manufacturer\" for Product", 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 \"manufacturer\" value not matching map[string]any for Product", ErrTypeNotFound)) break } val, ok = m["id"] if !ok { entityResolverErrs = append(entityResolverErrs, fmt.Errorf("%w due to missing Key Field \"id\" for Product", ErrTypeNotFound)) break } if allNull { allNull = val == nil } m = rep val, ok = m["id"] if !ok { entityResolverErrs = append(entityResolverErrs, fmt.Errorf("%w due to missing Key Field \"id\" 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 "findManyProductByManufacturerIDAndIDs", nil } return "", fmt.Errorf("%w for Product due to %v", ErrTypeNotFound, errors.Join(entityResolverErrs...).Error()) } func entityResolverNameForUser(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 User", ErrTypeNotFound)) break } if allNull { allNull = val == nil } if allNull { entityResolverErrs = append(entityResolverErrs, fmt.Errorf("%w due to all null value KeyFields for User", ErrTypeNotFound)) break } return "findUserByID", nil } return "", fmt.Errorf("%w for User due to %v", ErrTypeNotFound, errors.Join(entityResolverErrs...).Error()) } ================================================ FILE: _examples/federation/reviews/graph/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package graph import ( "bytes" "context" "embed" "errors" "fmt" "strconv" "sync/atomic" "github.com/99designs/gqlgen/_examples/federation/reviews/graph/model" "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 Product() ProductResolver User() UserResolver } type DirectiveRoot struct { } type ComplexityRoot struct { } type EntityResolver interface { FindManyProductByManufacturerIDAndIDs(ctx context.Context, reps []*model.ProductByManufacturerIDAndIDsInput) ([]*model.Product, error) FindUserByID(ctx context.Context, id string) (*model.User, error) } type ProductResolver interface { ManufacturerID(ctx context.Context, obj *model.Product, federationRequires map[string]any) (*string, error) } type UserResolver interface { Username(ctx context.Context, obj *model.User) (string, error) Reviews(ctx context.Context, obj *model.User, federationRequires map[string]any) ([]*model.Review, 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.unmarshalInputProductByManufacturerIDAndIDsInput, ) 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.graphqls" var sourcesFS embed.FS func sourceData(filename string) string { data, err := sourcesFS.ReadFile(filename) if err != nil { panic(fmt.Sprintf("codegen problem: %s not available", filename)) } return string(data) } var sources = []*ast.Source{ {Name: "schema.graphqls", Input: sourceData("schema.graphqls"), BuiltIn: false}, {Name: "../federation/directives.graphql", Input: ` directive @authenticated on FIELD_DEFINITION | OBJECT | INTERFACE | SCALAR | ENUM directive @composeDirective(name: String!) repeatable on SCHEMA directive @extends on OBJECT | INTERFACE directive @external on OBJECT | FIELD_DEFINITION directive @key(fields: FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE directive @inaccessible on | ARGUMENT_DEFINITION | ENUM | ENUM_VALUE | FIELD_DEFINITION | INPUT_FIELD_DEFINITION | INPUT_OBJECT | INTERFACE | OBJECT | SCALAR | UNION directive @interfaceObject on OBJECT directive @link(import: [String!], url: String!) repeatable on SCHEMA directive @override(from: String!, 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 = EmailHost | Manufacturer | Product | User input ProductByManufacturerIDAndIDsInput { ManufacturerID: String! ID: String! } # fake type to build resolver interfaces for users to implement type Entity { findManyProductByManufacturerIDAndIDs(reps: [ProductByManufacturerIDAndIDsInput]!): [Product] findUserByID(id: ID!,): User! } type _Service { sdl: String } extend type Query { _entities(representations: [_Any!]!): [_Entity]! _service: _Service! } `, BuiltIn: true}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) field_Entity_findManyProductByManufacturerIDAndIDs_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.unmarshalNProductByManufacturerIDAndIDsInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐProductByManufacturerIDAndIDsInput) if err != nil { return nil, err } args["reps"] = arg0 return args, nil } func (ec *executionContext) field_Entity_findUserByID_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.unmarshalNID2string) if err != nil { return nil, err } args["id"] = arg0 return args, nil } func (ec *executionContext) field_Product_manufacturerID_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Product_manufacturerID_argsFederationRequires(ctx, rawArgs) if err != nil { return nil, err } args["_federationRequires"] = arg0 return args, nil } func (ec *executionContext) field_Product_manufacturerID_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_User_reviews_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_User_reviews_argsFederationRequires(ctx, rawArgs) if err != nil { return nil, err } args["_federationRequires"] = arg0 return args, nil } func (ec *executionContext) field_User_reviews_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___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) _EmailHost_id(ctx context.Context, field graphql.CollectedField, obj *model.EmailHost) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_EmailHost_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_EmailHost_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "EmailHost", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Entity_findManyProductByManufacturerIDAndIDs(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Entity_findManyProductByManufacturerIDAndIDs, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Entity().FindManyProductByManufacturerIDAndIDs(ctx, fc.Args["reps"].([]*model.ProductByManufacturerIDAndIDsInput)) }, nil, ec.marshalOProduct2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐProduct, true, false, ) } func (ec *executionContext) fieldContext_Entity_findManyProductByManufacturerIDAndIDs(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Entity", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Product_id(ctx, field) case "manufacturer": return ec.fieldContext_Product_manufacturer(ctx, field) case "manufacturerID": return ec.fieldContext_Product_manufacturerID(ctx, field) case "reviews": return ec.fieldContext_Product_reviews(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Product", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Entity_findManyProductByManufacturerIDAndIDs_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Entity_findUserByID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Entity_findUserByID, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Entity().FindUserByID(ctx, fc.Args["id"].(string)) }, nil, ec.marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐUser, true, true, ) } func (ec *executionContext) fieldContext_Entity_findUserByID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Entity", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_User_id(ctx, field) case "host": return ec.fieldContext_User_host(ctx, field) case "email": return ec.fieldContext_User_email(ctx, field) case "username": return ec.fieldContext_User_username(ctx, field) case "reviews": return ec.fieldContext_User_reviews(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Entity_findUserByID_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Manufacturer_id(ctx context.Context, field graphql.CollectedField, obj *model.Manufacturer) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Manufacturer_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Manufacturer_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Manufacturer", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Product_id(ctx context.Context, field graphql.CollectedField, obj *model.Product) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Product_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Product_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Product", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Product_manufacturer(ctx context.Context, field graphql.CollectedField, obj *model.Product) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Product_manufacturer, func(ctx context.Context) (any, error) { return obj.Manufacturer, nil }, nil, ec.marshalNManufacturer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐManufacturer, true, true, ) } func (ec *executionContext) fieldContext_Product_manufacturer(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Product", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Manufacturer_id(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Manufacturer", field.Name) }, } return fc, nil } func (ec *executionContext) _Product_manufacturerID(ctx context.Context, field graphql.CollectedField, obj *model.Product) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Product_manufacturerID, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Product().ManufacturerID(ctx, obj, fc.Args["_federationRequires"].(map[string]any)) }, nil, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Product_manufacturerID(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Product", 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_Product_manufacturerID_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Product_reviews(ctx context.Context, field graphql.CollectedField, obj *model.Product) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Product_reviews, func(ctx context.Context) (any, error) { return obj.Reviews, nil }, nil, ec.marshalOReview2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐReview, true, false, ) } func (ec *executionContext) fieldContext_Product_reviews(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Product", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "body": return ec.fieldContext_Review_body(ctx, field) case "author": return ec.fieldContext_Review_author(ctx, field) case "product": return ec.fieldContext_Review_product(ctx, field) case "hostIDEmail": return ec.fieldContext_Review_hostIDEmail(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Review", field.Name) }, } return fc, nil } func (ec *executionContext) _Query__entities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 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) _Review_body(ctx context.Context, field graphql.CollectedField, obj *model.Review) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Review_body, func(ctx context.Context) (any, error) { return obj.Body, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Review_body(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Review", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Review_author(ctx context.Context, field graphql.CollectedField, obj *model.Review) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Review_author, func(ctx context.Context) (any, error) { return obj.Author, nil }, nil, ec.marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐUser, true, true, ) } func (ec *executionContext) fieldContext_Review_author(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Review", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_User_id(ctx, field) case "host": return ec.fieldContext_User_host(ctx, field) case "email": return ec.fieldContext_User_email(ctx, field) case "username": return ec.fieldContext_User_username(ctx, field) case "reviews": return ec.fieldContext_User_reviews(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } func (ec *executionContext) _Review_product(ctx context.Context, field graphql.CollectedField, obj *model.Review) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Review_product, func(ctx context.Context) (any, error) { return obj.Product, nil }, nil, ec.marshalNProduct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐProduct, true, true, ) } func (ec *executionContext) fieldContext_Review_product(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Review", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Product_id(ctx, field) case "manufacturer": return ec.fieldContext_Product_manufacturer(ctx, field) case "manufacturerID": return ec.fieldContext_Product_manufacturerID(ctx, field) case "reviews": return ec.fieldContext_Product_reviews(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Product", field.Name) }, } return fc, nil } func (ec *executionContext) _Review_hostIDEmail(ctx context.Context, field graphql.CollectedField, obj *model.Review) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Review_hostIDEmail, func(ctx context.Context) (any, error) { return obj.HostIDEmail, nil }, nil, ec.marshalOString2string, true, false, ) } func (ec *executionContext) fieldContext_Review_hostIDEmail(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Review", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, nil, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_User_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _User_host(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_host, func(ctx context.Context) (any, error) { return obj.Host, nil }, nil, ec.marshalNEmailHost2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐEmailHost, true, true, ) } func (ec *executionContext) fieldContext_User_host(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_EmailHost_id(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type EmailHost", field.Name) }, } return fc, nil } func (ec *executionContext) _User_email(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_email, func(ctx context.Context) (any, error) { return obj.Email, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_User_email(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _User_username(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_username, func(ctx context.Context) (any, error) { return ec.Resolvers.User().Username(ctx, obj) }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_User_username(_ 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_reviews(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_reviews, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.User().Reviews(ctx, obj, fc.Args["_federationRequires"].(map[string]any)) }, nil, ec.marshalOReview2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐReview, true, false, ) } func (ec *executionContext) fieldContext_User_reviews(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "body": return ec.fieldContext_Review_body(ctx, field) case "author": return ec.fieldContext_Review_author(ctx, field) case "product": return ec.fieldContext_Review_product(ctx, field) case "hostIDEmail": return ec.fieldContext_Review_hostIDEmail(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Review", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_User_reviews_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } 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) unmarshalInputProductByManufacturerIDAndIDsInput(ctx context.Context, obj any) (model.ProductByManufacturerIDAndIDsInput, error) { var it model.ProductByManufacturerIDAndIDsInput if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"ManufacturerID", "ID"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "ManufacturerID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ManufacturerID")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.ManufacturerID = data case "ID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ID")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.ID = 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.User: return ec._User(ctx, sel, &obj) case *model.User: if obj == nil { return graphql.Null } return ec._User(ctx, sel, obj) case model.Product: return ec._Product(ctx, sel, &obj) case *model.Product: if obj == nil { return graphql.Null } return ec._Product(ctx, sel, obj) case model.Manufacturer: return ec._Manufacturer(ctx, sel, &obj) case *model.Manufacturer: if obj == nil { return graphql.Null } return ec._Manufacturer(ctx, sel, obj) case model.EmailHost: return ec._EmailHost(ctx, sel, &obj) case *model.EmailHost: if obj == nil { return graphql.Null } return ec._EmailHost(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 emailHostImplementors = []string{"EmailHost", "_Entity"} func (ec *executionContext) _EmailHost(ctx context.Context, sel ast.SelectionSet, obj *model.EmailHost) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, emailHostImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("EmailHost") case "id": out.Values[i] = ec._EmailHost_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var entityImplementors = []string{"Entity"} func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, entityImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Entity", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Entity") case "findManyProductByManufacturerIDAndIDs": 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_findManyProductByManufacturerIDAndIDs(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 "findUserByID": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Entity_findUserByID(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var manufacturerImplementors = []string{"Manufacturer", "_Entity"} func (ec *executionContext) _Manufacturer(ctx context.Context, sel ast.SelectionSet, obj *model.Manufacturer) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, manufacturerImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Manufacturer") case "id": out.Values[i] = ec._Manufacturer_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var productImplementors = []string{"Product", "_Entity"} func (ec *executionContext) _Product(ctx context.Context, sel ast.SelectionSet, obj *model.Product) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, productImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Product") case "id": out.Values[i] = ec._Product_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "manufacturer": out.Values[i] = ec._Product_manufacturer(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "manufacturerID": 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._Product_manufacturerID(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 "reviews": out.Values[i] = ec._Product_reviews(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "_entities": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query__entities(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "_service": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query__service(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) case "__schema": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var reviewImplementors = []string{"Review"} func (ec *executionContext) _Review(ctx context.Context, sel ast.SelectionSet, obj *model.Review) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, reviewImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Review") case "body": out.Values[i] = ec._Review_body(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "author": out.Values[i] = ec._Review_author(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "product": out.Values[i] = ec._Review_product(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "hostIDEmail": out.Values[i] = ec._Review_hostIDEmail(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", "_Entity"} func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *model.User) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("User") case "id": out.Values[i] = ec._User_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "host": out.Values[i] = ec._User_host(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "email": out.Values[i] = ec._User_email(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "username": field := field innerFunc := func(ctx 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_username(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 "reviews": 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_reviews(ctx, field, obj) return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var _ServiceImplementors = []string{"_Service"} func (ec *executionContext) __Service(ctx context.Context, sel ast.SelectionSet, obj *fedruntime.Service) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, _ServiceImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("_Service") case "sdl": out.Values[i] = ec.__Service_sdl(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": out.Values[i] = ec.___Directive_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "description": out.Values[i] = ec.___Directive_description(ctx, field, obj) case "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) marshalNEmailHost2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐEmailHost(ctx context.Context, sel ast.SelectionSet, v *model.EmailHost) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._EmailHost(ctx, sel, v) } 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) 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) marshalNManufacturer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐManufacturer(ctx context.Context, sel ast.SelectionSet, v *model.Manufacturer) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._Manufacturer(ctx, sel, v) } func (ec *executionContext) marshalNProduct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐProduct(ctx context.Context, sel ast.SelectionSet, v *model.Product) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 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) unmarshalNProductByManufacturerIDAndIDsInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐProductByManufacturerIDAndIDsInput(ctx context.Context, v any) ([]*model.ProductByManufacturerIDAndIDsInput, error) { var vSlice []any vSlice = graphql.CoerceList(v) var err error res := make([]*model.ProductByManufacturerIDAndIDsInput, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) res[i], err = ec.unmarshalOProductByManufacturerIDAndIDsInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐProductByManufacturerIDAndIDsInput(ctx, vSlice[i]) if err != nil { return nil, err } } return res, nil } 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) marshalNUser2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v model.User) graphql.Marshaler { return ec._User(ctx, sel, &v) } func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { 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) 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) marshalOProduct2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐProduct(ctx context.Context, sel ast.SelectionSet, v []*model.Product) 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.marshalOProduct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐProduct(ctx, sel, v[i]) }) return ret } func (ec *executionContext) marshalOProduct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐProduct(ctx context.Context, sel ast.SelectionSet, v *model.Product) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Product(ctx, sel, v) } func (ec *executionContext) unmarshalOProductByManufacturerIDAndIDsInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐProductByManufacturerIDAndIDsInput(ctx context.Context, v any) (*model.ProductByManufacturerIDAndIDsInput, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputProductByManufacturerIDAndIDsInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOReview2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐReview(ctx context.Context, sel ast.SelectionSet, v []*model.Review) graphql.Marshaler { if v == nil { return graphql.Null } ret := 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.marshalOReview2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐReview(ctx, sel, v[i]) }) return ret } func (ec *executionContext) marshalOReview2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋreviewsᚋgraphᚋmodelᚐReview(ctx context.Context, sel ast.SelectionSet, v *model.Review) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Review(ctx, sel, v) } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v 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) 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: _examples/federation/reviews/graph/model/models.go ================================================ package model type Product struct { ID string `json:"id"` Manufacturer *Manufacturer `json:"manufacturer"` Reviews []*Review `json:"reviews"` } func (Product) IsEntity() {} type Review struct { Body string Author *User Product *Product HostIDEmail string } type User struct { ID string `json:"id"` Host *EmailHost `json:"host"` Email string `json:"email"` } func (User) IsEntity() {} ================================================ FILE: _examples/federation/reviews/graph/model/models_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package model type EmailHost struct { ID string `json:"id"` } func (EmailHost) IsEntity() {} type Manufacturer struct { ID string `json:"id"` } func (Manufacturer) IsEntity() {} type ProductByManufacturerIDAndIDsInput struct { ManufacturerID string `json:"ManufacturerID"` ID string `json:"ID"` } type Query struct { } ================================================ FILE: _examples/federation/reviews/graph/resolver.go ================================================ // This file will not be regenerated automatically. // // It serves as dependency injection for your app, add any dependencies you require here. package graph import ( "context" "github.com/99designs/gqlgen/_examples/federation/reviews/graph/model" ) type Resolver struct{} func (r *entityResolver) FindProductByManufacturerIDAndID( ctx context.Context, manufacturerID, id string, ) (*model.Product, error) { var productReviews []*model.Review for _, review := range reviews { if review.Product.ID == id && review.Product.Manufacturer.ID == manufacturerID { productReviews = append(productReviews, review) } } return &model.Product{ ID: id, Manufacturer: &model.Manufacturer{ ID: manufacturerID, }, Reviews: productReviews, }, nil } ================================================ FILE: _examples/federation/reviews/graph/reviews.go ================================================ package graph import "github.com/99designs/gqlgen/_examples/federation/reviews/graph/model" var reviews = []*model.Review{ { Body: "A highly effective form of birth control.", Product: &model.Product{ID: "111", Manufacturer: &model.Manufacturer{ID: "1234"}}, Author: &model.User{ID: "1234"}, }, { Body: "Fedoras are one of the most fashionable hats around and can look great with a variety of outfits.", Product: &model.Product{ID: "222", Manufacturer: &model.Manufacturer{ID: "2345"}}, Author: &model.User{ID: "1234"}, }, { Body: "This is the last straw. Hat you will wear. 11/10", Product: &model.Product{ID: "333", Manufacturer: &model.Manufacturer{ID: "2345"}}, Author: &model.User{ID: "7777"}, }, } ================================================ FILE: _examples/federation/reviews/graph/schema.graphqls ================================================ directive @entityResolver(multi: Boolean) on OBJECT extend type EmailHost @key(fields: "id") { id: String! @external } extend type Manufacturer @key(fields: "id") { id: String! @external } extend type Product @key(fields: "manufacturer { id } id") @entityResolver(multi: true) { id: String! @external manufacturer: Manufacturer! @external manufacturerID: String @requires(fields: "manufacturer { id }") reviews: [Review] } extend type User @key(fields: "id") { id: ID! @external host: EmailHost! @external email: String! @external username: String! @external reviews: [Review] @requires(fields: "host { id } email") } type Review { body: String! author: User! @provides(fields: "username") product: Product! hostIDEmail: String } ================================================ FILE: _examples/federation/reviews/graph/schema.resolvers.go ================================================ package graph // This file will be automatically regenerated based on the schema, any resolver // implementations // will be copied through when generating and any unknown code will be moved to the end. // Code generated by github.com/99designs/gqlgen version v0.17.88-dev import ( "context" "fmt" "github.com/99designs/gqlgen/_examples/federation/reviews/graph/model" ) // ManufacturerID is the resolver for the manufacturerID field. func (r *productResolver) ManufacturerID(ctx context.Context, obj *model.Product, federationRequires map[string]any) (*string, error) { manufacturer, ok := federationRequires["manufacturer"].(map[string]any) if !ok { return nil, fmt.Errorf("manufacturer not provided or not an object") } manufacturerID, ok := manufacturer["id"].(string) if !ok { return nil, fmt.Errorf("manufacturer.id not provided or not a string") } return &manufacturerID, nil } // Username is the resolver for the username field. func (r *userResolver) Username(ctx context.Context, obj *model.User) (string, error) { panic(fmt.Errorf("not implemented: Username - username")) } // Reviews is the resolver for the reviews field. func (r *userResolver) Reviews(ctx context.Context, obj *model.User, federationRequires map[string]any) ([]*model.Review, error) { var productReviews []*model.Review for _, review := range reviews { if review.Author.ID == obj.ID { host, ok := federationRequires["host"].(map[string]any) if !ok { return nil, fmt.Errorf("host not provided or not an object") } hostID, ok := host["id"].(string) if !ok { return nil, fmt.Errorf("host.id not provided or not a string") } email, ok := federationRequires["email"].(string) if !ok { return nil, fmt.Errorf("email not provided or not a string") } productReviews = append(productReviews, &model.Review{ Body: review.Body, Author: review.Author, Product: review.Product, HostIDEmail: hostID + ":" + email, }) } } return productReviews, nil } // Product returns ProductResolver implementation. func (r *Resolver) Product() ProductResolver { return &productResolver{r} } // User returns UserResolver implementation. func (r *Resolver) User() UserResolver { return &userResolver{r} } type productResolver struct{ *Resolver } type userResolver struct{ *Resolver } ================================================ FILE: _examples/federation/reviews/schema/schema.go ================================================ package schema import ( "github.com/99designs/gqlgen/_examples/federation/reviews/graph" ) const DefaultPort = "4003" var Schema = graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}}) ================================================ FILE: _examples/federation/reviews/server.go ================================================ //go:generate go run ../../../testdata/gqlgen.go package main import ( "log" "net/http" "os" "github.com/99designs/gqlgen/_examples/federation/reviews/graph" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/debug" "github.com/99designs/gqlgen/graphql/handler/extension" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/playground" ) const defaultPort = "4003" func main() { port := os.Getenv("PORT") if port == "" { port = defaultPort } srv := handler.New( graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}}), ) srv.AddTransport(transport.GET{}) srv.AddTransport(transport.POST{}) srv.Use(extension.Introspection{}) 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: _examples/federation/src/__test__/integration.spec.ts ================================================ import {describe, expect, it} from "vitest"; import {InMemoryCache, ApolloClient, HttpLink, gql} from '@apollo/client/core'; const uri = process.env.SERVER_URL || 'http://localhost:4000/'; const client = new ApolloClient({ link: new HttpLink({uri}), cache: new InMemoryCache(), }); describe('Json', () => { it('can join across services', async () => { console.log(uri) let res = await client.query({ query: gql(`query { me { username reviews { body product { name upc } } } }`), }); expect(res.data).toEqual({ "me": { "__typename": "User", "username": "Me", "reviews": [ { "__typename": "Review", "body": "A highly effective form of birth control.", "product": { "__typename": "Product", "name": "Trilby", "upc": "top-1" } }, { "__typename": "Review", "body": "Fedoras are one of the most fashionable hats around and can look great with a variety of outfits.", "product": { "__typename": "Product", "name": "Fedora", "upc": "top-2" } } ] } }); expect(res.error).toBeUndefined(); }); }); ================================================ FILE: _examples/federation/src/gateway/index.ts ================================================ import {ApolloServer} from '@apollo/server'; import {startStandaloneServer} from '@apollo/server/standalone'; import {ApolloGateway, IntrospectAndCompose} from '@apollo/gateway'; const gateway = new ApolloGateway({ supergraphSdl: new IntrospectAndCompose({ subgraphs: [ {name: 'accounts', url: 'http://localhost:4001/query'}, {name: 'products', url: 'http://localhost:4002/query'}, {name: 'reviews', url: 'http://localhost:4003/query'} ], }), }); const server = new ApolloServer({gateway}); // Note the top-level `await`! const {url} = await startStandaloneServer(server); console.log(`🚀 Server ready at ${url}`); ================================================ FILE: _examples/federation/start.sh ================================================ #!/usr/bin/env bash function cleanup { kill "$ACCOUNTS_PID" kill "$PRODUCTS_PID" kill "$REVIEWS_PID" } trap cleanup EXIT go build -o /tmp/srv-accounts ./accounts go build -o /tmp/srv-products ./products go build -o /tmp/srv-reviews ./reviews /tmp/srv-accounts & ACCOUNTS_PID=$! /tmp/srv-products & PRODUCTS_PID=$! /tmp/srv-reviews & REVIEWS_PID=$! sleep 1 node src/gateway/index.ts ================================================ FILE: _examples/federation/subgraphs/subgraphs.go ================================================ package subgraphs import ( "context" "errors" "fmt" "log" "net/http" "golang.org/x/sync/errgroup" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/debug" "github.com/99designs/gqlgen/graphql/handler/extension" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/playground" ) type Config struct { EnableDebug bool } type Subgraphs struct { servers []*http.Server } type SubgraphConfig struct { Name string Schema graphql.ExecutableSchema Port string } func (s *Subgraphs) Shutdown(ctx context.Context) error { for _, srv := range s.servers { if err := srv.Shutdown(ctx); err != nil { return err } } return nil } func (s *Subgraphs) ListenAndServe(ctx context.Context) error { group, _ := errgroup.WithContext(ctx) for _, srv := range s.servers { group.Go(func() error { err := srv.ListenAndServe() if err != nil && !errors.Is(err, http.ErrServerClosed) { log.Printf("error listening and serving: %v", err) return err } return nil }) } return group.Wait() } func newServer(name, port string, schema graphql.ExecutableSchema) *http.Server { if port == "" { panic(fmt.Errorf("port for %s is empty", name)) } srv := handler.New(schema) srv.AddTransport(transport.GET{}) srv.AddTransport(transport.POST{}) srv.Use(extension.Introspection{}) srv.Use(&debug.Tracer{}) mux := http.NewServeMux() mux.Handle("/", playground.Handler("GraphQL playground", "/query")) mux.Handle("/query", srv) return &http.Server{ Addr: ":" + port, Handler: mux, } } func New(ctx context.Context, subgraphs ...SubgraphConfig) (*Subgraphs, error) { servers := make([]*http.Server, len(subgraphs)) for i, config := range subgraphs { servers[i] = newServer(config.Name, config.Port, config.Schema) } return &Subgraphs{ servers: servers, }, nil } ================================================ FILE: _examples/federation/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: _examples/fileupload/.gqlgen.yml ================================================ model: filename: model/generated.go ================================================ FILE: _examples/fileupload/fileupload_test.go ================================================ //go:generate go run ../../testdata/gqlgen.go -stub stubs.go package fileupload import ( "context" "io" "net/http/httptest" "os" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/_examples/fileupload/model" gqlclient "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestFileUpload(t *testing.T) { resolver := &Stub{} h := handler.New(NewExecutableSchema(Config{Resolvers: resolver})) h.AddTransport(transport.MultipartForm{}) srv := httptest.NewServer(h) defer srv.Close() gql := gqlclient.New(srv.Config.Handler, gqlclient.Path("/graphql")) aTxtFile, err := os.CreateTemp(t.TempDir(), "a.txt") require.NoError(t, err) defer aTxtFile.Close() aTxtFile.WriteString(`test`) a1TxtFile, err := os.CreateTemp(t.TempDir(), "a.txt") require.NoError(t, err) defer a1TxtFile.Close() b1TxtFile, err := os.CreateTemp(t.TempDir(), "b.txt") require.NoError(t, err) defer b1TxtFile.Close() a1TxtFile.WriteString(`test1`) b1TxtFile.WriteString(`test2`) t.Run("valid single file upload", func(t *testing.T) { resolver.MutationResolver.SingleUpload = func(ctx context.Context, file graphql.Upload) (*model.File, error) { require.NotNil(t, file) require.NotNil(t, file.File) content, err := io.ReadAll(file.File) require.NoError(t, err) require.Equal(t, "test", string(content)) return &model.File{ ID: 1, Name: file.Filename, Content: string(content), ContentType: file.ContentType, }, nil } mutation := `mutation ($file: Upload!) { singleUpload(file: $file) { id name content contentType } }` var result struct { SingleUpload *model.File } err := gql.Post(mutation, &result, gqlclient.Var("file", aTxtFile), gqlclient.WithFiles()) require.NoError(t, err) require.Equal(t, 1, result.SingleUpload.ID) require.Contains(t, result.SingleUpload.Name, "a.txt") require.Equal(t, "test", result.SingleUpload.Content) require.Equal(t, "text/plain; charset=utf-8", result.SingleUpload.ContentType) }) t.Run("valid single file upload with payload", func(t *testing.T) { resolver.MutationResolver.SingleUploadWithPayload = func(ctx context.Context, req model.UploadFile) (*model.File, error) { require.Equal(t, 1, req.ID) require.NotNil(t, req.File) require.NotNil(t, req.File.File) content, err := io.ReadAll(req.File.File) require.NoError(t, err) require.Equal(t, "test", string(content)) return &model.File{ ID: 1, Name: req.File.Filename, Content: string(content), ContentType: req.File.ContentType, }, nil } mutation := `mutation ($req: UploadFile!) { singleUploadWithPayload(req: $req) { id name content contentType } }` var result struct { SingleUploadWithPayload *model.File } err := gql.Post( mutation, &result, gqlclient.Var("req", map[string]any{"id": 1, "file": aTxtFile}), gqlclient.WithFiles(), ) require.NoError(t, err) require.Equal(t, 1, result.SingleUploadWithPayload.ID) require.Contains(t, result.SingleUploadWithPayload.Name, "a.txt") require.Equal(t, "test", result.SingleUploadWithPayload.Content) require.Equal(t, "text/plain; charset=utf-8", result.SingleUploadWithPayload.ContentType) }) t.Run("valid file list upload", func(t *testing.T) { resolver.MutationResolver.MultipleUpload = func(ctx context.Context, files []*graphql.Upload) ([]*model.File, error) { require.Len(t, files, 2) var contents []string var resp []*model.File for i := range files { require.NotNil(t, files[i].File) content, err := io.ReadAll(files[i].File) require.NoError(t, err) contents = append(contents, string(content)) resp = append(resp, &model.File{ ID: i + 1, Name: files[i].Filename, Content: string(content), ContentType: files[i].ContentType, }) } require.ElementsMatch(t, []string{"test1", "test2"}, contents) return resp, nil } mutation := `mutation($files: [Upload!]!) { multipleUpload(files: $files) { id name content contentType } }` var result struct { MultipleUpload []*model.File } err := gql.Post( mutation, &result, gqlclient.Var("files", []*os.File{a1TxtFile, b1TxtFile}), gqlclient.WithFiles(), ) require.NoError(t, err) require.Equal(t, 1, result.MultipleUpload[0].ID) require.Equal(t, 2, result.MultipleUpload[1].ID) for _, mu := range result.MultipleUpload { if mu.Name == "a.txt" { require.Equal(t, "test1", mu.Content) } if mu.Name == "b.txt" { require.Equal(t, "test2", mu.Content) } require.Equal(t, "text/plain; charset=utf-8", mu.ContentType) } }) t.Run("valid file list upload with payload", func(t *testing.T) { resolver.MutationResolver.MultipleUploadWithPayload = func(ctx context.Context, req []*model.UploadFile) ([]*model.File, error) { require.Len(t, req, 2) var ids []int var contents []string var resp []*model.File for i := range req { require.NotNil(t, req[i].File) require.NotNil(t, req[i].File.File) content, err := io.ReadAll(req[i].File.File) require.NoError(t, err) ids = append(ids, req[i].ID) contents = append(contents, string(content)) resp = append(resp, &model.File{ ID: i + 1, Name: req[i].File.Filename, Content: string(content), ContentType: req[i].File.ContentType, }) } require.ElementsMatch(t, []int{1, 2}, ids) require.ElementsMatch(t, []string{"test1", "test2"}, contents) return resp, nil } mutation := `mutation($req: [UploadFile!]!) { multipleUploadWithPayload(req: $req) { id name content contentType } }` var result struct { MultipleUploadWithPayload []*model.File } err := gql.Post(mutation, &result, gqlclient.Var("req", []map[string]any{ {"id": 1, "file": a1TxtFile}, {"id": 2, "file": b1TxtFile}, }), gqlclient.WithFiles()) require.NoError(t, err) require.Equal(t, 1, result.MultipleUploadWithPayload[0].ID) require.Equal(t, 2, result.MultipleUploadWithPayload[1].ID) for _, mu := range result.MultipleUploadWithPayload { if mu.Name == "a.txt" { require.Equal(t, "test1", mu.Content) } if mu.Name == "b.txt" { require.Equal(t, "test2", mu.Content) } require.Equal(t, "text/plain; charset=utf-8", mu.ContentType) } }) t.Run("valid file list upload with payload and file reuse", func(t *testing.T) { resolver := &Stub{} resolver.MutationResolver.MultipleUploadWithPayload = func(ctx context.Context, req []*model.UploadFile) ([]*model.File, error) { require.Len(t, req, 2) var ids []int var contents []string var resp []*model.File for i := range req { require.NotNil(t, req[i].File) require.NotNil(t, req[i].File.File) ids = append(ids, req[i].ID) var got []byte buf := make([]byte, 2) for { n, err := req[i].File.File.Read(buf) got = append(got, buf[:n]...) if err != nil { if err == io.EOF { break } require.Fail(t, "unexpected error while reading", err.Error()) } } contents = append(contents, string(got)) resp = append(resp, &model.File{ ID: i + 1, Name: req[i].File.Filename, Content: string(got), ContentType: req[i].File.ContentType, }) } require.ElementsMatch(t, []int{1, 2}, ids) require.ElementsMatch(t, []string{"test1", "test1"}, contents) return resp, nil } test := func(uploadMaxMemory int64) { hndlr := handler.New(NewExecutableSchema(Config{Resolvers: resolver})) hndlr.AddTransport(transport.MultipartForm{MaxMemory: uploadMaxMemory}) srv := httptest.NewServer(hndlr) defer srv.Close() gql := gqlclient.New(srv.Config.Handler, gqlclient.Path("/graphql")) mutation := `mutation($req: [UploadFile!]!) { multipleUploadWithPayload(req: $req) { id name content contentType } }` var result struct { MultipleUploadWithPayload []*model.File } err := gql.Post(mutation, &result, gqlclient.Var("req", []map[string]any{ {"id": 1, "file": a1TxtFile}, {"id": 2, "file": a1TxtFile}, }), gqlclient.WithFiles()) require.NoError(t, err) require.Equal(t, 1, result.MultipleUploadWithPayload[0].ID) require.Contains(t, result.MultipleUploadWithPayload[0].Name, "a.txt") require.Equal(t, "test1", result.MultipleUploadWithPayload[0].Content) require.Equal( t, "text/plain; charset=utf-8", result.MultipleUploadWithPayload[0].ContentType, ) require.Equal(t, 2, result.MultipleUploadWithPayload[1].ID) require.Contains(t, result.MultipleUploadWithPayload[1].Name, "a.txt") require.Equal(t, "test1", result.MultipleUploadWithPayload[1].Content) require.Equal( t, "text/plain; charset=utf-8", result.MultipleUploadWithPayload[1].ContentType, ) } t.Run("payload smaller than UploadMaxMemory, stored in memory", func(t *testing.T) { test(5000) }) t.Run("payload bigger than UploadMaxMemory, persisted to disk", func(t *testing.T) { test(2) }) }) } ================================================ FILE: _examples/fileupload/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package fileupload import ( "bytes" "context" "embed" "errors" "fmt" "strconv" "sync/atomic" "github.com/99designs/gqlgen/_examples/fileupload/model" "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 } type DirectiveRoot struct { } type ComplexityRoot struct { File struct { Content func(childComplexity int) int ContentType func(childComplexity int) int ID func(childComplexity int) int Name func(childComplexity int) int } Mutation struct { MultipleUpload func(childComplexity int, files []*graphql.Upload) int MultipleUploadWithPayload func(childComplexity int, req []*model.UploadFile) int SingleUpload func(childComplexity int, file graphql.Upload) int SingleUploadWithPayload func(childComplexity int, req model.UploadFile) int } Query struct { Empty func(childComplexity int) int } } type MutationResolver interface { SingleUpload(ctx context.Context, file graphql.Upload) (*model.File, error) SingleUploadWithPayload(ctx context.Context, req model.UploadFile) (*model.File, error) MultipleUpload(ctx context.Context, files []*graphql.Upload) ([]*model.File, error) MultipleUploadWithPayload(ctx context.Context, req []*model.UploadFile) ([]*model.File, error) } type QueryResolver interface { Empty(ctx context.Context) (string, error) } type executableSchema 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 "File.content": if e.ComplexityRoot.File.Content == nil { break } return e.ComplexityRoot.File.Content(childComplexity), true case "File.contentType": if e.ComplexityRoot.File.ContentType == nil { break } return e.ComplexityRoot.File.ContentType(childComplexity), true case "File.id": if e.ComplexityRoot.File.ID == nil { break } return e.ComplexityRoot.File.ID(childComplexity), true case "File.name": if e.ComplexityRoot.File.Name == nil { break } return e.ComplexityRoot.File.Name(childComplexity), true case "Mutation.multipleUpload": if e.ComplexityRoot.Mutation.MultipleUpload == nil { break } args, err := ec.field_Mutation_multipleUpload_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Mutation.MultipleUpload(childComplexity, args["files"].([]*graphql.Upload)), true case "Mutation.multipleUploadWithPayload": if e.ComplexityRoot.Mutation.MultipleUploadWithPayload == nil { break } args, err := ec.field_Mutation_multipleUploadWithPayload_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Mutation.MultipleUploadWithPayload(childComplexity, args["req"].([]*model.UploadFile)), true case "Mutation.singleUpload": if e.ComplexityRoot.Mutation.SingleUpload == nil { break } args, err := ec.field_Mutation_singleUpload_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Mutation.SingleUpload(childComplexity, args["file"].(graphql.Upload)), true case "Mutation.singleUploadWithPayload": if e.ComplexityRoot.Mutation.SingleUploadWithPayload == nil { break } args, err := ec.field_Mutation_singleUploadWithPayload_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Mutation.SingleUploadWithPayload(childComplexity, args["req"].(model.UploadFile)), true case "Query.empty": if e.ComplexityRoot.Query.Empty == nil { break } return e.ComplexityRoot.Query.Empty(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.unmarshalInputUploadFile, ) 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(), } } 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_Mutation_multipleUploadWithPayload_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, "req", ec.unmarshalNUploadFile2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐUploadFileᚄ) if err != nil { return nil, err } args["req"] = arg0 return args, nil } func (ec *executionContext) field_Mutation_multipleUpload_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "files", ec.unmarshalNUpload2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUploadᚄ) if err != nil { return nil, err } args["files"] = arg0 return args, nil } func (ec *executionContext) field_Mutation_singleUploadWithPayload_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "req", ec.unmarshalNUploadFile2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐUploadFile) if err != nil { return nil, err } args["req"] = arg0 return args, nil } func (ec *executionContext) field_Mutation_singleUpload_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "file", ec.unmarshalNUpload2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload) if err != nil { return nil, err } args["file"] = arg0 return args, nil } func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]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) _File_id(ctx context.Context, field graphql.CollectedField, obj *model.File) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_File_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, nil, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_File_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "File", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _File_name(ctx context.Context, field graphql.CollectedField, obj *model.File) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_File_name, func(ctx context.Context) (any, error) { return obj.Name, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_File_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "File", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _File_content(ctx context.Context, field graphql.CollectedField, obj *model.File) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_File_content, func(ctx context.Context) (any, error) { return obj.Content, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_File_content(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "File", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _File_contentType(ctx context.Context, field graphql.CollectedField, obj *model.File) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_File_contentType, func(ctx context.Context) (any, error) { return obj.ContentType, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_File_contentType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "File", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Mutation_singleUpload(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Mutation_singleUpload, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Mutation().SingleUpload(ctx, fc.Args["file"].(graphql.Upload)) }, nil, ec.marshalNFile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐFile, true, true, ) } func (ec *executionContext) fieldContext_Mutation_singleUpload(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_File_id(ctx, field) case "name": return ec.fieldContext_File_name(ctx, field) case "content": return ec.fieldContext_File_content(ctx, field) case "contentType": return ec.fieldContext_File_contentType(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type File", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_singleUpload_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Mutation_singleUploadWithPayload(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Mutation_singleUploadWithPayload, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Mutation().SingleUploadWithPayload(ctx, fc.Args["req"].(model.UploadFile)) }, nil, ec.marshalNFile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐFile, true, true, ) } func (ec *executionContext) fieldContext_Mutation_singleUploadWithPayload(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_File_id(ctx, field) case "name": return ec.fieldContext_File_name(ctx, field) case "content": return ec.fieldContext_File_content(ctx, field) case "contentType": return ec.fieldContext_File_contentType(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type File", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_singleUploadWithPayload_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Mutation_multipleUpload(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Mutation_multipleUpload, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Mutation().MultipleUpload(ctx, fc.Args["files"].([]*graphql.Upload)) }, nil, ec.marshalNFile2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐFileᚄ, true, true, ) } func (ec *executionContext) fieldContext_Mutation_multipleUpload(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_File_id(ctx, field) case "name": return ec.fieldContext_File_name(ctx, field) case "content": return ec.fieldContext_File_content(ctx, field) case "contentType": return ec.fieldContext_File_contentType(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type File", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_multipleUpload_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Mutation_multipleUploadWithPayload(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Mutation_multipleUploadWithPayload, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Mutation().MultipleUploadWithPayload(ctx, fc.Args["req"].([]*model.UploadFile)) }, nil, ec.marshalNFile2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐFileᚄ, true, true, ) } func (ec *executionContext) fieldContext_Mutation_multipleUploadWithPayload(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_File_id(ctx, field) case "name": return ec.fieldContext_File_name(ctx, field) case "content": return ec.fieldContext_File_content(ctx, field) case "contentType": return ec.fieldContext_File_contentType(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type File", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_multipleUploadWithPayload_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_empty(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_empty, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Empty(ctx) }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Query_empty(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 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) ___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) unmarshalInputUploadFile(ctx context.Context, obj any) (model.UploadFile, error) { var it model.UploadFile if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"id", "file"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "id": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) data, err := ec.unmarshalNInt2int(ctx, v) if err != nil { return it, err } it.ID = data case "file": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("file")) data, err := ec.unmarshalNUpload2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx, v) if err != nil { return it, err } it.File = data } } return it, nil } // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var fileImplementors = []string{"File"} func (ec *executionContext) _File(ctx context.Context, sel ast.SelectionSet, obj *model.File) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, fileImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("File") case "id": out.Values[i] = ec._File_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "name": out.Values[i] = ec._File_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "content": out.Values[i] = ec._File_content(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "contentType": out.Values[i] = ec._File_contentType(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var mutationImplementors = []string{"Mutation"} func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Mutation", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Mutation") case "singleUpload": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_singleUpload(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } case "singleUploadWithPayload": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_singleUploadWithPayload(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } case "multipleUpload": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_multipleUpload(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } case "multipleUploadWithPayload": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_multipleUploadWithPayload(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "empty": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_empty(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) case "__schema": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": out.Values[i] = ec.___Directive_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "description": out.Values[i] = ec.___Directive_description(ctx, field, obj) case "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) marshalNFile2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐFile(ctx context.Context, sel ast.SelectionSet, v model.File) graphql.Marshaler { return ec._File(ctx, sel, &v) } func (ec *executionContext) marshalNFile2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐFileᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.File) 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.marshalNFile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐFile(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalNFile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐFile(ctx context.Context, sel ast.SelectionSet, v *model.File) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._File(ctx, sel, v) } func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v 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) 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) unmarshalNUpload2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, v any) (graphql.Upload, error) { res, err := graphql.UnmarshalUpload(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNUpload2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, sel ast.SelectionSet, v graphql.Upload) graphql.Marshaler { _ = sel res := graphql.MarshalUpload(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) unmarshalNUpload2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUploadᚄ(ctx context.Context, v any) ([]*graphql.Upload, error) { var vSlice []any vSlice = graphql.CoerceList(v) var err error res := make([]*graphql.Upload, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) res[i], err = ec.unmarshalNUpload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx, vSlice[i]) if err != nil { return nil, err } } return res, nil } func (ec *executionContext) marshalNUpload2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUploadᚄ(ctx context.Context, sel ast.SelectionSet, v []*graphql.Upload) graphql.Marshaler { ret := make(graphql.Array, len(v)) for i := range v { ret[i] = ec.marshalNUpload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx, sel, v[i]) } for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) unmarshalNUpload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, v any) (*graphql.Upload, error) { res, err := graphql.UnmarshalUpload(v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNUpload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, sel ast.SelectionSet, v *graphql.Upload) 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.MarshalUpload(*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) unmarshalNUploadFile2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐUploadFile(ctx context.Context, v any) (model.UploadFile, error) { res, err := ec.unmarshalInputUploadFile(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalNUploadFile2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐUploadFileᚄ(ctx context.Context, v any) ([]*model.UploadFile, error) { var vSlice []any vSlice = graphql.CoerceList(v) var err error res := make([]*model.UploadFile, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) res[i], err = ec.unmarshalNUploadFile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐUploadFile(ctx, vSlice[i]) if err != nil { return nil, err } } return res, nil } func (ec *executionContext) unmarshalNUploadFile2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfileuploadᚋmodelᚐUploadFile(ctx context.Context, v any) (*model.UploadFile, error) { res, err := ec.unmarshalInputUploadFile(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } 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) 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/fileupload/model/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package model import ( "github.com/99designs/gqlgen/graphql" ) // The `File` type, represents the response of uploading a file. type File struct { ID int `json:"id"` Name string `json:"name"` Content string `json:"content"` ContentType string `json:"contentType"` } // The `Mutation` type, represents all updates we can make to our data. type Mutation struct { } // The `Query` type, represents all of the entry points into our object graph. type Query struct { } // The `UploadFile` type, represents the request for uploading a file with certain payload. type UploadFile struct { ID int `json:"id"` File graphql.Upload `json:"file"` } ================================================ FILE: _examples/fileupload/readme.md ================================================ ### fileupload example This server demonstrates how to handle file upload to run this server ```bash go run ./server/server.go ``` and open http://localhost:8087 in your browser ### Single file #### Operations ``` { query: ` mutation($file: Upload!) { singleUpload(file: $file) { id } } `, variables: { file: File // a.txt } } ``` #### cURL request ```shell curl localhost:8087/query \ -F operations='{ "query": "mutation ($file: Upload!) { singleUpload(file: $file) { id, name, content } }", "variables": { "file": null } }' \ -F map='{ "0": ["variables.file"] }' \ -F 0=@./_examples/fileupload./testfiles/a.txt ``` #### Request payload ``` --------------------------e6b2b29561e71173 Content-Disposition: form-data; name="operations" { "query": "mutation ($file: Upload!) { singleUpload(file: $file) { id, name, content } }", "variables": { "file": null } } --------------------------e6b2b29561e71173 Content-Disposition: form-data; name="map" { "0": ["variables.file"] } --------------------------e6b2b29561e71173 Content-Disposition: form-data; name="0"; filename="a.txt" Content-Type: text/plain Alpha file content. --------------------------e6b2b29561e71173-- ``` ### Single file with payload #### Operations ``` { query: ` mutation($file: Upload!) { singleUpload(file: $file) { id } } `, variables: { file: File // a.txt } } ``` #### cURL request ```shell curl localhost:8087/query \ -F operations='{ "query": "mutation ($req: UploadFile!) { singleUploadWithPayload(req: $req) { id, name, content } }", "variables": { "req": {"file": null, "id": 1 } } }' \ -F map='{ "0": ["variables.req.file"] }' \ -F 0=@./_examples/fileupload/testfiles/a.txt ``` #### Request payload ``` --------------------------38752760889d14aa Content-Disposition: form-data; name="operations" { "query": "mutation ($req: UploadFile!) { singleUploadWithPayload(req: $req) { id, name, content } }", "variables": { "req": {"file": null, "id": 1 } } } --------------------------38752760889d14aa Content-Disposition: form-data; name="map" { "0": ["variables.req.file"] } --------------------------38752760889d14aa Content-Disposition: form-data; name="0"; filename="a.txt" Content-Type: text/plain Alpha file content. --------------------------38752760889d14aa-- ``` ### File list #### Operations ``` { query: ` mutation($files: [Upload!]!) { multipleUpload(files: $files) { id } } `, variables: { files: [ File, // b.txt File // c.txt ] } } ``` #### cURL request ``` curl localhost:8087/query \ -F operations='{ "query": "mutation($files: [Upload!]!) { multipleUpload(files: $files) { id, name, content } }", "variables": { "files": [null, null] } }' \ -F map='{ "0": ["variables.files.0"], "1": ["variables.files.1"] }' \ -F 0=@./_examples/fileupload/testfiles/b.txt \ -F 1=@./_examples/fileupload/testfiles/c.txt ``` #### Request payload ``` --------------------------d7aca2a93c3655e0 Content-Disposition: form-data; name="operations" { "query": "mutation($files: [Upload!]!) { multipleUpload(files: $files) { id, name, content } }", "variables": { "files": [null, null] } } --------------------------d7aca2a93c3655e0 Content-Disposition: form-data; name="map" { "0": ["variables.files.0"], "1": ["variables.files.1"] } --------------------------d7aca2a93c3655e0 Content-Disposition: form-data; name="0"; filename="b.txt" Content-Type: text/plain Bravo file content. --------------------------d7aca2a93c3655e0 Content-Disposition: form-data; name="1"; filename="c.txt" Content-Type: text/plain Charlie file content. --------------------------d7aca2a93c3655e0-- ``` ### File list with payload #### Operations ``` { query: ` mutation($req: [UploadFile!]!) multipleUploadWithPayload(req: $req) { id, name, content } } `, variables: { req: [ { id: 1, File, // b.txt }, { id: 2, File, // c.txt } ] } } ``` #### cURL request ``` curl localhost:8087/query \ -F operations='{ "query": "mutation($req: [UploadFile!]!) { multipleUploadWithPayload(req: $req) { id, name, content } }", "variables": { "req": [ { "id": 1, "file": null }, { "id": 2, "file": null } ] } }' \ -F map='{ "0": ["variables.req.0.file"], "1": ["variables.req.1.file"] }' \ -F 0=@./_examples/fileupload/testfiles/b.txt \ -F 1=@./_examples/fileupload/testfiles/c.txt ``` #### Request payload ``` --------------------------65aab09fb49ee66f Content-Disposition: form-data; name="operations" { "query": "mutation($req: [UploadFile!]!) { multipleUploadWithPayload(req: $req) { id, name, content } }", "variables": { "req": [ { "id": 1, "file": null }, { "id": 2, "file": null } ] } } --------------------------65aab09fb49ee66f Content-Disposition: form-data; name="map" { "0": ["variables.req.0.file"], "1": ["variables.req.1.file"] } --------------------------65aab09fb49ee66f Content-Disposition: form-data; name="0"; filename="b.txt" Content-Type: text/plain Bravo file content. --------------------------65aab09fb49ee66f Content-Disposition: form-data; name="1"; filename="c.txt" Content-Type: text/plain Charlie file content. --------------------------65aab09fb49ee66f-- ``` ================================================ FILE: _examples/fileupload/schema.graphql ================================================ "The `Upload` scalar type represents a multipart file upload." scalar Upload "The `File` type, represents the response of uploading a file." type File { id: Int! name: String! content: String! contentType: String! } "The `UploadFile` type, represents the request for uploading a file with certain payload." input UploadFile { id: Int! file: Upload! } "The `Query` type, represents all of the entry points into our object graph." type Query { empty: String! } "The `Mutation` type, represents all updates we can make to our data." type Mutation { singleUpload(file: Upload!): File! singleUploadWithPayload(req: UploadFile!): File! multipleUpload(files: [Upload!]!): [File!]! multipleUploadWithPayload(req: [UploadFile!]!): [File!]! } ================================================ FILE: _examples/fileupload/server/server.go ================================================ package main import ( "context" "errors" "io" "log" "net/http" "github.com/99designs/gqlgen/_examples/fileupload" "github.com/99designs/gqlgen/_examples/fileupload/model" "github.com/99designs/gqlgen/graphql" "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() { http.Handle("/", playground.Handler("File Upload Demo", "/query")) resolver := getResolver() var mb int64 = 1 << 20 srv := handler.New(fileupload.NewExecutableSchema(fileupload.Config{Resolvers: resolver})) srv.AddTransport(transport.POST{}) srv.AddTransport(transport.MultipartForm{ MaxMemory: 32 * mb, MaxUploadSize: 50 * mb, }) srv.Use(extension.Introspection{}) http.Handle("/query", srv) log.Print("connect to http://localhost:8087/ for GraphQL playground") log.Fatal(http.ListenAndServe(":8087", nil)) } func getResolver() *fileupload.Stub { resolver := &fileupload.Stub{} resolver.MutationResolver.SingleUpload = func(ctx context.Context, file graphql.Upload) (*model.File, error) { content, err := io.ReadAll(file.File) if err != nil { return nil, err } return &model.File{ ID: 1, Name: file.Filename, Content: string(content), }, nil } resolver.MutationResolver.SingleUploadWithPayload = func(ctx context.Context, req model.UploadFile) (*model.File, error) { content, err := io.ReadAll(req.File.File) if err != nil { return nil, err } return &model.File{ ID: 1, Name: req.File.Filename, Content: string(content), }, nil } resolver.MutationResolver.MultipleUpload = func(ctx context.Context, files []*graphql.Upload) ([]*model.File, error) { if len(files) == 0 { return nil, errors.New("empty list") } var resp []*model.File for i := range files { content, err := io.ReadAll(files[i].File) if err != nil { return []*model.File{}, err } resp = append(resp, &model.File{ ID: i + 1, Name: files[i].Filename, Content: string(content), }) } return resp, nil } resolver.MutationResolver.MultipleUploadWithPayload = func(ctx context.Context, req []*model.UploadFile) ([]*model.File, error) { if len(req) == 0 { return nil, errors.New("empty list") } var resp []*model.File for i := range req { content, err := io.ReadAll(req[i].File.File) if err != nil { return []*model.File{}, err } resp = append(resp, &model.File{ ID: i + 1, Name: req[i].File.Filename, Content: string(content), }) } return resp, nil } return resolver } ================================================ FILE: _examples/fileupload/stubs.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package fileupload import ( "context" "github.com/99designs/gqlgen/_examples/fileupload/model" "github.com/99designs/gqlgen/graphql" ) type Stub struct { MutationResolver struct { SingleUpload func(ctx context.Context, file graphql.Upload) (*model.File, error) SingleUploadWithPayload func(ctx context.Context, req model.UploadFile) (*model.File, error) MultipleUpload func(ctx context.Context, files []*graphql.Upload) ([]*model.File, error) MultipleUploadWithPayload func(ctx context.Context, req []*model.UploadFile) ([]*model.File, error) } QueryResolver struct { Empty func(ctx context.Context) (string, error) } } func (r *Stub) Mutation() MutationResolver { return &stubMutation{r} } func (r *Stub) Query() QueryResolver { return &stubQuery{r} } type stubMutation struct{ *Stub } func (r *stubMutation) SingleUpload(ctx context.Context, file graphql.Upload) (*model.File, error) { return r.MutationResolver.SingleUpload(ctx, file) } func (r *stubMutation) SingleUploadWithPayload(ctx context.Context, req model.UploadFile) (*model.File, error) { return r.MutationResolver.SingleUploadWithPayload(ctx, req) } func (r *stubMutation) MultipleUpload(ctx context.Context, files []*graphql.Upload) ([]*model.File, error) { return r.MutationResolver.MultipleUpload(ctx, files) } func (r *stubMutation) MultipleUploadWithPayload(ctx context.Context, req []*model.UploadFile) ([]*model.File, error) { return r.MutationResolver.MultipleUploadWithPayload(ctx, req) } type stubQuery struct{ *Stub } func (r *stubQuery) Empty(ctx context.Context) (string, error) { return r.QueryResolver.Empty(ctx) } ================================================ FILE: _examples/fileupload/testfiles/a.txt ================================================ Alpha file content ================================================ FILE: _examples/fileupload/testfiles/b.txt ================================================ Bravo file content ================================================ FILE: _examples/fileupload/testfiles/c.txt ================================================ Charlie file content ================================================ FILE: _examples/go.mod ================================================ module github.com/99designs/gqlgen/_examples go 1.25.0 replace github.com/99designs/gqlgen => ../ require ( github.com/99designs/gqlgen v0.17.86 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.1 github.com/rs/cors v1.11.1 github.com/stretchr/testify v1.11.1 github.com/vektah/dataloaden v0.3.0 github.com/vektah/gqlparser/v2 v2.5.32 golang.org/x/sync v0.20.0 ) require ( github.com/agnivade/levenshtein v1.2.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/logrusorgru/aurora/v4 v4.0.0 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/sosodev/duration v1.4.0 // indirect golang.org/x/mod v0.33.0 // indirect golang.org/x/sys v0.42.0 // indirect golang.org/x/tools v0.42.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) require ( github.com/pkg/errors v0.9.1 // indirect golang.org/x/text v0.34.0 ) replace github.com/gorilla/websocket => github.com/gorilla/websocket v1.5.0 ================================================ FILE: _examples/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.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/trifles v0.0.0-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 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 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/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/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA= github.com/rs/cors v1.11.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= 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.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 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/vektah/dataloaden v0.3.0 h1:ZfVN2QD6swgvp+tDqdH/OIT/wu3Dhu0cus0k5gIZS84= github.com/vektah/dataloaden v0.3.0/go.mod h1:/HUdMve7rvxZma+2ZELQeNh88+003LL7Pf/CZ089j8U= github.com/vektah/gqlparser/v2 v2.5.32 h1:k9QPJd4sEDTL+qB4ncPLflqTJ3MmjB9SrVzJrawpFSc= github.com/vektah/gqlparser/v2 v2.5.32/go.mod h1:c1I28gSOVNzlfc4WuDlqU7voQnsqI6OG2amkBAFmgts= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 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-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 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.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.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 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-20190515012406-7d7faa4812bd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.42.0 h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k= golang.org/x/tools v0.42.0/go.mod h1:Ma6lCIwGZvHK6XtgbswSoWroEkhugApmsXyrUmBhfr0= 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: _examples/large-project-structure/integration/go.mod ================================================ module github.com/99designs/gqlgen/_examples/large-project-structure/integration go 1.25.0 require github.com/99designs/gqlgen/_examples/large-project-structure/main v0.0.0 replace github.com/99designs/gqlgen/_examples/large-project-structure/main => ../main replace github.com/99designs/gqlgen/_examples/large-project-structure/shared => ../shared ================================================ FILE: _examples/large-project-structure/integration/go.sum ================================================ ================================================ FILE: _examples/large-project-structure/integration/integration.go ================================================ package integration import ( "context" "errors" "fmt" "github.com/99designs/gqlgen/_examples/large-project-structure/main/graph/model" ) type Resolver struct{} // Implement the Tezz method that is managed by another team func (r *Resolver) Tezz(ctx context.Context) (*model.Test, error) { // Can do whatever logic is needed... return &model.Test{ID: "external-1"}, nil } func (r *Resolver) GetYaSome( ctx context.Context, input *model.CustomInput, ) ([]*model.CustomZeekIntel, error) { intels := []*model.CustomZeekIntel{} if input.Error != nil && *input.Error { return intels, errors.New("error as requested") } if input.Limit != nil { count := int(*input.Limit) for i := 0; i < count; i++ { czi := &model.CustomZeekIntel{ ID: fmt.Sprintf("%d", i), Name: fmt.Sprintf("external-%d", i), ExtraField: "let other teams resolve", } intels = append(intels, czi) } } return intels, nil } func (r *Resolver) AddIndicator( ctx context.Context, input model.IndicatorInput, ) (*model.Indicator, error) { return &model.Indicator{ ID: "1234", Indicator: input.Indicator, IndicatorType: input.IndicatorType, MetaSource: input.MetaSource, }, nil } ================================================ FILE: _examples/large-project-structure/integration/schema.graphqls ================================================ type Test { id: ID! } type CustomZeekIntel implements ZeekIntel{ id: ID! name: String! extraField: String! } input CustomInput { limit: Int error: Boolean } extend type Query { tezz: Test! getYaSome(input: CustomInput): [CustomZeekIntel!]! } type Indicator { id: ID! indicator: String! indicatorType: String! metaSource: String! } input IndicatorInput { indicator: String! indicatorType: String! metaSource: String! } extend type Mutation { addIndicator(input: IndicatorInput!): Indicator! } ================================================ FILE: _examples/large-project-structure/main/go.mod ================================================ module github.com/99designs/gqlgen/_examples/large-project-structure/main go 1.25.0 require ( github.com/99designs/gqlgen v0.17.78 github.com/99designs/gqlgen/_examples/large-project-structure/integration v0.0.0-00010101000000-000000000000 github.com/99designs/gqlgen/_examples/large-project-structure/shared v0.0.0 github.com/vektah/gqlparser/v2 v2.5.30 ) replace github.com/99designs/gqlgen/_examples/large-project-structure/shared => ../shared replace github.com/99designs/gqlgen/_examples/large-project-structure/integration => ../integration require ( github.com/agnivade/levenshtein v1.2.1 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sosodev/duration v1.3.1 // indirect github.com/urfave/cli/v2 v2.27.7 // indirect github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect golang.org/x/mod v0.26.0 // indirect golang.org/x/sync v0.16.0 // indirect golang.org/x/text v0.27.0 // indirect golang.org/x/tools v0.35.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) ================================================ FILE: _examples/large-project-structure/main/go.sum ================================================ github.com/99designs/gqlgen v0.17.78 h1:bhIi7ynrc3js2O8wu1sMQj1YHPENDt3jQGyifoBvoVI= github.com/99designs/gqlgen v0.17.78/go.mod h1:yI/o31IauG2kX0IsskM4R894OCCG1jXJORhtLQqB7Oc= github.com/PuerkitoBio/goquery v1.10.3 h1:pFYcNSqHxBD06Fpj/KsbStFRsgRATgnf3LeXiUkhzPo= github.com/PuerkitoBio/goquery v1.10.3/go.mod h1:tMUX0zDMHXYlAQk6p35XxQMqMweEKB7iK7iLNd4RH4Y= 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/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo= github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= 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.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs= github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 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/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/sosodev/duration v1.3.1 h1:qtHBDMQ6lvMQsL15g4aopM4HEfOaYuhWBw3NPTtlqq4= github.com/sosodev/duration v1.3.1/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/urfave/cli/v2 v2.27.7 h1:bH59vdhbjLv3LAvIu6gd0usJHgoTTPhCFib8qqOwXYU= github.com/urfave/cli/v2 v2.27.7/go.mod h1:CyNAG/xg+iAOg0N4MPGZqVmv2rCoP267496AOXUZjA4= github.com/vektah/gqlparser/v2 v2.5.30 h1:EqLwGAFLIzt1wpx1IPpY67DwUujF1OfzgEyDsLrN6kE= github.com/vektah/gqlparser/v2 v2.5.30/go.mod h1:D1/VCZtV3LPnQrcPBeR/q5jkSQIPti0uYCP/RI0gIeo= github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4= github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= golang.org/x/mod v0.26.0 h1:EGMPT//Ezu+ylkCijjPc+f4Aih7sZvaAr+O3EHBxvZg= golang.org/x/mod v0.26.0/go.mod h1:/j6NAhSk8iQ723BGAUyoAcn7SlD7s15Dp9Nd/SfeaFQ= golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw= golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= golang.org/x/tools v0.35.0 h1:mBffYraMEf7aa0sB+NuKnuCy8qI/9Bughn8dC2Gu5r0= golang.org/x/tools v0.35.0/go.mod h1:NKdj5HkL/73byiZSJjqJgKn3ep7KjFkBOkR/Hps3VPw= 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: _examples/large-project-structure/main/gqlgen.yml ================================================ # Where are all the schema files located? globs are supported eg src/**/*.graphqls schema: - ../shared/schema.graphqls - graph/*.graphqls - ../integration/schema.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: # computed_requires: true # 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: turn on use ` + "`" + `gqlgen:"fieldName"` + "`" + ` tags in your models # struct_tag: json # Optional: turn on to use []Thing instead of []*Thing # omit_slice_element_pointers: false # Optional: turn on to omit Is() methods to interface and unions # omit_interface_checks: true # Optional: turn on to skip generation of ComplexityRoot struct content and Complexity function # omit_complexity: false # Optional: turn on to not generate any file notice comments in generated files # omit_gqlgen_file_notice: false # Optional: turn on to exclude the gqlgen version in the generated file notice. No effect if `omit_gqlgen_file_notice` is true. # omit_gqlgen_version_in_file_notice: false # Optional: turn on to exclude root models such as Query and Mutation from the generated models file. # omit_root_models: false # Optional: turn on to exclude resolver fields from the generated models file. # omit_resolver_fields: false # Optional: turn off to make struct-type struct fields not use pointers # e.g. type Thing struct { FieldA OtherThing } instead of { FieldA *OtherThing } # struct_fields_always_pointers: true # Optional: turn off to make resolvers return values instead of pointers for structs # resolvers_always_return_pointers: true # Optional: turn on to return pointers instead of values in unmarshalInput # return_pointers_in_unmarshalinput: false # Optional: wrap nullable input fields with Omittable # nullable_input_omittable: true # Optional: set to speed up generation time by not performing a final validation pass. # skip_validation: true # Optional: set to skip running `go mod tidy` when generating server code # skip_mod_tidy: true # 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 # Optional: set build tags that will be used to load packages # go_build_tags: # - private # - enterprise # Optional: set to modify the initialisms regarded for Go names # go_initialisms: # replace_defaults: false # if true, the default initialisms will get dropped in favor of the new ones instead of being added # initialisms: # List of initialisms to for Go names # - 'CC' # - 'BCC' # gqlgen will search for any type names in the schema in these go packages # if they match it will use them, otherwise it will generate them. autobind: # - "github.com/99designs/gqlgen/_examples/large-project-structure/main/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: _examples/large-project-structure/main/graph/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package graph import ( "bytes" "context" "embed" "errors" "fmt" "strconv" "sync" "sync/atomic" "github.com/99designs/gqlgen/_examples/large-project-structure/main/graph/model" "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{ schema: cfg.Schema, resolvers: cfg.Resolvers, directives: cfg.Directives, complexity: cfg.Complexity, } } type Config struct { Schema *ast.Schema Resolvers ResolverRoot Directives DirectiveRoot Complexity ComplexityRoot } type ResolverRoot interface { Mutation() MutationResolver Query() QueryResolver } type DirectiveRoot struct { } type ComplexityRoot struct { CustomZeekIntel struct { ExtraField func(childComplexity int) int ID func(childComplexity int) int Name func(childComplexity int) int } Indicator struct { ID func(childComplexity int) int Indicator func(childComplexity int) int IndicatorType func(childComplexity int) int MetaSource func(childComplexity int) int } Mutation struct { AddIndicator func(childComplexity int, input model.IndicatorInput) int CreateTodo func(childComplexity int, input model.NewTodo) int } Query struct { GetYaSome func(childComplexity int, input *model.CustomInput) int Tezz func(childComplexity int) int Todos func(childComplexity int) int } Test struct { ID func(childComplexity int) int } Todo struct { Done func(childComplexity int) int ID func(childComplexity int) int Text func(childComplexity int) int User func(childComplexity int) int } User struct { ID func(childComplexity int) int Name func(childComplexity int) int } } type MutationResolver interface { CreateTodo(ctx context.Context, input model.NewTodo) (*model.Todo, error) AddIndicator(ctx context.Context, input model.IndicatorInput) (*model.Indicator, error) } type QueryResolver interface { Todos(ctx context.Context) ([]*model.Todo, error) Tezz(ctx context.Context) (*model.Test, error) GetYaSome(ctx context.Context, input *model.CustomInput) ([]*model.CustomZeekIntel, error) } type executableSchema struct { schema *ast.Schema resolvers ResolverRoot directives DirectiveRoot complexity ComplexityRoot } func (e *executableSchema) Schema() *ast.Schema { if e.schema != nil { return e.schema } return parsedSchema } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]any) (int, bool) { ec := executionContext{nil, e, 0, 0, nil} _ = ec switch typeName + "." + field { case "CustomZeekIntel.extraField": if e.complexity.CustomZeekIntel.ExtraField == nil { break } return e.complexity.CustomZeekIntel.ExtraField(childComplexity), true case "CustomZeekIntel.id": if e.complexity.CustomZeekIntel.ID == nil { break } return e.complexity.CustomZeekIntel.ID(childComplexity), true case "CustomZeekIntel.name": if e.complexity.CustomZeekIntel.Name == nil { break } return e.complexity.CustomZeekIntel.Name(childComplexity), true case "Indicator.id": if e.complexity.Indicator.ID == nil { break } return e.complexity.Indicator.ID(childComplexity), true case "Indicator.indicator": if e.complexity.Indicator.Indicator == nil { break } return e.complexity.Indicator.Indicator(childComplexity), true case "Indicator.indicatorType": if e.complexity.Indicator.IndicatorType == nil { break } return e.complexity.Indicator.IndicatorType(childComplexity), true case "Indicator.metaSource": if e.complexity.Indicator.MetaSource == nil { break } return e.complexity.Indicator.MetaSource(childComplexity), true case "Mutation.addIndicator": if e.complexity.Mutation.AddIndicator == nil { break } args, err := ec.field_Mutation_addIndicator_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Mutation.AddIndicator(childComplexity, args["input"].(model.IndicatorInput)), true case "Mutation.createTodo": if e.complexity.Mutation.CreateTodo == nil { break } args, err := ec.field_Mutation_createTodo_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Mutation.CreateTodo(childComplexity, args["input"].(model.NewTodo)), true case "Query.getYaSome": if e.complexity.Query.GetYaSome == nil { break } args, err := ec.field_Query_getYaSome_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Query.GetYaSome(childComplexity, args["input"].(*model.CustomInput)), true case "Query.tezz": if e.complexity.Query.Tezz == nil { break } return e.complexity.Query.Tezz(childComplexity), true case "Query.todos": if e.complexity.Query.Todos == nil { break } return e.complexity.Query.Todos(childComplexity), true case "Test.id": if e.complexity.Test.ID == nil { break } return e.complexity.Test.ID(childComplexity), true case "Todo.done": if e.complexity.Todo.Done == nil { break } return e.complexity.Todo.Done(childComplexity), true case "Todo.id": if e.complexity.Todo.ID == nil { break } return e.complexity.Todo.ID(childComplexity), true case "Todo.text": if e.complexity.Todo.Text == nil { break } return e.complexity.Todo.Text(childComplexity), true case "Todo.user": if e.complexity.Todo.User == nil { break } return e.complexity.Todo.User(childComplexity), true case "User.id": if e.complexity.User.ID == nil { break } return e.complexity.User.ID(childComplexity), true case "User.name": if e.complexity.User.Name == nil { break } return e.complexity.User.Name(childComplexity), true } return 0, false } func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { opCtx := graphql.GetOperationContext(ctx) ec := executionContext{opCtx, e, 0, 0, make(chan graphql.DeferredResult)} inputUnmarshalMap := graphql.BuildUnmarshalerMap( ec.unmarshalInputCustomInput, ec.unmarshalInputIndicatorInput, ec.unmarshalInputNewTodo, ) 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(), } } default: return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) } } type executionContext struct { *graphql.OperationContext *executableSchema deferred int32 pendingDeferred int32 deferredResults chan graphql.DeferredResult } func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { atomic.AddInt32(&ec.pendingDeferred, 1) go func() { ctx := graphql.WithFreshResponseContext(dg.Context) dg.FieldSet.Dispatch(ctx) ds := graphql.DeferredResult{ Path: dg.Path, Label: dg.Label, Result: dg.FieldSet, Errors: graphql.GetErrors(ctx), } // null fields should bubble up if dg.FieldSet.Invalids > 0 { ds.Result = graphql.Null } ec.deferredResults <- ds }() } func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } return introspection.WrapSchema(ec.Schema()), nil } func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil } //go:embed "schema.graphqls" var sourcesFS embed.FS func sourceData(filename string) string { data, err := sourcesFS.ReadFile(filename) if err != nil { panic(fmt.Sprintf("codegen problem: %s not available", filename)) } return string(data) } var sources = []*ast.Source{ {Name: "../../shared/schema.graphqls", Input: `# GraphQL schema example # # https://gqlgen.com/getting-started/ interface ZeekIntel { id: ID! name: String! } `, BuiltIn: false}, {Name: "schema.graphqls", Input: sourceData("schema.graphqls"), BuiltIn: false}, {Name: "../../integration/schema.graphqls", Input: `type Test { id: ID! } type CustomZeekIntel implements ZeekIntel{ id: ID! name: String! extraField: String! } input CustomInput { limit: Int error: Boolean } extend type Query { tezz: Test! getYaSome(input: CustomInput): [CustomZeekIntel!]! } type Indicator { id: ID! indicator: String! indicatorType: String! metaSource: String! } input IndicatorInput { indicator: String! indicatorType: String! metaSource: String! } extend type Mutation { addIndicator(input: IndicatorInput!): Indicator! }`, BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) field_Mutation_addIndicator_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Mutation_addIndicator_argsInput(ctx, rawArgs) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Mutation_addIndicator_argsInput( ctx context.Context, rawArgs map[string]any, ) (model.IndicatorInput, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) if tmp, ok := rawArgs["input"]; ok { return ec.unmarshalNIndicatorInput2githubᚗcomᚋcorelightᚋmainᚋgraphᚋmodelᚐIndicatorInput(ctx, tmp) } var zeroVal model.IndicatorInput return zeroVal, nil } func (ec *executionContext) field_Mutation_createTodo_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Mutation_createTodo_argsInput(ctx, rawArgs) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Mutation_createTodo_argsInput( ctx context.Context, rawArgs map[string]any, ) (model.NewTodo, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) if tmp, ok := rawArgs["input"]; ok { return ec.unmarshalNNewTodo2githubᚗcomᚋcorelightᚋmainᚋgraphᚋmodelᚐNewTodo(ctx, tmp) } var zeroVal model.NewTodo return zeroVal, 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 := ec.field_Query___type_argsName(ctx, rawArgs) if err != nil { return nil, err } args["name"] = arg0 return args, nil } func (ec *executionContext) field_Query___type_argsName( ctx context.Context, rawArgs map[string]any, ) (string, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) if tmp, ok := rawArgs["name"]; ok { return ec.unmarshalNString2string(ctx, tmp) } var zeroVal string return zeroVal, nil } func (ec *executionContext) field_Query_getYaSome_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Query_getYaSome_argsInput(ctx, rawArgs) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Query_getYaSome_argsInput( ctx context.Context, rawArgs map[string]any, ) (*model.CustomInput, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) if tmp, ok := rawArgs["input"]; ok { return ec.unmarshalOCustomInput2ᚖgithubᚗcomᚋcorelightᚋmainᚋgraphᚋmodelᚐCustomInput(ctx, tmp) } var zeroVal *model.CustomInput return zeroVal, 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 := ec.field___Directive_args_argsIncludeDeprecated(ctx, rawArgs) if err != nil { return nil, err } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Directive_args_argsIncludeDeprecated( ctx context.Context, rawArgs map[string]any, ) (*bool, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) if tmp, ok := rawArgs["includeDeprecated"]; ok { return ec.unmarshalOBoolean2ᚖbool(ctx, tmp) } var zeroVal *bool return zeroVal, 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 := ec.field___Field_args_argsIncludeDeprecated(ctx, rawArgs) if err != nil { return nil, err } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Field_args_argsIncludeDeprecated( ctx context.Context, rawArgs map[string]any, ) (*bool, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) if tmp, ok := rawArgs["includeDeprecated"]; ok { return ec.unmarshalOBoolean2ᚖbool(ctx, tmp) } var zeroVal *bool return zeroVal, 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 := ec.field___Type_enumValues_argsIncludeDeprecated(ctx, rawArgs) if err != nil { return nil, err } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Type_enumValues_argsIncludeDeprecated( ctx context.Context, rawArgs map[string]any, ) (bool, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) if tmp, ok := rawArgs["includeDeprecated"]; ok { return ec.unmarshalOBoolean2bool(ctx, tmp) } var zeroVal bool return zeroVal, 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 := ec.field___Type_fields_argsIncludeDeprecated(ctx, rawArgs) if err != nil { return nil, err } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Type_fields_argsIncludeDeprecated( ctx context.Context, rawArgs map[string]any, ) (bool, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) if tmp, ok := rawArgs["includeDeprecated"]; ok { return ec.unmarshalOBoolean2bool(ctx, tmp) } var zeroVal bool return zeroVal, nil } // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _CustomZeekIntel_id(ctx context.Context, field graphql.CollectedField, obj *model.CustomZeekIntel) (ret graphql.Marshaler) { fc, err := ec.fieldContext_CustomZeekIntel_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_CustomZeekIntel_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "CustomZeekIntel", 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) _CustomZeekIntel_name(ctx context.Context, field graphql.CollectedField, obj *model.CustomZeekIntel) (ret graphql.Marshaler) { fc, err := ec.fieldContext_CustomZeekIntel_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_CustomZeekIntel_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "CustomZeekIntel", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _CustomZeekIntel_extraField(ctx context.Context, field graphql.CollectedField, obj *model.CustomZeekIntel) (ret graphql.Marshaler) { fc, err := ec.fieldContext_CustomZeekIntel_extraField(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { 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.ExtraField, nil }) if err != nil { ec.Error(ctx, 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_CustomZeekIntel_extraField(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "CustomZeekIntel", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Indicator_id(ctx context.Context, field graphql.CollectedField, obj *model.Indicator) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Indicator_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_Indicator_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Indicator", 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) _Indicator_indicator(ctx context.Context, field graphql.CollectedField, obj *model.Indicator) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Indicator_indicator(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { 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.Indicator, nil }) if err != nil { ec.Error(ctx, 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_Indicator_indicator(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Indicator", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Indicator_indicatorType(ctx context.Context, field graphql.CollectedField, obj *model.Indicator) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Indicator_indicatorType(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { 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.IndicatorType, nil }) if err != nil { ec.Error(ctx, 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_Indicator_indicatorType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Indicator", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Indicator_metaSource(ctx context.Context, field graphql.CollectedField, obj *model.Indicator) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Indicator_metaSource(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { 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.MetaSource, nil }) if err != nil { ec.Error(ctx, 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_Indicator_metaSource(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Indicator", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Mutation_createTodo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Mutation_createTodo(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Mutation().CreateTodo(rctx, fc.Args["input"].(model.NewTodo)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*model.Todo) fc.Result = res return ec.marshalNTodo2ᚖgithubᚗcomᚋcorelightᚋmainᚋgraphᚋmodelᚐTodo(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Mutation_createTodo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Todo_id(ctx, field) case "text": return ec.fieldContext_Todo_text(ctx, field) case "done": return ec.fieldContext_Todo_done(ctx, field) case "user": return ec.fieldContext_Todo_user(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_createTodo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Mutation_addIndicator(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Mutation_addIndicator(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { 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.Mutation().AddIndicator(rctx, fc.Args["input"].(model.IndicatorInput)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*model.Indicator) fc.Result = res return ec.marshalNIndicator2ᚖgithubᚗcomᚋcorelightᚋmainᚋgraphᚋmodelᚐIndicator(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Mutation_addIndicator(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_Indicator_id(ctx, field) case "indicator": return ec.fieldContext_Indicator_indicator(ctx, field) case "indicatorType": return ec.fieldContext_Indicator_indicatorType(ctx, field) case "metaSource": return ec.fieldContext_Indicator_metaSource(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Indicator", field.Name) }, } defer func() { if 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_addIndicator_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Query_todos(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Todos(rctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]*model.Todo) fc.Result = res return ec.marshalNTodo2ᚕᚖgithubᚗcomᚋcorelightᚋmainᚋgraphᚋmodelᚐTodoᚄ(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Query_todos(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Todo_id(ctx, field) case "text": return ec.fieldContext_Todo_text(ctx, field) case "done": return ec.fieldContext_Todo_done(ctx, field) case "user": return ec.fieldContext_Todo_user(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_tezz(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Query_tezz(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { 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().Tezz(rctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*model.Test) fc.Result = res return ec.marshalNTest2ᚖgithubᚗcomᚋcorelightᚋmainᚋgraphᚋmodelᚐTest(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Query_tezz(_ 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_Test_id(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Test", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_getYaSome(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Query_getYaSome(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { 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().GetYaSome(rctx, fc.Args["input"].(*model.CustomInput)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]*model.CustomZeekIntel) fc.Result = res return ec.marshalNCustomZeekIntel2ᚕᚖgithubᚗcomᚋcorelightᚋmainᚋgraphᚋmodelᚐCustomZeekIntelᚄ(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Query_getYaSome(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_CustomZeekIntel_id(ctx, field) case "name": return ec.fieldContext_CustomZeekIntel_name(ctx, field) case "extraField": return ec.fieldContext_CustomZeekIntel_extraField(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type CustomZeekIntel", field.Name) }, } defer func() { if 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_getYaSome_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Query___type(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (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 "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) { 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(_ 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) _Test_id(ctx context.Context, field graphql.CollectedField, obj *model.Test) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Test_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_Test_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Test", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *model.Todo) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Todo_id(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (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_Todo_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *model.Todo) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Todo_text(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return obj.Text, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_text(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *model.Todo) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Todo_done(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return obj.Done, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_done(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } func (ec *executionContext) _Todo_user(ctx context.Context, field graphql.CollectedField, obj *model.Todo) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Todo_user(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return obj.User, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*model.User) fc.Result = res return ec.marshalNUser2ᚖgithubᚗcomᚋcorelightᚋmainᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_user(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_User_id(ctx, field) case "name": return ec.fieldContext_User_name(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { fc, err := ec.fieldContext_User_id(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { fc, err := ec.fieldContext_User_name(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (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(_ 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(_ 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(_ 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) { 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(_ 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) { 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(_ 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) 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) { 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(_ 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(_ 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(_ 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(_ 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(_ 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(_ 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) 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) { 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(_ 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) { 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(_ 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(_ 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(_ 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(_ 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(_ 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) { 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(_ 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) { fc, err := ec.fieldContext___InputValue_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___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) { fc, err := ec.fieldContext___InputValue_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___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) { 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(_ 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(_ 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) { 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(_ 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) { 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(_ 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) { 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(_ 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) { 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(_ 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) { 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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) { 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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 fc, err } return fc, nil } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { fc, err := ec.fieldContext___Type_interfaces(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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) { 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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) { 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 fc, err } return fc, nil } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { fc, err := ec.fieldContext___Type_inputFields(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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) { 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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) { fc, err := ec.fieldContext___Type_isOneOf(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { 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.IsOneOf(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(bool) fc.Result = res return ec.marshalOBoolean2bool(ctx, field.Selections, res) } 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) unmarshalInputCustomInput(ctx context.Context, obj any) (model.CustomInput, error) { var it model.CustomInput asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"limit", "error"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "limit": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("limit")) data, err := ec.unmarshalOInt2ᚖint32(ctx, v) if err != nil { return it, err } it.Limit = data case "error": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("error")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } it.Error = data } } return it, nil } func (ec *executionContext) unmarshalInputIndicatorInput(ctx context.Context, obj any) (model.IndicatorInput, error) { var it model.IndicatorInput asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"indicator", "indicatorType", "metaSource"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "indicator": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("indicator")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Indicator = data case "indicatorType": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("indicatorType")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.IndicatorType = data case "metaSource": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("metaSource")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.MetaSource = data } } return it, nil } func (ec *executionContext) unmarshalInputNewTodo(ctx context.Context, obj any) (model.NewTodo, error) { var it model.NewTodo asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"text", "userId"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "text": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Text = data case "userId": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userId")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.UserID = data } } return it, nil } // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** func (ec *executionContext) _ZeekIntel(ctx context.Context, sel ast.SelectionSet, obj model.ZeekIntel) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null case model.CustomZeekIntel: return ec._CustomZeekIntel(ctx, sel, &obj) case *model.CustomZeekIntel: if obj == nil { return graphql.Null } return ec._CustomZeekIntel(ctx, sel, obj) default: panic(fmt.Errorf("unexpected type %T", obj)) } } // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var customZeekIntelImplementors = []string{"CustomZeekIntel", "ZeekIntel"} func (ec *executionContext) _CustomZeekIntel(ctx context.Context, sel ast.SelectionSet, obj *model.CustomZeekIntel) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, customZeekIntelImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("CustomZeekIntel") case "id": out.Values[i] = ec._CustomZeekIntel_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "name": out.Values[i] = ec._CustomZeekIntel_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "extraField": out.Values[i] = ec._CustomZeekIntel_extraField(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 indicatorImplementors = []string{"Indicator"} func (ec *executionContext) _Indicator(ctx context.Context, sel ast.SelectionSet, obj *model.Indicator) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, indicatorImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Indicator") case "id": out.Values[i] = ec._Indicator_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "indicator": out.Values[i] = ec._Indicator_indicator(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "indicatorType": out.Values[i] = ec._Indicator_indicatorType(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "metaSource": out.Values[i] = ec._Indicator_metaSource(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 "createTodo": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_createTodo(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } case "addIndicator": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_addIndicator(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.deferred, int32(len(deferred))) for label, dfs := range deferred { ec.processDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "todos": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_todos(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "tezz": field := field innerFunc := func(ctx 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_tezz(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 "getYaSome": field := field innerFunc := func(ctx 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_getYaSome(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 testImplementors = []string{"Test"} func (ec *executionContext) _Test(ctx context.Context, sel ast.SelectionSet, obj *model.Test) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, testImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Test") case "id": out.Values[i] = ec._Test_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.deferred, int32(len(deferred))) for label, dfs := range deferred { ec.processDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var todoImplementors = []string{"Todo"} func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *model.Todo) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, todoImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Todo") case "id": out.Values[i] = ec._Todo_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "text": out.Values[i] = ec._Todo_text(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "done": out.Values[i] = ec._Todo_done(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "user": out.Values[i] = ec._Todo_user(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.deferred, int32(len(deferred))) for label, dfs := range deferred { ec.processDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var userImplementors = []string{"User"} func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *model.User) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("User") case "id": out.Values[i] = ec._User_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "name": out.Values[i] = ec._User_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.deferred, int32(len(deferred))) for label, dfs := range deferred { ec.processDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": out.Values[i] = ec.___Directive_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "description": out.Values[i] = ec.___Directive_description(ctx, field, obj) case "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 { 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) marshalNCustomZeekIntel2ᚕᚖgithubᚗcomᚋcorelightᚋmainᚋgraphᚋmodelᚐCustomZeekIntelᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.CustomZeekIntel) 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.marshalNCustomZeekIntel2ᚖgithubᚗcomᚋcorelightᚋmainᚋgraphᚋmodelᚐCustomZeekIntel(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) marshalNCustomZeekIntel2ᚖgithubᚗcomᚋcorelightᚋmainᚋgraphᚋmodelᚐCustomZeekIntel(ctx context.Context, sel ast.SelectionSet, v *model.CustomZeekIntel) 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._CustomZeekIntel(ctx, sel, v) } 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) marshalNIndicator2githubᚗcomᚋcorelightᚋmainᚋgraphᚋmodelᚐIndicator(ctx context.Context, sel ast.SelectionSet, v model.Indicator) graphql.Marshaler { return ec._Indicator(ctx, sel, &v) } func (ec *executionContext) marshalNIndicator2ᚖgithubᚗcomᚋcorelightᚋmainᚋgraphᚋmodelᚐIndicator(ctx context.Context, sel ast.SelectionSet, v *model.Indicator) 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._Indicator(ctx, sel, v) } func (ec *executionContext) unmarshalNIndicatorInput2githubᚗcomᚋcorelightᚋmainᚋgraphᚋmodelᚐIndicatorInput(ctx context.Context, v any) (model.IndicatorInput, error) { res, err := ec.unmarshalInputIndicatorInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalNNewTodo2githubᚗcomᚋcorelightᚋmainᚋgraphᚋmodelᚐNewTodo(ctx context.Context, v any) (model.NewTodo, error) { res, err := ec.unmarshalInputNewTodo(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } 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) marshalNTest2githubᚗcomᚋcorelightᚋmainᚋgraphᚋmodelᚐTest(ctx context.Context, sel ast.SelectionSet, v model.Test) graphql.Marshaler { return ec._Test(ctx, sel, &v) } func (ec *executionContext) marshalNTest2ᚖgithubᚗcomᚋcorelightᚋmainᚋgraphᚋmodelᚐTest(ctx context.Context, sel ast.SelectionSet, v *model.Test) 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._Test(ctx, sel, v) } func (ec *executionContext) marshalNTodo2githubᚗcomᚋcorelightᚋmainᚋgraphᚋmodelᚐTodo(ctx context.Context, sel ast.SelectionSet, v model.Todo) graphql.Marshaler { return ec._Todo(ctx, sel, &v) } func (ec *executionContext) marshalNTodo2ᚕᚖgithubᚗcomᚋcorelightᚋmainᚋgraphᚋmodelᚐTodoᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.Todo) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 if !isLen1 { wg.Add(len(v)) } for i := range v { i := i fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = nil } }() if !isLen1 { defer wg.Done() } ret[i] = ec.marshalNTodo2ᚖgithubᚗcomᚋcorelightᚋmainᚋgraphᚋmodelᚐTodo(ctx, sel, v[i]) } if isLen1 { f(i) } else { go f(i) } } wg.Wait() for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalNTodo2ᚖgithubᚗcomᚋcorelightᚋmainᚋgraphᚋmodelᚐTodo(ctx context.Context, sel ast.SelectionSet, v *model.Todo) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._Todo(ctx, sel, v) } func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋcorelightᚋmainᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._User(ctx, sel, v) } func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ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 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) unmarshalOCustomInput2ᚖgithubᚗcomᚋcorelightᚋmainᚋgraphᚋmodelᚐCustomInput(ctx context.Context, v any) (*model.CustomInput, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputCustomInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalOInt2ᚖint32(ctx context.Context, v any) (*int32, error) { if v == nil { return nil, nil } res, err := graphql.UnmarshalInt32(v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOInt2ᚖint32(ctx context.Context, sel ast.SelectionSet, v *int32) graphql.Marshaler { if v == nil { return graphql.Null } res := graphql.MarshalInt32(*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) 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: _examples/large-project-structure/main/graph/model/models_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package model type ZeekIntel interface { IsZeekIntel() GetID() string GetName() string } type CustomInput struct { Limit *int32 `json:"limit,omitempty"` Error *bool `json:"error,omitempty"` } type CustomZeekIntel struct { ID string `json:"id"` Name string `json:"name"` ExtraField string `json:"extraField"` } func (CustomZeekIntel) IsZeekIntel() {} func (this CustomZeekIntel) GetID() string { return this.ID } func (this CustomZeekIntel) GetName() string { return this.Name } type Indicator struct { ID string `json:"id"` Indicator string `json:"indicator"` IndicatorType string `json:"indicatorType"` MetaSource string `json:"metaSource"` } type IndicatorInput struct { Indicator string `json:"indicator"` IndicatorType string `json:"indicatorType"` MetaSource string `json:"metaSource"` } type Mutation struct { } type NewTodo struct { Text string `json:"text"` UserID string `json:"userId"` } type Query struct { } type Test struct { ID string `json:"id"` } type Todo struct { ID string `json:"id"` Text string `json:"text"` Done bool `json:"done"` User *User `json:"user"` } type User struct { ID string `json:"id"` Name string `json:"name"` } ================================================ FILE: _examples/large-project-structure/main/graph/resolver.go ================================================ package graph import ( "context" "github.com/99designs/gqlgen/_examples/large-project-structure/main/graph/model" ) // This file will not be regenerated automatically. // // It serves as dependency injection for your app, add any dependencies you require here. // Define an interface for each resolver method type ExternalQueryResolver interface { // Example query resolver Tezz(ctx context.Context) (*model.Test, error) // Example query resolver with args GetYaSome(context.Context, *model.CustomInput) ([]*model.CustomZeekIntel, error) // Example mutation resolver with args AddIndicator(context.Context, model.IndicatorInput) (*model.Indicator, error) } type Resolver struct { ExternalQueryResolver } ================================================ FILE: _examples/large-project-structure/main/graph/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: _examples/large-project-structure/main/graph/schema.resolvers.go ================================================ package graph // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. // Code generated by github.com/99designs/gqlgen version v0.17.70 import ( "context" "fmt" "github.com/99designs/gqlgen/_examples/large-project-structure/main/graph/model" ) // CreateTodo is the resolver for the createTodo field. func (r *mutationResolver) CreateTodo( ctx context.Context, input model.NewTodo, ) (*model.Todo, error) { panic(fmt.Errorf("not implemented: CreateTodo - createTodo")) } // Todos is the resolver for the todos field. func (r *queryResolver) Todos(ctx context.Context) ([]*model.Todo, error) { return []*model.Todo{ { ID: "1", Text: "local todo", }, }, nil } // Mutation returns MutationResolver implementation. func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } // Query returns QueryResolver implementation. func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } type ( mutationResolver struct{ *Resolver } queryResolver struct{ *Resolver } ) ================================================ FILE: _examples/large-project-structure/main/server.go ================================================ package main import ( "log" "net/http" "os" "github.com/vektah/gqlparser/v2/ast" "github.com/99designs/gqlgen/_examples/large-project-structure/integration" "github.com/99designs/gqlgen/_examples/large-project-structure/main/graph" _ "github.com/99designs/gqlgen/_examples/large-project-structure/shared" "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" ) const defaultPort = "8080" func main() { port := os.Getenv("PORT") if port == "" { port = defaultPort } // Create a new executable schema with the composed resolver srv := handler.NewDefaultServer(graph.NewExecutableSchema(graph.Config{ Resolvers: &graph.Resolver{ ExternalQueryResolver: &integration.Resolver{}, // Add other team resolvers here }, })) 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: _examples/large-project-structure/main/tools.go ================================================ //go:build tools package tools import ( _ "github.com/99designs/gqlgen" ) ================================================ FILE: _examples/large-project-structure/shared/go.mod ================================================ module github.com/99designs/gqlgen/_examples/large-project-structure/shared go 1.25.0 ================================================ FILE: _examples/large-project-structure/shared/go.sum ================================================ ================================================ FILE: _examples/large-project-structure/shared/schema.graphqls ================================================ # GraphQL schema example # # https://gqlgen.com/getting-started/ interface ZeekIntel { id: ID! name: String! } ================================================ FILE: _examples/large-project-structure/shared/shared.go ================================================ package shared import "embed" //go:embed "schema.graphqls" var sourcesFS embed.FS ================================================ FILE: _examples/mini-habr-with-subscriptions/Dockerfile ================================================ FROM golang:alpine WORKDIR /app COPY . . RUN go build -o main ./cmd/main.go EXPOSE 8080 CMD ["./main"] ================================================ FILE: _examples/mini-habr-with-subscriptions/README.md ================================================ # 📝 mini-habr-API This project demonstrates how to implement GraphQL subscriptions and cursor-based pagination using gqlgen in a mini API similar to Habr. The implementation follows the official GraphQL documentation specifications and showcases real-time data exchange and efficient data fetching patterns. ## Key GraphQL Features Demonstrated ### GraphQL Subscriptions The project provides a complete implementation of GraphQL subscriptions using WebSockets, allowing clients to receive real-time updates when new comments are added to posts. This follows the GraphQL subscription specification and shows how to: - Set up subscription resolvers in gqlgen - Manage WebSocket connections efficiently - Implement the publish-subscribe pattern for real-time updates - Handle connection lifecycle and cleanup ### Cursor-based Pagination Following GraphQL's Relay Cursor Connections Specification, this project implements efficient cursor-based pagination for comments on posts. This approach: - Provides stable pagination that works reliably with changing datasets - Enables clients to navigate large result sets efficiently - Implements proper pageInfo with hasNextPage and cursor management - Demonstrates how to structure connection types in gqlgen schemas This project implements an API for Ozon similar to Habr. It allows working with posts and comments using GraphQL. The system supports creating posts, adding comments, managing comment enabling/disabling for posts, as well as subscribing to new comment notifications. ## 📡 Subscription System (WebSockets)[1](./graph/subscription.go)[2](./graph/schema.resolvers.go#L317): - **Publish-Subscribe Pattern**: Implementation of Pub/Sub for real-time notifications about new comments, where components interact through a central channel mechanism - **Thread-safe subscription management**: Using mutexes for safe access to the subscriber list in a concurrent environment - **Automatic resource cleanup**: Proper closing of channels and removal of inactive subscribers to prevent memory leaks - **Asynchrony**: Using non-blocking Go channels for data transmission - **Error resistance**: Protection against panics when sending data to closed channels using deferred functions - **Scalability**: Ability to subscribe to events by specific post identifier, providing targeted notification delivery > **Note on patterns**: Unlike the classic Observer pattern, where observers directly register with the observed object, this project implements the Publish-Subscribe pattern, which introduces an intermediate layer (message broker) between publishers and subscribers. This provides a higher degree of decomposition: publishers don't know about specific subscribers, and subscribers don't know about publishers. Subscriptions are grouped by post identifier, which allows implementing event filtering at the broker level. ## 🚀 Project Launch To launch the project, follow these steps: ### Prerequisites - Docker and Docker Compose installed on your system - Git for cloning the repository ### Installation Steps 1. **Clone the repository** ```bash git clone https://github.com/nabishec/ozon_habr_api.git cd ozon_habr_api ``` 2. **Launch in Docker containers** ```bash docker-compose up ``` 3. **Using the API** After launching, open your browser and go to: ``` http://localhost:8080 ``` ### Choosing Data Storage By default, the project uses PostgreSQL for data storage. If you want to use in-memory storage for testing, change the line in the Dockerfile: ``` RUN go build -o main ./cmd/main.go ``` and add the flag [`-s m`](Dockerfile#L7): ``` RUN go build -o main ./cmd/main.go -s m ``` ## 📖 API Documentation Interactive GraphQL playground console is available at: * **http://localhost:8080** ### GraphQL Query Examples
Getting a list of all posts query{ posts{ id title text authorID commentsEnabled createDate } }
Getting a specific post with comments query { post(postID: 1) { id title text comments(first: 5) { edges { node { id text authorID createDate } cursor } pageInfo { hasNextPage endCursor } } } }
Creating a new post mutation { addPost(postInput: { authorID: "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11" title: "New post" text: "Post content" commentsEnabled: true }) { id title createDate } }
Creating a new comment mutation { addComment(commentInput: { authorID: "123e4567-e89b-12d3-a456-426614174000", postID: 1, parentID: 1, # ID of existing comment text: "This is a reply to comment 1" }) { id text parentID } }
Subscribing to new comments subscription { commentAdded(postID: 1) { id text authorID createDate } }
For testing the API, you can use any GraphQL clients, such as Insomnia, Postman, or GraphiQL. ## 📁 Project Structure
Show structure `ozon_habr_api/`
`├── cmd/`
`│ ├── db_connection/`
`│ │ ├──` [`cache.go`](./cmd/db_connection/cache.go) (Redis connection and configuration for caching)
`│ │ └──` [`database.go`](./cmd/db_connection/database.go) (PostgreSQL connection and configuration)
`│ ├── server/`
`│ │ └──` [`server.go`](./cmd/server/server.go) (GraphQL server setup and launch)
`│ └──` [`main.go`](./cmd/main.go) (Main entry point, application setup and launch)
`├── graph/`
`│ ├── model/`
`│ │ └──` [`models_gen.go`](./graph/model/models_gen.go) (Automatically generated GraphQL models)
`│ ├──` [`generated.go`](./graph/generated.go) (Generated GraphQL code (gqlgen))
`│ ├──` [`resolver.go`](./graph/resolver.go) (Main GraphQL resolvers)
`│ ├──` [`schema.graphqls`](./graph/schema.graphqls) (GraphQL schema definition)
`│ ├──` [`schema.resolvers.go`](./graph/schema.resolvers.go) (GraphQL resolvers implementation)
`│ └──` [`subscription.go`](./graph/subscription.go) (Implementation of structures and methods for subscription management)
`├── internal/`
`│ ├── handlers/`
`│ │ ├── comment_mutation/` (Comment mutations logic handlers)
`│ │ │ ├──` [`interface.go`](./internal/handlers/comment_mutation/interface.go) (Interface for comment mutations)
`│ │ │ └──` [`mutations.go`](./internal/handlers/comment_mutation/mutations.go) (Comment mutations implementation)
`│ │ ├── comment_query/` (Comment queries logic handlers)
`│ │ │ ├──` [`interface.go`](./internal/handlers/comment_query/interface.go) (Interface for comment queries)
`│ │ │ └──` [`query.go`](./internal/handlers/comment_query/query.go) (Comment queries implementation)
`│ │ ├── post_mutation/` (Post mutations logic handlers)
`│ │ │ ├──` [`interface.go`](./internal/handlers/post_mutation/interface.go) (Interface for post mutations)
`│ │ │ └──` [`mutations.go`](./internal/handlers/post_mutation/mutations.go) (Post mutations implementation)
`│ │ └── post_query/` (Post queries logic handlers)
`│ │ ├──` [`interface.go`](./internal/handlers/post_query/interface.go) (Interface for post queries)
`│ │ └──` [`query.go`](./internal/handlers/post_query/query.go) (Post queries implementation)
`│ ├── pkg/`
`│ │ ├── cursor/`
`│ │ | └──` [`cursor.go`](./internal/pkg/cursor/cursor.go) (Functions for working with cursors in pagination)
`│ │ └── errs/`
`│ │ └──` [`errors.go`](./internal/pkg/errs/errors.go) (Stores business logic errors)
`│ ├── model/`
`│ │ └──` [`model.go`](./internal/model/model.go) (Internal data models)
`│ └── storage/`
`│ ├── db/` (Implementation of database storage)
`│ │ └──` [`resolvers.go`](./internal/storage/db/resolvers.go) (Implementation of methods for working with PostgreSQL database)
`│ ├── in-memory/` (Implementation of in-memory data storage)
`│ │ └──` [`resolvers.go`](./internal/storage/in-memory/resolvers.go) (Implementation of methods for working with in-memory data)
`│ └──` [`interface.go`](./internal/storage/interface.go) (Interface for data storage (PostgreSQL, in-memory))
`├── migrations/`
`│ └──` [`001_create_tables.up.sql`](./migrations/001_create_tables.up.sql) (SQL script for database migration (creating tables))
`├──` [`.env`](./.env) (Environment variables file (database settings, Redis, etc.))
`├──` [`.gitignore`](./.gitignore) (List of ignored files and directories for Git)
`├──` [`docker-compose.yml`](./docker-compose.yml) (Docker Compose configuration for launching the application and dependencies)
`├──` [`Dockerfile`](./Dockerfile) (Instructions for building Docker image)
`├──` [`go.mod`](./go.mod) (Go dependencies file)
`├──` [`go.sum`](./go.sum) (Go dependencies checksums file)
`├──` [`gqlgen.yml`](./gqlgen.yml) (Configuration file for gqlgen)
`├──` [`LICENSE`](./LICENSE) (Project license)
`└──` [`README.md`](./README.md) (Project description file)
## 🔧 Stack: * Go 1.25 * GraphQL (gqlgen) * PostgreSQL 17 * Redis 9 * Docker & Docker Compose ================================================ FILE: _examples/mini-habr-with-subscriptions/cmd/db_connection/cache.go ================================================ package dbconnection import ( "context" "fmt" "os" "strconv" "time" "github.com/go-redis/cache/v9" "github.com/redis/go-redis/v9" "github.com/rs/zerolog/log" ) type Cache struct { Cache *cache.Cache } const DefaultRedisDB = 0 func NewCacheConnection() (*Cache, error) { const op = "cmd.dbconnection.NewCacheConnection()" redisDB, err := strconv.Atoi(os.Getenv("REDIS_DB")) if err != nil { log.Warn().Msg("Failed get redis db from env") redisDB = DefaultRedisDB } ring := redis.NewRing(&redis.RingOptions{ Addrs: map[string]string{ "shard1": os.Getenv("REDIS_HOST1") + ":" + os.Getenv("REDIS_PORT1"), "shard2": os.Getenv("REDIS_HOST2") + ":" + os.Getenv("REDIS_PORT2"), }, DB: redisDB, Password: os.Getenv("REDIS_PASSWORD"), MaxRetries: 3, DialTimeout: 50 * time.Millisecond, }) if err := ring.Ping(context.TODO()).Err(); err != nil { return nil, fmt.Errorf("failed to ping Redis: %v", err) } cache := &Cache{ Cache: cache.New(&cache.Options{ Redis: ring, LocalCache: cache.NewTinyLFU(1000, time.Minute), }), } return cache, nil } ================================================ FILE: _examples/mini-habr-with-subscriptions/cmd/db_connection/database.go ================================================ package dbconnection import ( "fmt" "os" _ "github.com/jackc/pgx/v5/stdlib" "github.com/jmoiron/sqlx" "github.com/rs/zerolog/log" ) type DatabaseConnection struct { dataSourceName string DB *sqlx.DB } func NewDatabaseConnection() (*DatabaseConnection, error) { log.Info().Msg("Connecting to database") log.Debug().Msg("Init database") var databaseCon DatabaseConnection config, err := newDSN() if err != nil { return nil, err } err = databaseCon.connectDatabase(config) if err != nil { return nil, err } log.Info().Msg("Сonnection to the database is successful") return &databaseCon, err } func (db *DatabaseConnection) connectDatabase(config string) error { const op = "cmd.dbconnection.connectDatabase()" log.Debug().Msg("Attempting to connect to database") db.dataSourceName = config var connectError error db.DB, connectError = sqlx.Connect("pgx", db.dataSourceName) if connectError != nil { return fmt.Errorf("%s:%w", op, connectError) } log.Debug().Msg("Connecting to database is successfully") return nil } func (db *DatabaseConnection) PingDatabase() error { const op = "cmd.dbconnection.PingDatabase()" log.Info().Msg("Attempting to ping Database") if db.DB == nil { return fmt.Errorf("%s:%s", op, "database isn`t established") } pingError := db.DB.Ping() if pingError != nil { return fmt.Errorf("%s:%w", op, pingError) } log.Info().Msg("Ping database is successful") return nil } func (db *DatabaseConnection) CloseDatabase() error { const op = "cmd.dbconnection.CloseDatabase()" log.Info().Msg("Attempting to close database") closingError := db.DB.Close() if closingError != nil { return fmt.Errorf("%s:%w", op, closingError) } log.Info().Msg("Successful closing of database") return nil } func newDSN() (string, error) { const op = "cmd.dbconnection.NewDSN()" log.Debug().Msg("Reading dsn from env variables") dsnProtocol := os.Getenv("DB_PROTOCOL") if dsnProtocol == "" { return "", fmt.Errorf("%s:%s", op, "DB_PROTOCOL isn't set") } dsnUserName := os.Getenv("DB_USER") if dsnUserName == "" { return "", fmt.Errorf("%s:%s", op, "DB_USER isn't set") } dsnPassword := os.Getenv("DB_PASSWORD") if dsnPassword == "" { return "", fmt.Errorf("%s:%s", op, "DB_PASSWORD isn't set") } dsnHost := os.Getenv("DB_HOST") if dsnHost == "" { return "", fmt.Errorf("%s:%s", op, "DB_HOST isn't set") } dsnPort := os.Getenv("DB_PORT") if dsnPort == "" { return "", fmt.Errorf("%s:%s", op, "DB_PORT isn't set") } dsnDBName := os.Getenv("DB_NAME") if dsnDBName == "" { return "", fmt.Errorf("%s:%s", op, "DB_NAME isn't set") } dsnOptions := os.Getenv("DB_OPTIONS") if dsnOptions == "" { return "", fmt.Errorf("%s:%s", op, "DB_OPTIONS isn't set") } dsn := dsnProtocol + "://" + dsnUserName + ":" + dsnPassword + "@" + dsnHost + ":" + dsnPort + "/" + dsnDBName + "?" + dsnOptions log.Debug().Msgf("Reading dsn is successful dsn = %s", dsn) return dsn, nil } ================================================ FILE: _examples/mini-habr-with-subscriptions/cmd/main.go ================================================ package main import ( "flag" "fmt" "os" dbconnection "github.com/gqlgen/_examples/mini-habr-with-subscriptions/cmd/db_connection" "github.com/gqlgen/_examples/mini-habr-with-subscriptions/cmd/server" "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/storage" "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/storage/db" inmemory "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/storage/in-memory" "github.com/joho/godotenv" "github.com/rs/zerolog" "github.com/rs/zerolog/log" ) func main() { zerolog.TimeFieldFormat = zerolog.TimeFormatUnix debug := flag.Bool("d", false, "set log level to debug") easyReading := flag.Bool("r", false, "set console writer") var storageType string const defaultStorageType = "postgres" flag.StringVar( &storageType, "storage", "postgres", "set storage type 'memory'('m') or postgres('p')", ) flag.StringVar(&storageType, "s", "p", "set storage type 'memory'('m') or postgres('p')") flag.Parse() zerolog.SetGlobalLevel(zerolog.InfoLevel) if *debug { zerolog.SetGlobalLevel(zerolog.DebugLevel) } // for reading logs if *easyReading { log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}) } switch storageType { case "postgres": case "memory": case "p": storageType = "postgres" case "m": storageType = "memory" default: log.Error().Msg("Storage type is incorrectly selected") storageType = defaultStorageType log.Warn().Msg("Default storage type is selected for further work") } // load enviroments err := loadEnv() if err != nil { log.Error().Err(err).Msg("Don't found configuration") os.Exit(1) } // creating storage according to the settings of the parameters storage, err := createStorage(storageType) if err != nil { log.Error().Err(err).Msg("Failed init storage") os.Exit(1) } server.RunServer(storage) // TODO: RUN SERVER } func loadEnv() error { const op = "cmd.loadEnv()" err := godotenv.Load(".env") if err != nil { return fmt.Errorf("%s:%s", op, "failed load env file") } return nil } func createStorage(storageType string) (storage.StorageImp, error) { if storageType == "memory" { return createResolverInMemory() } else { return createResolverWithDB() } } func createResolverInMemory() (storage.StorageImp, error) { const op = "cmd.createResolverInMemory()" inmemory := inmemory.NewStorage() return inmemory, nil } func createResolverWithDB() (storage.StorageImp, error) { const op = "cmd.createDBStorage()" dbConn, err := dbconnection.NewDatabaseConnection() if err != nil { return nil, fmt.Errorf("%s:%w", op, err) } cacheConn, err := dbconnection.NewCacheConnection() if err != nil { return nil, fmt.Errorf("%s:%w", op, err) } storage := db.NewStorage(dbConn.DB, cacheConn.Cache) return storage, nil } ================================================ FILE: _examples/mini-habr-with-subscriptions/cmd/server/server.go ================================================ package server import ( "net/http" "os" "slices" "time" "github.com/gorilla/websocket" "github.com/gqlgen/_examples/mini-habr-with-subscriptions/graph" commentmutation "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/handlers/comment_mutation" commentquery "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/handlers/comment_query" postmutation "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/handlers/post_mutation" postquery "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/handlers/post_query" "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/storage" "github.com/rs/zerolog/log" "github.com/vektah/gqlparser/v2/ast" "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" ) const defaultPort = "8080" func RunServer(storage storage.StorageImp) { op := "cmd.server.RunServer()" port := os.Getenv("SERVER_PORT") if port == "" { port = defaultPort } postMutation := postmutation.NewPostMutation(storage) postQuery := postquery.NewPostQuery(storage) commentMutation := commentmutation.NewCommentMutation(storage) commentQuery := commentquery.NewCommentQuery(storage) resolver := graph.NewResolver(postMutation, postQuery, commentMutation, commentQuery) c := graph.Config{Resolvers: resolver} countComplexityComment := func(childComplexity int, first *int32, after *string) int { return int(*first) * childComplexity } countComplexityReplice := func(childComplexity int, first *int32, after *string) int { return int(*first) * childComplexity } c.Complexity.Post.Comments = countComplexityComment c.Complexity.Comment.Replies = countComplexityReplice srv := handler.New(graph.NewExecutableSchema(c)) srv.AddTransport(transport.Options{}) srv.AddTransport(transport.Websocket{ KeepAlivePingInterval: 10 * time.Second, Upgrader: websocket.Upgrader{ CheckOrigin: func(r *http.Request) bool { origin := r.Header.Get("Origin") if origin == "" || origin == r.Header.Get("Host") { return true } return slices.Contains( []string{"http://localhost:8080", "https://ozonhabr.com"}, origin, ) }, }, }) srv.AddTransport(transport.GET{}) srv.AddTransport(transport.POST{}) srv.AddTransport(transport.GRAPHQL{}) srv.SetQueryCache(lru.New[*ast.QueryDocument](1000)) srv.Use(extension.Introspection{}) srv.Use(extension.AutomaticPersistedQuery{ Cache: lru.New[string](100), }) srv.Use( extension.FixedComplexityLimit(450), ) // limit to +- 50 commments because there is not much space on web page http.Handle("/", playground.Handler("GraphQL playground", "/query")) http.Handle("/query", srv) log.Info().Msgf("Connect to http://localhost:%s/ for GraphQL playground", port) if err := http.ListenAndServe(":"+port, nil); err != nil { log.Error().AnErr(op, err).Msg("Failed to start server") os.Exit(1) } log.Error().Msg("Unknown error") } ================================================ FILE: _examples/mini-habr-with-subscriptions/docker-compose.yml ================================================ services: redis1: image: redis:latest container_name: redis1 ports: - 127.0.0.1:6379:6379 environment: REDIS_PASSWORD: ${REDIS_PASSWORD} restart: always healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 5s timeout: 5s retries: 5 volumes: - redis_data1:/data networks: - mini_habr_network env_file: - .env redis2: image: redis:latest container_name: redis2 ports: - 127.0.0.1:6380:6379 environment: REDIS_PASSWORD: ${REDIS_PASSWORD} restart: always healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 5s timeout: 5s retries: 5 volumes: - redis_data2:/data networks: - mini_habr_network env_file: - .env db: image: postgres:17 container_name: mini_habr_db environment: POSTGRES_USER: ${DB_USER} POSTGRES_PASSWORD: ${DB_PASSWORD} POSTGRES_DB: ${DB_NAME} ports: - 127.0.0.1:5432:5432 healthcheck: test: ["CMD-SHELL", "pg_isready -U ${DB_USER} -d ${DB_NAME}"] interval: 5s timeout: 5s retries: 5 start_period: 10s volumes: - db_data:/var/lib/postgresql/data networks: - mini_habr_network env_file: - .env app: build: context: . dockerfile: Dockerfile container_name: mini_habr_app environment: REDIS_HOST1: redis1 REDIS_PORT1: ${REDIS_PORT1} REDIS_HOST2: redis2 REDIS_PORT2: ${REDIS_PORT2} REDIS_DB: ${REDIS_DB} TIMEOIUT: ${TIMEOUT} IDLE_TIMEOUT: ${IDLE_TIMEOUT} SERVER_PORT: ${SERVER_PORT} DB_PROTOCOL: ${DB_PROTOCOL} DB_HOST: ${DB_HOST} DB_PORT: ${DB_PORT} DB_USER: ${DB_USER} DB_NAME: ${DB_NAME} DB_PASSWORD: ${DB_PASSWORD} DB_OPTIONS: ${DB_OPTIONS} depends_on: db: condition: service_healthy redis1: condition: service_healthy redis2: condition: service_healthy ports: - 127.0.0.1:8080:8080 networks: - mini_habr_network env_file: - .env migrate: image: ghcr.io/kukymbr/goose-docker:latest container_name: mini_habr_migrate environment: GOOSE_DRIVER: ${DB_PROTOCOL} GOOSE_DBSTRING: "host=${DB_HOST} port=${DB_PORT} user=${DB_USER} dbname=${DB_NAME} password=${DB_PASSWORD} ${DB_OPTIONS}" depends_on: db: condition: service_healthy volumes: - ./migrations:/migrations networks: - mini_habr_network env_file: - .env volumes: redis_data1: redis_data2: db_data: networks: mini_habr_network: driver: bridge ================================================ FILE: _examples/mini-habr-with-subscriptions/go.mod ================================================ module github.com/gqlgen/_examples/mini-habr-with-subscriptions go 1.25.0 require ( github.com/99designs/gqlgen v0.17.66 github.com/go-redis/cache/v9 v9.0.0 github.com/google/uuid v1.6.0 github.com/gorilla/websocket v1.5.0 github.com/jackc/pgx/v5 v5.7.4 github.com/jmoiron/sqlx v1.4.0 github.com/joho/godotenv v1.5.1 github.com/redis/go-redis/v9 v9.7.3 github.com/rs/zerolog v1.33.0 github.com/vektah/gqlparser/v2 v2.5.22 ) require ( github.com/agnivade/levenshtein v1.2.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect github.com/jackc/puddle/v2 v2.2.2 // indirect github.com/klauspost/compress v1.13.6 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sosodev/duration v1.3.1 // indirect github.com/urfave/cli/v2 v2.27.5 // indirect github.com/vmihailenco/go-tinylfu v0.2.2 // indirect github.com/vmihailenco/msgpack/v5 v5.3.4 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect golang.org/x/crypto v0.45.0 // indirect golang.org/x/mod v0.29.0 // indirect golang.org/x/sync v0.18.0 // indirect golang.org/x/sys v0.38.0 // indirect golang.org/x/text v0.31.0 // indirect golang.org/x/tools v0.38.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) ================================================ FILE: _examples/mini-habr-with-subscriptions/go.sum ================================================ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= github.com/99designs/gqlgen v0.17.66 h1:2/SRc+h3115fCOZeTtsqrB5R5gTGm+8qCAwcrZa+CXA= github.com/99designs/gqlgen v0.17.66/go.mod h1:gucrb5jK5pgCKzAGuOMMVU9C8PnReecHEHd2UxLQwCg= github.com/PuerkitoBio/goquery v1.9.3 h1:mpJr/ikUA9/GNJB/DBZcGeFDXUtosHRyRrwh7KGdTG0= github.com/PuerkitoBio/goquery v1.9.3/go.mod h1:1ndLHPdTz+DyQPICCWYlYQMPl0oXZj0G6D4LCYA6u4U= github.com/agnivade/levenshtein v1.2.0 h1:U9L4IOT0Y3i0TIlUIDJ7rVUziKi/zPbrJGaFrtYH3SY= github.com/agnivade/levenshtein v1.2.0/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.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss= github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU= 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/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c= github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc= github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= 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/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-redis/cache/v9 v9.0.0 h1:0thdtFo0xJi0/WXbRVu8B066z8OvVymXTJGaXrVWnN0= github.com/go-redis/cache/v9 v9.0.0/go.mod h1:cMwi1N8ASBOufbIvk7cdXe2PbPjK/WMRL95FFHWsSgI= github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y= github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs= github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= 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/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo= github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= github.com/jackc/pgx/v5 v5.7.4 h1:9wKznZrhWa2QiHL+NjTSPP6yjl3451BX3imWDnokYlg= github.com/jackc/pgx/v5 v5.7.4/go.mod h1:ncY89UGWxg82EykZUwSpUKEfccBGGYq1xjrOpsbsfGQ= github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo= github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o= github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= 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.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= 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/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= github.com/onsi/ginkgo/v2 v2.1.4/go.mod h1:um6tUpWM/cxCK3/FK8BXqEiUMUwRgSM4JXG47RKZmLU= github.com/onsi/ginkgo/v2 v2.1.6/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7AG4VIk= github.com/onsi/ginkgo/v2 v2.3.0/go.mod h1:Eew0uilEqZmIEZr8JrvYlvOM7Rr6xzTmMV8AyFNU9d0= github.com/onsi/ginkgo/v2 v2.4.0/go.mod h1:iHkDK1fKGcBoEHT5W7YBq4RFWaQulw+caOMkAt4OrFo= github.com/onsi/ginkgo/v2 v2.5.0/go.mod h1:Luc4sArBICYCS8THh8v3i3i5CuSZO+RaQRaJoeNwomw= github.com/onsi/ginkgo/v2 v2.7.0/go.mod h1:yjiuMwPokqY1XauOgju45q3sJt6VzQ/Fict1LFVcsAo= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= github.com/onsi/gomega v1.20.1/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo= github.com/onsi/gomega v1.21.1/go.mod h1:iYAIXgPSaDHak0LCMA+AWBpIKBr8WZicMxnE8luStNc= github.com/onsi/gomega v1.22.1/go.mod h1:x6n7VNe4hw0vkyYUM4mjIXx3JbLiPaBPNgB7PRQ1tuM= github.com/onsi/gomega v1.24.0/go.mod h1:Z/NWtiqwBrwUt4/2loMmHL63EDLnYHmVbuBpDr2vQAg= github.com/onsi/gomega v1.24.1/go.mod h1:3AOiACssS3/MajrniINInwbfOOtfZvplPzuRSmvt1jM= github.com/onsi/gomega v1.25.0 h1:Vw7br2PCDYijJHSfBOWhov+8cAnUf8MfMaIOV323l6Y= github.com/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/redis/go-redis/v9 v9.0.0-rc.4/go.mod h1:Vo3EsyWnicKnSKCA7HhgnvnyA74wOA69Cd2Meli5mmA= github.com/redis/go-redis/v9 v9.7.3 h1:YpPyAayJV+XErNsatSElgRZZVCwXX9QzkKYNvO7x0wM= github.com/redis/go-redis/v9 v9.7.3/go.mod h1:bGUrSggJ9X9GUmZpZNEOQKaANxSGgOEBRltRTZHSvrA= github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/sosodev/duration v1.3.1 h1:qtHBDMQ6lvMQsL15g4aopM4HEfOaYuhWBw3NPTtlqq4= github.com/sosodev/duration v1.3.1/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w= github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ= github.com/vektah/gqlparser/v2 v2.5.22 h1:yaaeJ0fu+nv1vUMW0Hl+aS1eiv1vMfapBNjpffAda1I= github.com/vektah/gqlparser/v2 v2.5.22/go.mod h1:xMl+ta8a5M1Yo1A1Iwt/k7gSpscwSnHZdw7tfhEGfTM= github.com/vmihailenco/go-tinylfu v0.2.2 h1:H1eiG6HM36iniK6+21n9LLpzx1G9R3DJa2UjUjbynsI= github.com/vmihailenco/go-tinylfu v0.2.2/go.mod h1:CutYi2Q9puTxfcolkliPq4npPuofg9N9t8JVrjzwa3Q= github.com/vmihailenco/msgpack/v5 v5.3.4 h1:qMKAwOV+meBw2Y8k9cVwAy7qErtYCwBzZ2ellBfvnqc= github.com/vmihailenco/msgpack/v5 v5.3.4/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4= github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q= golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA= golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/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.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I= golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= 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.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= 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.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ= golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ= golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= ================================================ FILE: _examples/mini-habr-with-subscriptions/gqlgen.yml ================================================ # Where are all the schema files located? globs are supported eg src/**/*.graphqls schema: - graph/*.graphqls # Where should the generated server code go? exec: 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: # computed_requires: true # 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: turn on use ` + "`" + `gqlgen:"fieldName"` + "`" + ` tags in your models # struct_tag: json # Optional: turn on to use []Thing instead of []*Thing # omit_slice_element_pointers: false # Optional: turn on to omit Is() methods to interface and unions # omit_interface_checks: true # Optional: turn on to skip generation of ComplexityRoot struct content and Complexity function # omit_complexity: false # Optional: turn on to not generate any file notice comments in generated files # omit_gqlgen_file_notice: false # Optional: turn on to exclude the gqlgen version in the generated file notice. No effect if `omit_gqlgen_file_notice` is true. # omit_gqlgen_version_in_file_notice: false # Optional: turn on to exclude root models such as Query and Mutation from the generated models file. # omit_root_models: false # Optional: turn on to exclude resolver fields from the generated models file. # omit_resolver_fields: false # Optional: turn off to make struct-type struct fields not use pointers # e.g. type Thing struct { FieldA OtherThing } instead of { FieldA *OtherThing } # struct_fields_always_pointers: true # Optional: turn off to make resolvers return values instead of pointers for structs # resolvers_always_return_pointers: true # Optional: turn on to return pointers instead of values in unmarshalInput # return_pointers_in_unmarshalinput: false # Optional: wrap nullable input fields with Omittable # nullable_input_omittable: true # Optional: set to speed up generation time by not performing a final validation pass. # skip_validation: true # Optional: set to skip running `go mod tidy` when generating server code # skip_mod_tidy: true # 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 # Optional: set build tags that will be used to load packages # go_build_tags: # - private # - enterprise # Optional: set to modify the initialisms regarded for Go names # go_initialisms: # replace_defaults: false # if true, the default initialisms will get dropped in favor of the new ones instead of being added # initialisms: # List of initialisms to for Go names # - 'CC' # - 'BCC' # gqlgen will search for any type names in the schema in these go packages # if they match it will use them, otherwise it will generate them. autobind: # - "github.com/nabishec/ozon_habr_api/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.Int64 ================================================ FILE: _examples/mini-habr-with-subscriptions/graph/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package graph import ( "bytes" "context" "embed" "errors" "fmt" "io" "strconv" "sync" "sync/atomic" "time" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" "github.com/google/uuid" "github.com/gqlgen/_examples/mini-habr-with-subscriptions/graph/model" gqlparser "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { return &executableSchema{ 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 { Comment() CommentResolver Mutation() MutationResolver Post() PostResolver Query() QueryResolver Subscription() SubscriptionResolver } type DirectiveRoot struct { } type ComplexityRoot struct { Comment struct { AuthorID func(childComplexity int) int CreateDate func(childComplexity int) int ID func(childComplexity int) int ParentID func(childComplexity int) int PostID func(childComplexity int) int Replies func(childComplexity int, first *int32, after *string) int Text func(childComplexity int) int } CommentConnection struct { Edges func(childComplexity int) int PageInfo func(childComplexity int) int } CommentEdge struct { Cursor func(childComplexity int) int Node func(childComplexity int) int } Mutation struct { AddComment func(childComplexity int, commentInput model.NewComment) int AddPost func(childComplexity int, postInput model.NewPost) int UpdateEnableComment func(childComplexity int, postID int64, authorID uuid.UUID, commentsEnabled bool) int } PageInfo struct { EndCursor func(childComplexity int) int HasNextPage func(childComplexity int) int } Post struct { AuthorID func(childComplexity int) int Comments func(childComplexity int, first *int32, after *string) int CommentsEnabled func(childComplexity int) int CreateDate func(childComplexity int) int ID func(childComplexity int) int Text func(childComplexity int) int Title func(childComplexity int) int } Query struct { Post func(childComplexity int, postID int64) int Posts func(childComplexity int) int } Subscription struct { CommentAdded func(childComplexity int, postID int64) int } } type CommentResolver interface { Replies(ctx context.Context, obj *model.Comment, first *int32, after *string) (*model.CommentConnection, error) } type MutationResolver interface { AddPost(ctx context.Context, postInput model.NewPost) (*model.Post, error) AddComment(ctx context.Context, commentInput model.NewComment) (*model.Comment, error) UpdateEnableComment(ctx context.Context, postID int64, authorID uuid.UUID, commentsEnabled bool) (*model.Post, error) } type PostResolver interface { Comments(ctx context.Context, obj *model.Post, first *int32, after *string) (*model.CommentConnection, error) } type QueryResolver interface { Posts(ctx context.Context) ([]*model.Post, error) Post(ctx context.Context, postID int64) (*model.Post, error) } type SubscriptionResolver interface { CommentAdded(ctx context.Context, postID int64) (<-chan *model.Comment, error) } type executableSchema struct { schema *ast.Schema resolvers ResolverRoot directives DirectiveRoot complexity ComplexityRoot } func (e *executableSchema) Schema() *ast.Schema { if e.schema != nil { return e.schema } return parsedSchema } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]any) (int, bool) { ec := executionContext{nil, e, 0, 0, nil} _ = ec switch typeName + "." + field { case "Comment.authorID": if e.complexity.Comment.AuthorID == nil { break } return e.complexity.Comment.AuthorID(childComplexity), true case "Comment.createDate": if e.complexity.Comment.CreateDate == nil { break } return e.complexity.Comment.CreateDate(childComplexity), true case "Comment.id": if e.complexity.Comment.ID == nil { break } return e.complexity.Comment.ID(childComplexity), true case "Comment.parentID": if e.complexity.Comment.ParentID == nil { break } return e.complexity.Comment.ParentID(childComplexity), true case "Comment.postID": if e.complexity.Comment.PostID == nil { break } return e.complexity.Comment.PostID(childComplexity), true case "Comment.replies": if e.complexity.Comment.Replies == nil { break } args, err := ec.field_Comment_replies_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Comment.Replies(childComplexity, args["first"].(*int32), args["after"].(*string)), true case "Comment.text": if e.complexity.Comment.Text == nil { break } return e.complexity.Comment.Text(childComplexity), true case "CommentConnection.edges": if e.complexity.CommentConnection.Edges == nil { break } return e.complexity.CommentConnection.Edges(childComplexity), true case "CommentConnection.pageInfo": if e.complexity.CommentConnection.PageInfo == nil { break } return e.complexity.CommentConnection.PageInfo(childComplexity), true case "CommentEdge.cursor": if e.complexity.CommentEdge.Cursor == nil { break } return e.complexity.CommentEdge.Cursor(childComplexity), true case "CommentEdge.node": if e.complexity.CommentEdge.Node == nil { break } return e.complexity.CommentEdge.Node(childComplexity), true case "Mutation.addComment": if e.complexity.Mutation.AddComment == nil { break } args, err := ec.field_Mutation_addComment_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Mutation.AddComment(childComplexity, args["commentInput"].(model.NewComment)), true case "Mutation.addPost": if e.complexity.Mutation.AddPost == nil { break } args, err := ec.field_Mutation_addPost_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Mutation.AddPost(childComplexity, args["postInput"].(model.NewPost)), true case "Mutation.updateEnableComment": if e.complexity.Mutation.UpdateEnableComment == nil { break } args, err := ec.field_Mutation_updateEnableComment_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Mutation.UpdateEnableComment(childComplexity, args["postID"].(int64), args["authorID"].(uuid.UUID), args["commentsEnabled"].(bool)), true case "PageInfo.endCursor": if e.complexity.PageInfo.EndCursor == nil { break } return e.complexity.PageInfo.EndCursor(childComplexity), true case "PageInfo.hasNextPage": if e.complexity.PageInfo.HasNextPage == nil { break } return e.complexity.PageInfo.HasNextPage(childComplexity), true case "Post.authorID": if e.complexity.Post.AuthorID == nil { break } return e.complexity.Post.AuthorID(childComplexity), true case "Post.comments": if e.complexity.Post.Comments == nil { break } args, err := ec.field_Post_comments_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Post.Comments(childComplexity, args["first"].(*int32), args["after"].(*string)), true case "Post.commentsEnabled": if e.complexity.Post.CommentsEnabled == nil { break } return e.complexity.Post.CommentsEnabled(childComplexity), true case "Post.createDate": if e.complexity.Post.CreateDate == nil { break } return e.complexity.Post.CreateDate(childComplexity), true case "Post.id": if e.complexity.Post.ID == nil { break } return e.complexity.Post.ID(childComplexity), true case "Post.text": if e.complexity.Post.Text == nil { break } return e.complexity.Post.Text(childComplexity), true case "Post.title": if e.complexity.Post.Title == nil { break } return e.complexity.Post.Title(childComplexity), true case "Query.post": if e.complexity.Query.Post == nil { break } args, err := ec.field_Query_post_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Query.Post(childComplexity, args["postID"].(int64)), true case "Query.posts": if e.complexity.Query.Posts == nil { break } return e.complexity.Query.Posts(childComplexity), true case "Subscription.commentAdded": if e.complexity.Subscription.CommentAdded == nil { break } args, err := ec.field_Subscription_commentAdded_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Subscription.CommentAdded(childComplexity, args["postID"].(int64)), 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( ec.unmarshalInputNewComment, ec.unmarshalInputNewPost, ) 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._Subscription(ctx, opCtx.Operation.SelectionSet) var buf bytes.Buffer return func(ctx context.Context) *graphql.Response { buf.Reset() data := next(ctx) if data == nil { return nil } data.MarshalGQL(&buf) return &graphql.Response{ Data: buf.Bytes(), } } default: return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) } } type executionContext struct { *graphql.OperationContext *executableSchema deferred int32 pendingDeferred int32 deferredResults chan graphql.DeferredResult } func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { atomic.AddInt32(&ec.pendingDeferred, 1) go func() { ctx := graphql.WithFreshResponseContext(dg.Context) dg.FieldSet.Dispatch(ctx) ds := graphql.DeferredResult{ Path: dg.Path, Label: dg.Label, Result: dg.FieldSet, Errors: graphql.GetErrors(ctx), } // null fields should bubble up if dg.FieldSet.Invalids > 0 { ds.Result = graphql.Null } ec.deferredResults <- ds }() } func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } return introspection.WrapSchema(ec.Schema()), nil } func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil } //go:embed "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_Comment_replies_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Comment_replies_argsFirst(ctx, rawArgs) if err != nil { return nil, err } args["first"] = arg0 arg1, err := ec.field_Comment_replies_argsAfter(ctx, rawArgs) if err != nil { return nil, err } args["after"] = arg1 return args, nil } func (ec *executionContext) field_Comment_replies_argsFirst( ctx context.Context, rawArgs map[string]any, ) (*int32, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) if tmp, ok := rawArgs["first"]; ok { return ec.unmarshalOInt2ᚖint32(ctx, tmp) } var zeroVal *int32 return zeroVal, nil } func (ec *executionContext) field_Comment_replies_argsAfter( ctx context.Context, rawArgs map[string]any, ) (*string, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) if tmp, ok := rawArgs["after"]; ok { return ec.unmarshalOString2ᚖstring(ctx, tmp) } var zeroVal *string return zeroVal, nil } func (ec *executionContext) field_Mutation_addComment_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Mutation_addComment_argsCommentInput(ctx, rawArgs) if err != nil { return nil, err } args["commentInput"] = arg0 return args, nil } func (ec *executionContext) field_Mutation_addComment_argsCommentInput( ctx context.Context, rawArgs map[string]any, ) (model.NewComment, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("commentInput")) if tmp, ok := rawArgs["commentInput"]; ok { return ec.unmarshalNNewComment2githubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐNewComment(ctx, tmp) } var zeroVal model.NewComment return zeroVal, nil } func (ec *executionContext) field_Mutation_addPost_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Mutation_addPost_argsPostInput(ctx, rawArgs) if err != nil { return nil, err } args["postInput"] = arg0 return args, nil } func (ec *executionContext) field_Mutation_addPost_argsPostInput( ctx context.Context, rawArgs map[string]any, ) (model.NewPost, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("postInput")) if tmp, ok := rawArgs["postInput"]; ok { return ec.unmarshalNNewPost2githubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐNewPost(ctx, tmp) } var zeroVal model.NewPost return zeroVal, nil } func (ec *executionContext) field_Mutation_updateEnableComment_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Mutation_updateEnableComment_argsPostID(ctx, rawArgs) if err != nil { return nil, err } args["postID"] = arg0 arg1, err := ec.field_Mutation_updateEnableComment_argsAuthorID(ctx, rawArgs) if err != nil { return nil, err } args["authorID"] = arg1 arg2, err := ec.field_Mutation_updateEnableComment_argsCommentsEnabled(ctx, rawArgs) if err != nil { return nil, err } args["commentsEnabled"] = arg2 return args, nil } func (ec *executionContext) field_Mutation_updateEnableComment_argsPostID( ctx context.Context, rawArgs map[string]any, ) (int64, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("postID")) if tmp, ok := rawArgs["postID"]; ok { return ec.unmarshalNInt642int64(ctx, tmp) } var zeroVal int64 return zeroVal, nil } func (ec *executionContext) field_Mutation_updateEnableComment_argsAuthorID( ctx context.Context, rawArgs map[string]any, ) (uuid.UUID, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("authorID")) if tmp, ok := rawArgs["authorID"]; ok { return ec.unmarshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, tmp) } var zeroVal uuid.UUID return zeroVal, nil } func (ec *executionContext) field_Mutation_updateEnableComment_argsCommentsEnabled( ctx context.Context, rawArgs map[string]any, ) (bool, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("commentsEnabled")) if tmp, ok := rawArgs["commentsEnabled"]; ok { return ec.unmarshalNBoolean2bool(ctx, tmp) } var zeroVal bool return zeroVal, nil } func (ec *executionContext) field_Post_comments_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Post_comments_argsFirst(ctx, rawArgs) if err != nil { return nil, err } args["first"] = arg0 arg1, err := ec.field_Post_comments_argsAfter(ctx, rawArgs) if err != nil { return nil, err } args["after"] = arg1 return args, nil } func (ec *executionContext) field_Post_comments_argsFirst( ctx context.Context, rawArgs map[string]any, ) (*int32, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) if tmp, ok := rawArgs["first"]; ok { return ec.unmarshalOInt2ᚖint32(ctx, tmp) } var zeroVal *int32 return zeroVal, nil } func (ec *executionContext) field_Post_comments_argsAfter( ctx context.Context, rawArgs map[string]any, ) (*string, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) if tmp, ok := rawArgs["after"]; ok { return ec.unmarshalOString2ᚖstring(ctx, tmp) } var zeroVal *string return zeroVal, 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 := ec.field_Query___type_argsName(ctx, rawArgs) if err != nil { return nil, err } args["name"] = arg0 return args, nil } func (ec *executionContext) field_Query___type_argsName( ctx context.Context, rawArgs map[string]any, ) (string, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) if tmp, ok := rawArgs["name"]; ok { return ec.unmarshalNString2string(ctx, tmp) } var zeroVal string return zeroVal, nil } func (ec *executionContext) field_Query_post_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Query_post_argsPostID(ctx, rawArgs) if err != nil { return nil, err } args["postID"] = arg0 return args, nil } func (ec *executionContext) field_Query_post_argsPostID( ctx context.Context, rawArgs map[string]any, ) (int64, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("postID")) if tmp, ok := rawArgs["postID"]; ok { return ec.unmarshalNInt642int64(ctx, tmp) } var zeroVal int64 return zeroVal, nil } func (ec *executionContext) field_Subscription_commentAdded_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Subscription_commentAdded_argsPostID(ctx, rawArgs) if err != nil { return nil, err } args["postID"] = arg0 return args, nil } func (ec *executionContext) field_Subscription_commentAdded_argsPostID( ctx context.Context, rawArgs map[string]any, ) (int64, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("postID")) if tmp, ok := rawArgs["postID"]; ok { return ec.unmarshalNInt642int64(ctx, tmp) } var zeroVal int64 return zeroVal, 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 := ec.field___Directive_args_argsIncludeDeprecated(ctx, rawArgs) if err != nil { return nil, err } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Directive_args_argsIncludeDeprecated( ctx context.Context, rawArgs map[string]any, ) (*bool, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) if tmp, ok := rawArgs["includeDeprecated"]; ok { return ec.unmarshalOBoolean2ᚖbool(ctx, tmp) } var zeroVal *bool return zeroVal, 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 := ec.field___Field_args_argsIncludeDeprecated(ctx, rawArgs) if err != nil { return nil, err } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Field_args_argsIncludeDeprecated( ctx context.Context, rawArgs map[string]any, ) (*bool, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) if tmp, ok := rawArgs["includeDeprecated"]; ok { return ec.unmarshalOBoolean2ᚖbool(ctx, tmp) } var zeroVal *bool return zeroVal, 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 := ec.field___Type_enumValues_argsIncludeDeprecated(ctx, rawArgs) if err != nil { return nil, err } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Type_enumValues_argsIncludeDeprecated( ctx context.Context, rawArgs map[string]any, ) (bool, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) if tmp, ok := rawArgs["includeDeprecated"]; ok { return ec.unmarshalOBoolean2bool(ctx, tmp) } var zeroVal bool return zeroVal, 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 := ec.field___Type_fields_argsIncludeDeprecated(ctx, rawArgs) if err != nil { return nil, err } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Type_fields_argsIncludeDeprecated( ctx context.Context, rawArgs map[string]any, ) (bool, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) if tmp, ok := rawArgs["includeDeprecated"]; ok { return ec.unmarshalOBoolean2bool(ctx, tmp) } var zeroVal bool return zeroVal, nil } // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _Comment_id(ctx context.Context, field graphql.CollectedField, obj *model.Comment) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Comment_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.(int64) fc.Result = res return ec.marshalNInt642int64(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Comment_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Comment", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int64 does not have child fields") }, } return fc, nil } func (ec *executionContext) _Comment_authorID(ctx context.Context, field graphql.CollectedField, obj *model.Comment) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Comment_authorID(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { 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.AuthorID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(uuid.UUID) fc.Result = res return ec.marshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Comment_authorID(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Comment", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type UUID does not have child fields") }, } return fc, nil } func (ec *executionContext) _Comment_postID(ctx context.Context, field graphql.CollectedField, obj *model.Comment) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Comment_postID(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { 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.PostID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int64) fc.Result = res return ec.marshalNInt642int64(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Comment_postID(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Comment", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int64 does not have child fields") }, } return fc, nil } func (ec *executionContext) _Comment_parentID(ctx context.Context, field graphql.CollectedField, obj *model.Comment) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Comment_parentID(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { 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.ParentID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*int64) fc.Result = res return ec.marshalOInt642ᚖint64(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Comment_parentID(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Comment", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int64 does not have child fields") }, } return fc, nil } func (ec *executionContext) _Comment_text(ctx context.Context, field graphql.CollectedField, obj *model.Comment) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Comment_text(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return obj.Text, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Comment_text(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Comment", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Comment_createDate(ctx context.Context, field graphql.CollectedField, obj *model.Comment) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Comment_createDate(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { 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.CreateDate, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(time.Time) fc.Result = res return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Comment_createDate(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Comment", 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) _Comment_replies(ctx context.Context, field graphql.CollectedField, obj *model.Comment) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Comment_replies(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { 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.Comment().Replies(rctx, obj, fc.Args["first"].(*int32), fc.Args["after"].(*string)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*model.CommentConnection) fc.Result = res return ec.marshalOCommentConnection2ᚖgithubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐCommentConnection(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Comment_replies(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Comment", 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_CommentConnection_edges(ctx, field) case "pageInfo": return ec.fieldContext_CommentConnection_pageInfo(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type CommentConnection", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Comment_replies_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _CommentConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.CommentConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_CommentConnection_edges(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return obj.Edges, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]*model.CommentEdge) fc.Result = res return ec.marshalNCommentEdge2ᚕᚖgithubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐCommentEdgeᚄ(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_CommentConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "CommentConnection", 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_CommentEdge_node(ctx, field) case "cursor": return ec.fieldContext_CommentEdge_cursor(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type CommentEdge", field.Name) }, } return fc, nil } func (ec *executionContext) _CommentConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.CommentConnection) (ret graphql.Marshaler) { fc, err := ec.fieldContext_CommentConnection_pageInfo(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return obj.PageInfo, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*model.PageInfo) fc.Result = res return ec.marshalNPageInfo2ᚖgithubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐPageInfo(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_CommentConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "CommentConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "endCursor": return ec.fieldContext_PageInfo_endCursor(ctx, field) case "hasNextPage": return ec.fieldContext_PageInfo_hasNextPage(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } func (ec *executionContext) _CommentEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.CommentEdge) (ret graphql.Marshaler) { fc, err := ec.fieldContext_CommentEdge_node(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return obj.Node, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*model.Comment) fc.Result = res return ec.marshalNComment2ᚖgithubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐComment(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_CommentEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "CommentEdge", 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_Comment_id(ctx, field) case "authorID": return ec.fieldContext_Comment_authorID(ctx, field) case "postID": return ec.fieldContext_Comment_postID(ctx, field) case "parentID": return ec.fieldContext_Comment_parentID(ctx, field) case "text": return ec.fieldContext_Comment_text(ctx, field) case "createDate": return ec.fieldContext_Comment_createDate(ctx, field) case "replies": return ec.fieldContext_Comment_replies(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Comment", field.Name) }, } return fc, nil } func (ec *executionContext) _CommentEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.CommentEdge) (ret graphql.Marshaler) { fc, err := ec.fieldContext_CommentEdge_cursor(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return obj.Cursor, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_CommentEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "CommentEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Mutation_addPost(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Mutation_addPost(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { 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.Mutation().AddPost(rctx, fc.Args["postInput"].(model.NewPost)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*model.Post) fc.Result = res return ec.marshalNPost2ᚖgithubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐPost(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Mutation_addPost(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_Post_id(ctx, field) case "authorID": return ec.fieldContext_Post_authorID(ctx, field) case "title": return ec.fieldContext_Post_title(ctx, field) case "text": return ec.fieldContext_Post_text(ctx, field) case "commentsEnabled": return ec.fieldContext_Post_commentsEnabled(ctx, field) case "comments": return ec.fieldContext_Post_comments(ctx, field) case "createDate": return ec.fieldContext_Post_createDate(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Post", field.Name) }, } defer func() { if 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_addPost_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Mutation_addComment(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Mutation_addComment(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { 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.Mutation().AddComment(rctx, fc.Args["commentInput"].(model.NewComment)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*model.Comment) fc.Result = res return ec.marshalNComment2ᚖgithubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐComment(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Mutation_addComment(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_Comment_id(ctx, field) case "authorID": return ec.fieldContext_Comment_authorID(ctx, field) case "postID": return ec.fieldContext_Comment_postID(ctx, field) case "parentID": return ec.fieldContext_Comment_parentID(ctx, field) case "text": return ec.fieldContext_Comment_text(ctx, field) case "createDate": return ec.fieldContext_Comment_createDate(ctx, field) case "replies": return ec.fieldContext_Comment_replies(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Comment", field.Name) }, } defer func() { if 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_addComment_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Mutation_updateEnableComment(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Mutation_updateEnableComment(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { 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.Mutation().UpdateEnableComment(rctx, fc.Args["postID"].(int64), fc.Args["authorID"].(uuid.UUID), fc.Args["commentsEnabled"].(bool)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*model.Post) fc.Result = res return ec.marshalNPost2ᚖgithubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐPost(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Mutation_updateEnableComment(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_Post_id(ctx, field) case "authorID": return ec.fieldContext_Post_authorID(ctx, field) case "title": return ec.fieldContext_Post_title(ctx, field) case "text": return ec.fieldContext_Post_text(ctx, field) case "commentsEnabled": return ec.fieldContext_Post_commentsEnabled(ctx, field) case "comments": return ec.fieldContext_Post_comments(ctx, field) case "createDate": return ec.fieldContext_Post_createDate(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Post", field.Name) }, } defer func() { if 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_updateEnableComment_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *model.PageInfo) (ret graphql.Marshaler) { fc, err := ec.fieldContext_PageInfo_endCursor(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return obj.EndCursor, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*string) fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_PageInfo_endCursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PageInfo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *model.PageInfo) (ret graphql.Marshaler) { fc, err := ec.fieldContext_PageInfo_hasNextPage(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return obj.HasNextPage, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_PageInfo_hasNextPage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PageInfo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } func (ec *executionContext) _Post_id(ctx context.Context, field graphql.CollectedField, obj *model.Post) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Post_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.(int64) fc.Result = res return ec.marshalNInt642int64(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Post_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: http.MethodPost, Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int64 does not have child fields") }, } return fc, nil } func (ec *executionContext) _Post_authorID(ctx context.Context, field graphql.CollectedField, obj *model.Post) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Post_authorID(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { 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.AuthorID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(uuid.UUID) fc.Result = res return ec.marshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Post_authorID(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: http.MethodPost, Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type UUID does not have child fields") }, } return fc, nil } func (ec *executionContext) _Post_title(ctx context.Context, field graphql.CollectedField, obj *model.Post) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Post_title(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return obj.Title, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Post_title(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: http.MethodPost, Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Post_text(ctx context.Context, field graphql.CollectedField, obj *model.Post) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Post_text(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return obj.Text, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Post_text(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: http.MethodPost, Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Post_commentsEnabled(ctx context.Context, field graphql.CollectedField, obj *model.Post) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Post_commentsEnabled(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { 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.CommentsEnabled, nil }) if err != nil { ec.Error(ctx, 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_Post_commentsEnabled(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: http.MethodPost, 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) _Post_comments(ctx context.Context, field graphql.CollectedField, obj *model.Post) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Post_comments(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { 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.Post().Comments(rctx, obj, fc.Args["first"].(*int32), fc.Args["after"].(*string)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*model.CommentConnection) fc.Result = res return ec.marshalOCommentConnection2ᚖgithubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐCommentConnection(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Post_comments(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: http.MethodPost, 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_CommentConnection_edges(ctx, field) case "pageInfo": return ec.fieldContext_CommentConnection_pageInfo(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type CommentConnection", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Post_comments_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Post_createDate(ctx context.Context, field graphql.CollectedField, obj *model.Post) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Post_createDate(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { 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.CreateDate, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(time.Time) fc.Result = res return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Post_createDate(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: http.MethodPost, 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) _Query_posts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Query_posts(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { 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().Posts(rctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]*model.Post) fc.Result = res return ec.marshalNPost2ᚕᚖgithubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐPostᚄ(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Query_posts(_ 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_Post_id(ctx, field) case "authorID": return ec.fieldContext_Post_authorID(ctx, field) case "title": return ec.fieldContext_Post_title(ctx, field) case "text": return ec.fieldContext_Post_text(ctx, field) case "commentsEnabled": return ec.fieldContext_Post_commentsEnabled(ctx, field) case "comments": return ec.fieldContext_Post_comments(ctx, field) case "createDate": return ec.fieldContext_Post_createDate(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Post", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_post(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Query_post(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Post(rctx, fc.Args["postID"].(int64)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*model.Post) fc.Result = res return ec.marshalOPost2ᚖgithubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐPost(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Query_post(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_Post_id(ctx, field) case "authorID": return ec.fieldContext_Post_authorID(ctx, field) case "title": return ec.fieldContext_Post_title(ctx, field) case "text": return ec.fieldContext_Post_text(ctx, field) case "commentsEnabled": return ec.fieldContext_Post_commentsEnabled(ctx, field) case "comments": return ec.fieldContext_Post_comments(ctx, field) case "createDate": return ec.fieldContext_Post_createDate(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Post", field.Name) }, } defer func() { if 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_post_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Query___type(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (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) 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) { 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(_ 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_commentAdded(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { fc, err := ec.fieldContext_Subscription_commentAdded(ctx, field) if err != nil { return nil } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = nil } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Subscription().CommentAdded(rctx, fc.Args["postID"].(int64)) }) if err != nil { ec.Error(ctx, err) return nil } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return nil } return func(ctx context.Context) graphql.Marshaler { select { case res, ok := <-resTmp.(<-chan *model.Comment): if !ok { return nil } return graphql.WriterFunc(func(w io.Writer) { w.Write([]byte{'{'}) graphql.MarshalString(field.Alias).MarshalGQL(w) w.Write([]byte{':'}) ec.marshalNComment2ᚖgithubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐComment(ctx, field.Selections, res).MarshalGQL(w) w.Write([]byte{'}'}) }) case <-ctx.Done(): return nil } } } func (ec *executionContext) fieldContext_Subscription_commentAdded(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_Comment_id(ctx, field) case "authorID": return ec.fieldContext_Comment_authorID(ctx, field) case "postID": return ec.fieldContext_Comment_postID(ctx, field) case "parentID": return ec.fieldContext_Comment_parentID(ctx, field) case "text": return ec.fieldContext_Comment_text(ctx, field) case "createDate": return ec.fieldContext_Comment_createDate(ctx, field) case "replies": return ec.fieldContext_Comment_replies(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Comment", field.Name) }, } defer func() { if 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_commentAdded_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { fc, err := ec.fieldContext___Directive_name(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (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(_ 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(_ 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(_ 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) 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) ___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(_ 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(_ 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(_ 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(_ 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(_ 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(_ 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(_ 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) 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) { 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(_ 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) 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) { 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(_ 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(_ 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(_ 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(_ 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(_ 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) 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) { 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(_ 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) { fc, err := ec.fieldContext___InputValue_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___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) { fc, err := ec.fieldContext___InputValue_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___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) { 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(_ 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(_ 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) 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) { 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(_ 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) 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) { 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(_ 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) 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) { 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(_ 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) 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) { 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(_ 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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 fc, err } return fc, nil } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { fc, err := ec.fieldContext___Type_interfaces(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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) 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) { 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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) 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) { 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 fc, err } return fc, nil } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { fc, err := ec.fieldContext___Type_inputFields(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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) { 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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) 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_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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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_isOneOf(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { fc, err := ec.fieldContext___Type_isOneOf(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { 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.IsOneOf(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(bool) fc.Result = res return ec.marshalOBoolean2bool(ctx, field.Selections, res) } 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) unmarshalInputNewComment(ctx context.Context, obj any) (model.NewComment, error) { var it model.NewComment asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"authorID", "postID", "parentID", "text"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "authorID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("authorID")) data, err := ec.unmarshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.AuthorID = data case "postID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("postID")) data, err := ec.unmarshalNInt642int64(ctx, v) if err != nil { return it, err } it.PostID = data case "parentID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parentID")) data, err := ec.unmarshalOInt642ᚖint64(ctx, v) if err != nil { return it, err } it.ParentID = data case "text": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Text = data } } return it, nil } func (ec *executionContext) unmarshalInputNewPost(ctx context.Context, obj any) (model.NewPost, error) { var it model.NewPost asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"authorID", "title", "text", "commentsEnabled"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "authorID": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("authorID")) data, err := ec.unmarshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.AuthorID = data case "title": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("title")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Title = data case "text": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Text = data case "commentsEnabled": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("commentsEnabled")) data, err := ec.unmarshalNBoolean2bool(ctx, v) if err != nil { return it, err } it.CommentsEnabled = data } } return it, nil } // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var commentImplementors = []string{"Comment"} func (ec *executionContext) _Comment(ctx context.Context, sel ast.SelectionSet, obj *model.Comment) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, commentImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Comment") case "id": out.Values[i] = ec._Comment_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "authorID": out.Values[i] = ec._Comment_authorID(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "postID": out.Values[i] = ec._Comment_postID(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "parentID": out.Values[i] = ec._Comment_parentID(ctx, field, obj) case "text": out.Values[i] = ec._Comment_text(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "createDate": out.Values[i] = ec._Comment_createDate(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "replies": 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._Comment_replies(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 commentConnectionImplementors = []string{"CommentConnection"} func (ec *executionContext) _CommentConnection(ctx context.Context, sel ast.SelectionSet, obj *model.CommentConnection) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, commentConnectionImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("CommentConnection") case "edges": out.Values[i] = ec._CommentConnection_edges(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "pageInfo": out.Values[i] = ec._CommentConnection_pageInfo(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 commentEdgeImplementors = []string{"CommentEdge"} func (ec *executionContext) _CommentEdge(ctx context.Context, sel ast.SelectionSet, obj *model.CommentEdge) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, commentEdgeImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("CommentEdge") case "node": out.Values[i] = ec._CommentEdge_node(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "cursor": out.Values[i] = ec._CommentEdge_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 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 "addPost": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_addPost(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } case "addComment": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_addComment(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } case "updateEnableComment": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_updateEnableComment(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 pageInfoImplementors = []string{"PageInfo"} func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *model.PageInfo) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, pageInfoImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("PageInfo") case "endCursor": out.Values[i] = ec._PageInfo_endCursor(ctx, field, obj) case "hasNextPage": out.Values[i] = ec._PageInfo_hasNextPage(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.deferred, int32(len(deferred))) for label, dfs := range deferred { ec.processDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var postImplementors = []string{http.MethodPost} func (ec *executionContext) _Post(ctx context.Context, sel ast.SelectionSet, obj *model.Post) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, postImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString(http.MethodPost) case "id": out.Values[i] = ec._Post_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "authorID": out.Values[i] = ec._Post_authorID(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "title": out.Values[i] = ec._Post_title(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "text": out.Values[i] = ec._Post_text(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "commentsEnabled": out.Values[i] = ec._Post_commentsEnabled(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "comments": 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._Post_comments(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 "createDate": out.Values[i] = ec._Post_createDate(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 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 "posts": field := field innerFunc := func(ctx 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_posts(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 http.MethodPost: 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_post(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) case "__schema": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.deferred, int32(len(deferred))) for label, dfs := range deferred { ec.processDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var subscriptionImplementors = []string{"Subscription"} func (ec *executionContext) _Subscription(ctx context.Context, sel ast.SelectionSet) func(ctx context.Context) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, subscriptionImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Subscription", }) if len(fields) != 1 { ec.Errorf(ctx, "must subscribe to exactly one stream") return nil } switch fields[0].Name { case "commentAdded": return ec._Subscription_commentAdded(ctx, fields[0]) default: panic("unknown field " + strconv.Quote(fields[0].Name)) } } var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": out.Values[i] = ec.___Directive_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "description": out.Values[i] = ec.___Directive_description(ctx, field, obj) case "locations": out.Values[i] = ec.___Directive_locations(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "args": out.Values[i] = ec.___Directive_args(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "isRepeatable": out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.deferred, int32(len(deferred))) for label, dfs := range deferred { ec.processDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__EnumValue") case "name": out.Values[i] = ec.___EnumValue_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "description": out.Values[i] = ec.___EnumValue_description(ctx, field, obj) case "isDeprecated": out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "deprecationReason": out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.deferred, int32(len(deferred))) for label, dfs := range deferred { ec.processDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Field") case "name": out.Values[i] = ec.___Field_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "description": out.Values[i] = ec.___Field_description(ctx, field, obj) case "args": out.Values[i] = ec.___Field_args(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "type": out.Values[i] = ec.___Field_type(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "isDeprecated": out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "deprecationReason": out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.deferred, int32(len(deferred))) for label, dfs := range deferred { ec.processDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__InputValue") case "name": out.Values[i] = ec.___InputValue_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "description": out.Values[i] = ec.___InputValue_description(ctx, field, obj) case "type": out.Values[i] = ec.___InputValue_type(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "defaultValue": out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) 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 "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) 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 { 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) marshalNComment2githubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐComment(ctx context.Context, sel ast.SelectionSet, v model.Comment) graphql.Marshaler { return ec._Comment(ctx, sel, &v) } func (ec *executionContext) marshalNComment2ᚖgithubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐComment(ctx context.Context, sel ast.SelectionSet, v *model.Comment) 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._Comment(ctx, sel, v) } func (ec *executionContext) marshalNCommentEdge2ᚕᚖgithubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐCommentEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.CommentEdge) 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.marshalNCommentEdge2ᚖgithubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐCommentEdge(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) marshalNCommentEdge2ᚖgithubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐCommentEdge(ctx context.Context, sel ast.SelectionSet, v *model.CommentEdge) 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._CommentEdge(ctx, sel, v) } func (ec *executionContext) unmarshalNInt642int64(ctx context.Context, v any) (int64, error) { res, err := graphql.UnmarshalInt64(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNInt642int64(ctx context.Context, sel ast.SelectionSet, v int64) graphql.Marshaler { res := graphql.MarshalInt64(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } } return res } func (ec *executionContext) unmarshalNNewComment2githubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐNewComment(ctx context.Context, v any) (model.NewComment, error) { res, err := ec.unmarshalInputNewComment(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalNNewPost2githubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐNewPost(ctx context.Context, v any) (model.NewPost, error) { res, err := ec.unmarshalInputNewPost(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNPageInfo2ᚖgithubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐPageInfo(ctx context.Context, sel ast.SelectionSet, v *model.PageInfo) 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._PageInfo(ctx, sel, v) } func (ec *executionContext) marshalNPost2githubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐPost(ctx context.Context, sel ast.SelectionSet, v model.Post) graphql.Marshaler { return ec._Post(ctx, sel, &v) } func (ec *executionContext) marshalNPost2ᚕᚖgithubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐPostᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.Post) 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.marshalNPost2ᚖgithubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐPost(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) marshalNPost2ᚖgithubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐPost(ctx context.Context, sel ast.SelectionSet, v *model.Post) 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._Post(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 { res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } } return res } func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v 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 { res := graphql.MarshalTime(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } } return res } func (ec *executionContext) unmarshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx context.Context, v any) (uuid.UUID, error) { res, err := graphql.UnmarshalUUID(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx context.Context, sel ast.SelectionSet, v uuid.UUID) graphql.Marshaler { res := graphql.MarshalUUID(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } } return res } func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ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) marshalOCommentConnection2ᚖgithubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐCommentConnection(ctx context.Context, sel ast.SelectionSet, v *model.CommentConnection) graphql.Marshaler { if v == nil { return graphql.Null } return ec._CommentConnection(ctx, sel, v) } func (ec *executionContext) unmarshalOInt2ᚖint32(ctx context.Context, v any) (*int32, error) { if v == nil { return nil, nil } res, err := graphql.UnmarshalInt32(v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOInt2ᚖint32(ctx context.Context, sel ast.SelectionSet, v *int32) graphql.Marshaler { if v == nil { return graphql.Null } res := graphql.MarshalInt32(*v) return res } func (ec *executionContext) unmarshalOInt642ᚖint64(ctx context.Context, v any) (*int64, error) { if v == nil { return nil, nil } res, err := graphql.UnmarshalInt64(v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOInt642ᚖint64(ctx context.Context, sel ast.SelectionSet, v *int64) graphql.Marshaler { if v == nil { return graphql.Null } res := graphql.MarshalInt64(*v) return res } func (ec *executionContext) marshalOPost2ᚖgithubᚗcomᚋnabishecᚋozon_habr_apiᚋgraphᚋmodelᚐPost(ctx context.Context, sel ast.SelectionSet, v *model.Post) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Post(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 } 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: _examples/mini-habr-with-subscriptions/graph/model/models_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package model import ( "time" "github.com/google/uuid" ) type Comment struct { ID int64 `json:"id"` AuthorID uuid.UUID `json:"authorID"` PostID int64 `json:"postID"` ParentID *int64 `json:"parentID,omitempty"` Text string `json:"text"` CreateDate time.Time `json:"createDate"` Replies *CommentConnection `json:"replies,omitempty"` } type CommentConnection struct { Edges []*CommentEdge `json:"edges"` PageInfo *PageInfo `json:"pageInfo"` } type CommentEdge struct { Node *Comment `json:"node"` Cursor string `json:"cursor"` } type Mutation struct { } type NewComment struct { AuthorID uuid.UUID `json:"authorID"` PostID int64 `json:"postID"` ParentID *int64 `json:"parentID,omitempty"` Text string `json:"text"` } type NewPost struct { AuthorID uuid.UUID `json:"authorID"` Title string `json:"title"` Text string `json:"text"` CommentsEnabled bool `json:"commentsEnabled"` } type PageInfo struct { EndCursor *string `json:"endCursor,omitempty"` HasNextPage bool `json:"hasNextPage"` } type Post struct { ID int64 `json:"id"` AuthorID uuid.UUID `json:"authorID"` Title string `json:"title"` Text string `json:"text"` CommentsEnabled bool `json:"commentsEnabled"` Comments *CommentConnection `json:"comments,omitempty"` CreateDate time.Time `json:"createDate"` } type Query struct { } type Subscription struct { } ================================================ FILE: _examples/mini-habr-with-subscriptions/graph/resolver.go ================================================ package graph import ( commentmutation "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/handlers/comment_mutation" commentquery "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/handlers/comment_query" postmutation "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/handlers/post_mutation" postquery "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/handlers/post_query" ) // This file will not be regenerated automatically. // // It serves as dependency injection for your app, add any dependencies you require here. type Resolver struct { PostMutation *postmutation.PostMutation PostQuery *postquery.PostQuery CommentMutation *commentmutation.CommentMutation CommentQuery *commentquery.CommentQuery Subscribers *Subscribers } func NewResolver( postMutation *postmutation.PostMutation, postQuery *postquery.PostQuery, commentMutation *commentmutation.CommentMutation, commentQuery *commentquery.CommentQuery, ) *Resolver { return &Resolver{ PostMutation: postMutation, PostQuery: postQuery, CommentMutation: commentMutation, CommentQuery: commentQuery, Subscribers: NewSubscribers(), } } ================================================ FILE: _examples/mini-habr-with-subscriptions/graph/schema.graphqls ================================================ # GraphQL schema example # # https://gqlgen.com/getting-started/ scalar Time scalar UUID scalar Int64 type Post { id: Int64! authorID: UUID! title: String! text: String! commentsEnabled: Boolean! comments(first: Int, after: String): CommentConnection @goField(forceResolver: true) createDate: Time! } type CommentConnection { edges: [CommentEdge!]! pageInfo: PageInfo! } type CommentEdge { node: Comment! cursor: String! } type PageInfo { endCursor: String hasNextPage: Boolean! } type Comment { id: Int64! authorID: UUID! postID: Int64! parentID: Int64 text: String! createDate: Time! replies(first: Int, after: String): CommentConnection @goField(forceResolver: true) } type Query { posts: [Post!]! post(postID: Int64!): Post } input NewPost { authorID: UUID! title: String! text: String! commentsEnabled: Boolean! } input NewComment { authorID: UUID! postID: Int64! parentID: Int64 text: String! } type Mutation { addPost(postInput: NewPost!): Post! addComment(commentInput: NewComment!): Comment! updateEnableComment(postID: Int64!, authorID: UUID!, commentsEnabled: Boolean!): Post! } type Subscription { commentAdded(postID: Int64!): Comment! } directive @goField( forceResolver: Boolean name: String omittable: Boolean ) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION ================================================ FILE: _examples/mini-habr-with-subscriptions/graph/schema.resolvers.go ================================================ package graph // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. // Code generated by github.com/99designs/gqlgen version v0.17.66 import ( "context" "errors" "github.com/google/uuid" "github.com/gqlgen/_examples/mini-habr-with-subscriptions/graph/model" internalmodel "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/model" "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/pkg/cursor" "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/pkg/errs" "github.com/rs/zerolog/log" ) // Replies is the resolver for the replies field. func (r *commentResolver) Replies( ctx context.Context, obj *model.Comment, first *int32, after *string, ) (*model.CommentConnection, error) { const op = "graph.Replies()" log.Debug().Msgf("%s start", op) var path string var err error if after != nil { err = cursor.ValidateAfter(after) if err != nil { return nil, errors.New("invalid after") } path, err = cursor.GetPath(after) if err != nil { return nil, errors.New("invalid after") } } else { path, err = r.CommentQuery.GetPathToComments(obj.ID) if err != nil { if err != errs.ErrCommentsNotExist { err = errors.New("internal server error") } return nil, err } } internalCommentsBranch, err := r.CommentQuery.GetCommentsBranchToPost(obj.PostID, path) if err != nil { if err != errs.ErrCommentsNotExist { if err == errs.ErrPathNotExist { return nil, nil // it works when there are no replies to the comment. } err = errors.New("internal server error") } return nil, err } commentBranch, err := paginateInternalBranch(internalCommentsBranch, first, after) log.Debug().Msgf("%s end", op) return commentBranch, nil } // AddPost is the resolver for the addPost field. func (r *mutationResolver) AddPost( ctx context.Context, postInput model.NewPost, ) (*model.Post, error) { const op = "graph.AddPost()" log.Debug().Msgf("%s start", op) newPost := newPostToInternalModel(&postInput) post, err := r.PostMutation.AddPost(newPost) if err != nil { log.Error().Err(err).Msgf("%s end with error", op) return nil, errors.New("internal server error") } log.Debug().Msgf("%s end", op) return postFromInternalModel(post), err } func newPostToInternalModel(post *model.NewPost) *internalmodel.NewPost { return &internalmodel.NewPost{ AuthorID: post.AuthorID, Title: post.Title, Text: post.Text, CommentsEnabled: post.CommentsEnabled, } } func postFromInternalModel(internalPost *internalmodel.Post) *model.Post { return &model.Post{ ID: internalPost.ID, AuthorID: internalPost.AuthorID, Title: internalPost.Title, Text: internalPost.Text, CommentsEnabled: internalPost.CommentsEnabled, CreateDate: internalPost.CreateDate, } } // AddComment is the resolver for the addComment field. func (r *mutationResolver) AddComment( ctx context.Context, commentInput model.NewComment, ) (*model.Comment, error) { const op = "graph.AddComment()" log.Debug().Msgf("%s start", op) newInternalComment := newCommentToInternalModel(&commentInput) internalComment, err := r.CommentMutation.AddComment( newInternalComment.PostID, newInternalComment, ) if err != nil { if err != errs.ErrPostNotExist && err != errs.ErrParentCommentNotExist && err != errs.ErrCommentsNotEnabled { err = errors.New("internal server error") } return nil, err } comment := commentFromInternalModel(internalComment) r.Subscribers.Pub(commentInput.PostID, comment) log.Debug().Msgf("%s end", op) return comment, nil } func newCommentToInternalModel(newComment *model.NewComment) *internalmodel.NewComment { return &internalmodel.NewComment{ AuthorID: newComment.AuthorID, PostID: newComment.PostID, ParentID: newComment.ParentID, Text: newComment.Text, } } // UpdateEnableComment is the resolver for the updateEnableComment field. func (r *mutationResolver) UpdateEnableComment( ctx context.Context, postID int64, authorID uuid.UUID, commentsEnabled bool, ) (*model.Post, error) { const op = "graph.UpdateEnableComment()" log.Debug().Msgf("%s start", op) post, err := r.PostMutation.UpdateEnableCommentToPost(postID, authorID, commentsEnabled) if err != nil { log.Error().Err(err).Msgf("%s end with error", op) if err != errs.ErrPostNotExist && err != errs.ErrUnauthorizedAccess { err = errors.New("internal server error") } return nil, err } log.Debug().Msgf("%s end", op) return postFromInternalModel(post), err } // Comments is the resolver for the comments field. func (r *postResolver) Comments( ctx context.Context, obj *model.Post, first *int32, after *string, ) (*model.CommentConnection, error) { const op = "graph.Comments()" log.Debug().Msgf("%s start", op) var path string if after != nil { err := cursor.ValidateAfter(after) if err != nil { return nil, errors.New("invalid after") } path, err = cursor.GetPath(after) if err != nil { return nil, errors.New("invalid after") } } internalCommentsBranch, err := r.CommentQuery.GetCommentsBranchToPost(obj.ID, path) if err != nil { if err != errs.ErrCommentsNotExist && err != errs.ErrPathNotExist { err = errors.New("internal server error") } return nil, err } commentBranch, err := paginateInternalBranch(internalCommentsBranch, first, after) log.Debug().Msgf("%s end", op) return commentBranch, nil } const defaultFirst int = 5 func paginateInternalBranch( internalComments []*internalmodel.Comment, firstInput *int32, after *string, ) (*model.CommentConnection, error) { var first int if firstInput == nil { first = defaultFirst } else { first = int(*firstInput) } edges := make([]*model.CommentEdge, 0, first) start := false var commentID int64 var err error if after != nil { commentID, err = cursor.GetCommentID(after) if err != nil { return nil, err } } else { start = true } hasNextPage := false counter := 0 for i, v := range internalComments { if v.ID == commentID && start == false { start = true continue } if start == true { edges = append(edges, &model.CommentEdge{ Node: commentFromInternalModel(v), Cursor: cursor.CreateCursorFromComment(v), }) counter += 1 } if counter == first { if i+1 < len(internalComments) { hasNextPage = true } break } } if start == false { // not found comment with commentID return &model.CommentConnection{ Edges: []*model.CommentEdge{}, PageInfo: &model.PageInfo{HasNextPage: false}, }, nil } var endCursor *string if len(edges) > 0 { endCursor = &edges[len(edges)-1].Cursor } pageInfo := &model.PageInfo{ EndCursor: endCursor, HasNextPage: hasNextPage, } return &model.CommentConnection{ Edges: edges, PageInfo: pageInfo, }, nil } func commentFromInternalModel(internalComment *internalmodel.Comment) *model.Comment { return &model.Comment{ ID: internalComment.ID, AuthorID: internalComment.AuthorID, PostID: internalComment.PostID, ParentID: internalComment.ParentID, Text: internalComment.Text, CreateDate: internalComment.CreateDate, } } // Posts is the resolver for the posts field. func (r *queryResolver) Posts(ctx context.Context) ([]*model.Post, error) { const op = "graph.Posts()" log.Debug().Msgf("%s start", op) internalPosts, err := r.PostQuery.GetAllPosts() if err != nil { log.Error().Err(err).Msgf("%s end with error", op) if err != errs.ErrPostsNotExist { err = errors.New("internal server error") } return nil, err } posts := make([]*model.Post, len(internalPosts)) for i, v := range internalPosts { posts[i] = postFromInternalModel(v) } log.Debug().Msgf("%s end", op) return posts, err } // Post is the resolver for the post field. func (r *queryResolver) Post(ctx context.Context, postID int64) (*model.Post, error) { const op = "graph.Post()" log.Debug().Msgf("%s start", op) postInternal, err := r.PostQuery.GetPost(postID) if err != nil { log.Error().Err(err).Msgf("%s end with error", op) if err != errs.ErrPostNotExist { err = errors.New("internal server error") } return nil, err } post := postFromInternalModel(postInternal) log.Debug().Msgf("%s end", op) return post, err } // CommentAdded is the resolver for the commentAdded field. func (r *subscriptionResolver) CommentAdded( ctx context.Context, postID int64, ) (<-chan *model.Comment, error) { const op = "graph.CommentAdded()" log.Debug().Msgf("%s subscription init", op) ch := make(chan *model.Comment, 10) go func() { defer r.Subscribers.CloseSub(postID, ch) r.Subscribers.Sub(postID, ch) for { select { case <-ctx.Done(): log.Debug().Msgf("%s subscription closed", op) return } } }() return ch, nil } // Comment returns CommentResolver implementation. func (r *Resolver) Comment() CommentResolver { return &commentResolver{r} } // Mutation returns MutationResolver implementation. func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } // Post returns PostResolver implementation. func (r *Resolver) Post() PostResolver { return &postResolver{r} } // Query returns QueryResolver implementation. func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } // Subscription returns SubscriptionResolver implementation. func (r *Resolver) Subscription() SubscriptionResolver { return &subscriptionResolver{r} } type ( commentResolver struct{ *Resolver } mutationResolver struct{ *Resolver } postResolver struct{ *Resolver } queryResolver struct{ *Resolver } subscriptionResolver struct{ *Resolver } ) ================================================ FILE: _examples/mini-habr-with-subscriptions/graph/subscription.go ================================================ package graph import ( "slices" "sync" "github.com/gqlgen/_examples/mini-habr-with-subscriptions/graph/model" ) type Subscribers struct { Subscribers map[int64][]chan *model.Comment mu sync.Mutex } func NewSubscribers() *Subscribers { return &Subscribers{ Subscribers: make(map[int64][]chan *model.Comment), // on postID chans } } func (s *Subscribers) Pub(postID int64, comment *model.Comment) { defer s.mu.Unlock() s.mu.Lock() chArray, ok := s.Subscribers[postID] if !ok { return } var activeChannels []chan *model.Comment for _, ch := range chArray { func() { defer func() { if r := recover(); r != nil { closeChan(ch) // panic may be due to channel overflow return } activeChannels = append(activeChannels, ch) }() ch <- comment }() } if len(activeChannels) < len(chArray) { s.Subscribers[postID] = activeChannels } } func (s *Subscribers) Sub(postID int64, ch chan *model.Comment) { defer s.mu.Unlock() s.mu.Lock() s.Subscribers[postID] = append(s.Subscribers[postID], ch) } func (s *Subscribers) CloseSub(postID int64, ch chan *model.Comment) { defer s.mu.Unlock() s.mu.Lock() if ch == nil { return } if chArray, ok := s.Subscribers[postID]; ok { if idx := slices.Index(chArray, ch); idx != -1 { closeChan(ch) s.Subscribers[postID] = slices.Delete(chArray, idx, idx+1) } } if len(s.Subscribers[postID]) == 0 { delete(s.Subscribers, postID) } } func closeChan(ch chan *model.Comment) { defer func() { if r := recover(); r != nil { return } }() close(ch) } ================================================ FILE: _examples/mini-habr-with-subscriptions/internal/handlers/comment_mutation/interface.go ================================================ package commentmutation import ( "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/model" ) type CommentMutationImp interface { AddComment(postID int64, newComment *model.NewComment) (*model.Comment, error) } ================================================ FILE: _examples/mini-habr-with-subscriptions/internal/handlers/comment_mutation/mutations.go ================================================ package commentmutation import ( "fmt" "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/model" "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/pkg/errs" "github.com/rs/zerolog/log" ) type CommentMutation struct { commentMutationImp CommentMutationImp } func NewCommentMutation(commentMutationImp CommentMutationImp) *CommentMutation { return &CommentMutation{commentMutationImp: commentMutationImp} } func (h *CommentMutation) AddComment( postID int64, newComment *model.NewComment, ) (*model.Comment, error) { op := "internal.handlers.commentmutation.AddComment()" log.Debug().Msgf("%s start", op) if len(newComment.Text) > 2000 || len(newComment.Text) <= 0 { return nil, errs.ErrIncorrectCommentLength } comment, err := h.commentMutationImp.AddComment(postID, newComment) if err != nil { if err == errs.ErrPostNotExist || err == errs.ErrParentCommentNotExist || err == errs.ErrCommentsNotEnabled { return nil, err } return nil, fmt.Errorf("%s:%w", op, err) } log.Debug().Msgf("%s end", op) return comment, nil } ================================================ FILE: _examples/mini-habr-with-subscriptions/internal/handlers/comment_query/interface.go ================================================ package commentquery import ( "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/model" ) type CommentQueryImp interface { GetCommentsBranch(postID int64, path string) ([]*model.Comment, error) GetCommentPath(parentID int64) (string, error) } ================================================ FILE: _examples/mini-habr-with-subscriptions/internal/handlers/comment_query/query.go ================================================ package commentquery import ( "fmt" "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/model" "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/pkg/errs" "github.com/rs/zerolog/log" ) type CommentQuery struct { commentQueryImp CommentQueryImp } func NewCommentQuery(commentQueryImp CommentQueryImp) *CommentQuery { return &CommentQuery{commentQueryImp: commentQueryImp} } func (h *CommentQuery) GetCommentsBranchToPost( postID int64, path string, ) ([]*model.Comment, error) { op := "internal.handlers.commentquery.GetCommentsBranchToPost()" log.Debug().Msgf("%s start", op) comments, err := h.commentQueryImp.GetCommentsBranch(postID, path) if err != nil { if err == errs.ErrCommentsNotExist || err == errs.ErrPathNotExist { return nil, err } return nil, fmt.Errorf("%s:%w", op, err) } log.Debug().Msgf("%s end", op) return comments, nil } func (h *CommentQuery) GetPathToComments(parentID int64) (string, error) { op := "internal.handlers.commentquery.GetPathToComments()" log.Debug().Msgf("%s start", op) path, err := h.commentQueryImp.GetCommentPath(parentID) if err != nil { if err == errs.ErrCommentsNotExist { return "", err } return "", fmt.Errorf("%s:%w", op, err) } log.Debug().Msgf("%s start", op) return path, nil } ================================================ FILE: _examples/mini-habr-with-subscriptions/internal/handlers/post_mutation/interface.go ================================================ package postmutation import ( "github.com/google/uuid" "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/model" ) type PostMutImp interface { AddPost(newPost *model.NewPost) (*model.Post, error) UpdateEnableCommentToPost( postID int64, authorID uuid.UUID, commentsEnabled bool, ) (*model.Post, error) } ================================================ FILE: _examples/mini-habr-with-subscriptions/internal/handlers/post_mutation/mutations.go ================================================ package postmutation import ( "fmt" "github.com/google/uuid" "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/model" "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/pkg/errs" "github.com/rs/zerolog/log" ) type PostMutation struct { postMutImp PostMutImp } func NewPostMutation(postImp PostMutImp) *PostMutation { return &PostMutation{postMutImp: postImp} } func (h *PostMutation) AddPost(newPost *model.NewPost) (*model.Post, error) { op := "internal.handlers.postmutation.AddPost()" log.Debug().Msgf("%s start", op) post, err := h.postMutImp.AddPost(newPost) if err != nil { return nil, fmt.Errorf("%s:%w", op, err) } log.Debug().Msgf("%s end", op) return post, nil } func (h *PostMutation) UpdateEnableCommentToPost( postID int64, authorID uuid.UUID, commentsEnabled bool, ) (*model.Post, error) { op := "internal.handlers.postmutation.UpdateEnableCommentToPost()" log.Debug().Msgf("%s start", op) post, err := h.postMutImp.UpdateEnableCommentToPost(postID, authorID, commentsEnabled) if err != nil { if err == errs.ErrPostNotExist || err == errs.ErrUnauthorizedAccess { return nil, err } return nil, fmt.Errorf("%s:%w", op, err) } log.Debug().Msgf("%s end", op) return post, nil } ================================================ FILE: _examples/mini-habr-with-subscriptions/internal/handlers/post_query/interface.go ================================================ package postquery import ( "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/model" ) type PostQueryImp interface { GetAllPosts() ([]*model.Post, error) GetPost(postID int64) (*model.Post, error) } ================================================ FILE: _examples/mini-habr-with-subscriptions/internal/handlers/post_query/query.go ================================================ package postquery import ( "fmt" "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/model" "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/pkg/errs" "github.com/rs/zerolog/log" ) type PostQuery struct { postQueryImp PostQueryImp } func NewPostQuery(postQueryImp PostQueryImp) *PostQuery { return &PostQuery{postQueryImp: postQueryImp} } func (h *PostQuery) GetAllPosts() ([]*model.Post, error) { op := "internal.handlers.postquery.GetAllPosts()" log.Debug().Msgf("%s start", op) posts, err := h.postQueryImp.GetAllPosts() if err != nil { if err == errs.ErrPostsNotExist { return nil, err } return nil, fmt.Errorf("%s:%w", op, err) } log.Debug().Msgf("%s end", op) return posts, nil } func (h *PostQuery) GetPost(postID int64) (*model.Post, error) { op := "internal.handlers.postquery.GetPostWithComment()" log.Debug().Msgf("%s start", op) post, err := h.postQueryImp.GetPost(postID) if err != nil { if err == errs.ErrPostNotExist { return nil, err } return nil, fmt.Errorf("%s:%w", op, err) } log.Debug().Msgf("%s end", op) return post, nil } ================================================ FILE: _examples/mini-habr-with-subscriptions/internal/model/model.go ================================================ package model import ( "time" "github.com/google/uuid" ) type Comment struct { ID int64 `json:"id" db:"comment_id"` AuthorID uuid.UUID `json:"authorID" db:"author_id"` PostID int64 `json:"postID" db:"post_id"` ParentID *int64 `json:"parentID,omitempty" db:"parent_id"` Path string ` db:"path"` Text string `json:"text" db:"text"` CreateDate time.Time `json:"createDate" db:"create_date"` } type NewComment struct { AuthorID uuid.UUID `json:"authorID" db:"author_id"` PostID int64 `json:"postID" db:"post_id"` ParentID *int64 `json:"parentID,omitempty" db:"parent_id"` Text string `json:"text" db:"text"` } type NewPost struct { AuthorID uuid.UUID `json:"authorID" db:"author_id"` Title string `json:"title" db:"title"` Text string `json:"text" db:"text"` CommentsEnabled bool `json:"commentsEnabled" db:"comments_enabled"` } type Post struct { ID int64 `json:"id" db:"post_id"` AuthorID uuid.UUID `json:"authorID" db:"author_id"` Title string `json:"title" db:"title"` Text string `json:"text" db:"text"` CommentsEnabled bool `json:"commentsEnabled" db:"comments_enabled"` Comments []*Comment `json:"comments,omitempty"` CreateDate time.Time `json:"createDate" db:"create_date"` } ================================================ FILE: _examples/mini-habr-with-subscriptions/internal/pkg/cursor/cursor.go ================================================ package cursor import ( "encoding/base64" "strconv" "strings" "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/model" ) func GetCommentID(after *string) (int64, error) { cursorLine, err := decodeCursor(*after) if err != nil { return 0, err } lastIndex := strings.LastIndex(cursorLine, "/") commentID, err := strconv.ParseInt(cursorLine[:lastIndex], 10, 64) return commentID, err } func CreateCursorFromComment(comment *model.Comment) string { lastIndex := strings.LastIndex(comment.Path, ".") var parentPath string if lastIndex == -1 { parentPath = "" } else { parentPath = comment.Path[:lastIndex] } commentID := comment.Path[lastIndex+1:] cursorLine := []byte(parentPath + "/" + commentID) cursor := base64.RawStdEncoding.EncodeToString(cursorLine) return cursor } func GetPath(after *string) (string, error) { cursorLine, err := decodeCursor(*after) lastIndex := strings.LastIndex(cursorLine, "/") return cursorLine[:lastIndex], err } func ValidateAfter(after *string) error { cursorLine, err := decodeCursor(*after) if err != nil { return err } lastIndex := strings.LastIndex(cursorLine, "/") _, err = strconv.ParseInt(cursorLine[:lastIndex], 10, 64) return err } func decodeCursor(after string) (string, error) { cursorLine, err := base64.RawStdEncoding.DecodeString(after) return string(cursorLine), err } ================================================ FILE: _examples/mini-habr-with-subscriptions/internal/pkg/errs/errors.go ================================================ package errs import ( "errors" ) var ( ErrPostNotExist = errors.New("post not exist") ErrUnauthorizedAccess = errors.New("user doesn't have access rights") ErrPostsNotExist = errors.New("no posts have been created yet") ErrCommentsNotExist = errors.New("no comments have been created yet") ErrPostNotCached = errors.New("post not cached yet") ErrPathNotExist = errors.New("path not exist") ErrParentCommentNotExist = errors.New("parent comment not exist yet") ErrIncorrectCommentLength = errors.New("incorrect comment length") ErrCommentsNotEnabled = errors.New("сomments on the post are not allowed") ) ================================================ FILE: _examples/mini-habr-with-subscriptions/internal/storage/db/resolvers.go ================================================ package db import ( "context" "database/sql" "fmt" "strconv" "strings" "sync" "time" "github.com/go-redis/cache/v9" "github.com/google/uuid" "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/model" "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/pkg/errs" "github.com/jmoiron/sqlx" "github.com/rs/zerolog/log" ) type Storage struct { db *sqlx.DB cache *cache.Cache } func NewStorage(db *sqlx.DB, cache *cache.Cache) *Storage { return &Storage{ db: db, cache: cache, } } func (r *Storage) AddPost(newPost *model.NewPost) (*model.Post, error) { op := "internal.storage.db.AddPost()" log.Debug().Msgf("%s start", op) post := &model.Post{ AuthorID: newPost.AuthorID, Title: newPost.Title, Text: newPost.Text, CommentsEnabled: newPost.CommentsEnabled, CreateDate: time.Now(), } queryNewPost := `INSERT INTO Posts (author_id, title, text, comments_enabled, create_date) VALUES ($1, $2, $3, $4, $5) RETURNING post_id ` err := r.db.QueryRow(queryNewPost, post.AuthorID, post.Title, post.Text, post.CommentsEnabled, post.CreateDate). Scan(&post.ID) if err != nil { return nil, fmt.Errorf("%s:%w", op, err) } log.Debug().Msgf("%s end", op) return post, err } func (r *Storage) AddComment(postID int64, newComment *model.NewComment) (*model.Comment, error) { op := "internal.storage.db.AddComment()" log.Debug().Msgf("%s start", op) tx, err := r.db.Beginx() if err != nil { return nil, fmt.Errorf("%s:%w", op, err) } defer func() { if err != nil { errRB := tx.Rollback() if errRB != nil { log.Error().Err(errRB).Msg(" roll back transaction failed") } } }() comment := &model.Comment{ AuthorID: newComment.AuthorID, PostID: postID, ParentID: newComment.ParentID, Text: newComment.Text, CreateDate: time.Now(), } queryGetCommentEnabledForPost := `SELECT comments_enabled FROM Posts WHERE post_id = $1` queryGetParentPath := `SELECT path FROM Comments WHERE comment_id = $1 AND post_id = $2` queryNewComment := `INSERT INTO Comments (author_id, post_id, parent_id, path, replies_level, text, create_date) VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING comment_id ` queryUpdateCommentPath := `UPDATE Comments SET path = $1, replies_level = $2 WHERE comment_id = $3` var commentEnabled bool err = tx.Get(&commentEnabled, queryGetCommentEnabledForPost, postID) if err != nil { if err == sql.ErrNoRows { return nil, errs.ErrPostNotExist } return nil, fmt.Errorf("%s:%w", op, err) } if commentEnabled == false { return nil, errs.ErrCommentsNotEnabled } var parentPath string if comment.ParentID != nil { err = tx.Get(&parentPath, queryGetParentPath, comment.ParentID, comment.PostID) if err != nil { if err == sql.ErrNoRows { return nil, errs.ErrParentCommentNotExist } return nil, fmt.Errorf("%s:%w", op, err) } parentPath += "." } // we specify 0 as the path and 1 as rep. level, because we know that the comment ID cannot be // zero, and the query did not return errors due to not null err = tx.QueryRow(queryNewComment, comment.AuthorID, comment.PostID, comment.ParentID, "0", 1, comment.Text, comment.CreateDate). Scan(&comment.ID) if err != nil { return nil, fmt.Errorf("%s:%w", op, err) } path := parentPath + strconv.FormatInt(comment.ID, 10) repliceLevel := strings.Count(path, ".") + 1 _, err = tx.Exec(queryUpdateCommentPath, path, repliceLevel, comment.ID) if err != nil { return nil, fmt.Errorf("%s:%w", op, err) } err = tx.Commit() if err != nil { return nil, fmt.Errorf("%s:%w", op, err) } comment.Path = path commentsBranch, err := r.getCommentsToPostFromCashe(comment.PostID, parentPath) if err == nil { commentsBranch = append(commentsBranch, comment) err = r.setCommentsBranchToPostInCache( commentsBranch, comment.PostID, parentPath[:len(parentPath)-1], ) if err != nil { return nil, fmt.Errorf("%s:%w", op, err) // it must be update in future } } else { if err != cache.ErrCacheMiss { log.Warn().Err(err).Msg("cache returned error") } err = nil } log.Debug().Msgf("%s end", op) return comment, nil } func (r *Storage) setCommentsBranchToPostInCache( commentsBranch []*model.Comment, postID int64, path string, ) error { op := "internal.storage.db.SetCommentsBranchToPostInCache()" log.Debug().Msgf("%s start", op) var err error if path == "" { err = r.cache.Set(&cache.Item{ Key: "post:" + strconv.FormatInt(postID, 10), Value: commentsBranch, TTL: 30 * time.Minute, }) } else { err = r.cache.Set(&cache.Item{ Key: "comments:" + path, Value: commentsBranch, TTL: 30 * time.Minute, }) } if err != nil { return fmt.Errorf("%s: %w", op, err) } log.Debug().Msgf("%s end", op) return nil } func (r *Storage) UpdateEnableCommentToPost( postID int64, authorID uuid.UUID, commentsEnabled bool, ) (*model.Post, error) { op := "internal.storage.db.UpdateEnableCommentToPost()" log.Debug().Msgf("%s start", op) tx, err := r.db.Beginx() if err != nil { return nil, fmt.Errorf("%s:%w", op, err) } defer func() { if err != nil { errRB := tx.Rollback() if errRB != nil { log.Error().Err(errRB).Msg(" roll back transaction failed") } } }() post := &model.Post{ ID: postID, } queryGetPost := `SELECT author_id, title, text, comments_enabled, create_date FROM Posts WHERE post_id = $1 ` queryUpdatePost := `UPDATE Posts SET comments_enabled = $1 WHERE post_id = $2` err = tx.Get(post, queryGetPost, postID) if err != nil { if err == sql.ErrNoRows { return nil, errs.ErrPostNotExist } return nil, fmt.Errorf("%s:%w", op, err) } if post.AuthorID != authorID { return nil, errs.ErrUnauthorizedAccess } _, err = tx.Exec(queryUpdatePost, commentsEnabled, postID) if err != nil { return nil, fmt.Errorf("%s:%w", op, err) } err = tx.Commit() if err != nil { return nil, fmt.Errorf("%s:%w", op, err) } post.CommentsEnabled = commentsEnabled log.Debug().Msgf("%s end", op) return post, nil } func (r *Storage) GetAllPosts() ([]*model.Post, error) { op := "internal.storage.db.GetAllPosts()" log.Debug().Msgf("%s start", op) queryGetAllPosts := `SELECT post_id, author_id, title, text, comments_enabled, create_date FROM Posts ORDER BY create_date` var posts []*model.Post err := r.db.Select(&posts, queryGetAllPosts) if err != nil { if err == sql.ErrNoRows { return nil, errs.ErrPostsNotExist } return nil, fmt.Errorf("%s:%w", op, err) } log.Debug().Msgf("%s end", op) return posts, nil } func (r *Storage) GetPost(postID int64) (*model.Post, error) { op := "internal.storage.db.GetPost()" log.Debug().Msgf("%s start", op) queryGetPost := `SELECT post_id, author_id, title, text, comments_enabled, create_date FROM Posts WHERE post_id = $1` post := new(model.Post) err := r.db.Get(post, queryGetPost, postID) if err != nil { if err == sql.ErrNoRows { return nil, errs.ErrPostNotExist } return nil, fmt.Errorf("%s:%w", op, err) } log.Debug().Msgf("%s end", op) return post, nil } func (r *Storage) GetCommentsBranch(postID int64, path string) ([]*model.Comment, error) { op := "internal.storage.db.GetCommentsBranch()" log.Debug().Msgf("%s start", op) allComments, err := r.getCommentsToPostFromCashe(postID, path) if err != nil { if err == errs.ErrPathNotExist { return nil, err } log.Warn().Err(err).Msg("Cache returned error") } else { return allComments, nil } allComments = make([]*model.Comment, 0) queryGetCommentsToPost := `SELECT comment_id, author_id, post_id, parent_id, path, text, create_date FROM Comments WHERE post_id = $1 ORDER BY string_to_array(path::text, '.')::int[], create_date DESC` err = r.db.Select(&allComments, queryGetCommentsToPost, postID) if err != nil { return nil, fmt.Errorf("%s:%w", op, err) } if len(allComments) == 0 { return nil, errs.ErrCommentsNotExist } commentsMap, rootComments := createCommentMap(allComments) err = r.setCommentsToPostInCache(commentsMap, rootComments, postID) if err != nil { log.Warn().Err(err).Msg("Cache returned error") } if path == "" { log.Debug().Msgf("%s end", op) return rootComments, nil } else { if v, ok := commentsMap[path]; ok != true { return nil, errs.ErrPathNotExist } else { log.Debug().Msgf("%s end", op) return v, nil } } } func createCommentMap( allComments []*model.Comment, ) (map[string][]*model.Comment, []*model.Comment) { var rootComments []*model.Comment commentsMap := make(map[string][]*model.Comment) pathMap := make(map[int64]string, len(allComments)) for _, v := range allComments { pathMap[v.ID] = v.Path if v.ParentID == nil { rootComments = append(rootComments, v) } else { commentsMap[pathMap[*v.ParentID]] = append( commentsMap[pathMap[*v.ParentID]], v, ) // we know that parent comment exists because of the query is ordered by path } } log.Debug().Msg("Comment map created successfully") return commentsMap, rootComments } func (r *Storage) getCommentsToPostFromCashe(postID int64, path string) ([]*model.Comment, error) { op := "internal.storage.db.GetCommentsToPostFromCashe()" log.Debug().Msgf("%s start", op) var rootComments []*model.Comment err := r.cache.Get(context.Background(), "post:"+strconv.FormatInt(postID, 10), &rootComments) if err != nil { if err == cache.ErrCacheMiss { return nil, err } return nil, fmt.Errorf("%s: %w", op, err) } if len(rootComments) == 0 { return nil, errs.ErrPostNotCached } if path == "" { log.Debug().Msgf("%s end", op) return rootComments, nil } var commentsBranch []*model.Comment err = r.cache.Get(context.Background(), "comments:"+path, &commentsBranch) if err != nil { if err == cache.ErrCacheMiss && len(rootComments) > 0 { return nil, nil // it work when try get replies of comment without replies } return nil, fmt.Errorf("%s: %w", op, err) } if len(commentsBranch) == 0 { return nil, errs.ErrPathNotExist } log.Debug().Msgf("%s end", op) return commentsBranch, nil } func (r *Storage) setCommentsToPostInCache( commentsMap map[string][]*model.Comment, rootComments []*model.Comment, postID int64, ) error { op := "internal.storage.db.SetCommentToPostInCache()" log.Debug().Msgf("%s start", op) var wg sync.WaitGroup var mu sync.Mutex var firstErr error for path, comments := range commentsMap { wg.Add(1) go func(path string, comments []*model.Comment) { defer wg.Done() err := r.cache.Set(&cache.Item{ Key: "comments:" + path, Value: comments, TTL: 30 * time.Minute, }) mu.Lock() defer mu.Unlock() if err != nil && firstErr == nil { firstErr = err return } }(path, comments) } wg.Wait() if firstErr != nil { return fmt.Errorf("%s: %w", op, firstErr) } err := r.cache.Set(&cache.Item{ Key: "post:" + strconv.FormatInt(postID, 10), Value: rootComments, TTL: 30 * time.Minute, }) if err != nil { return fmt.Errorf("%s: %w", op, err) } log.Debug().Msgf("%s end", op) return nil } func (r *Storage) GetCommentPath(commentID int64) (string, error) { op := "internal.storage.db.GetCommentPath()" log.Debug().Msgf("%s start", op) var path string queryGetCommentsToPost := `SELECT path FROM Comments WHERE comment_id = $1` err := r.db.Get(&path, queryGetCommentsToPost, commentID) if err != nil { if err == sql.ErrNoRows { return "", errs.ErrCommentsNotExist } return "", fmt.Errorf("%s:%w", op, err) } log.Debug().Msgf("%s end", op) return path, nil } ================================================ FILE: _examples/mini-habr-with-subscriptions/internal/storage/in-memory/resolvers.go ================================================ package inmemory import ( "strconv" "time" "github.com/google/uuid" "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/model" "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/pkg/errs" "github.com/rs/zerolog/log" ) type Storage struct { postsLastIndex int64 commentLastIndex int64 comments map[int64][]*model.Comment commentPath map[int64]string repliesByPath map[string][]*model.Comment posts map[int64]*model.Post } func NewStorage() *Storage { return &Storage{ postsLastIndex: 0, commentLastIndex: 0, comments: make(map[int64][]*model.Comment), // root comments commentPath: make(map[int64]string), repliesByPath: make(map[string][]*model.Comment), posts: make(map[int64]*model.Post), } } func (r *Storage) AddPost(newPost *model.NewPost) (*model.Post, error) { op := "internal.storage.inmemory.AddPost()" log.Debug().Msgf("%s start", op) post := &model.Post{ AuthorID: newPost.AuthorID, Title: newPost.Title, Text: newPost.Text, CommentsEnabled: newPost.CommentsEnabled, CreateDate: time.Now(), } postID := r.postsLastIndex + 1 r.postsLastIndex += 1 post.ID = postID r.posts[postID] = post log.Debug().Msgf("%s end", op) return post, nil } func (r *Storage) AddComment(postID int64, newComment *model.NewComment) (*model.Comment, error) { op := "internal.storage.inmemory.AddComment()" log.Debug().Msgf("%s start", op) comment := &model.Comment{ AuthorID: newComment.AuthorID, PostID: postID, ParentID: newComment.ParentID, Text: newComment.Text, CreateDate: time.Now(), } post, ok := r.posts[postID] if !ok { return nil, errs.ErrPostNotExist } if !post.CommentsEnabled { return nil, errs.ErrCommentsNotEnabled } commentID := r.commentLastIndex + 1 r.commentLastIndex += 1 comment.ID = commentID var parentPath string if comment.ParentID != nil { if parentCommentPath, ok := r.commentPath[*comment.ParentID]; ok { parentPath = parentCommentPath } else { return nil, errs.ErrParentCommentNotExist } r.repliesByPath[parentPath] = append(r.repliesByPath[parentPath], comment) parentPath += "." } else { r.comments[postID] = append(r.comments[postID], comment) } path := parentPath + strconv.FormatInt(comment.ID, 10) comment.Path = path r.commentPath[commentID] = path log.Debug().Msgf("%s end", op) return comment, nil } func (r *Storage) UpdateEnableCommentToPost( postID int64, authorID uuid.UUID, commentsEnabled bool, ) (*model.Post, error) { op := "internal.storage.inmemory.UpdateEnableCommentToPost()" log.Debug().Msgf("%s start", op) post, ok := r.posts[postID] if !ok { return nil, errs.ErrPostNotExist } if post.AuthorID != authorID { return nil, errs.ErrUnauthorizedAccess } post.CommentsEnabled = commentsEnabled log.Debug().Msgf("%s end", op) return post, nil } func (r *Storage) GetAllPosts() ([]*model.Post, error) { op := "internal.storage.inmemory.GetAllPosts()" log.Debug().Msgf("%s start", op) var posts []*model.Post for _, v := range r.posts { posts = append(posts, v) } if len(posts) == 0 { return nil, errs.ErrPostsNotExist } log.Debug().Msgf("%s end", op) return posts, nil } func (r *Storage) GetPost(postID int64) (*model.Post, error) { op := "internal.storage.inmemory.GetPost()" log.Debug().Msgf("%s start", op) post, ok := r.posts[postID] if !ok { return nil, errs.ErrPostNotExist } log.Debug().Msgf("%s end", op) return post, nil } func (r *Storage) GetCommentsBranch(postID int64, path string) ([]*model.Comment, error) { op := "internal.storage.inmemory.GetCommentsBranch()" log.Debug().Msgf("%s start", op) if path == "" { if v, ok := r.comments[postID]; ok { return v, nil } return nil, errs.ErrCommentsNotExist } comments, ok := r.repliesByPath[path] if !ok { return nil, errs.ErrPathNotExist } if len(comments) == 0 { return nil, errs.ErrCommentsNotExist } return comments, nil } func (r *Storage) GetCommentPath(commentID int64) (string, error) { op := "internal.storage.inmemory.GetCommentPath()" log.Debug().Msgf("%s start", op) path, ok := r.commentPath[commentID] if !ok { return "", errs.ErrCommentsNotExist } log.Debug().Msgf("%s end", op) return path, nil } ================================================ FILE: _examples/mini-habr-with-subscriptions/internal/storage/interface.go ================================================ package storage import ( "github.com/google/uuid" "github.com/gqlgen/_examples/mini-habr-with-subscriptions/internal/model" ) type StorageImp interface { AddPost(newPost *model.NewPost) (*model.Post, error) AddComment(postID int64, newComment *model.NewComment) (*model.Comment, error) UpdateEnableCommentToPost( postID int64, authorID uuid.UUID, commentsEnabled bool, ) (*model.Post, error) GetAllPosts() ([]*model.Post, error) GetPost(postID int64) (*model.Post, error) GetCommentsBranch(postID int64, path string) ([]*model.Comment, error) GetCommentPath(parentID int64) (string, error) } ================================================ FILE: _examples/mini-habr-with-subscriptions/migrations/001_create_tables.up.sql ================================================ -- +goose Up -- +goose StatementBegin CREATE EXTENSION IF NOT EXISTS ltree; CREATE TABLE IF NOT EXISTS Posts ( post_id BIGSERIAL PRIMARY KEY, author_id UUID NOT NULL, title TEXT NOT NULL, text TEXT NOT NULL, comments_enabled BOOLEAN NOT NULL DEFAULT TRUE, create_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); CREATE TABLE IF NOT EXISTS Comments ( comment_id BIGSERIAL PRIMARY KEY, author_id UUID NOT NULL, post_id BIGINT NOT NULL REFERENCES posts(post_id) ON DELETE CASCADE, parent_id BIGINT REFERENCES comments(comment_id) ON DELETE CASCADE, path LTREE UNIQUE NOT NULL, replies_level INTEGER NOT NULL, text TEXT NOT NULL, create_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); CREATE INDEX path_gist_idx ON Comments USING GIST (path); CREATE INDEX create_date_idx ON Comments (create_date); CREATE INDEX post_idx ON Comments (post_id); -- +goose StatementEnd ================================================ FILE: _examples/mini-habr-with-subscriptions/tools/tools.go ================================================ package tools import ( _ "github.com/99designs/gqlgen" _ "github.com/99designs/gqlgen/graphql/introspection" ) ================================================ FILE: _examples/readme.md ================================================ ### examples - todo: A simple todo checklist. A good place to get the basics down - starwars: A starwars movie database. It has examples of advanced graphql features - dataloader: How to avoid n+1 database query problems ================================================ FILE: _examples/scalars/.gqlgen.yml ================================================ model: filename: model/generated.go models: User: model: github.com/99designs/gqlgen/_examples/scalars/model.User Timestamp: model: github.com/99designs/gqlgen/_examples/scalars/model.Timestamp SearchArgs: model: github.com/99designs/gqlgen/_examples/scalars/model.SearchArgs Point: model: github.com/99designs/gqlgen/_examples/scalars/model.Point ID: model: github.com/99designs/gqlgen/_examples/scalars/model.ID Tier: model: github.com/99designs/gqlgen/_examples/scalars/model.Tier Banned: model: github.com/99designs/gqlgen/_examples/scalars/model.Banned DarkMode: model: github.com/99designs/gqlgen/_examples/scalars/model.Preferences ================================================ FILE: _examples/scalars/external/model.go ================================================ package external type ObjectID int ================================================ FILE: _examples/scalars/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package scalars import ( "bytes" "context" "embed" "errors" "fmt" "strconv" "sync/atomic" "time" "github.com/99designs/gqlgen/_examples/scalars/external" "github.com/99designs/gqlgen/_examples/scalars/model" "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 { Query() QueryResolver User() UserResolver } type DirectiveRoot struct { } type ComplexityRoot struct { Address struct { ID func(childComplexity int) int Location func(childComplexity int) int } Query struct { Search func(childComplexity int, input *model.SearchArgs) int User func(childComplexity int, id external.ObjectID) int UserByTier func(childComplexity int, tier model.Tier, darkMode *model.Prefs) int } User struct { Address func(childComplexity int) int Created func(childComplexity int) int CustomResolver func(childComplexity int) int ID func(childComplexity int) int IsBanned func(childComplexity int) int Modified func(childComplexity int) int Name func(childComplexity int) int PrimitiveResolver func(childComplexity int) int PtrPrefs func(childComplexity int) int Tier func(childComplexity int) int ValPrefs func(childComplexity int) int } } type QueryResolver interface { User(ctx context.Context, id external.ObjectID) (*model.User, error) Search(ctx context.Context, input *model.SearchArgs) ([]*model.User, error) UserByTier(ctx context.Context, tier model.Tier, darkMode *model.Prefs) ([]*model.User, error) } type UserResolver interface { PrimitiveResolver(ctx context.Context, obj *model.User) (string, error) CustomResolver(ctx context.Context, obj *model.User) (*model.Point, error) } type executableSchema 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 "Address.id": if e.ComplexityRoot.Address.ID == nil { break } return e.ComplexityRoot.Address.ID(childComplexity), true case "Address.location": if e.ComplexityRoot.Address.Location == nil { break } return e.ComplexityRoot.Address.Location(childComplexity), true case "Query.search": if e.ComplexityRoot.Query.Search == nil { break } args, err := ec.field_Query_search_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.Search(childComplexity, args["input"].(*model.SearchArgs)), true case "Query.user": if e.ComplexityRoot.Query.User == nil { break } args, err := ec.field_Query_user_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.User(childComplexity, args["id"].(external.ObjectID)), true case "Query.userByTier": if e.ComplexityRoot.Query.UserByTier == nil { break } args, err := ec.field_Query_userByTier_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.UserByTier(childComplexity, args["tier"].(model.Tier), args["darkMode"].(*model.Prefs)), true case "User.address": if e.ComplexityRoot.User.Address == nil { break } return e.ComplexityRoot.User.Address(childComplexity), true case "User.created": if e.ComplexityRoot.User.Created == nil { break } return e.ComplexityRoot.User.Created(childComplexity), true case "User.customResolver": if e.ComplexityRoot.User.CustomResolver == nil { break } return e.ComplexityRoot.User.CustomResolver(childComplexity), true case "User.id": if e.ComplexityRoot.User.ID == nil { break } return e.ComplexityRoot.User.ID(childComplexity), true case "User.isBanned": if e.ComplexityRoot.User.IsBanned == nil { break } return e.ComplexityRoot.User.IsBanned(childComplexity), true case "User.modified": if e.ComplexityRoot.User.Modified == nil { break } return e.ComplexityRoot.User.Modified(childComplexity), true case "User.name": if e.ComplexityRoot.User.Name == nil { break } return e.ComplexityRoot.User.Name(childComplexity), true case "User.primitiveResolver": if e.ComplexityRoot.User.PrimitiveResolver == nil { break } return e.ComplexityRoot.User.PrimitiveResolver(childComplexity), true case "User.ptrPrefs": if e.ComplexityRoot.User.PtrPrefs == nil { break } return e.ComplexityRoot.User.PtrPrefs(childComplexity), true case "User.tier": if e.ComplexityRoot.User.Tier == nil { break } return e.ComplexityRoot.User.Tier(childComplexity), true case "User.valPrefs": if e.ComplexityRoot.User.ValPrefs == nil { break } return e.ComplexityRoot.User.ValPrefs(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.unmarshalInputSearchArgs, ) 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_Query_search_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, "input", ec.unmarshalOSearchArgs2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐSearchArgs) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Query_userByTier_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "tier", ec.unmarshalNTier2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐTier) if err != nil { return nil, err } args["tier"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "darkMode", ec.unmarshalNDarkMode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPrefs) if err != nil { return nil, err } args["darkMode"] = arg1 return args, nil } func (ec *executionContext) field_Query_user_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", ec.unmarshalNID2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋexternalᚐObjectID) if err != nil { return nil, err } args["id"] = 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) _Address_id(ctx context.Context, field graphql.CollectedField, obj *model.Address) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Address_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, nil, ec.marshalNID2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋexternalᚐObjectID, true, true, ) } func (ec *executionContext) fieldContext_Address_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Address", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _Address_location(ctx context.Context, field graphql.CollectedField, obj *model.Address) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Address_location, func(ctx context.Context) (any, error) { return obj.Location, nil }, nil, ec.marshalOPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPoint, true, false, ) } func (ec *executionContext) fieldContext_Address_location(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Address", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Point does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_user, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().User(ctx, fc.Args["id"].(external.ObjectID)) }, nil, ec.marshalOUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐUser, true, false, ) } func (ec *executionContext) fieldContext_Query_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_User_id(ctx, field) case "name": return ec.fieldContext_User_name(ctx, field) case "created": return ec.fieldContext_User_created(ctx, field) case "modified": return ec.fieldContext_User_modified(ctx, field) case "valPrefs": return ec.fieldContext_User_valPrefs(ctx, field) case "ptrPrefs": return ec.fieldContext_User_ptrPrefs(ctx, field) case "isBanned": return ec.fieldContext_User_isBanned(ctx, field) case "primitiveResolver": return ec.fieldContext_User_primitiveResolver(ctx, field) case "customResolver": return ec.fieldContext_User_customResolver(ctx, field) case "address": return ec.fieldContext_User_address(ctx, field) case "tier": return ec.fieldContext_User_tier(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_user_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_search(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_search, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().Search(ctx, fc.Args["input"].(*model.SearchArgs)) }, nil, ec.marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐUserᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_search(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_User_id(ctx, field) case "name": return ec.fieldContext_User_name(ctx, field) case "created": return ec.fieldContext_User_created(ctx, field) case "modified": return ec.fieldContext_User_modified(ctx, field) case "valPrefs": return ec.fieldContext_User_valPrefs(ctx, field) case "ptrPrefs": return ec.fieldContext_User_ptrPrefs(ctx, field) case "isBanned": return ec.fieldContext_User_isBanned(ctx, field) case "primitiveResolver": return ec.fieldContext_User_primitiveResolver(ctx, field) case "customResolver": return ec.fieldContext_User_customResolver(ctx, field) case "address": return ec.fieldContext_User_address(ctx, field) case "tier": return ec.fieldContext_User_tier(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_search_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_userByTier(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_userByTier, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().UserByTier(ctx, fc.Args["tier"].(model.Tier), fc.Args["darkMode"].(*model.Prefs)) }, nil, ec.marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐUserᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_userByTier(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_User_id(ctx, field) case "name": return ec.fieldContext_User_name(ctx, field) case "created": return ec.fieldContext_User_created(ctx, field) case "modified": return ec.fieldContext_User_modified(ctx, field) case "valPrefs": return ec.fieldContext_User_valPrefs(ctx, field) case "ptrPrefs": return ec.fieldContext_User_ptrPrefs(ctx, field) case "isBanned": return ec.fieldContext_User_isBanned(ctx, field) case "primitiveResolver": return ec.fieldContext_User_primitiveResolver(ctx, field) case "customResolver": return ec.fieldContext_User_customResolver(ctx, field) case "address": return ec.fieldContext_User_address(ctx, field) case "tier": return ec.fieldContext_User_tier(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_userByTier_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 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_id(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, nil, ec.marshalNID2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋexternalᚐObjectID, true, true, ) } func (ec *executionContext) fieldContext_User_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { 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_created(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_created, func(ctx context.Context) (any, error) { return obj.Created, nil }, nil, ec.marshalOTimestamp2timeᚐTime, true, false, ) } func (ec *executionContext) fieldContext_User_created(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Timestamp does not have child fields") }, } return fc, nil } func (ec *executionContext) _User_modified(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_modified, func(ctx context.Context) (any, error) { return obj.Modified, nil }, nil, ec.marshalOTimestamp2ᚖtimeᚐTime, true, false, ) } func (ec *executionContext) fieldContext_User_modified(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Timestamp does not have child fields") }, } return fc, nil } func (ec *executionContext) _User_valPrefs(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_valPrefs, func(ctx context.Context) (any, error) { return obj.ValPrefs, nil }, nil, ec.marshalODarkMode2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPrefs, true, false, ) } func (ec *executionContext) fieldContext_User_valPrefs(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type DarkMode does not have child fields") }, } return fc, nil } func (ec *executionContext) _User_ptrPrefs(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_ptrPrefs, func(ctx context.Context) (any, error) { return obj.PtrPrefs, nil }, nil, ec.marshalODarkMode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPrefs, true, false, ) } func (ec *executionContext) fieldContext_User_ptrPrefs(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type DarkMode does not have child fields") }, } return fc, nil } func (ec *executionContext) _User_isBanned(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_isBanned, func(ctx context.Context) (any, error) { return obj.IsBanned, nil }, nil, ec.marshalNBanned2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐBanned, true, true, ) } func (ec *executionContext) fieldContext_User_isBanned(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Banned does not have child fields") }, } return fc, nil } func (ec *executionContext) _User_primitiveResolver(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_primitiveResolver, func(ctx context.Context) (any, error) { return ec.Resolvers.User().PrimitiveResolver(ctx, obj) }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_User_primitiveResolver(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _User_customResolver(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_customResolver, func(ctx context.Context) (any, error) { return ec.Resolvers.User().CustomResolver(ctx, obj) }, nil, ec.marshalNPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPoint, true, true, ) } func (ec *executionContext) fieldContext_User_customResolver(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Point does not have child fields") }, } return fc, nil } func (ec *executionContext) _User_address(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_address, func(ctx context.Context) (any, error) { return obj.Address, nil }, nil, ec.marshalOAddress2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐAddress, true, false, ) } func (ec *executionContext) fieldContext_User_address(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Address_id(ctx, field) case "location": return ec.fieldContext_Address_location(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Address", field.Name) }, } return fc, nil } func (ec *executionContext) _User_tier(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_tier, func(ctx context.Context) (any, error) { return obj.Tier, nil }, nil, ec.marshalOTier2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐTier, true, false, ) } func (ec *executionContext) fieldContext_User_tier(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Tier does not have child fields") }, } return fc, nil } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 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) unmarshalInputSearchArgs(ctx context.Context, obj any) (model.SearchArgs, error) { var it model.SearchArgs if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"location", "createdAfter", "isBanned"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "location": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("location")) data, err := ec.unmarshalOPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPoint(ctx, v) if err != nil { return it, err } it.Location = data case "createdAfter": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAfter")) data, err := ec.unmarshalOTimestamp2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } it.CreatedAfter = data case "isBanned": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("isBanned")) data, err := ec.unmarshalOBanned2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐBanned(ctx, v) if err != nil { return it, err } it.IsBanned = data } } return it, nil } // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var addressImplementors = []string{"Address"} func (ec *executionContext) _Address(ctx context.Context, sel ast.SelectionSet, obj *model.Address) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, addressImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Address") case "id": out.Values[i] = ec._Address_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "location": out.Values[i] = ec._Address_location(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "user": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_user(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "search": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_search(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "userByTier": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_userByTier(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) case "__schema": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var userImplementors = []string{"User"} func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *model.User) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("User") case "id": out.Values[i] = ec._User_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "name": out.Values[i] = ec._User_name(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "created": out.Values[i] = ec._User_created(ctx, field, obj) case "modified": out.Values[i] = ec._User_modified(ctx, field, obj) case "valPrefs": out.Values[i] = ec._User_valPrefs(ctx, field, obj) case "ptrPrefs": out.Values[i] = ec._User_ptrPrefs(ctx, field, obj) case "isBanned": out.Values[i] = ec._User_isBanned(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "primitiveResolver": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._User_primitiveResolver(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "customResolver": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._User_customResolver(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "address": out.Values[i] = ec._User_address(ctx, field, obj) case "tier": out.Values[i] = ec._User_tier(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": out.Values[i] = ec.___Directive_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "description": out.Values[i] = ec.___Directive_description(ctx, field, obj) case "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) unmarshalNBanned2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐBanned(ctx context.Context, v any) (model.Banned, error) { var res model.Banned err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNBanned2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐBanned(ctx context.Context, sel ast.SelectionSet, v model.Banned) graphql.Marshaler { return v } func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v 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) unmarshalNDarkMode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPrefs(ctx context.Context, v any) (*model.Prefs, error) { res, err := model.UnmarshalPreferences(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNDarkMode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPrefs(ctx context.Context, sel ast.SelectionSet, v *model.Prefs) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } _ = sel res := model.MarshalPreferences(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) unmarshalNID2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋexternalᚐObjectID(ctx context.Context, v any) (external.ObjectID, error) { res, err := model.UnmarshalID(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNID2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋexternalᚐObjectID(ctx context.Context, sel ast.SelectionSet, v external.ObjectID) graphql.Marshaler { _ = sel res := model.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) unmarshalNPoint2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPoint(ctx context.Context, v any) (model.Point, error) { var res model.Point err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNPoint2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPoint(ctx context.Context, sel ast.SelectionSet, v model.Point) graphql.Marshaler { return v } func (ec *executionContext) unmarshalNPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPoint(ctx context.Context, v any) (*model.Point, error) { var res = new(model.Point) err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPoint(ctx context.Context, sel ast.SelectionSet, v *model.Point) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return v } func (ec *executionContext) unmarshalNString2string(ctx context.Context, v 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) unmarshalNTier2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐTier(ctx context.Context, v any) (model.Tier, error) { var res model.Tier err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNTier2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐTier(ctx context.Context, sel ast.SelectionSet, v model.Tier) graphql.Marshaler { return v } func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐUserᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.User) 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.marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐ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ᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.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 { 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) marshalOAddress2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐAddress(ctx context.Context, sel ast.SelectionSet, v model.Address) graphql.Marshaler { return ec._Address(ctx, sel, &v) } func (ec *executionContext) unmarshalOBanned2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐBanned(ctx context.Context, v any) (model.Banned, error) { var res model.Banned err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOBanned2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐBanned(ctx context.Context, sel ast.SelectionSet, v model.Banned) graphql.Marshaler { return v } func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v 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) unmarshalODarkMode2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPrefs(ctx context.Context, v any) (model.Prefs, error) { res, err := model.UnmarshalPreferences(v) return *res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalODarkMode2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPrefs(ctx context.Context, sel ast.SelectionSet, v model.Prefs) graphql.Marshaler { _ = sel _ = ctx res := model.MarshalPreferences(&v) return res } func (ec *executionContext) unmarshalODarkMode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPrefs(ctx context.Context, v any) (*model.Prefs, error) { if v == nil { return nil, nil } res, err := model.UnmarshalPreferences(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalODarkMode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPrefs(ctx context.Context, sel ast.SelectionSet, v *model.Prefs) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel _ = ctx res := model.MarshalPreferences(v) return res } func (ec *executionContext) unmarshalOPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPoint(ctx context.Context, v any) (*model.Point, error) { if v == nil { return nil, nil } var res = new(model.Point) err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOPoint2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐPoint(ctx context.Context, sel ast.SelectionSet, v *model.Point) graphql.Marshaler { if v == nil { return graphql.Null } return v } func (ec *executionContext) unmarshalOSearchArgs2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐSearchArgs(ctx context.Context, v any) (*model.SearchArgs, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputSearchArgs(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v 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) unmarshalOTier2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐTier(ctx context.Context, v any) (model.Tier, error) { var res model.Tier err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOTier2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐTier(ctx context.Context, sel ast.SelectionSet, v model.Tier) graphql.Marshaler { return v } func (ec *executionContext) unmarshalOTimestamp2timeᚐTime(ctx context.Context, v any) (time.Time, error) { res, err := model.UnmarshalTimestamp(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOTimestamp2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { _ = sel _ = ctx res := model.MarshalTimestamp(v) return res } func (ec *executionContext) unmarshalOTimestamp2ᚖtimeᚐTime(ctx context.Context, v any) (*time.Time, error) { if v == nil { return nil, nil } res, err := model.UnmarshalTimestamp(v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOTimestamp2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel _ = ctx res := model.MarshalTimestamp(*v) return res } func (ec *executionContext) marshalOUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋscalarsᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { if v == nil { return graphql.Null } return ec._User(ctx, sel, v) } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ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/scalars/model/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package model import ( "github.com/99designs/gqlgen/_examples/scalars/external" ) type Address struct { ID external.ObjectID `json:"id"` Location *Point `json:"location,omitempty"` } type Query struct { } ================================================ FILE: _examples/scalars/model/model.go ================================================ package model import ( "errors" "fmt" "io" "strconv" "strings" "time" "github.com/99designs/gqlgen/_examples/scalars/external" "github.com/99designs/gqlgen/graphql" ) type Banned bool func (b Banned) MarshalGQL(w io.Writer) { if b { w.Write([]byte("true")) } else { w.Write([]byte("false")) } } func (b *Banned) UnmarshalGQL(v any) error { switch v := v.(type) { case string: *b = Banned(strings.EqualFold(v, "true")) return nil case bool: *b = Banned(v) return nil default: return fmt.Errorf("%T is not a bool", v) } } type User struct { ID external.ObjectID Name string Created time.Time // direct binding to builtin types with external Marshal/Unmarshal methods Modified *time.Time // direct binding to builtin types with external Marshal/Unmarshal methods ValPrefs Prefs // external un/marshal that act on pointers PtrPrefs *Prefs IsBanned Banned Address Address Tier Tier } // Point is serialized as a simple array, eg [1, 2] type Point struct { X int Y int } func (p *Point) UnmarshalGQL(v any) error { pointStr, ok := v.(string) if !ok { return errors.New("points must be strings") } parts := strings.Split(pointStr, ",") if len(parts) != 2 { return errors.New("points must have 2 parts") } var err error if p.X, err = strconv.Atoi(parts[0]); err != nil { return err } if p.Y, err = strconv.Atoi(parts[1]); err != nil { return err } return nil } // MarshalGQL implements the graphql.Marshaler interface func (p Point) MarshalGQL(w io.Writer) { fmt.Fprintf(w, `"%d,%d"`, p.X, p.Y) } // if the type referenced in .gqlgen.yml is a function that returns a marshaller we can use it to // encode and decode // onto any existing go type. func MarshalTimestamp(t time.Time) graphql.Marshaler { return graphql.WriterFunc(func(w io.Writer) { io.WriteString(w, strconv.FormatInt(t.Unix(), 10)) }) } // Unmarshal{Typename} is only required if the scalar appears as an input. The raw values have // already been decoded // from json into int/float64/bool/nil/map[string]interface/[]interface func UnmarshalTimestamp(v any) (time.Time, error) { if tmpStr, ok := v.(int64); ok { return time.Unix(tmpStr, 0), nil } return time.Time{}, errors.New("time should be a unix timestamp") } // Lets redefine the base ID type to use an id from an external library func MarshalID(id external.ObjectID) graphql.Marshaler { return graphql.WriterFunc(func(w io.Writer) { io.WriteString(w, strconv.Quote(fmt.Sprintf("=%d=", id))) }) } // And the same for the unmarshaler func UnmarshalID(v any) (external.ObjectID, error) { str, ok := v.(string) if !ok { return 0, errors.New("ids must be strings") } i, err := strconv.Atoi(str[1 : len(str)-1]) return external.ObjectID(i), err } type SearchArgs struct { Location *Point CreatedAfter *time.Time IsBanned Banned } // A custom enum that uses integers to represent the values in memory but serialize as string for // graphql type Tier uint const ( TierA Tier = iota TierB Tier = iota TierC Tier = iota ) func TierForStr(str string) (Tier, error) { switch str { case "A": return TierA, nil case "B": return TierB, nil case "C": return TierC, nil default: return 0, fmt.Errorf("%s is not a valid Tier", str) } } func (e Tier) IsValid() bool { switch e { case TierA, TierB, TierC: return true } return false } func (e Tier) String() string { switch e { case TierA: return "A" case TierB: return "B" case TierC: return "C" default: panic("invalid enum value") } } func (e *Tier) UnmarshalGQL(v any) error { str, ok := v.(string) if !ok { return errors.New("enums must be strings") } var err error *e, err = TierForStr(str) return err } func (e Tier) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } type Prefs struct { DarkMode bool } func MarshalPreferences(p *Prefs) graphql.Marshaler { return graphql.MarshalBoolean(p.DarkMode) } func UnmarshalPreferences(v any) (*Prefs, error) { tmp, err := graphql.UnmarshalBoolean(v) if err != nil { return nil, err } return &Prefs{DarkMode: tmp}, nil } ================================================ FILE: _examples/scalars/resolvers.go ================================================ //go:generate go run ../../testdata/gqlgen.go package scalars import ( "context" "fmt" "time" "github.com/99designs/gqlgen/_examples/scalars/external" "github.com/99designs/gqlgen/_examples/scalars/model" ) type Resolver struct{} func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } func (r *Resolver) User() UserResolver { return &userResolver{r} } type queryResolver struct{ *Resolver } func (r *queryResolver) UserByTier( ctx context.Context, tier model.Tier, darkMode *model.Prefs, ) ([]*model.User, error) { panic("implement me") } func (r *queryResolver) User(ctx context.Context, id external.ObjectID) (*model.User, error) { return &model.User{ ID: id, Name: fmt.Sprintf("Test User %d", id), Created: time.Now(), Address: model.Address{ID: 1, Location: &model.Point{X: 1, Y: 2}}, Tier: model.TierC, }, nil } func (r *queryResolver) Search( ctx context.Context, input *model.SearchArgs, ) ([]*model.User, error) { location := model.Point{X: 1, Y: 2} if input.Location != nil { location = *input.Location } created := time.Now() if input.CreatedAfter != nil { created = *input.CreatedAfter } return []*model.User{ { ID: 1, Name: "Test User 1", Created: created, Address: model.Address{ID: 2, Location: &location}, Tier: model.TierA, }, { ID: 2, Name: "Test User 2", Created: created, Address: model.Address{ID: 1, Location: &location}, Tier: model.TierC, }, }, nil } type userResolver struct{ *Resolver } func (r *userResolver) PrimitiveResolver(ctx context.Context, obj *model.User) (string, error) { return "test", nil } func (r *userResolver) CustomResolver(ctx context.Context, obj *model.User) (*model.Point, error) { return &model.Point{X: 5, Y: 1}, nil } ================================================ FILE: _examples/scalars/scalar_test.go ================================================ package scalars import ( "testing" "time" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "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/introspection" ) type RawUser struct { ID string Name string Created int64 Address struct{ Location string } PrimitiveResolver string CustomResolver string Tier string } func TestScalars(t *testing.T) { srv := handler.New(NewExecutableSchema(Config{Resolvers: &Resolver{}})) srv.AddTransport(transport.POST{}) srv.Use(extension.Introspection{}) c := client.New(srv) t.Run("marshaling", func(t *testing.T) { var resp struct { User RawUser Search []RawUser } c.MustPost(`{ user(id:"=1=") { ...UserData } search(input:{location:"6,66", createdAfter:666}) { ...UserData } } fragment UserData on User { id name created tier address { location } }`, &resp) require.Equal(t, "1,2", resp.User.Address.Location) // There can be a delay between creation and test assertion, so we // give some leeway to eliminate false positives. require.WithinDuration(t, time.Now(), time.Unix(resp.User.Created, 0), 5*time.Second) require.Equal(t, "6,66", resp.Search[0].Address.Location) require.Equal(t, int64(666), resp.Search[0].Created) require.Equal(t, "A", resp.Search[0].Tier) }) t.Run("default search location", func(t *testing.T) { var resp struct{ Search []RawUser } err := c.Post(`{ search { address { location } } }`, &resp) require.NoError(t, err) require.Equal(t, "37,144", resp.Search[0].Address.Location) }) t.Run("custom error messages", func(t *testing.T) { var resp struct{ Search []RawUser } err := c.Post(`{ search(input:{createdAfter:"2014"}) { id } }`, &resp) require.EqualError( t, err, `[{"message":"time should be a unix timestamp","path":["search","input","createdAfter"]}]`, ) }) t.Run("scalar resolver methods", func(t *testing.T) { var resp struct{ User RawUser } c.MustPost(`{ user(id: "=1=") { primitiveResolver, customResolver } }`, &resp) require.Equal(t, "test", resp.User.PrimitiveResolver) require.Equal(t, "5,1", resp.User.CustomResolver) }) t.Run("introspection", func(t *testing.T) { // Make sure we can run the graphiql introspection query without errors var resp any c.MustPost(introspection.Query, &resp) }) } ================================================ FILE: _examples/scalars/schema.graphql ================================================ type Query { user(id: ID!): User search(input: SearchArgs = {location: "37,144", isBanned: false}): [User!]! userByTier(tier: Tier!, darkMode: DarkMode!): [User!]! } type User { id: ID! name: String! created: Timestamp modified: Timestamp valPrefs: DarkMode ptrPrefs: DarkMode isBanned: Banned! primitiveResolver: String! customResolver: Point! address: Address tier: Tier } type Address { id: ID! location: Point } input SearchArgs { location: Point createdAfter: Timestamp isBanned: Banned # TODO: This can be a Boolean again once multiple backing types are allowed } enum Tier { A B C } scalar Timestamp scalar Point scalar Banned scalar DarkMode ================================================ FILE: _examples/scalars/server/server.go ================================================ package main import ( "log" "net/http" "github.com/99designs/gqlgen/_examples/scalars" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/playground" ) func main() { srv := handler.New( scalars.NewExecutableSchema(scalars.Config{Resolvers: &scalars.Resolver{}}), ) srv.AddTransport(transport.GET{}) srv.AddTransport(transport.POST{}) http.Handle("/", playground.Handler("Starwars", "/query")) http.Handle("/query", srv) log.Fatal(http.ListenAndServe(":8084", nil)) } ================================================ FILE: _examples/selection/.gqlgen.yml ================================================ schema: schema.graphql model: filename: models_gen.go exec: filename: generated.go ================================================ FILE: _examples/selection/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package selection 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 { Query() QueryResolver } type DirectiveRoot struct { } type ComplexityRoot struct { Like struct { Collected func(childComplexity int) int Reaction func(childComplexity int) int Selection func(childComplexity int) int Sent func(childComplexity int) int } Post struct { Collected func(childComplexity int) int Message func(childComplexity int) int Selection func(childComplexity int) int Sent func(childComplexity int) int } Query struct { Events func(childComplexity int) int } } type QueryResolver interface { Events(ctx context.Context) ([]Event, error) } type executableSchema 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 "Like.collected": if e.ComplexityRoot.Like.Collected == nil { break } return e.ComplexityRoot.Like.Collected(childComplexity), true case "Like.reaction": if e.ComplexityRoot.Like.Reaction == nil { break } return e.ComplexityRoot.Like.Reaction(childComplexity), true case "Like.selection": if e.ComplexityRoot.Like.Selection == nil { break } return e.ComplexityRoot.Like.Selection(childComplexity), true case "Like.sent": if e.ComplexityRoot.Like.Sent == nil { break } return e.ComplexityRoot.Like.Sent(childComplexity), true case "Post.collected": if e.ComplexityRoot.Post.Collected == nil { break } return e.ComplexityRoot.Post.Collected(childComplexity), true case "Post.message": if e.ComplexityRoot.Post.Message == nil { break } return e.ComplexityRoot.Post.Message(childComplexity), true case "Post.selection": if e.ComplexityRoot.Post.Selection == nil { break } return e.ComplexityRoot.Post.Selection(childComplexity), true case "Post.sent": if e.ComplexityRoot.Post.Sent == nil { break } return e.ComplexityRoot.Post.Sent(childComplexity), true case "Query.events": if e.ComplexityRoot.Query.Events == nil { break } return e.ComplexityRoot.Query.Events(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___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) _Like_reaction(ctx context.Context, field graphql.CollectedField, obj *Like) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Like_reaction, func(ctx context.Context) (any, error) { return obj.Reaction, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Like_reaction(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Like", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Like_sent(ctx context.Context, field graphql.CollectedField, obj *Like) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Like_sent, func(ctx context.Context) (any, error) { return obj.Sent, nil }, nil, ec.marshalNTime2timeᚐTime, true, true, ) } func (ec *executionContext) fieldContext_Like_sent(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Like", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } func (ec *executionContext) _Like_selection(ctx context.Context, field graphql.CollectedField, obj *Like) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Like_selection, func(ctx context.Context) (any, error) { return obj.Selection, nil }, nil, ec.marshalOString2ᚕstringᚄ, true, false, ) } func (ec *executionContext) fieldContext_Like_selection(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Like", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Like_collected(ctx context.Context, field graphql.CollectedField, obj *Like) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Like_collected, func(ctx context.Context) (any, error) { return obj.Collected, nil }, nil, ec.marshalOString2ᚕstringᚄ, true, false, ) } func (ec *executionContext) fieldContext_Like_collected(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Like", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Post_message(ctx context.Context, field graphql.CollectedField, obj *Post) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Post_message, func(ctx context.Context) (any, error) { return obj.Message, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Post_message(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Post", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Post_sent(ctx context.Context, field graphql.CollectedField, obj *Post) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Post_sent, func(ctx context.Context) (any, error) { return obj.Sent, nil }, nil, ec.marshalNTime2timeᚐTime, true, true, ) } func (ec *executionContext) fieldContext_Post_sent(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Post", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } func (ec *executionContext) _Post_selection(ctx context.Context, field graphql.CollectedField, obj *Post) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Post_selection, func(ctx context.Context) (any, error) { return obj.Selection, nil }, nil, ec.marshalOString2ᚕstringᚄ, true, false, ) } func (ec *executionContext) fieldContext_Post_selection(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Post", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Post_collected(ctx context.Context, field graphql.CollectedField, obj *Post) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Post_collected, func(ctx context.Context) (any, error) { return obj.Collected, nil }, nil, ec.marshalOString2ᚕstringᚄ, true, false, ) } func (ec *executionContext) fieldContext_Post_collected(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Post", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_events(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_events, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Events(ctx) }, nil, ec.marshalOEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋselectionᚐEventᚄ, true, false, ) } func (ec *executionContext) fieldContext_Query_events(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } return fc, nil } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 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) ___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) _Event(ctx context.Context, sel ast.SelectionSet, obj Event) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null case Post: return ec._Post(ctx, sel, &obj) case *Post: if obj == nil { return graphql.Null } return ec._Post(ctx, sel, obj) case Like: return ec._Like(ctx, sel, &obj) case *Like: if obj == nil { return graphql.Null } return ec._Like(ctx, sel, obj) default: if typedObj, ok := obj.(graphql.Marshaler); ok { return typedObj } else { panic(fmt.Errorf("unexpected type %T; non-generated variants of Event must implement graphql.Marshaler", obj)) } } } // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var likeImplementors = []string{"Like", "Event"} func (ec *executionContext) _Like(ctx context.Context, sel ast.SelectionSet, obj *Like) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, likeImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Like") case "reaction": out.Values[i] = ec._Like_reaction(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "sent": out.Values[i] = ec._Like_sent(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "selection": out.Values[i] = ec._Like_selection(ctx, field, obj) case "collected": out.Values[i] = ec._Like_collected(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var postImplementors = []string{"Post", "Event"} func (ec *executionContext) _Post(ctx context.Context, sel ast.SelectionSet, obj *Post) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, postImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Post") case "message": out.Values[i] = ec._Post_message(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "sent": out.Values[i] = ec._Post_sent(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "selection": out.Values[i] = ec._Post_selection(ctx, field, obj) case "collected": out.Values[i] = ec._Post_collected(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "events": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_events(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) case "__schema": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": out.Values[i] = ec.___Directive_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "description": out.Values[i] = ec.___Directive_description(ctx, field, obj) case "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) marshalNEvent2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋselectionᚐEvent(ctx context.Context, sel ast.SelectionSet, v Event) 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._Event(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) 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) marshalOEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋselectionᚐEventᚄ(ctx context.Context, sel ast.SelectionSet, v []Event) 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.marshalNEvent2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋselectionᚐEvent(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 } 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__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/selection/models_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package selection import ( "time" ) type Event interface { IsEvent() GetSelection() []string GetCollected() []string } type Like struct { Reaction string `json:"reaction"` Sent time.Time `json:"sent"` Selection []string `json:"selection,omitempty"` Collected []string `json:"collected,omitempty"` } func (Like) IsEvent() {} func (this Like) GetSelection() []string { if this.Selection == nil { return nil } interfaceSlice := make([]string, 0, len(this.Selection)) for _, concrete := range this.Selection { interfaceSlice = append(interfaceSlice, concrete) } return interfaceSlice } func (this Like) GetCollected() []string { if this.Collected == nil { return nil } interfaceSlice := make([]string, 0, len(this.Collected)) for _, concrete := range this.Collected { interfaceSlice = append(interfaceSlice, concrete) } return interfaceSlice } type Post struct { Message string `json:"message"` Sent time.Time `json:"sent"` Selection []string `json:"selection,omitempty"` Collected []string `json:"collected,omitempty"` } func (Post) IsEvent() {} func (this Post) GetSelection() []string { if this.Selection == nil { return nil } interfaceSlice := make([]string, 0, len(this.Selection)) for _, concrete := range this.Selection { interfaceSlice = append(interfaceSlice, concrete) } return interfaceSlice } func (this Post) GetCollected() []string { if this.Collected == nil { return nil } interfaceSlice := make([]string, 0, len(this.Collected)) for _, concrete := range this.Collected { interfaceSlice = append(interfaceSlice, concrete) } return interfaceSlice } type Query struct { } ================================================ FILE: _examples/selection/readme.md ================================================ ### selection app This is the simplest example of a graphql server. to run this server ```bash go run ./server/server.go ``` and open http://localhost:8086 in your browser ================================================ FILE: _examples/selection/schema.graphql ================================================ interface Event { selection: [String!] collected: [String!] } type Post implements Event { message: String! sent: Time! selection: [String!] collected: [String!] } type Like implements Event { reaction: String! sent: Time! selection: [String!] collected: [String!] } type Query { events: [Event!] } scalar Time ================================================ FILE: _examples/selection/selection.go ================================================ //go:generate go run ../../testdata/gqlgen.go package selection import ( "context" "fmt" "net/http" "time" "github.com/vektah/gqlparser/v2/ast" "github.com/99designs/gqlgen/graphql" ) type Resolver struct{} func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } type queryResolver struct{ *Resolver } func (r *queryResolver) Events(ctx context.Context) ([]Event, error) { var sels []string opCtx := graphql.GetOperationContext(ctx) fieldSelections := graphql.GetFieldContext(ctx).Field.Selections for _, sel := range fieldSelections { switch sel := sel.(type) { case *ast.Field: sels = append(sels, fmt.Sprintf("%s as %s", sel.Name, sel.Alias)) case *ast.InlineFragment: sels = append(sels, fmt.Sprintf("inline fragment on %s", sel.TypeCondition)) case *ast.FragmentSpread: fragment := opCtx.Doc.Fragments.ForName(sel.Name) sels = append( sels, fmt.Sprintf("named fragment %s on %s", sel.Name, fragment.TypeCondition), ) } } var events []Event for i := 0; i < 10; i++ { if i%2 == 0 { events = append(events, &Like{ Selection: sels, Collected: formatCollected(graphql.CollectFieldsCtx(ctx, []string{"Like"})), Reaction: ":=)", Sent: time.Now(), }) } else { events = append(events, &Post{ Selection: sels, Collected: formatCollected( graphql.CollectFieldsCtx(ctx, []string{http.MethodPost}), ), Message: "Hey", Sent: time.Now(), }) } } return events, nil } func formatCollected(cf []graphql.CollectedField) []string { res := make([]string, len(cf)) for i, f := range cf { res[i] = f.Name + " as " + f.Alias } return res } ================================================ FILE: _examples/selection/selection_test.go ================================================ package selection 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" ) func TestSelection(t *testing.T) { srv := handler.New(NewExecutableSchema(Config{Resolvers: &Resolver{}})) srv.AddTransport(transport.POST{}) c := client.New(srv) query := `{ events { selection collected ... on Post { message sent } ...LikeFragment } } fragment LikeFragment on Like { reaction sent } ` var resp struct { Events []struct { Selection []string Collected []string Message string Reaction string Sent string } } c.MustPost(query, &resp) require.Equal(t, []string{ "selection as selection", "collected as collected", "inline fragment on Post", "named fragment LikeFragment on Like", }, resp.Events[0].Selection) require.Equal(t, []string{ "selection as selection", "collected as collected", "reaction as reaction", "sent as sent", }, resp.Events[0].Collected) } ================================================ FILE: _examples/selection/server/server.go ================================================ package main import ( "log" "net/http" "github.com/99designs/gqlgen/_examples/selection" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/playground" ) func main() { srv := handler.New( selection.NewExecutableSchema(selection.Config{Resolvers: &selection.Resolver{}}), ) srv.AddTransport(transport.GET{}) srv.AddTransport(transport.POST{}) http.Handle("/", playground.Handler("Selection Demo", "/query")) http.Handle("/query", srv) log.Fatal(http.ListenAndServe(":8086", nil)) } ================================================ FILE: _examples/starwars/.gqlgen.yml ================================================ exec: filename: generated/exec.go model: filename: models/generated.go package: models autobind: - github.com/99designs/gqlgen/_examples/starwars/models models: ReviewInput: model: models.Review Starship: fields: length: resolver: true ================================================ FILE: _examples/starwars/benchmarks_test.go ================================================ package starwars import ( "net/http" "net/http/httptest" "strings" "testing" "github.com/99designs/gqlgen/_examples/starwars/generated" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func BenchmarkSimpleQueryNoArgs(b *testing.B) { server := handler.New(generated.NewExecutableSchema(NewResolver())) server.AddTransport(transport.POST{}) q := `{"query":"{ search(text:\"Luke\") { ... on Human { starships { name } } } }"}` var body strings.Reader r := httptest.NewRequest(http.MethodPost, "/graphql", &body) r.Header.Set("Content-Type", "application/json") b.ReportAllocs() b.ResetTimer() rec := httptest.NewRecorder() for i := 0; i < b.N; i++ { body.Reset(q) rec.Body.Reset() server.ServeHTTP(rec, r) if rec.Body.String() != `{"data":{"search":[{"starships":[{"name":"X-Wing"},{"name":"Imperial shuttle"}]}]}}` { b.Fatalf("Unexpected response: %s", rec.Body.String()) } } } ================================================ FILE: _examples/starwars/generated/exec.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package generated import ( "bytes" "context" "errors" "fmt" "strconv" "sync/atomic" "time" "github.com/99designs/gqlgen/_examples/starwars/models" "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 { Droid() DroidResolver FriendsConnection() FriendsConnectionResolver Human() HumanResolver Mutation() MutationResolver Query() QueryResolver Starship() StarshipResolver } type DirectiveRoot struct { } type ComplexityRoot struct { Droid struct { AppearsIn func(childComplexity int) int Friends func(childComplexity int) int FriendsConnection func(childComplexity int, first *int, after *string) int ID func(childComplexity int) int Name func(childComplexity int) int PrimaryFunction func(childComplexity int) int } FriendsConnection struct { Edges func(childComplexity int) int Friends func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } FriendsEdge struct { Cursor func(childComplexity int) int Node func(childComplexity int) int } Human struct { AppearsIn func(childComplexity int) int Friends func(childComplexity int) int FriendsConnection func(childComplexity int, first *int, after *string) int Height func(childComplexity int, unit models.LengthUnit) int ID func(childComplexity int) int Mass func(childComplexity int) int Mutation func(childComplexity int) int Name func(childComplexity int) int Query func(childComplexity int) int Starships func(childComplexity int) int } Mutation struct { CreateReview func(childComplexity int, episode models.Episode, review models.Review) int } PageInfo struct { EndCursor func(childComplexity int) int HasNextPage func(childComplexity int) int StartCursor func(childComplexity int) int } Query struct { Character func(childComplexity int, id string) int Droid func(childComplexity int, id string) int Hero func(childComplexity int, episode *models.Episode) int Human func(childComplexity int, id string) int Reviews func(childComplexity int, episode models.Episode, since *time.Time) int Search func(childComplexity int, text string) int Starship func(childComplexity int, id string) int } Review struct { Commentary func(childComplexity int) int Stars func(childComplexity int) int Time func(childComplexity int) int } Starship struct { History func(childComplexity int) int ID func(childComplexity int) int Length func(childComplexity int, unit *models.LengthUnit) int Name func(childComplexity int) int } } type DroidResolver interface { Friends(ctx context.Context, obj *models.Droid) ([]models.Character, error) FriendsConnection(ctx context.Context, obj *models.Droid, first *int, after *string) (*models.FriendsConnection, error) } type FriendsConnectionResolver interface { Edges(ctx context.Context, obj *models.FriendsConnection) ([]*models.FriendsEdge, error) Friends(ctx context.Context, obj *models.FriendsConnection) ([]models.Character, error) } type HumanResolver interface { Friends(ctx context.Context, obj *models.Human) ([]models.Character, error) FriendsConnection(ctx context.Context, obj *models.Human, first *int, after *string) (*models.FriendsConnection, error) Starships(ctx context.Context, obj *models.Human) ([]*models.Starship, error) } type MutationResolver interface { CreateReview(ctx context.Context, episode models.Episode, review models.Review) (*models.Review, error) } type QueryResolver interface { Hero(ctx context.Context, episode *models.Episode) (models.Character, error) Reviews(ctx context.Context, episode models.Episode, since *time.Time) ([]*models.Review, error) Search(ctx context.Context, text string) ([]models.SearchResult, error) Character(ctx context.Context, id string) (models.Character, error) Droid(ctx context.Context, id string) (*models.Droid, error) Human(ctx context.Context, id string) (*models.Human, error) Starship(ctx context.Context, id string) (*models.Starship, error) } type StarshipResolver interface { Length(ctx context.Context, obj *models.Starship, unit *models.LengthUnit) (float64, error) } type executableSchema 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 "Droid.appearsIn": if e.ComplexityRoot.Droid.AppearsIn == nil { break } return e.ComplexityRoot.Droid.AppearsIn(childComplexity), true case "Droid.friends": if e.ComplexityRoot.Droid.Friends == nil { break } return e.ComplexityRoot.Droid.Friends(childComplexity), true case "Droid.friendsConnection": if e.ComplexityRoot.Droid.FriendsConnection == nil { break } args, err := ec.field_Droid_friendsConnection_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Droid.FriendsConnection(childComplexity, args["first"].(*int), args["after"].(*string)), true case "Droid.id": if e.ComplexityRoot.Droid.ID == nil { break } return e.ComplexityRoot.Droid.ID(childComplexity), true case "Droid.name": if e.ComplexityRoot.Droid.Name == nil { break } return e.ComplexityRoot.Droid.Name(childComplexity), true case "Droid.primaryFunction": if e.ComplexityRoot.Droid.PrimaryFunction == nil { break } return e.ComplexityRoot.Droid.PrimaryFunction(childComplexity), true case "FriendsConnection.edges": if e.ComplexityRoot.FriendsConnection.Edges == nil { break } return e.ComplexityRoot.FriendsConnection.Edges(childComplexity), true case "FriendsConnection.friends": if e.ComplexityRoot.FriendsConnection.Friends == nil { break } return e.ComplexityRoot.FriendsConnection.Friends(childComplexity), true case "FriendsConnection.pageInfo": if e.ComplexityRoot.FriendsConnection.PageInfo == nil { break } return e.ComplexityRoot.FriendsConnection.PageInfo(childComplexity), true case "FriendsConnection.totalCount": if e.ComplexityRoot.FriendsConnection.TotalCount == nil { break } return e.ComplexityRoot.FriendsConnection.TotalCount(childComplexity), true case "FriendsEdge.cursor": if e.ComplexityRoot.FriendsEdge.Cursor == nil { break } return e.ComplexityRoot.FriendsEdge.Cursor(childComplexity), true case "FriendsEdge.node": if e.ComplexityRoot.FriendsEdge.Node == nil { break } return e.ComplexityRoot.FriendsEdge.Node(childComplexity), true case "Human.appearsIn": if e.ComplexityRoot.Human.AppearsIn == nil { break } return e.ComplexityRoot.Human.AppearsIn(childComplexity), true case "Human.friends": if e.ComplexityRoot.Human.Friends == nil { break } return e.ComplexityRoot.Human.Friends(childComplexity), true case "Human.friendsConnection": if e.ComplexityRoot.Human.FriendsConnection == nil { break } args, err := ec.field_Human_friendsConnection_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Human.FriendsConnection(childComplexity, args["first"].(*int), args["after"].(*string)), true case "Human.height": if e.ComplexityRoot.Human.Height == nil { break } args, err := ec.field_Human_height_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Human.Height(childComplexity, args["unit"].(models.LengthUnit)), true case "Human.id": if e.ComplexityRoot.Human.ID == nil { break } return e.ComplexityRoot.Human.ID(childComplexity), true case "Human.mass": if e.ComplexityRoot.Human.Mass == nil { break } return e.ComplexityRoot.Human.Mass(childComplexity), true case "Human.mutation": if e.ComplexityRoot.Human.Mutation == nil { break } return e.ComplexityRoot.Human.Mutation(childComplexity), true case "Human.name": if e.ComplexityRoot.Human.Name == nil { break } return e.ComplexityRoot.Human.Name(childComplexity), true case "Human.query": if e.ComplexityRoot.Human.Query == nil { break } return e.ComplexityRoot.Human.Query(childComplexity), true case "Human.starships": if e.ComplexityRoot.Human.Starships == nil { break } return e.ComplexityRoot.Human.Starships(childComplexity), true case "Mutation.createReview": if e.ComplexityRoot.Mutation.CreateReview == nil { break } args, err := ec.field_Mutation_createReview_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Mutation.CreateReview(childComplexity, args["episode"].(models.Episode), args["review"].(models.Review)), true case "PageInfo.endCursor": if e.ComplexityRoot.PageInfo.EndCursor == nil { break } return e.ComplexityRoot.PageInfo.EndCursor(childComplexity), true case "PageInfo.hasNextPage": if e.ComplexityRoot.PageInfo.HasNextPage == nil { break } return e.ComplexityRoot.PageInfo.HasNextPage(childComplexity), true case "PageInfo.startCursor": if e.ComplexityRoot.PageInfo.StartCursor == nil { break } return e.ComplexityRoot.PageInfo.StartCursor(childComplexity), true case "Query.character": if e.ComplexityRoot.Query.Character == nil { break } args, err := ec.field_Query_character_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.Character(childComplexity, args["id"].(string)), true case "Query.droid": if e.ComplexityRoot.Query.Droid == nil { break } args, err := ec.field_Query_droid_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.Droid(childComplexity, args["id"].(string)), true case "Query.hero": if e.ComplexityRoot.Query.Hero == nil { break } args, err := ec.field_Query_hero_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.Hero(childComplexity, args["episode"].(*models.Episode)), true case "Query.human": if e.ComplexityRoot.Query.Human == nil { break } args, err := ec.field_Query_human_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.Human(childComplexity, args["id"].(string)), true case "Query.reviews": if e.ComplexityRoot.Query.Reviews == nil { break } args, err := ec.field_Query_reviews_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.Reviews(childComplexity, args["episode"].(models.Episode), args["since"].(*time.Time)), true case "Query.search": if e.ComplexityRoot.Query.Search == nil { break } args, err := ec.field_Query_search_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.Search(childComplexity, args["text"].(string)), true case "Query.starship": if e.ComplexityRoot.Query.Starship == nil { break } args, err := ec.field_Query_starship_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.Starship(childComplexity, args["id"].(string)), true case "Review.commentary": if e.ComplexityRoot.Review.Commentary == nil { break } return e.ComplexityRoot.Review.Commentary(childComplexity), true case "Review.stars": if e.ComplexityRoot.Review.Stars == nil { break } return e.ComplexityRoot.Review.Stars(childComplexity), true case "Review.time": if e.ComplexityRoot.Review.Time == nil { break } return e.ComplexityRoot.Review.Time(childComplexity), true case "Starship.history": if e.ComplexityRoot.Starship.History == nil { break } return e.ComplexityRoot.Starship.History(childComplexity), true case "Starship.id": if e.ComplexityRoot.Starship.ID == nil { break } return e.ComplexityRoot.Starship.ID(childComplexity), true case "Starship.length": if e.ComplexityRoot.Starship.Length == nil { break } args, err := ec.field_Starship_length_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Starship.Length(childComplexity, args["unit"].(*models.LengthUnit)), true case "Starship.name": if e.ComplexityRoot.Starship.Name == nil { break } return e.ComplexityRoot.Starship.Name(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.unmarshalInputReviewInput, ) 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(), } } 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: `# The query type, represents all of the entry points into our object graph type Query { hero(episode: Episode = NEWHOPE): Character reviews(episode: Episode!, since: Time): [Review!]! search(text: String!): [SearchResult!]! character(id: ID!): Character droid(id: ID!): Droid human(id: ID!): Human starship(id: ID!): Starship } # The mutation type, represents all updates we can make to our data type Mutation { createReview(episode: Episode!, review: ReviewInput!): Review } # The episodes in the Star Wars trilogy enum Episode { # Star Wars Episode IV: A New Hope, released in 1977. NEWHOPE # Star Wars Episode V: The Empire Strikes Back, released in 1980. EMPIRE # Star Wars Episode VI: Return of the Jedi, released in 1983. JEDI } # A character from the Star Wars universe interface Character { # The ID of the character id: ID! # The name of the character name: String! # The friends of the character, or an empty list if they have none friends: [Character!] # The friends of the character exposed as a connection with edges friendsConnection(first: Int, after: ID): FriendsConnection! # The movies this character appears in appearsIn: [Episode!]! } # Units of height enum LengthUnit { # The standard unit around the world METER # Primarily used in the United States FOOT } # A humanoid creature from the Star Wars universe type Human implements Character { # The ID of the human id: ID! # What this human calls themselves name: String! # Height in the preferred unit, default is meters height(unit: LengthUnit = METER): Float! # Mass in kilograms, or null if unknown mass: Float # This human's friends, or an empty list if they have none friends: [Character!] # The friends of the human exposed as a connection with edges friendsConnection(first: Int, after: ID): FriendsConnection! # The movies this human appears in appearsIn: [Episode!]! # A list of starships this person has piloted, or an empty list if none starships: [Starship!] # Root level query query: Query! # Root level mutation mutation: Mutation! } # An autonomous mechanical character in the Star Wars universe type Droid implements Character { # The ID of the droid id: ID! # What others call this droid name: String! # This droid's friends, or an empty list if they have none friends: [Character!] # The friends of the droid exposed as a connection with edges friendsConnection(first: Int, after: ID): FriendsConnection! # The movies this droid appears in appearsIn: [Episode!]! # This droid's primary function primaryFunction: String } # A connection object for a character's friends type FriendsConnection { # The total number of friends totalCount: Int! # The edges for each of the character's friends. edges: [FriendsEdge!] # A list of the friends, as a convenience when edges are not needed. friends: [Character!] # Information for paginating this connection pageInfo: PageInfo! } # An edge object for a character's friends type FriendsEdge { # A cursor used for pagination cursor: ID! # The character represented by this friendship edge node: Character } # Information for paginating this connection type PageInfo { startCursor: ID! endCursor: ID! hasNextPage: Boolean! } # Represents a review for a movie type Review { # The number of stars this review gave, 1-5 stars: Int! # Comment about the movie commentary: String # when the review was posted time: Time } # The input object sent when someone is creating a new review input ReviewInput { # 0-5 stars stars: Int! # Comment about the movie, optional commentary: String # when the review was posted time: Time } type Starship { # The ID of the starship id: ID! # The name of the starship name: String! # Length of the starship, along the longest axis length(unit: LengthUnit = METER): Float! # coordinates tracking this ship history: [[Int!]!]! } union SearchResult = Human | Droid | Starship scalar Time `, BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) field_Droid_friendsConnection_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "first", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["first"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "after", ec.unmarshalOID2ᚖstring) if err != nil { return nil, err } args["after"] = arg1 return args, nil } func (ec *executionContext) field_Human_friendsConnection_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "first", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["first"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "after", ec.unmarshalOID2ᚖstring) if err != nil { return nil, err } args["after"] = arg1 return args, nil } func (ec *executionContext) field_Human_height_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "unit", ec.unmarshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐLengthUnit) if err != nil { return nil, err } args["unit"] = arg0 return args, nil } func (ec *executionContext) field_Mutation_createReview_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "episode", ec.unmarshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisode) if err != nil { return nil, err } args["episode"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "review", ec.unmarshalNReviewInput2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐReview) if err != nil { return nil, err } args["review"] = arg1 return args, nil } func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]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_character_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.unmarshalNID2string) if err != nil { return nil, err } args["id"] = arg0 return args, nil } func (ec *executionContext) field_Query_droid_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", ec.unmarshalNID2string) if err != nil { return nil, err } args["id"] = arg0 return args, nil } func (ec *executionContext) field_Query_hero_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "episode", ec.unmarshalOEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisode) if err != nil { return nil, err } args["episode"] = arg0 return args, nil } func (ec *executionContext) field_Query_human_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", ec.unmarshalNID2string) if err != nil { return nil, err } args["id"] = arg0 return args, nil } func (ec *executionContext) field_Query_reviews_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "episode", ec.unmarshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisode) if err != nil { return nil, err } args["episode"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "since", ec.unmarshalOTime2ᚖtimeᚐTime) if err != nil { return nil, err } args["since"] = arg1 return args, nil } func (ec *executionContext) field_Query_search_args(ctx context.Context, rawArgs map[string]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 return args, nil } func (ec *executionContext) field_Query_starship_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.unmarshalNID2string) if err != nil { return nil, err } args["id"] = arg0 return args, nil } func (ec *executionContext) field_Starship_length_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "unit", ec.unmarshalOLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐLengthUnit) if err != nil { return nil, err } args["unit"] = 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) _Droid_id(ctx context.Context, field graphql.CollectedField, obj *models.Droid) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Droid_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, nil, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_Droid_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Droid", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _Droid_name(ctx context.Context, field graphql.CollectedField, obj *models.Droid) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Droid_name, func(ctx context.Context) (any, error) { return obj.Name, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Droid_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Droid", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Droid_friends(ctx context.Context, field graphql.CollectedField, obj *models.Droid) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Droid_friends, func(ctx context.Context) (any, error) { return ec.Resolvers.Droid().Friends(ctx, obj) }, nil, ec.marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐCharacterᚄ, true, false, ) } func (ec *executionContext) fieldContext_Droid_friends(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Droid", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } return fc, nil } func (ec *executionContext) _Droid_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *models.Droid) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Droid_friendsConnection, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Droid().FriendsConnection(ctx, obj, fc.Args["first"].(*int), fc.Args["after"].(*string)) }, nil, ec.marshalNFriendsConnection2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐFriendsConnection, true, true, ) } func (ec *executionContext) fieldContext_Droid_friendsConnection(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Droid", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "totalCount": return ec.fieldContext_FriendsConnection_totalCount(ctx, field) case "edges": return ec.fieldContext_FriendsConnection_edges(ctx, field) case "friends": return ec.fieldContext_FriendsConnection_friends(ctx, field) case "pageInfo": return ec.fieldContext_FriendsConnection_pageInfo(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type FriendsConnection", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Droid_friendsConnection_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Droid_appearsIn(ctx context.Context, field graphql.CollectedField, obj *models.Droid) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Droid_appearsIn, func(ctx context.Context) (any, error) { return obj.AppearsIn, nil }, nil, ec.marshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisodeᚄ, true, true, ) } func (ec *executionContext) fieldContext_Droid_appearsIn(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Droid", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Episode does not have child fields") }, } return fc, nil } func (ec *executionContext) _Droid_primaryFunction(ctx context.Context, field graphql.CollectedField, obj *models.Droid) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Droid_primaryFunction, func(ctx context.Context) (any, error) { return obj.PrimaryFunction, nil }, nil, ec.marshalOString2string, true, false, ) } func (ec *executionContext) fieldContext_Droid_primaryFunction(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Droid", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _FriendsConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *models.FriendsConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_FriendsConnection_totalCount, func(ctx context.Context) (any, error) { return obj.TotalCount(), nil }, nil, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_FriendsConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "FriendsConnection", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _FriendsConnection_edges(ctx context.Context, field graphql.CollectedField, obj *models.FriendsConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_FriendsConnection_edges, func(ctx context.Context) (any, error) { return ec.Resolvers.FriendsConnection().Edges(ctx, obj) }, nil, ec.marshalOFriendsEdge2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐFriendsEdgeᚄ, true, false, ) } func (ec *executionContext) fieldContext_FriendsConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "FriendsConnection", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "cursor": return ec.fieldContext_FriendsEdge_cursor(ctx, field) case "node": return ec.fieldContext_FriendsEdge_node(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type FriendsEdge", field.Name) }, } return fc, nil } func (ec *executionContext) _FriendsConnection_friends(ctx context.Context, field graphql.CollectedField, obj *models.FriendsConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_FriendsConnection_friends, func(ctx context.Context) (any, error) { return ec.Resolvers.FriendsConnection().Friends(ctx, obj) }, nil, ec.marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐCharacterᚄ, true, false, ) } func (ec *executionContext) fieldContext_FriendsConnection_friends(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "FriendsConnection", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } return fc, nil } func (ec *executionContext) _FriendsConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *models.FriendsConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_FriendsConnection_pageInfo, func(ctx context.Context) (any, error) { return obj.PageInfo(), nil }, nil, ec.marshalNPageInfo2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐPageInfo, true, true, ) } func (ec *executionContext) fieldContext_FriendsConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "FriendsConnection", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "startCursor": return ec.fieldContext_PageInfo_startCursor(ctx, field) case "endCursor": return ec.fieldContext_PageInfo_endCursor(ctx, field) case "hasNextPage": return ec.fieldContext_PageInfo_hasNextPage(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } func (ec *executionContext) _FriendsEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *models.FriendsEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_FriendsEdge_cursor, func(ctx context.Context) (any, error) { return obj.Cursor, nil }, nil, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_FriendsEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "FriendsEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _FriendsEdge_node(ctx context.Context, field graphql.CollectedField, obj *models.FriendsEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_FriendsEdge_node, func(ctx context.Context) (any, error) { return obj.Node, nil }, nil, ec.marshalOCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐCharacter, true, false, ) } func (ec *executionContext) fieldContext_FriendsEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "FriendsEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } return fc, nil } func (ec *executionContext) _Human_id(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Human_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, nil, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_Human_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Human", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _Human_name(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Human_name, func(ctx context.Context) (any, error) { return obj.Name, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Human_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Human", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Human_height(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Human_height, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return obj.Height(fc.Args["unit"].(models.LengthUnit)), nil }, nil, ec.marshalNFloat2float64, true, true, ) } func (ec *executionContext) fieldContext_Human_height(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Human", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Float does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Human_height_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Human_mass(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Human_mass, func(ctx context.Context) (any, error) { return obj.Mass, nil }, nil, ec.marshalOFloat2float64, true, false, ) } func (ec *executionContext) fieldContext_Human_mass(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Human", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Float does not have child fields") }, } return fc, nil } func (ec *executionContext) _Human_friends(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Human_friends, func(ctx context.Context) (any, error) { return ec.Resolvers.Human().Friends(ctx, obj) }, nil, ec.marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐCharacterᚄ, true, false, ) } func (ec *executionContext) fieldContext_Human_friends(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Human", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } return fc, nil } func (ec *executionContext) _Human_friendsConnection(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Human_friendsConnection, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Human().FriendsConnection(ctx, obj, fc.Args["first"].(*int), fc.Args["after"].(*string)) }, nil, ec.marshalNFriendsConnection2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐFriendsConnection, true, true, ) } func (ec *executionContext) fieldContext_Human_friendsConnection(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Human", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "totalCount": return ec.fieldContext_FriendsConnection_totalCount(ctx, field) case "edges": return ec.fieldContext_FriendsConnection_edges(ctx, field) case "friends": return ec.fieldContext_FriendsConnection_friends(ctx, field) case "pageInfo": return ec.fieldContext_FriendsConnection_pageInfo(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type FriendsConnection", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Human_friendsConnection_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Human_appearsIn(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Human_appearsIn, func(ctx context.Context) (any, error) { return obj.AppearsIn, nil }, nil, ec.marshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisodeᚄ, true, true, ) } func (ec *executionContext) fieldContext_Human_appearsIn(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Human", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Episode does not have child fields") }, } return fc, nil } func (ec *executionContext) _Human_starships(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Human_starships, func(ctx context.Context) (any, error) { return ec.Resolvers.Human().Starships(ctx, obj) }, nil, ec.marshalOStarship2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐStarshipᚄ, true, false, ) } func (ec *executionContext) fieldContext_Human_starships(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Human", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Starship_id(ctx, field) case "name": return ec.fieldContext_Starship_name(ctx, field) case "length": return ec.fieldContext_Starship_length(ctx, field) case "history": return ec.fieldContext_Starship_history(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Starship", field.Name) }, } return fc, nil } func (ec *executionContext) _Human_query(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Human_query(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() res := models.Query{} fc.Result = res return ec.marshalNQuery2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐQuery(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Human_query(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Human", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "hero": return ec.fieldContext_Query_hero(ctx, field) case "reviews": return ec.fieldContext_Query_reviews(ctx, field) case "search": return ec.fieldContext_Query_search(ctx, field) case "character": return ec.fieldContext_Query_character(ctx, field) case "droid": return ec.fieldContext_Query_droid(ctx, field) case "human": return ec.fieldContext_Query_human(ctx, field) case "starship": return ec.fieldContext_Query_starship(ctx, field) case "__schema": return ec.fieldContext_Query___schema(ctx, field) case "__type": return ec.fieldContext_Query___type(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Query", field.Name) }, } return fc, nil } func (ec *executionContext) _Human_mutation(ctx context.Context, field graphql.CollectedField, obj *models.Human) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Human_mutation(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() res := models.Mutation{} fc.Result = res return ec.marshalNMutation2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐMutation(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Human_mutation(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Human", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "createReview": return ec.fieldContext_Mutation_createReview(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Mutation", field.Name) }, } return fc, nil } func (ec *executionContext) _Mutation_createReview(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Mutation_createReview, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Mutation().CreateReview(ctx, fc.Args["episode"].(models.Episode), fc.Args["review"].(models.Review)) }, nil, ec.marshalOReview2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐReview, true, false, ) } func (ec *executionContext) fieldContext_Mutation_createReview(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "stars": return ec.fieldContext_Review_stars(ctx, field) case "commentary": return ec.fieldContext_Review_commentary(ctx, field) case "time": return ec.fieldContext_Review_time(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Review", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_createReview_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *models.PageInfo) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PageInfo_startCursor, func(ctx context.Context) (any, error) { return obj.StartCursor, nil }, nil, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_PageInfo_startCursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PageInfo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *models.PageInfo) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PageInfo_endCursor, func(ctx context.Context) (any, error) { return obj.EndCursor, nil }, nil, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_PageInfo_endCursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PageInfo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *models.PageInfo) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PageInfo_hasNextPage, func(ctx context.Context) (any, error) { return obj.HasNextPage, nil }, nil, ec.marshalNBoolean2bool, true, true, ) } func (ec *executionContext) fieldContext_PageInfo_hasNextPage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PageInfo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_hero(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_hero, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().Hero(ctx, fc.Args["episode"].(*models.Episode)) }, nil, ec.marshalOCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐCharacter, true, false, ) } func (ec *executionContext) fieldContext_Query_hero(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_hero_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_reviews(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_reviews, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().Reviews(ctx, fc.Args["episode"].(models.Episode), fc.Args["since"].(*time.Time)) }, nil, ec.marshalNReview2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐReviewᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_reviews(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "stars": return ec.fieldContext_Review_stars(ctx, field) case "commentary": return ec.fieldContext_Review_commentary(ctx, field) case "time": return ec.fieldContext_Review_time(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Review", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_reviews_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_search(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_search, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().Search(ctx, fc.Args["text"].(string)) }, nil, ec.marshalNSearchResult2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐSearchResultᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_search(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type SearchResult does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_search_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_character(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_character, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().Character(ctx, fc.Args["id"].(string)) }, nil, ec.marshalOCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐCharacter, true, false, ) } func (ec *executionContext) fieldContext_Query_character(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_character_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_droid(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_droid, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().Droid(ctx, fc.Args["id"].(string)) }, nil, ec.marshalODroid2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐDroid, true, false, ) } func (ec *executionContext) fieldContext_Query_droid(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Droid_id(ctx, field) case "name": return ec.fieldContext_Droid_name(ctx, field) case "friends": return ec.fieldContext_Droid_friends(ctx, field) case "friendsConnection": return ec.fieldContext_Droid_friendsConnection(ctx, field) case "appearsIn": return ec.fieldContext_Droid_appearsIn(ctx, field) case "primaryFunction": return ec.fieldContext_Droid_primaryFunction(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Droid", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_droid_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_human(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_human, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().Human(ctx, fc.Args["id"].(string)) }, nil, ec.marshalOHuman2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐHuman, true, false, ) } func (ec *executionContext) fieldContext_Query_human(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Human_id(ctx, field) case "name": return ec.fieldContext_Human_name(ctx, field) case "height": return ec.fieldContext_Human_height(ctx, field) case "mass": return ec.fieldContext_Human_mass(ctx, field) case "friends": return ec.fieldContext_Human_friends(ctx, field) case "friendsConnection": return ec.fieldContext_Human_friendsConnection(ctx, field) case "appearsIn": return ec.fieldContext_Human_appearsIn(ctx, field) case "starships": return ec.fieldContext_Human_starships(ctx, field) case "query": return ec.fieldContext_Human_query(ctx, field) case "mutation": return ec.fieldContext_Human_mutation(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Human", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_human_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_starship(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_starship, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().Starship(ctx, fc.Args["id"].(string)) }, nil, ec.marshalOStarship2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐStarship, true, false, ) } func (ec *executionContext) fieldContext_Query_starship(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Starship_id(ctx, field) case "name": return ec.fieldContext_Starship_name(ctx, field) case "length": return ec.fieldContext_Starship_length(ctx, field) case "history": return ec.fieldContext_Starship_history(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Starship", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_starship_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 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) _Review_stars(ctx context.Context, field graphql.CollectedField, obj *models.Review) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Review_stars, func(ctx context.Context) (any, error) { return obj.Stars, nil }, nil, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_Review_stars(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Review", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _Review_commentary(ctx context.Context, field graphql.CollectedField, obj *models.Review) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Review_commentary, func(ctx context.Context) (any, error) { return obj.Commentary, nil }, nil, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Review_commentary(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Review", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Review_time(ctx context.Context, field graphql.CollectedField, obj *models.Review) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Review_time, func(ctx context.Context) (any, error) { return obj.Time, nil }, nil, ec.marshalOTime2timeᚐTime, true, false, ) } func (ec *executionContext) fieldContext_Review_time(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Review", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } func (ec *executionContext) _Starship_id(ctx context.Context, field graphql.CollectedField, obj *models.Starship) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Starship_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, nil, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_Starship_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Starship", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _Starship_name(ctx context.Context, field graphql.CollectedField, obj *models.Starship) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Starship_name, func(ctx context.Context) (any, error) { return obj.Name, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Starship_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Starship", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Starship_length(ctx context.Context, field graphql.CollectedField, obj *models.Starship) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Starship_length, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Starship().Length(ctx, obj, fc.Args["unit"].(*models.LengthUnit)) }, nil, ec.marshalNFloat2float64, true, true, ) } func (ec *executionContext) fieldContext_Starship_length(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Starship", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Float does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Starship_length_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Starship_history(ctx context.Context, field graphql.CollectedField, obj *models.Starship) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Starship_history, func(ctx context.Context) (any, error) { return obj.History, nil }, nil, ec.marshalNInt2ᚕᚕintᚄ, true, true, ) } func (ec *executionContext) fieldContext_Starship_history(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Starship", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 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) unmarshalInputReviewInput(ctx context.Context, obj any) (models.Review, error) { var it models.Review if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"stars", "commentary", "time"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "stars": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("stars")) data, err := ec.unmarshalNInt2int(ctx, v) if err != nil { return it, err } it.Stars = data case "commentary": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("commentary")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it.Commentary = data case "time": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("time")) data, err := ec.unmarshalOTime2timeᚐTime(ctx, v) if err != nil { return it, err } it.Time = data } } return it, nil } // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** func (ec *executionContext) _Character(ctx context.Context, sel ast.SelectionSet, obj models.Character) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null case models.Human: return ec._Human(ctx, sel, &obj) case *models.Human: if obj == nil { return graphql.Null } return ec._Human(ctx, sel, obj) case models.Droid: return ec._Droid(ctx, sel, &obj) case *models.Droid: if obj == nil { return graphql.Null } return ec._Droid(ctx, sel, obj) default: if typedObj, ok := obj.(graphql.Marshaler); ok { return typedObj } else { panic(fmt.Errorf("unexpected type %T; non-generated variants of Character must implement graphql.Marshaler", obj)) } } } func (ec *executionContext) _SearchResult(ctx context.Context, sel ast.SelectionSet, obj models.SearchResult) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null case models.Human: return ec._Human(ctx, sel, &obj) case *models.Human: if obj == nil { return graphql.Null } return ec._Human(ctx, sel, obj) case models.Droid: return ec._Droid(ctx, sel, &obj) case *models.Droid: if obj == nil { return graphql.Null } return ec._Droid(ctx, sel, obj) case models.Starship: return ec._Starship(ctx, sel, &obj) case *models.Starship: if obj == nil { return graphql.Null } return ec._Starship(ctx, sel, obj) default: if typedObj, ok := obj.(graphql.Marshaler); ok { return typedObj } else { panic(fmt.Errorf("unexpected type %T; non-generated variants of SearchResult must implement graphql.Marshaler", obj)) } } } // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var droidImplementors = []string{"Droid", "Character", "SearchResult"} func (ec *executionContext) _Droid(ctx context.Context, sel ast.SelectionSet, obj *models.Droid) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, droidImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Droid") case "id": out.Values[i] = ec._Droid_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "name": out.Values[i] = ec._Droid_name(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "friends": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Droid_friends(ctx, field, obj) return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "friendsConnection": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Droid_friendsConnection(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "appearsIn": out.Values[i] = ec._Droid_appearsIn(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "primaryFunction": out.Values[i] = ec._Droid_primaryFunction(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var friendsConnectionImplementors = []string{"FriendsConnection"} func (ec *executionContext) _FriendsConnection(ctx context.Context, sel ast.SelectionSet, obj *models.FriendsConnection) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, friendsConnectionImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("FriendsConnection") case "totalCount": out.Values[i] = ec._FriendsConnection_totalCount(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "edges": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._FriendsConnection_edges(ctx, field, obj) return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "friends": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._FriendsConnection_friends(ctx, field, obj) return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "pageInfo": out.Values[i] = ec._FriendsConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var friendsEdgeImplementors = []string{"FriendsEdge"} func (ec *executionContext) _FriendsEdge(ctx context.Context, sel ast.SelectionSet, obj *models.FriendsEdge) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, friendsEdgeImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("FriendsEdge") case "cursor": out.Values[i] = ec._FriendsEdge_cursor(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "node": out.Values[i] = ec._FriendsEdge_node(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var humanImplementors = []string{"Human", "Character", "SearchResult"} func (ec *executionContext) _Human(ctx context.Context, sel ast.SelectionSet, obj *models.Human) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, humanImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Human") case "id": out.Values[i] = ec._Human_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "name": out.Values[i] = ec._Human_name(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "height": out.Values[i] = ec._Human_height(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "mass": out.Values[i] = ec._Human_mass(ctx, field, obj) case "friends": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Human_friends(ctx, field, obj) return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "friendsConnection": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Human_friendsConnection(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "appearsIn": out.Values[i] = ec._Human_appearsIn(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "starships": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Human_starships(ctx, field, obj) return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "query": out.Values[i] = ec._Human_query(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "mutation": out.Values[i] = ec._Human_mutation(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var mutationImplementors = []string{"Mutation"} func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Mutation", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Mutation") case "createReview": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_createReview(ctx, field) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var pageInfoImplementors = []string{"PageInfo"} func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *models.PageInfo) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, pageInfoImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("PageInfo") case "startCursor": out.Values[i] = ec._PageInfo_startCursor(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "endCursor": out.Values[i] = ec._PageInfo_endCursor(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "hasNextPage": out.Values[i] = ec._PageInfo_hasNextPage(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "hero": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_hero(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "reviews": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_reviews(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "search": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_search(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "character": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_character(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "droid": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_droid(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "human": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_human(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "starship": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_starship(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) case "__schema": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var reviewImplementors = []string{"Review"} func (ec *executionContext) _Review(ctx context.Context, sel ast.SelectionSet, obj *models.Review) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, reviewImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Review") case "stars": out.Values[i] = ec._Review_stars(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "commentary": out.Values[i] = ec._Review_commentary(ctx, field, obj) case "time": out.Values[i] = ec._Review_time(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var starshipImplementors = []string{"Starship", "SearchResult"} func (ec *executionContext) _Starship(ctx context.Context, sel ast.SelectionSet, obj *models.Starship) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, starshipImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Starship") case "id": out.Values[i] = ec._Starship_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "name": out.Values[i] = ec._Starship_name(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "length": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Starship_length(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "history": out.Values[i] = ec._Starship_history(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": out.Values[i] = ec.___Directive_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "description": out.Values[i] = ec.___Directive_description(ctx, field, obj) case "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) marshalNCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v models.Character) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._Character(ctx, sel, v) } func (ec *executionContext) unmarshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisode(ctx context.Context, v any) (models.Episode, error) { var res models.Episode err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v models.Episode) graphql.Marshaler { return v } func (ec *executionContext) unmarshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisodeᚄ(ctx context.Context, v any) ([]models.Episode, error) { var vSlice []any vSlice = graphql.CoerceList(v) var err error res := make([]models.Episode, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) res[i], err = ec.unmarshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisode(ctx, vSlice[i]) if err != nil { return nil, err } } return res, nil } func (ec *executionContext) marshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisodeᚄ(ctx context.Context, sel ast.SelectionSet, v []models.Episode) 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.marshalNEpisode2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisode(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } 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) marshalNFriendsConnection2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐFriendsConnection(ctx context.Context, sel ast.SelectionSet, v models.FriendsConnection) graphql.Marshaler { return ec._FriendsConnection(ctx, sel, &v) } func (ec *executionContext) marshalNFriendsConnection2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐFriendsConnection(ctx context.Context, sel ast.SelectionSet, v *models.FriendsConnection) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._FriendsConnection(ctx, sel, v) } func (ec *executionContext) marshalNFriendsEdge2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐFriendsEdge(ctx context.Context, sel ast.SelectionSet, v *models.FriendsEdge) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._FriendsEdge(ctx, sel, v) } func (ec *executionContext) unmarshalNID2string(ctx context.Context, v 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) unmarshalNInt2ᚕintᚄ(ctx context.Context, v any) ([]int, error) { 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) marshalNInt2ᚕintᚄ(ctx context.Context, sel ast.SelectionSet, v []int) graphql.Marshaler { ret := make(graphql.Array, len(v)) for i := range v { ret[i] = ec.marshalNInt2int(ctx, sel, v[i]) } for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) unmarshalNInt2ᚕᚕintᚄ(ctx context.Context, v any) ([][]int, error) { 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.unmarshalNInt2ᚕintᚄ(ctx, vSlice[i]) if err != nil { return nil, err } } return res, nil } func (ec *executionContext) marshalNInt2ᚕᚕintᚄ(ctx context.Context, sel ast.SelectionSet, v [][]int) graphql.Marshaler { ret := make(graphql.Array, len(v)) for i := range v { ret[i] = ec.marshalNInt2ᚕintᚄ(ctx, sel, v[i]) } for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalNMutation2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐMutation(ctx context.Context, sel ast.SelectionSet, v models.Mutation) graphql.Marshaler { return ec._Mutation(ctx, sel) } func (ec *executionContext) marshalNPageInfo2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐPageInfo(ctx context.Context, sel ast.SelectionSet, v models.PageInfo) graphql.Marshaler { return ec._PageInfo(ctx, sel, &v) } func (ec *executionContext) marshalNQuery2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐQuery(ctx context.Context, sel ast.SelectionSet, v models.Query) graphql.Marshaler { return ec._Query(ctx, sel) } func (ec *executionContext) marshalNReview2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐReviewᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.Review) 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.marshalNReview2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐReview(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalNReview2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐReview(ctx context.Context, sel ast.SelectionSet, v *models.Review) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._Review(ctx, sel, v) } func (ec *executionContext) unmarshalNReviewInput2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐReview(ctx context.Context, v any) (models.Review, error) { res, err := ec.unmarshalInputReviewInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNSearchResult2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐSearchResult(ctx context.Context, sel ast.SelectionSet, v models.SearchResult) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._SearchResult(ctx, sel, v) } func (ec *executionContext) marshalNSearchResult2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐSearchResultᚄ(ctx context.Context, sel ast.SelectionSet, v []models.SearchResult) 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.marshalNSearchResult2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐSearchResult(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalNStarship2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐStarship(ctx context.Context, sel ast.SelectionSet, v *models.Starship) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._Starship(ctx, sel, v) } func (ec *executionContext) unmarshalNString2string(ctx context.Context, v 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) 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) marshalOCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐCharacter(ctx context.Context, sel ast.SelectionSet, v models.Character) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Character(ctx, sel, v) } func (ec *executionContext) marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐCharacterᚄ(ctx context.Context, sel ast.SelectionSet, v []models.Character) 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.marshalNCharacter2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐCharacter(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalODroid2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐDroid(ctx context.Context, sel ast.SelectionSet, v *models.Droid) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Droid(ctx, sel, v) } func (ec *executionContext) unmarshalOEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisode(ctx context.Context, v any) (*models.Episode, error) { if v == nil { return nil, nil } var res = new(models.Episode) err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOEpisode2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐEpisode(ctx context.Context, sel ast.SelectionSet, v *models.Episode) graphql.Marshaler { if v == nil { return graphql.Null } return v } func (ec *executionContext) unmarshalOFloat2float64(ctx context.Context, v any) (float64, error) { res, err := graphql.UnmarshalFloatContext(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { _ = sel res := graphql.MarshalFloatContext(v) return graphql.WrapContextMarshaler(ctx, res) } func (ec *executionContext) marshalOFriendsEdge2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐFriendsEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.FriendsEdge) 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.marshalNFriendsEdge2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐFriendsEdge(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalOHuman2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐHuman(ctx context.Context, sel ast.SelectionSet, v *models.Human) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Human(ctx, sel, v) } func (ec *executionContext) unmarshalOID2ᚖstring(ctx context.Context, v any) (*string, error) { if v == nil { return nil, nil } res, err := graphql.UnmarshalID(v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOID2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel _ = ctx res := graphql.MarshalID(*v) return res } 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) unmarshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐLengthUnit(ctx context.Context, v any) (models.LengthUnit, error) { var res models.LengthUnit err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOLengthUnit2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐLengthUnit(ctx context.Context, sel ast.SelectionSet, v models.LengthUnit) graphql.Marshaler { return v } func (ec *executionContext) unmarshalOLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐLengthUnit(ctx context.Context, v any) (*models.LengthUnit, error) { if v == nil { return nil, nil } var res = new(models.LengthUnit) err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOLengthUnit2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐLengthUnit(ctx context.Context, sel ast.SelectionSet, v *models.LengthUnit) graphql.Marshaler { if v == nil { return graphql.Null } return v } func (ec *executionContext) marshalOReview2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐReview(ctx context.Context, sel ast.SelectionSet, v *models.Review) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Review(ctx, sel, v) } func (ec *executionContext) marshalOStarship2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐStarshipᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.Starship) 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.marshalNStarship2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐStarship(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalOStarship2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋstarwarsᚋmodelsᚐStarship(ctx context.Context, sel ast.SelectionSet, v *models.Starship) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Starship(ctx, sel, v) } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v 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) unmarshalOTime2timeᚐTime(ctx context.Context, v any) (time.Time, error) { res, err := graphql.UnmarshalTime(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOTime2timeᚐTime(ctx context.Context, sel ast.SelectionSet, v time.Time) graphql.Marshaler { _ = sel _ = ctx res := graphql.MarshalTime(v) return res } func (ec *executionContext) unmarshalOTime2ᚖtimeᚐTime(ctx context.Context, v any) (*time.Time, error) { if v == nil { return nil, nil } res, err := graphql.UnmarshalTime(v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOTime2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel _ = ctx res := graphql.MarshalTime(*v) return res } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { 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/starwars/models/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package models import ( "bytes" "fmt" "io" "strconv" ) type Character interface { IsCharacter() GetID() string GetName() string GetFriends() []Character GetFriendsConnection() *FriendsConnection GetAppearsIn() []Episode } type SearchResult interface { IsSearchResult() } type FriendsEdge struct { Cursor string `json:"cursor"` Node Character `json:"node,omitempty"` } type Mutation struct { } type PageInfo struct { StartCursor string `json:"startCursor"` EndCursor string `json:"endCursor"` HasNextPage bool `json:"hasNextPage"` } type Query struct { } type Starship struct { ID string `json:"id"` Name string `json:"name"` Length float64 `json:"length"` History [][]int `json:"history"` } func (Starship) IsSearchResult() {} type Episode string const ( EpisodeNewhope Episode = "NEWHOPE" EpisodeEmpire Episode = "EMPIRE" EpisodeJedi Episode = "JEDI" ) var AllEpisode = []Episode{ EpisodeNewhope, EpisodeEmpire, EpisodeJedi, } func (e Episode) IsValid() bool { switch e { case EpisodeNewhope, EpisodeEmpire, EpisodeJedi: return true } return false } func (e Episode) String() string { return string(e) } func (e *Episode) UnmarshalGQL(v any) error { str, ok := v.(string) if !ok { return fmt.Errorf("enums must be strings") } *e = Episode(str) if !e.IsValid() { return fmt.Errorf("%s is not a valid Episode", str) } return nil } func (e Episode) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } func (e *Episode) UnmarshalJSON(b []byte) error { s, err := strconv.Unquote(string(b)) if err != nil { return err } return e.UnmarshalGQL(s) } func (e Episode) MarshalJSON() ([]byte, error) { var buf bytes.Buffer e.MarshalGQL(&buf) return buf.Bytes(), nil } type LengthUnit string const ( LengthUnitMeter LengthUnit = "METER" LengthUnitFoot LengthUnit = "FOOT" ) var AllLengthUnit = []LengthUnit{ LengthUnitMeter, LengthUnitFoot, } func (e LengthUnit) IsValid() bool { switch e { case LengthUnitMeter, LengthUnitFoot: return true } return false } func (e LengthUnit) String() string { return string(e) } func (e *LengthUnit) UnmarshalGQL(v any) error { str, ok := v.(string) if !ok { return fmt.Errorf("enums must be strings") } *e = LengthUnit(str) if !e.IsValid() { return fmt.Errorf("%s is not a valid LengthUnit", str) } return nil } func (e LengthUnit) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } func (e *LengthUnit) UnmarshalJSON(b []byte) error { s, err := strconv.Unquote(string(b)) if err != nil { return err } return e.UnmarshalGQL(s) } func (e LengthUnit) MarshalJSON() ([]byte, error) { var buf bytes.Buffer e.MarshalGQL(&buf) return buf.Bytes(), nil } ================================================ FILE: _examples/starwars/models/model.go ================================================ package models import ( "encoding/base64" "fmt" "time" ) type CharacterFields struct { ID string Name string FriendIds []string AppearsIn []Episode } func (cf CharacterFields) GetID() string { return cf.ID } func (cf CharacterFields) GetName() string { return cf.Name } func (cf CharacterFields) GetAppearsIn() []Episode { return cf.AppearsIn } func (cf CharacterFields) GetFriendsConnection() *FriendsConnection { return nil } // Handled in resolver func (cf CharacterFields) GetFriends() []Character { return nil } // Handled in resolver type Human struct { CharacterFields StarshipIds []string HeightMeters float64 Mass float64 } func (h *Human) Height(unit LengthUnit) float64 { switch unit { case "METER", "": return h.HeightMeters case "FOOT": return h.HeightMeters * 3.28084 default: panic("invalid unit") } } func (Human) IsCharacter() {} func (Human) IsSearchResult() {} type Review struct { Stars int Commentary *string Time time.Time } type Droid struct { CharacterFields PrimaryFunction string } func (Droid) IsCharacter() {} func (Droid) IsSearchResult() {} type FriendsConnection struct { Ids []string From int To int } func (f *FriendsConnection) TotalCount() int { return len(f.Ids) } func (f *FriendsConnection) PageInfo() PageInfo { return PageInfo{ StartCursor: EncodeCursor(f.From), EndCursor: EncodeCursor(f.To - 1), HasNextPage: f.To < len(f.Ids), } } func EncodeCursor(i int) string { return base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("cursor%d", i+1))) } ================================================ FILE: _examples/starwars/readme.md ================================================ ### starwars example This server demonstrates a few advanced features of graphql: - connections - unions - interfaces - enums to run this server ```bash go run ./server/server.go ``` and open http://localhost:8080 in your browser ================================================ FILE: _examples/starwars/resolvers.go ================================================ //go:generate rm -rf generated //go:generate go run ../../testdata/gqlgen.go package starwars import ( "context" "encoding/base64" "errors" "strconv" "strings" "time" "github.com/99designs/gqlgen/_examples/starwars/generated" "github.com/99designs/gqlgen/_examples/starwars/models" ) type Resolver struct { humans map[string]models.Human droid map[string]models.Droid starships map[string]models.Starship reviews map[models.Episode][]*models.Review } func (r *Resolver) Droid() generated.DroidResolver { return &droidResolver{r} } func (r *Resolver) FriendsConnection() generated.FriendsConnectionResolver { return &friendsConnectionResolver{r} } func (r *Resolver) Human() generated.HumanResolver { return &humanResolver{r} } func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} } func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } func (r *Resolver) Starship() generated.StarshipResolver { return &starshipResolver{r} } func (r *Resolver) resolveCharacters( ctx context.Context, ids []string, ) ([]models.Character, error) { result := make([]models.Character, len(ids)) for i, id := range ids { char, err := r.Query().Character(ctx, id) if err != nil { return nil, err } result[i] = char } return result, nil } type droidResolver struct{ *Resolver } func (r *droidResolver) Friends( ctx context.Context, obj *models.Droid, ) ([]models.Character, error) { return r.resolveCharacters(ctx, obj.FriendIds) } func (r *droidResolver) FriendsConnection( ctx context.Context, obj *models.Droid, first *int, after *string, ) (*models.FriendsConnection, error) { return r.resolveFriendConnection(ctx, obj.FriendIds, first, after) } type friendsConnectionResolver struct{ *Resolver } func (r *Resolver) resolveFriendConnection( _ context.Context, ids []string, first *int, after *string, ) (*models.FriendsConnection, error) { from := 0 if after != nil { b, err := base64.StdEncoding.DecodeString(*after) if err != nil { return nil, err } i, err := strconv.Atoi(strings.TrimPrefix(string(b), "cursor")) if err != nil { return nil, err } from = i } to := len(ids) if first != nil { to = from + *first if to > len(ids) { to = len(ids) } } return &models.FriendsConnection{ Ids: ids, From: from, To: to, }, nil } func (r *friendsConnectionResolver) Edges( ctx context.Context, obj *models.FriendsConnection, ) ([]*models.FriendsEdge, error) { friends, err := r.resolveCharacters(ctx, obj.Ids) if err != nil { return nil, err } edges := make([]*models.FriendsEdge, obj.To-obj.From) for i := range edges { edges[i] = &models.FriendsEdge{ Cursor: models.EncodeCursor(obj.From + i), Node: friends[obj.From+i], } } return edges, nil } func (r *friendsConnectionResolver) Friends( ctx context.Context, obj *models.FriendsConnection, ) ([]models.Character, error) { return r.resolveCharacters(ctx, obj.Ids) } type humanResolver struct{ *Resolver } func (r *humanResolver) Friends( ctx context.Context, obj *models.Human, ) ([]models.Character, error) { return r.resolveCharacters(ctx, obj.FriendIds) } func (r *humanResolver) FriendsConnection( ctx context.Context, obj *models.Human, first *int, after *string, ) (*models.FriendsConnection, error) { return r.resolveFriendConnection(ctx, obj.FriendIds, first, after) } func (r *humanResolver) Starships( ctx context.Context, obj *models.Human, ) ([]*models.Starship, error) { var result []*models.Starship for _, id := range obj.StarshipIds { char, err := r.Query().Starship(ctx, id) if err != nil { return nil, err } if char != nil { result = append(result, char) } } return result, nil } type mutationResolver struct{ *Resolver } func (r *mutationResolver) CreateReview( ctx context.Context, episode models.Episode, review models.Review, ) (*models.Review, error) { review.Time = time.Now() time.Sleep(1 * time.Second) r.reviews[episode] = append(r.reviews[episode], &review) return &review, nil } type queryResolver struct{ *Resolver } func (r *queryResolver) Hero( ctx context.Context, episode *models.Episode, ) (models.Character, error) { if *episode == models.EpisodeEmpire { return r.humans["1000"], nil } return r.droid["2001"], nil } func (r *queryResolver) Reviews( ctx context.Context, episode models.Episode, since *time.Time, ) ([]*models.Review, error) { if since == nil { return r.reviews[episode], nil } var filtered []*models.Review for _, rev := range r.reviews[episode] { if rev.Time.After(*since) { filtered = append(filtered, rev) } } return filtered, nil } func (r *queryResolver) Search(ctx context.Context, text string) ([]models.SearchResult, error) { var l []models.SearchResult for _, h := range r.humans { if strings.Contains(h.Name, text) { l = append(l, h) } } for _, d := range r.droid { if strings.Contains(d.Name, text) { l = append(l, d) } } for _, s := range r.starships { if strings.Contains(s.Name, text) { l = append(l, s) } } return l, nil } func (r *queryResolver) Character(ctx context.Context, id string) (models.Character, error) { if h, ok := r.humans[id]; ok { return &h, nil } if d, ok := r.droid[id]; ok { return &d, nil } return nil, nil } func (r *queryResolver) Droid(ctx context.Context, id string) (*models.Droid, error) { if d, ok := r.droid[id]; ok { return &d, nil } return nil, nil } func (r *queryResolver) Human(ctx context.Context, id string) (*models.Human, error) { if h, ok := r.humans[id]; ok { return &h, nil } return nil, nil } func (r *queryResolver) Starship(ctx context.Context, id string) (*models.Starship, error) { if s, ok := r.starships[id]; ok { return &s, nil } return nil, nil } type starshipResolver struct{ *Resolver } func (r *starshipResolver) Length( ctx context.Context, obj *models.Starship, unit *models.LengthUnit, ) (float64, error) { switch *unit { case models.LengthUnitMeter, "": return obj.Length, nil case models.LengthUnitFoot: return obj.Length * 3.28084, nil default: return 0, errors.New("invalid unit") } } func NewResolver() generated.Config { r := Resolver{} r.humans = map[string]models.Human{ "1000": { CharacterFields: models.CharacterFields{ ID: "1000", Name: "Luke Skywalker", FriendIds: []string{"1002", "1003", "2000", "2001"}, AppearsIn: []models.Episode{ models.EpisodeNewhope, models.EpisodeEmpire, models.EpisodeJedi, }, }, HeightMeters: 1.72, Mass: 77, StarshipIds: []string{"3001", "3003"}, }, "1001": { CharacterFields: models.CharacterFields{ ID: "1001", Name: "Darth Vader", FriendIds: []string{"1004"}, AppearsIn: []models.Episode{ models.EpisodeNewhope, models.EpisodeEmpire, models.EpisodeJedi, }, }, HeightMeters: 2.02, Mass: 136, StarshipIds: []string{"3002"}, }, "1002": { CharacterFields: models.CharacterFields{ ID: "1002", Name: "Han Solo", FriendIds: []string{"1000", "1003", "2001"}, AppearsIn: []models.Episode{ models.EpisodeNewhope, models.EpisodeEmpire, models.EpisodeJedi, }, }, HeightMeters: 1.8, Mass: 80, StarshipIds: []string{"3000", "3003"}, }, "1003": { CharacterFields: models.CharacterFields{ ID: "1003", Name: "Leia Organa", FriendIds: []string{"1000", "1002", "2000", "2001"}, AppearsIn: []models.Episode{ models.EpisodeNewhope, models.EpisodeEmpire, models.EpisodeJedi, }, }, HeightMeters: 1.5, Mass: 49, }, "1004": { CharacterFields: models.CharacterFields{ ID: "1004", Name: "Wilhuff Tarkin", FriendIds: []string{"1001"}, AppearsIn: []models.Episode{models.EpisodeNewhope}, }, HeightMeters: 1.8, Mass: 0, }, } r.droid = map[string]models.Droid{ "2000": { CharacterFields: models.CharacterFields{ ID: "2000", Name: "C-3PO", FriendIds: []string{"1000", "1002", "1003", "2001"}, AppearsIn: []models.Episode{ models.EpisodeNewhope, models.EpisodeEmpire, models.EpisodeJedi, }, }, PrimaryFunction: "Protocol", }, "2001": { CharacterFields: models.CharacterFields{ ID: "2001", Name: "R2-D2", FriendIds: []string{"1000", "1002", "1003"}, AppearsIn: []models.Episode{ models.EpisodeNewhope, models.EpisodeEmpire, models.EpisodeJedi, }, }, PrimaryFunction: "Astromech", }, } r.starships = map[string]models.Starship{ "3000": { ID: "3000", Name: "Millennium Falcon", History: [][]int{ {1, 2}, {4, 5}, {1, 2}, {3, 2}, }, Length: 34.37, }, "3001": { ID: "3001", Name: "X-Wing", History: [][]int{ {6, 4}, {3, 2}, {2, 3}, {5, 1}, }, Length: 12.5, }, "3002": { ID: "3002", Name: "TIE Advanced x1", History: [][]int{ {3, 2}, {7, 2}, {6, 4}, {3, 2}, }, Length: 9.2, }, "3003": { ID: "3003", Name: "Imperial shuttle", History: [][]int{ {1, 7}, {3, 5}, {5, 3}, {7, 1}, }, Length: 20, }, } r.reviews = map[models.Episode][]*models.Review{} return generated.Config{ Resolvers: &r, } } ================================================ FILE: _examples/starwars/schema.graphql ================================================ # The query type, represents all of the entry points into our object graph type Query { hero(episode: Episode = NEWHOPE): Character reviews(episode: Episode!, since: Time): [Review!]! search(text: String!): [SearchResult!]! character(id: ID!): Character droid(id: ID!): Droid human(id: ID!): Human starship(id: ID!): Starship } # The mutation type, represents all updates we can make to our data type Mutation { createReview(episode: Episode!, review: ReviewInput!): Review } # The episodes in the Star Wars trilogy enum Episode { # Star Wars Episode IV: A New Hope, released in 1977. NEWHOPE # Star Wars Episode V: The Empire Strikes Back, released in 1980. EMPIRE # Star Wars Episode VI: Return of the Jedi, released in 1983. JEDI } # A character from the Star Wars universe interface Character { # The ID of the character id: ID! # The name of the character name: String! # The friends of the character, or an empty list if they have none friends: [Character!] # The friends of the character exposed as a connection with edges friendsConnection(first: Int, after: ID): FriendsConnection! # The movies this character appears in appearsIn: [Episode!]! } # Units of height enum LengthUnit { # The standard unit around the world METER # Primarily used in the United States FOOT } # A humanoid creature from the Star Wars universe type Human implements Character { # The ID of the human id: ID! # What this human calls themselves name: String! # Height in the preferred unit, default is meters height(unit: LengthUnit = METER): Float! # Mass in kilograms, or null if unknown mass: Float # This human's friends, or an empty list if they have none friends: [Character!] # The friends of the human exposed as a connection with edges friendsConnection(first: Int, after: ID): FriendsConnection! # The movies this human appears in appearsIn: [Episode!]! # A list of starships this person has piloted, or an empty list if none starships: [Starship!] # Root level query query: Query! # Root level mutation mutation: Mutation! } # An autonomous mechanical character in the Star Wars universe type Droid implements Character { # The ID of the droid id: ID! # What others call this droid name: String! # This droid's friends, or an empty list if they have none friends: [Character!] # The friends of the droid exposed as a connection with edges friendsConnection(first: Int, after: ID): FriendsConnection! # The movies this droid appears in appearsIn: [Episode!]! # This droid's primary function primaryFunction: String } # A connection object for a character's friends type FriendsConnection { # The total number of friends totalCount: Int! # The edges for each of the character's friends. edges: [FriendsEdge!] # A list of the friends, as a convenience when edges are not needed. friends: [Character!] # Information for paginating this connection pageInfo: PageInfo! } # An edge object for a character's friends type FriendsEdge { # A cursor used for pagination cursor: ID! # The character represented by this friendship edge node: Character } # Information for paginating this connection type PageInfo { startCursor: ID! endCursor: ID! hasNextPage: Boolean! } # Represents a review for a movie type Review { # The number of stars this review gave, 1-5 stars: Int! # Comment about the movie commentary: String # when the review was posted time: Time } # The input object sent when someone is creating a new review input ReviewInput { # 0-5 stars stars: Int! # Comment about the movie, optional commentary: String # when the review was posted time: Time } type Starship { # The ID of the starship id: ID! # The name of the starship name: String! # Length of the starship, along the longest axis length(unit: LengthUnit = METER): Float! # coordinates tracking this ship history: [[Int!]!]! } union SearchResult = Human | Droid | Starship scalar Time ================================================ FILE: _examples/starwars/server/server.go ================================================ package main import ( "context" "fmt" "log" "net/http" "github.com/99designs/gqlgen/_examples/starwars" "github.com/99designs/gqlgen/_examples/starwars/generated" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/playground" ) func main() { srv := handler.New(generated.NewExecutableSchema(starwars.NewResolver())) srv.AddTransport(transport.GET{}) srv.AddTransport(transport.POST{}) srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res any, err error) { rc := graphql.GetFieldContext(ctx) fmt.Println("Entered", rc.Object, rc.Field.Name) res, err = next(ctx) fmt.Println("Left", rc.Object, rc.Field.Name, "=>", res, err) return res, err }) http.Handle("/", playground.Handler("Starwars", "/query")) http.Handle("/query", srv) log.Fatal(http.ListenAndServe(":8080", nil)) } ================================================ FILE: _examples/starwars/starwars_test.go ================================================ package starwars import ( "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/_examples/starwars/generated" "github.com/99designs/gqlgen/client" "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/introspection" ) func TestStarwars(t *testing.T) { srv := handler.New(generated.NewExecutableSchema(NewResolver())) srv.AddTransport(transport.POST{}) srv.Use(extension.Introspection{}) c := client.New(srv) t.Run("Lukes starships", func(t *testing.T) { var resp struct { Search []struct{ Starships []struct{ Name string } } } c.MustPost(`{ search(text:"Luke") { ... on Human { starships { name } } } }`, &resp) require.Equal(t, "X-Wing", resp.Search[0].Starships[0].Name) require.Equal(t, "Imperial shuttle", resp.Search[0].Starships[1].Name) }) t.Run("get character", func(t *testing.T) { var resp struct { Character struct { Name string Typename string `json:"__typename"` } } c.MustPost(`{ character(id:"2001") { name, __typename } }`, &resp) require.Equal(t, "R2-D2", resp.Character.Name) require.Equal(t, "Droid", resp.Character.Typename) }) t.Run("missing character", func(t *testing.T) { var resp struct { Character *struct{ Name string } } c.MustPost(`{ character(id:"2002") { name } }`, &resp) require.Nil(t, resp.Character) }) t.Run("get droid", func(t *testing.T) { var resp struct { Droid struct{ PrimaryFunction string } } c.MustPost(`{ droid(id:"2001") { primaryFunction } }`, &resp) require.Equal(t, "Astromech", resp.Droid.PrimaryFunction) }) t.Run("get human", func(t *testing.T) { var resp struct { Human struct { Starships []struct { Name string Length float64 } } } c.MustPost(`{ human(id:"1000") { starships { name length(unit:FOOT) } } }`, &resp) require.Equal(t, "X-Wing", resp.Human.Starships[0].Name) require.InDelta(t, 41.0105, resp.Human.Starships[0].Length, 0.0001) require.Equal(t, "Imperial shuttle", resp.Human.Starships[1].Name) require.InDelta(t, 65.6168, resp.Human.Starships[1].Length, 0.0001) }) t.Run("hero height", func(t *testing.T) { var resp struct { Hero struct { Height float64 } } c.MustPost(`{ hero(episode:EMPIRE) { ... on Human { height(unit:METER) } } }`, &resp) require.InDelta(t, 1.72, resp.Hero.Height, 0.001) }) t.Run("default hero episode", func(t *testing.T) { var resp struct { Hero struct { Name string } } c.MustPost(`{ hero { ... on Droid { name } } }`, &resp) require.Equal(t, "R2-D2", resp.Hero.Name) }) t.Run("friends", func(t *testing.T) { var resp struct { Human struct { Friends []struct { Name string } } } c.MustPost(`{ human(id: "1001") { friends { name } } }`, &resp) require.Equal(t, "Wilhuff Tarkin", resp.Human.Friends[0].Name) }) t.Run("friendsConnection.friends", func(t *testing.T) { var resp struct { Droid struct { FriendsConnection struct { Friends []struct { Name string } } } } c.MustPost(`{ droid(id:"2001") { friendsConnection { friends { name } } } }`, &resp) require.Equal(t, "Luke Skywalker", resp.Droid.FriendsConnection.Friends[0].Name) require.Equal(t, "Han Solo", resp.Droid.FriendsConnection.Friends[1].Name) require.Equal(t, "Leia Organa", resp.Droid.FriendsConnection.Friends[2].Name) }) t.Run("friendsConnection.edges", func(t *testing.T) { var resp struct { Droid struct { FriendsConnection struct { Edges []struct { Cursor string Node struct { Name string } } } } } c.MustPost( `{ droid(id:"2001") { friendsConnection { edges { cursor, node { name } } } } }`, &resp, ) require.Equal(t, "Y3Vyc29yMQ==", resp.Droid.FriendsConnection.Edges[0].Cursor) require.Equal(t, "Luke Skywalker", resp.Droid.FriendsConnection.Edges[0].Node.Name) require.Equal(t, "Y3Vyc29yMg==", resp.Droid.FriendsConnection.Edges[1].Cursor) require.Equal(t, "Han Solo", resp.Droid.FriendsConnection.Edges[1].Node.Name) require.Equal(t, "Y3Vyc29yMw==", resp.Droid.FriendsConnection.Edges[2].Cursor) require.Equal(t, "Leia Organa", resp.Droid.FriendsConnection.Edges[2].Node.Name) }) t.Run("unset optional arguments", func(t *testing.T) { var resp struct { Hero struct { FriendsConnection struct { Friends []struct { Name string } } } } query := ` query a($first:Int, $after:ID) { hero { friendsConnection(first:$first, after:$after) { friends { name } } } }` c.MustPost(query, &resp) require.Len(t, resp.Hero.FriendsConnection.Friends, 3) }) t.Run("mutations must be run in sequence", func(t *testing.T) { var resp struct { A struct{ Time string } B struct{ Time string } C struct{ Time string } } c.MustPost(`mutation f{ a:createReview(episode: NEWHOPE, review:{stars:1, commentary:"Blah blah"}) { time } b:createReview(episode: NEWHOPE, review:{stars:1, commentary:"Blah blah"}) { time } c:createReview(episode: NEWHOPE, review:{stars:1, commentary:"Blah blah"}) { time } }`, &resp) require.NotEqual(t, resp.A.Time, resp.B.Time) require.NotEqual(t, resp.C.Time, resp.B.Time) }) t.Run("multidimensional arrays", func(t *testing.T) { var resp struct { Starship struct { History [][]int } } c.MustPost(`{ starship(id:"3001") { history } }`, &resp) require.Len(t, resp.Starship.History, 4) require.Len(t, resp.Starship.History[0], 2) }) t.Run("invalid enums in variables", func(t *testing.T) { var resp struct{} err := c.Post(`mutation($episode: Episode!) { createReview(episode: $episode, review:{stars:1, commentary:"Blah blah"}) { time } }`, &resp, client.Var("episode", "INVALID")) require.EqualError( t, err, `http 422: {"errors":[{"message":"INVALID is not a valid Episode","path":["variable","episode"],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}],"data":null}`, ) }) t.Run("introspection", func(t *testing.T) { // Make sure we can run the graphiql introspection query without errors var resp any c.MustPost(introspection.Query, &resp) }) t.Run("aliased field and non-aliased field", func(t *testing.T) { var resp struct { Character struct { Name string } AliasedCharacter struct { Name string } } c.MustPost(`{ character(id: "2001") { name } aliasedCharacter: character(id: "2001") { name } }`, &resp) require.Equal(t, resp.Character, resp.AliasedCharacter) }) } ================================================ FILE: _examples/todo/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package todo 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 { MyMutation() MyMutationResolver MyQuery() MyQueryResolver } type DirectiveRoot struct { HasRole func(ctx context.Context, obj any, next graphql.Resolver, role Role) (res any, err error) User func(ctx context.Context, obj any, next graphql.Resolver, id int) (res any, err error) } type ComplexityRoot struct { MyMutation struct { CreateTodo func(childComplexity int, todo TodoInput) int UpdateTodo func(childComplexity int, id int, changes map[string]any) int } MyQuery struct { LastTodo func(childComplexity int) int Todo func(childComplexity int, id int) int Todos func(childComplexity int) int } Todo struct { Done func(childComplexity int) int ID func(childComplexity int) int Text func(childComplexity int) int } } type MyMutationResolver interface { CreateTodo(ctx context.Context, todo TodoInput) (*Todo, error) UpdateTodo(ctx context.Context, id int, changes map[string]any) (*Todo, error) } type MyQueryResolver interface { Todo(ctx context.Context, id int) (*Todo, error) LastTodo(ctx context.Context) (*Todo, error) Todos(ctx context.Context) ([]*Todo, error) } type executableSchema 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 "MyMutation.createTodo": if e.ComplexityRoot.MyMutation.CreateTodo == nil { break } args, err := ec.field_MyMutation_createTodo_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.MyMutation.CreateTodo(childComplexity, args["todo"].(TodoInput)), true case "MyMutation.updateTodo": if e.ComplexityRoot.MyMutation.UpdateTodo == nil { break } args, err := ec.field_MyMutation_updateTodo_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.MyMutation.UpdateTodo(childComplexity, args["id"].(int), args["changes"].(map[string]any)), true case "MyQuery.lastTodo": if e.ComplexityRoot.MyQuery.LastTodo == nil { break } return e.ComplexityRoot.MyQuery.LastTodo(childComplexity), true case "MyQuery.todo": if e.ComplexityRoot.MyQuery.Todo == nil { break } args, err := ec.field_MyQuery_todo_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.MyQuery.Todo(childComplexity, args["id"].(int)), true case "MyQuery.todos": if e.ComplexityRoot.MyQuery.Todos == nil { break } return e.ComplexityRoot.MyQuery.Todos(childComplexity), true case "Todo.done": if e.ComplexityRoot.Todo.Done == nil { break } return e.ComplexityRoot.Todo.Done(childComplexity), true case "Todo.id": if e.ComplexityRoot.Todo.ID == nil { break } return e.ComplexityRoot.Todo.ID(childComplexity), true case "Todo.text": if e.ComplexityRoot.Todo.Text == nil { break } return e.ComplexityRoot.Todo.Text(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.unmarshalInputTodoInput, ) 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._queryMiddleware(ctx, opCtx.Operation, func(ctx context.Context) (any, error) { return ec._MyQuery(ctx, opCtx.Operation.SelectionSet), nil }) } else { if atomic.LoadInt32(&ec.PendingDeferred) > 0 { result := <-ec.DeferredResults atomic.AddInt32(&ec.PendingDeferred, -1) data = result.Result response.Path = result.Path response.Label = result.Label response.Errors = result.Errors } else { return nil } } var buf bytes.Buffer data.MarshalGQL(&buf) response.Data = buf.Bytes() if atomic.LoadInt32(&ec.Deferred) > 0 { hasNext := atomic.LoadInt32(&ec.PendingDeferred) > 0 response.HasNext = &hasNext } return &response } case ast.Mutation: return func(ctx context.Context) *graphql.Response { if !first { return nil } first = false ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) data := ec._mutationMiddleware(ctx, opCtx.Operation, func(ctx context.Context) (any, error) { return ec._MyMutation(ctx, opCtx.Operation.SelectionSet), nil }) var buf bytes.Buffer data.MarshalGQL(&buf) return &graphql.Response{ Data: buf.Bytes(), } } default: return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) } } type executionContext struct { *graphql.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_hasRole_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, "role", ec.unmarshalNRole2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtodoᚐRole) if err != nil { return nil, err } args["role"] = arg0 return args, nil } 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, "id", ec.unmarshalNID2int) if err != nil { return nil, err } args["id"] = arg0 return args, nil } func (ec *executionContext) field_MyMutation_createTodo_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "todo", ec.unmarshalNTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtodoᚐTodoInput) if err != nil { return nil, err } args["todo"] = arg0 return args, nil } func (ec *executionContext) field_MyMutation_updateTodo_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", ec.unmarshalNID2int) if err != nil { return nil, err } args["id"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "changes", ec.unmarshalNMap2map) if err != nil { return nil, err } args["changes"] = arg1 return args, nil } func (ec *executionContext) field_MyQuery___type_args(ctx context.Context, rawArgs map[string]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_MyQuery_todo_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.unmarshalNID2int) if err != nil { return nil, err } args["id"] = 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) _queryMiddleware(ctx context.Context, obj *ast.OperationDefinition, next func(ctx context.Context) (any, error)) graphql.Marshaler { for _, d := range obj.Directives { switch d.Name { case "user": rawArgs := d.ArgumentMap(ec.Variables) args, err := ec.dir_user_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } n := next next = func(ctx context.Context) (any, error) { if ec.Directives.User == nil { return nil, errors.New("directive user is not implemented") } return ec.Directives.User(ctx, obj, n, args["id"].(int)) } } } tmp, err := next(ctx) if err != nil { ec.Error(ctx, err) return graphql.Null } if data, ok := tmp.(graphql.Marshaler); ok { return data } graphql.AddErrorf(ctx, `unexpected type %T from directive, should be graphql.Marshaler`, tmp) return graphql.Null } func (ec *executionContext) _mutationMiddleware(ctx context.Context, obj *ast.OperationDefinition, next func(ctx context.Context) (any, error)) graphql.Marshaler { for _, d := range obj.Directives { switch d.Name { case "user": rawArgs := d.ArgumentMap(ec.Variables) args, err := ec.dir_user_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } n := next next = func(ctx context.Context) (any, error) { if ec.Directives.User == nil { return nil, errors.New("directive user is not implemented") } return ec.Directives.User(ctx, obj, n, args["id"].(int)) } } } tmp, err := next(ctx) if err != nil { ec.Error(ctx, err) return graphql.Null } if data, ok := tmp.(graphql.Marshaler); ok { return data } graphql.AddErrorf(ctx, `unexpected type %T from directive, should be graphql.Marshaler`, tmp) return graphql.Null } func (ec *executionContext) _fieldMiddleware(ctx context.Context, obj any, next graphql.Resolver) graphql.Resolver { fc := graphql.GetFieldContext(ctx) for _, d := range fc.Field.Directives { switch d.Name { case "user": rawArgs := d.ArgumentMap(ec.Variables) args, err := ec.dir_user_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return nil } n := next next = func(ctx context.Context) (any, error) { if ec.Directives.User == nil { return nil, errors.New("directive user is not implemented") } return ec.Directives.User(ctx, obj, n, args["id"].(int)) } } } return next } // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_MyMutation_createTodo, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.MyMutation().CreateTodo(ctx, fc.Args["todo"].(TodoInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtodoᚐTodo, true, true, ) } func (ec *executionContext) fieldContext_MyMutation_createTodo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MyMutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Todo_id(ctx, field) case "text": return ec.fieldContext_Todo_text(ctx, field) case "done": return ec.fieldContext_Todo_done(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_MyMutation_createTodo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _MyMutation_updateTodo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_MyMutation_updateTodo, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.MyMutation().UpdateTodo(ctx, fc.Args["id"].(int), fc.Args["changes"].(map[string]any)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtodoᚐTodo, true, false, ) } func (ec *executionContext) fieldContext_MyMutation_updateTodo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MyMutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Todo_id(ctx, field) case "text": return ec.fieldContext_Todo_text(ctx, field) case "done": return ec.fieldContext_Todo_done(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_MyMutation_updateTodo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_MyQuery_todo, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.MyQuery().Todo(ctx, fc.Args["id"].(int)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtodoᚐTodo, true, false, ) } func (ec *executionContext) fieldContext_MyQuery_todo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MyQuery", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Todo_id(ctx, field) case "text": return ec.fieldContext_Todo_text(ctx, field) case "done": return ec.fieldContext_Todo_done(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_MyQuery_todo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _MyQuery_lastTodo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_MyQuery_lastTodo, func(ctx context.Context) (any, error) { return ec.Resolvers.MyQuery().LastTodo(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtodoᚐTodo, true, false, ) } func (ec *executionContext) fieldContext_MyQuery_lastTodo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MyQuery", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Todo_id(ctx, field) case "text": return ec.fieldContext_Todo_text(ctx, field) case "done": return ec.fieldContext_Todo_done(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) }, } return fc, nil } func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_MyQuery_todos, func(ctx context.Context) (any, error) { return ec.Resolvers.MyQuery().Todos(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNTodo2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtodoᚐTodoᚄ, true, true, ) } func (ec *executionContext) fieldContext_MyQuery_todos(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MyQuery", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Todo_id(ctx, field) case "text": return ec.fieldContext_Todo_text(ctx, field) case "done": return ec.fieldContext_Todo_done(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) }, } return fc, nil } func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_MyQuery___type, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.IntrospectType(fc.Args["name"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType, true, false, ) } func (ec *executionContext) fieldContext_MyQuery___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MyQuery", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "kind": return ec.fieldContext___Type_kind(ctx, field) case "name": return ec.fieldContext___Type_name(ctx, field) case "description": return ec.fieldContext___Type_description(ctx, field) case "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_MyQuery___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_MyQuery___schema, func(ctx context.Context) (any, error) { return ec.IntrospectSchema() }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema, true, false, ) } func (ec *executionContext) fieldContext_MyQuery___schema(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MyQuery", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "description": return ec.fieldContext___Schema_description(ctx, field) case "types": return ec.fieldContext___Schema_types(ctx, field) case "queryType": return ec.fieldContext___Schema_queryType(ctx, field) case "mutationType": return ec.fieldContext___Schema_mutationType(ctx, field) case "subscriptionType": return ec.fieldContext___Schema_subscriptionType(ctx, field) case "directives": return ec.fieldContext___Schema_directives(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) }, } return fc, nil } func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Todo_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2int, true, true, ) } func (ec *executionContext) fieldContext_Todo_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Todo_text, func(ctx context.Context) (any, error) { return obj.Text, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Todo_text(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Todo_done, func(ctx context.Context) (any, error) { return obj.Done, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { role, err := ec.unmarshalNRole2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtodoᚐRole(ctx, "OWNER") if err != nil { var zeroVal bool return zeroVal, err } if ec.Directives.HasRole == nil { var zeroVal bool return zeroVal, errors.New("directive hasRole is not implemented") } return ec.Directives.HasRole(ctx, obj, directive0, role) } next = directive1 return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNBoolean2bool, true, true, ) } func (ec *executionContext) fieldContext_Todo_done(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext___Directive_name, func(ctx context.Context) (any, error) { return obj.Name, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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) unmarshalInputTodoInput(ctx context.Context, obj any) (TodoInput, error) { var it TodoInput if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"text", "done", "number"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "text": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Text = data case "done": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("done")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } it.Done = data case "number": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("number")) data, err := ec.unmarshalNInt2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtodoᚐNumber(ctx, v) if err != nil { return it, err } it.Number = data } } return it, nil } // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var myMutationImplementors = []string{"MyMutation"} func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, myMutationImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "MyMutation", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("MyMutation") case "createTodo": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._MyMutation_createTodo(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } case "updateTodo": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._MyMutation_updateTodo(ctx, field) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var myQueryImplementors = []string{"MyQuery"} func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, myQueryImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "MyQuery", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("MyQuery") case "todo": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._MyQuery_todo(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "lastTodo": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._MyQuery_lastTodo(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "todos": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._MyQuery_todos(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._MyQuery___type(ctx, field) }) case "__schema": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._MyQuery___schema(ctx, field) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var todoImplementors = []string{"Todo"} func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, todoImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Todo") case "id": out.Values[i] = ec._Todo_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "text": out.Values[i] = ec._Todo_text(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "done": out.Values[i] = ec._Todo_done(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": out.Values[i] = ec.___Directive_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "description": out.Values[i] = ec.___Directive_description(ctx, field, obj) case "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) unmarshalNID2int(ctx context.Context, v any) (int, error) { res, err := graphql.UnmarshalIntID(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNID2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { _ = sel res := graphql.MarshalIntID(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) unmarshalNInt2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtodoᚐNumber(ctx context.Context, v any) (Number, error) { var res Number err := res.UnmarshalGQLContext(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNInt2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtodoᚐNumber(ctx context.Context, sel ast.SelectionSet, v Number) graphql.Marshaler { return graphql.WrapContextMarshaler(ctx, v) } func (ec *executionContext) unmarshalNMap2map(ctx context.Context, v any) (map[string]any, error) { res, err := graphql.UnmarshalMap(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNMap2map(ctx context.Context, sel ast.SelectionSet, v map[string]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) unmarshalNRole2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtodoᚐRole(ctx context.Context, v any) (Role, error) { var res Role err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNRole2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtodoᚐRole(ctx context.Context, sel ast.SelectionSet, v Role) graphql.Marshaler { return 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) marshalNTodo2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { return ec._Todo(ctx, sel, &v) } func (ec *executionContext) marshalNTodo2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtodoᚐTodoᚄ(ctx context.Context, sel ast.SelectionSet, v []*Todo) 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.marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtodoᚐTodo(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) 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._Todo(ctx, sel, v) } func (ec *executionContext) unmarshalNTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtodoᚐTodoInput(ctx context.Context, v any) (TodoInput, error) { res, err := ec.unmarshalInputTodoInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } 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) 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) marshalOTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtodoᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Todo(ctx, sel, v) } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ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/todo/gqlgen.yml ================================================ models: Todo: model: github.com/99designs/gqlgen/_examples/todo.Todo ID: model: # override the default id marshaller to use ints - github.com/99designs/gqlgen/graphql.IntID - github.com/99designs/gqlgen/graphql.ID ================================================ FILE: _examples/todo/models.go ================================================ package todo import ( "context" "fmt" "io" "github.com/99designs/gqlgen/graphql" ) type Ownable interface { Owner() *User } type Todo struct { ID int Text string Done bool owner *User } func (t Todo) Owner() *User { return t.owner } type User struct { ID int Name string } type Number int func (e *Number) UnmarshalGQLContext(ctx context.Context, v any) error { num, err := graphql.UnmarshalInt(v) if err != nil { return err } *e = Number(num) return nil } func (e Number) MarshalGQLContext(_ context.Context, w io.Writer) error { fmt.Fprint(w, e) return nil } ================================================ FILE: _examples/todo/models_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package todo import ( "bytes" "fmt" "io" "strconv" ) type MyMutation struct { } type MyQuery struct { } // Passed to createTodo to create a new todo type TodoInput struct { // The body text Text string `json:"text"` // Is it done already? Done *bool `json:"done,omitempty"` Number Number `json:"number"` } type Role string const ( RoleAdmin Role = "ADMIN" RoleOwner Role = "OWNER" ) var AllRole = []Role{ RoleAdmin, RoleOwner, } func (e Role) IsValid() bool { switch e { case RoleAdmin, RoleOwner: return true } return false } func (e Role) String() string { return string(e) } func (e *Role) UnmarshalGQL(v any) error { str, ok := v.(string) if !ok { return fmt.Errorf("enums must be strings") } *e = Role(str) if !e.IsValid() { return fmt.Errorf("%s is not a valid Role", str) } return nil } func (e Role) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } func (e *Role) UnmarshalJSON(b []byte) error { s, err := strconv.Unquote(string(b)) if err != nil { return err } return e.UnmarshalGQL(s) } func (e Role) MarshalJSON() ([]byte, error) { var buf bytes.Buffer e.MarshalGQL(&buf) return buf.Bytes(), nil } ================================================ FILE: _examples/todo/readme.md ================================================ ### todo app This is the simplest example of a graphql server. to run this server ```bash go run ./server/server.go ``` and open http://localhost:8081 in your browser ================================================ FILE: _examples/todo/schema.graphql ================================================ directive @goField( forceResolver: Boolean name: String omittable: Boolean type: String ) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION enum Role { ADMIN OWNER } schema { query: MyQuery mutation: MyMutation } type MyQuery { todo(id: ID!): Todo lastTodo: Todo todos: [Todo!]! } type MyMutation { createTodo(todo: TodoInput!): Todo! updateTodo(id: ID!, changes: Map!): Todo } type Todo { id: ID! text: String! done: Boolean! @hasRole(role: OWNER) # only the owner can see if a todo is done } "Passed to createTodo to create a new todo" input TodoInput { "The body text" text: String! "Is it done already?" done: Boolean number: Int! @goField(type:"github.com/99designs/gqlgen/_examples/todo.Number") } scalar Map "Prevents access to a field if the user doesnt have the matching role" directive @hasRole(role: Role!) on FIELD_DEFINITION directive @user(id: ID!) on MUTATION | QUERY | FIELD ================================================ FILE: _examples/todo/server/server.go ================================================ package main import ( "context" "errors" "log" "net/http" "runtime/debug" "github.com/99designs/gqlgen/_examples/todo" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/playground" ) func main() { srv := handler.New(todo.NewExecutableSchema(todo.New())) srv.AddTransport(transport.GET{}) srv.AddTransport(transport.POST{}) srv.SetRecoverFunc(func(ctx context.Context, err any) (userMessage error) { // send this panic somewhere log.Print(err) debug.PrintStack() return errors.New("user message on panic") }) http.Handle("/", playground.Handler("Todo", "/query")) http.Handle("/query", srv) log.Fatal(http.ListenAndServe(":8081", nil)) } ================================================ FILE: _examples/todo/todo.go ================================================ //go:generate go run ../../testdata/gqlgen.go package todo import ( "context" "errors" "time" "github.com/go-viper/mapstructure/v2" "github.com/99designs/gqlgen/graphql" ) var ( you = &User{ID: 1, Name: "You"} them = &User{ID: 2, Name: "Them"} ) type ckey string func getUserId(ctx context.Context) int { if id, ok := ctx.Value(ckey("userId")).(int); ok { return id } return you.ID } func New() Config { c := Config{ Resolvers: &resolvers{ todos: []*Todo{ {ID: 1, Text: "A todo not to forget", Done: false, owner: you}, {ID: 2, Text: "This is the most important", Done: false, owner: you}, {ID: 3, Text: "Somebody else's todo", Done: true, owner: them}, {ID: 4, Text: "Please do this or else", Done: false, owner: you}, }, lastID: 4, }, } c.Directives.HasRole = func(ctx context.Context, obj any, next graphql.Resolver, role Role) (any, error) { switch role { case RoleAdmin: // No admin for you! return nil, nil case RoleOwner: ownable, isOwnable := obj.(Ownable) if !isOwnable { return nil, errors.New("obj cant be owned") } if ownable.Owner().ID != getUserId(ctx) { return nil, errors.New("you don't own that") } } return next(ctx) } c.Directives.User = func(ctx context.Context, obj any, next graphql.Resolver, id int) (any, error) { return next(context.WithValue(ctx, ckey("userId"), id)) } return c } type resolvers struct { todos []*Todo lastID int } func (r *resolvers) MyQuery() MyQueryResolver { return (*QueryResolver)(r) } func (r *resolvers) MyMutation() MyMutationResolver { return (*MutationResolver)(r) } type QueryResolver resolvers func (r *QueryResolver) Todo(ctx context.Context, id int) (*Todo, error) { time.Sleep(220 * time.Millisecond) if id == 666 { panic("critical failure") } for _, todo := range r.todos { if todo.ID == id { return todo, nil } } return nil, errors.New("not found") } func (r *QueryResolver) LastTodo(ctx context.Context) (*Todo, error) { if len(r.todos) == 0 { return nil, errors.New("not found") } return r.todos[len(r.todos)-1], nil } func (r *QueryResolver) Todos(ctx context.Context) ([]*Todo, error) { return r.todos, nil } type MutationResolver resolvers func (r *MutationResolver) CreateTodo(ctx context.Context, todo TodoInput) (*Todo, error) { newID := r.id() newTodo := &Todo{ ID: newID, Text: todo.Text, owner: you, } if todo.Done != nil { newTodo.Done = *todo.Done } r.todos = append(r.todos, newTodo) return newTodo, nil } func (r *MutationResolver) UpdateTodo( ctx context.Context, id int, changes map[string]any, ) (*Todo, error) { var affectedTodo *Todo for i := 0; i < len(r.todos); i++ { if r.todos[i].ID == id { affectedTodo = r.todos[i] break } } if affectedTodo == nil { return nil, nil } err := mapstructure.Decode(changes, affectedTodo) if err != nil { panic(err) } return affectedTodo, nil } func (r *MutationResolver) id() int { r.lastID++ return r.lastID } ================================================ FILE: _examples/todo/todo_test.go ================================================ package todo import ( "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "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/introspection" ) func TestTodo(t *testing.T) { srv := handler.New(NewExecutableSchema(New())) srv.AddTransport(transport.POST{}) srv.Use(extension.Introspection{}) c := client.New(srv) var resp struct { CreateTodo struct{ ID string } } c.MustPost(`mutation { createTodo(todo:{text:"Fery important", number:5}) { id } }`, &resp) require.Equal(t, "5", resp.CreateTodo.ID) t.Run("update the todo text", func(t *testing.T) { var resp struct { UpdateTodo struct{ Text string } } c.MustPost( `mutation($id: ID!, $text: String!) { updateTodo(id: $id, changes:{text:$text}) { text } }`, &resp, client.Var("id", 5), client.Var("text", "Very important"), ) require.Equal(t, "Very important", resp.UpdateTodo.Text) }) t.Run("get __typename", func(t *testing.T) { var resp struct { Todo struct { Typename string `json:"__typename"` } } c.MustPost(`{ todo(id: 5) { __typename } }`, &resp) require.Equal(t, "Todo", resp.Todo.Typename) }) t.Run("update the todo status", func(t *testing.T) { var resp struct { UpdateTodo struct{ Text string } } c.MustPost(`mutation { updateTodo(id: 5, changes:{done:true}) { text } }`, &resp) require.Equal(t, "Very important", resp.UpdateTodo.Text) }) t.Run("update the todo status by user id in mutation", func(t *testing.T) { var resp struct { UpdateTodo struct { Text string Done bool } } c.MustPost( `mutation @user(id:2){ updateTodo(id: 3, changes:{done:true}) { text, done } }`, &resp, ) require.Equal(t, "Somebody else's todo", resp.UpdateTodo.Text) }) t.Run("update the todo status by user id in field", func(t *testing.T) { var resp struct { UpdateTodo struct { Text string Done bool } } c.MustPost( `mutation { updateTodo(id: 3, changes:{done:true})@user(id:2) { text, done } }`, &resp, ) require.Equal(t, "Somebody else's todo", resp.UpdateTodo.Text) }) t.Run("failed update the todo status by user id in field", func(t *testing.T) { var resp struct { UpdateTodo *struct { Text string Done bool } } err := c.Post(`mutation { updateTodo(id: 3, changes:{done:true}) { text, done } }`, &resp) require.EqualError( t, err, "[{\"message\":\"you don't own that\",\"path\":[\"updateTodo\",\"done\"]}]", ) require.Nil(t, resp.UpdateTodo) }) t.Run("select with alias", func(t *testing.T) { var resp struct { A struct{ Text string } B struct{ ID string } } c.MustPost(`{ a: todo(id:1) { text } b: todo(id:2) { id } }`, &resp) require.Equal(t, "A todo not to forget", resp.A.Text) require.Equal(t, "2", resp.B.ID) }) t.Run("find a missing todo", func(t *testing.T) { var resp struct { Todo *struct{ Text string } } err := c.Post(`{ todo(id:99) { text } }`, &resp) require.Error(t, err) require.Nil(t, resp.Todo) }) t.Run("get done status of unowned todo", func(t *testing.T) { var resp struct { Todo *struct { Text string Done bool } } err := c.Post(`{ todo(id:3) { text, done } }`, &resp) require.EqualError(t, err, `[{"message":"you don't own that","path":["todo","done"]}]`) require.Nil(t, resp.Todo) }) t.Run("test panic", func(t *testing.T) { var resp struct { Todo *struct{ Text string } } err := c.Post(`{ todo(id:666) { text } }`, &resp) require.EqualError(t, err, `[{"message":"internal system error","path":["todo"]}]`) }) t.Run("select all", func(t *testing.T) { var resp struct { Todo struct { ID string Text string Done bool } LastTodo struct { ID string Text string Done bool } Todos []struct { ID string Text string } } c.MustPost(`{ todo(id:1) { id done text } lastTodo { id text done } todos { id text } }`, &resp) require.Equal(t, "1", resp.Todo.ID) require.Equal(t, "5", resp.LastTodo.ID) require.Len(t, resp.Todos, 5) require.Equal(t, "Very important", resp.LastTodo.Text) require.Equal(t, "5", resp.LastTodo.ID) }) t.Run("introspection", func(t *testing.T) { // Make sure we can run the graphiql introspection query without errors var resp any c.MustPost(introspection.Query, &resp) }) t.Run("null optional field", func(t *testing.T) { var resp struct { CreateTodo struct{ Text string } } c.MustPost( `mutation { createTodo(todo:{text:"Completed todo", number:5, done: null}) { text } }`, &resp, ) require.Equal(t, "Completed todo", resp.CreateTodo.Text) }) } func TestSkipAndIncludeDirectives(t *testing.T) { srv := handler.New(NewExecutableSchema(New())) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("skip on field", func(t *testing.T) { var resp map[string]any c.MustPost(`{ todo(id: 1) @skip(if:true) { __typename } }`, &resp) _, ok := resp["todo"] require.False(t, ok) }) t.Run("skip on variable", func(t *testing.T) { q := `query Test($cond: Boolean!) { todo(id: 1) @skip(if: $cond) { __typename } }` var resp map[string]any c.MustPost(q, &resp, client.Var("cond", true)) _, ok := resp["todo"] require.False(t, ok) c.MustPost(q, &resp, client.Var("cond", false)) _, ok = resp["todo"] require.True(t, ok) }) t.Run("skip on inline fragment", func(t *testing.T) { var resp struct { Todo struct { Typename string `json:"__typename"` } } c.MustPost(`{ todo(id: 1) { ...@skip(if:true) { __typename } } }`, &resp) require.Empty(t, resp.Todo.Typename) }) t.Run("skip on fragment", func(t *testing.T) { var resp struct { Todo struct { Typename string `json:"__typename"` } } c.MustPost(` { todo(id: 1) { ...todoFragment @skip(if:true) } } fragment todoFragment on Todo { __typename } `, &resp) require.Empty(t, resp.Todo.Typename) }) t.Run("include on field", func(t *testing.T) { q := `query Test($cond: Boolean!) { todo(id: 1) @include(if: $cond) { __typename } }` var resp map[string]any c.MustPost(q, &resp, client.Var("cond", true)) _, ok := resp["todo"] require.True(t, ok) c.MustPost(q, &resp, client.Var("cond", false)) _, ok = resp["todo"] require.False(t, ok) }) t.Run("both skip and include defined", func(t *testing.T) { type TestCase struct { Skip bool Include bool Expected bool } table := []TestCase{ {Skip: true, Include: true, Expected: false}, {Skip: true, Include: false, Expected: false}, {Skip: false, Include: true, Expected: true}, {Skip: false, Include: false, Expected: false}, } q := `query Test($skip: Boolean!, $include: Boolean!) { todo(id: 1) @skip(if: $skip) @include(if: $include) { __typename } }` for _, tc := range table { var resp map[string]any c.MustPost(q, &resp, client.Var("skip", tc.Skip), client.Var("include", tc.Include)) _, ok := resp["todo"] require.Equal(t, tc.Expected, ok) } }) t.Run("skip with default query argument", func(t *testing.T) { var resp map[string]any c.MustPost( `query Test($skip: Boolean = true) { todo(id: 1) @skip(if: $skip) { __typename } }`, &resp, ) _, ok := resp["todo"] require.False(t, ok) }) } ================================================ FILE: _examples/tools.go ================================================ //go:build tools package main import ( _ "github.com/goccy/go-yaml" _ "github.com/vektah/dataloaden" _ "golang.org/x/text" ) ================================================ FILE: _examples/type-system-extension/README.md ================================================ # Type System Extension example https://graphql.github.io/graphql-spec/draft/#sec-Type-System-Extensions ``` $ go run ./server/server.go 2018/10/25 12:46:45 connect to http://localhost:8080/ for GraphQL playground $ curl -X POST 'http://localhost:8080/query' --data-binary '{"query":"{ todos { id text state verified } }"}' {"data":{"todos":[{"id":"Todo:1","text":"Buy a cat food","state":"NOT_YET","verified":false},{"id":"Todo:2","text":"Check cat water","state":"DONE","verified":true},{"id":"Todo:3","text":"Check cat meal","state":"DONE","verified":true}]}} ``` ================================================ FILE: _examples/type-system-extension/directive.go ================================================ package type_system_extension import ( "context" "log" "github.com/99designs/gqlgen/graphql" ) func EnumLogging(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) { rc := graphql.GetFieldContext(ctx) log.Printf("enum logging: %v, %s, %T, %+v", rc.Path(), rc.Field.Name, obj, obj) return next(ctx) } func FieldLogging(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) { rc := graphql.GetFieldContext(ctx) log.Printf("field logging: %v, %s, %T, %+v", rc.Path(), rc.Field.Name, obj, obj) return next(ctx) } func InputLogging(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) { rc := graphql.GetFieldContext(ctx) log.Printf("input object logging: %v, %s, %T, %+v", rc.Path(), rc.Field.Name, obj, obj) return next(ctx) } func ObjectLogging(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) { rc := graphql.GetFieldContext(ctx) log.Printf("object logging: %v, %s, %T, %+v", rc.Path(), rc.Field.Name, obj, obj) return next(ctx) } func ScalarLogging(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) { rc := graphql.GetFieldContext(ctx) log.Printf("scalar logging: %v, %s, %T, %+v", rc.Path(), rc.Field.Name, obj, obj) return next(ctx) } func UnionLogging(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) { rc := graphql.GetFieldContext(ctx) log.Printf("union logging: %v, %s, %T, %+v", rc.Path(), rc.Field.Name, obj, obj) return next(ctx) } ================================================ FILE: _examples/type-system-extension/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package type_system_extension 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 { MyMutation() MyMutationResolver MyQuery() MyQueryResolver } type DirectiveRoot struct { EnumLogging func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) FieldLogging func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) InputLogging func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) InterfaceLogging func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) ObjectLogging func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) ScalarLogging func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) UnionLogging func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) } type ComplexityRoot struct { MyMutation struct { CreateTodo func(childComplexity int, todo TodoInput) int } MyQuery struct { Todo func(childComplexity int, id string) int Todos func(childComplexity int) int } Todo struct { ID func(childComplexity int) int State func(childComplexity int) int Text func(childComplexity int) int Verified func(childComplexity int) int } } type MyMutationResolver interface { CreateTodo(ctx context.Context, todo TodoInput) (*Todo, error) } type MyQueryResolver interface { Todos(ctx context.Context) ([]*Todo, error) Todo(ctx context.Context, id string) (*Todo, error) } type executableSchema 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 "MyMutation.createTodo": if e.ComplexityRoot.MyMutation.CreateTodo == nil { break } args, err := ec.field_MyMutation_createTodo_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.MyMutation.CreateTodo(childComplexity, args["todo"].(TodoInput)), true case "MyQuery.todo": if e.ComplexityRoot.MyQuery.Todo == nil { break } args, err := ec.field_MyQuery_todo_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.MyQuery.Todo(childComplexity, args["id"].(string)), true case "MyQuery.todos": if e.ComplexityRoot.MyQuery.Todos == nil { break } return e.ComplexityRoot.MyQuery.Todos(childComplexity), true case "Todo.id": if e.ComplexityRoot.Todo.ID == nil { break } return e.ComplexityRoot.Todo.ID(childComplexity), true case "Todo.state": if e.ComplexityRoot.Todo.State == nil { break } return e.ComplexityRoot.Todo.State(childComplexity), true case "Todo.text": if e.ComplexityRoot.Todo.Text == nil { break } return e.ComplexityRoot.Todo.Text(childComplexity), true case "Todo.verified": if e.ComplexityRoot.Todo.Verified == nil { break } return e.ComplexityRoot.Todo.Verified(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.unmarshalInputTodoInput, ) 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._MyQuery(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._MyMutation(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.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 "schemas/enum-extension.graphql" "schemas/input-object-extension.graphql" "schemas/interface-extension.graphql" "schemas/object-extension.graphql" "schemas/scalar-extension.graphql" "schemas/schema-extension.graphql" "schemas/schema.graphql" "schemas/type-extension.graphql" "schemas/union-extension.graphql" var sourcesFS embed.FS func sourceData(filename string) string { data, err := sourcesFS.ReadFile(filename) if err != nil { panic(fmt.Sprintf("codegen problem: %s not available", filename)) } return string(data) } var sources = []*ast.Source{ {Name: "schemas/enum-extension.graphql", Input: sourceData("schemas/enum-extension.graphql"), BuiltIn: false}, {Name: "schemas/input-object-extension.graphql", Input: sourceData("schemas/input-object-extension.graphql"), BuiltIn: false}, {Name: "schemas/interface-extension.graphql", Input: sourceData("schemas/interface-extension.graphql"), BuiltIn: false}, {Name: "schemas/object-extension.graphql", Input: sourceData("schemas/object-extension.graphql"), BuiltIn: false}, {Name: "schemas/scalar-extension.graphql", Input: sourceData("schemas/scalar-extension.graphql"), BuiltIn: false}, {Name: "schemas/schema-extension.graphql", Input: sourceData("schemas/schema-extension.graphql"), BuiltIn: false}, {Name: "schemas/schema.graphql", Input: sourceData("schemas/schema.graphql"), BuiltIn: false}, {Name: "schemas/type-extension.graphql", Input: sourceData("schemas/type-extension.graphql"), BuiltIn: false}, {Name: "schemas/union-extension.graphql", Input: sourceData("schemas/union-extension.graphql"), BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) field_MyMutation_createTodo_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "todo", ec.unmarshalNTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐTodoInput) if err != nil { return nil, err } args["todo"] = arg0 return args, nil } func (ec *executionContext) field_MyQuery___type_args(ctx context.Context, rawArgs map[string]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_MyQuery_todo_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.unmarshalNID2string) if err != nil { return nil, err } args["id"] = 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) _MyMutation_createTodo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_MyMutation_createTodo, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.MyMutation().CreateTodo(ctx, fc.Args["todo"].(TodoInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { if ec.Directives.ObjectLogging == nil { var zeroVal *Todo return zeroVal, errors.New("directive objectLogging is not implemented") } return ec.Directives.ObjectLogging(ctx, nil, directive0) } next = directive1 return next }, ec.marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐTodo, true, true, ) } func (ec *executionContext) fieldContext_MyMutation_createTodo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MyMutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Todo_id(ctx, field) case "text": return ec.fieldContext_Todo_text(ctx, field) case "state": return ec.fieldContext_Todo_state(ctx, field) case "verified": return ec.fieldContext_Todo_verified(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_MyMutation_createTodo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_MyQuery_todos, func(ctx context.Context) (any, error) { return ec.Resolvers.MyQuery().Todos(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { if ec.Directives.ObjectLogging == nil { var zeroVal []*Todo return zeroVal, errors.New("directive objectLogging is not implemented") } return ec.Directives.ObjectLogging(ctx, nil, directive0) } next = directive1 return next }, ec.marshalNTodo2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐTodoᚄ, true, true, ) } func (ec *executionContext) fieldContext_MyQuery_todos(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MyQuery", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Todo_id(ctx, field) case "text": return ec.fieldContext_Todo_text(ctx, field) case "state": return ec.fieldContext_Todo_state(ctx, field) case "verified": return ec.fieldContext_Todo_verified(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) }, } return fc, nil } func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_MyQuery_todo, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.MyQuery().Todo(ctx, fc.Args["id"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { if ec.Directives.ObjectLogging == nil { var zeroVal *Todo return zeroVal, errors.New("directive objectLogging is not implemented") } return ec.Directives.ObjectLogging(ctx, nil, directive0) } next = directive1 return next }, ec.marshalOTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐTodo, true, false, ) } func (ec *executionContext) fieldContext_MyQuery_todo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MyQuery", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Todo_id(ctx, field) case "text": return ec.fieldContext_Todo_text(ctx, field) case "state": return ec.fieldContext_Todo_state(ctx, field) case "verified": return ec.fieldContext_Todo_verified(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_MyQuery_todo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_MyQuery___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_MyQuery___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MyQuery", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "kind": return ec.fieldContext___Type_kind(ctx, field) case "name": return ec.fieldContext___Type_name(ctx, field) case "description": return ec.fieldContext___Type_description(ctx, field) case "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_MyQuery___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_MyQuery___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_MyQuery___schema(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MyQuery", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "description": return ec.fieldContext___Schema_description(ctx, field) case "types": return ec.fieldContext___Schema_types(ctx, field) case "queryType": return ec.fieldContext___Schema_queryType(ctx, field) case "mutationType": return ec.fieldContext___Schema_mutationType(ctx, field) case "subscriptionType": return ec.fieldContext___Schema_subscriptionType(ctx, field) case "directives": return ec.fieldContext___Schema_directives(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) }, } return fc, nil } func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Todo_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, nil, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_Todo_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Todo_text, func(ctx context.Context) (any, error) { return obj.Text, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Todo_text(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Todo_state(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Todo_state, func(ctx context.Context) (any, error) { return obj.State, nil }, nil, ec.marshalNState2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐState, true, true, ) } func (ec *executionContext) fieldContext_Todo_state(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type State does not have child fields") }, } return fc, nil } func (ec *executionContext) _Todo_verified(ctx context.Context, field graphql.CollectedField, obj *Todo) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Todo_verified, func(ctx context.Context) (any, error) { return obj.Verified, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { if ec.Directives.FieldLogging == nil { var zeroVal bool return zeroVal, errors.New("directive fieldLogging is not implemented") } return ec.Directives.FieldLogging(ctx, obj, directive0) } next = directive1 return next }, ec.marshalNBoolean2bool, true, true, ) } func (ec *executionContext) fieldContext_Todo_verified(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 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) unmarshalInputTodoInput(ctx context.Context, obj any) (TodoInput, error) { var it TodoInput if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"text"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "text": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Text = data } } // Execute INPUT_OBJECT level directives (e.g., @oneOf, @directive3) // These run after all fields have been unmarshaled directive0 := func(ctx context.Context) (any, error) { return it, nil } directive1 := func(ctx context.Context) (any, error) { if ec.Directives.InputLogging == nil { return it, errors.New("directive inputLogging is not implemented") } return ec.Directives.InputLogging(ctx, asMap, directive0) } tmp, err := directive1(ctx) if err != nil { return it, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(TodoInput); ok { return data, nil } return it, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from INPUT_OBJECT directive, should be TodoInput`, tmp)) } // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** func (ec *executionContext) _Data(ctx context.Context, sel ast.SelectionSet, obj Data) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null case Todo: return ec._Todo(ctx, sel, &obj) case *Todo: if obj == nil { return graphql.Null } return ec._Todo(ctx, sel, obj) default: if typedObj, ok := obj.(graphql.Marshaler); ok { return typedObj } else { panic(fmt.Errorf("unexpected type %T; non-generated variants of Data must implement graphql.Marshaler", obj)) } } } func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj Node) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null case Todo: return ec._Todo(ctx, sel, &obj) case *Todo: if obj == nil { return graphql.Null } return ec._Todo(ctx, sel, obj) default: if typedObj, ok := obj.(graphql.Marshaler); ok { return typedObj } else { panic(fmt.Errorf("unexpected type %T; non-generated variants of Node must implement graphql.Marshaler", obj)) } } } // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var myMutationImplementors = []string{"MyMutation"} func (ec *executionContext) _MyMutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, myMutationImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "MyMutation", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("MyMutation") case "createTodo": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._MyMutation_createTodo(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var myQueryImplementors = []string{"MyQuery"} func (ec *executionContext) _MyQuery(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, myQueryImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "MyQuery", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("MyQuery") case "todos": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._MyQuery_todos(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "todo": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._MyQuery_todo(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._MyQuery___type(ctx, field) }) case "__schema": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._MyQuery___schema(ctx, field) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var todoImplementors = []string{"Todo", "Node", "Data"} func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *Todo) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, todoImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Todo") case "id": out.Values[i] = ec._Todo_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "text": out.Values[i] = ec._Todo_text(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "state": out.Values[i] = ec._Todo_state(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "verified": out.Values[i] = ec._Todo_verified(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": out.Values[i] = ec.___Directive_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "description": out.Values[i] = ec.___Directive_description(ctx, field, obj) case "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) unmarshalNState2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐState(ctx context.Context, v any) (State, error) { var res State err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNState2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐState(ctx context.Context, sel ast.SelectionSet, v State) graphql.Marshaler { return v } func (ec *executionContext) unmarshalNString2string(ctx context.Context, v 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) marshalNTodo2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v Todo) graphql.Marshaler { return ec._Todo(ctx, sel, &v) } func (ec *executionContext) marshalNTodo2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐTodoᚄ(ctx context.Context, sel ast.SelectionSet, v []*Todo) 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.marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐTodo(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._Todo(ctx, sel, v) } func (ec *executionContext) unmarshalNTodoInput2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐTodoInput(ctx context.Context, v any) (TodoInput, error) { res, err := ec.unmarshalInputTodoInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } 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) 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) marshalOTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋtypeᚑsystemᚑextensionᚐTodo(ctx context.Context, sel ast.SelectionSet, v *Todo) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Todo(ctx, sel, v) } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ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/type-system-extension/gqlgen.yml ================================================ # .gqlgen.yml example # # Refer to https://gqlgen.com/config/ # for detailed .gqlgen.yml documentation. schema: - ./schemas/*.graphql exec: filename: generated.go model: filename: models_gen.go ================================================ FILE: _examples/type-system-extension/models_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package type_system_extension import ( "bytes" "fmt" "io" "strconv" ) type Data interface { IsData() } type Node interface { IsNode() GetID() string } type MyMutation struct { } type MyQuery struct { } type Todo struct { ID string `json:"id"` Text string `json:"text"` State State `json:"state"` Verified bool `json:"verified"` } func (Todo) IsNode() {} func (this Todo) GetID() string { return this.ID } func (Todo) IsData() {} type TodoInput struct { Text string `json:"text"` } type State string const ( StateNotYet State = "NOT_YET" StateDone State = "DONE" ) var AllState = []State{ StateNotYet, StateDone, } func (e State) IsValid() bool { switch e { case StateNotYet, StateDone: return true } return false } func (e State) String() string { return string(e) } func (e *State) UnmarshalGQL(v any) error { str, ok := v.(string) if !ok { return fmt.Errorf("enums must be strings") } *e = State(str) if !e.IsValid() { return fmt.Errorf("%s is not a valid State", str) } return nil } func (e State) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } func (e *State) UnmarshalJSON(b []byte) error { s, err := strconv.Unquote(string(b)) if err != nil { return err } return e.UnmarshalGQL(s) } func (e State) MarshalJSON() ([]byte, error) { var buf bytes.Buffer e.MarshalGQL(&buf) return buf.Bytes(), nil } ================================================ FILE: _examples/type-system-extension/resolver.go ================================================ //go:generate go run ../../testdata/gqlgen.go package type_system_extension import ( "context" "fmt" ) func NewRootResolver() ResolverRoot { return &resolver{ todos: []*Todo{ { ID: "Todo:1", Text: "Buy a cat food", State: StateNotYet, Verified: false, }, { ID: "Todo:2", Text: "Check cat water", State: StateDone, Verified: true, }, { ID: "Todo:3", Text: "Check cat meal", State: StateDone, Verified: true, }, }, } } type resolver struct { todos []*Todo } func (r *resolver) MyQuery() MyQueryResolver { return &queryResolver{r} } func (r *resolver) MyMutation() MyMutationResolver { return &mutationResolver{r} } type queryResolver struct{ *resolver } func (r *queryResolver) Todos(ctx context.Context) ([]*Todo, error) { return r.todos, nil } func (r *queryResolver) Todo(ctx context.Context, id string) (*Todo, error) { for _, todo := range r.todos { if todo.ID == id { return todo, nil } } return nil, nil } type mutationResolver struct{ *resolver } func (r *mutationResolver) CreateTodo(ctx context.Context, todoInput TodoInput) (*Todo, error) { newID := fmt.Sprintf("Todo:%d", len(r.todos)+1) newTodo := &Todo{ ID: newID, Text: todoInput.Text, State: StateNotYet, } r.todos = append(r.todos, newTodo) return newTodo, nil } ================================================ FILE: _examples/type-system-extension/schemas/enum-extension.graphql ================================================ directive @enumLogging on ENUM extend enum State @enumLogging ================================================ FILE: _examples/type-system-extension/schemas/input-object-extension.graphql ================================================ directive @inputLogging on INPUT_OBJECT extend input TodoInput @inputLogging ================================================ FILE: _examples/type-system-extension/schemas/interface-extension.graphql ================================================ directive @interfaceLogging on INTERFACE extend interface Node @interfaceLogging ================================================ FILE: _examples/type-system-extension/schemas/object-extension.graphql ================================================ directive @objectLogging on OBJECT extend type Todo @objectLogging ================================================ FILE: _examples/type-system-extension/schemas/scalar-extension.graphql ================================================ directive @scalarLogging on SCALAR extend scalar ID @scalarLogging ================================================ FILE: _examples/type-system-extension/schemas/schema-extension.graphql ================================================ extend schema { mutation: MyMutation } extend type MyQuery { todo(id: ID!): Todo } type MyMutation { createTodo(todo: TodoInput!): Todo! } input TodoInput { text: String! } ================================================ FILE: _examples/type-system-extension/schemas/schema.graphql ================================================ # GraphQL schema example # # https://gqlgen.com/getting-started/ schema { query: MyQuery } interface Node { id: ID! } type Todo implements Node { id: ID! text: String! state: State! } type MyQuery { todos: [Todo!]! } union Data = Todo enum State { NOT_YET DONE } ================================================ FILE: _examples/type-system-extension/schemas/type-extension.graphql ================================================ directive @fieldLogging on FIELD_DEFINITION extend type Todo { verified: Boolean! @fieldLogging } ================================================ FILE: _examples/type-system-extension/schemas/union-extension.graphql ================================================ directive @unionLogging on UNION extend union Data @unionLogging ================================================ FILE: _examples/type-system-extension/server/server.go ================================================ package main import ( "log" "net/http" "os" extension "github.com/99designs/gqlgen/_examples/type-system-extension" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/playground" ) const defaultPort = "8080" func main() { port := os.Getenv("PORT") if port == "" { port = defaultPort } srv := handler.New( extension.NewExecutableSchema( extension.Config{ Resolvers: extension.NewRootResolver(), Directives: extension.DirectiveRoot{ EnumLogging: extension.EnumLogging, FieldLogging: extension.FieldLogging, InputLogging: extension.InputLogging, ObjectLogging: extension.ObjectLogging, ScalarLogging: extension.ScalarLogging, UnionLogging: extension.UnionLogging, }, }, ), ) srv.AddTransport(transport.GET{}) srv.AddTransport(transport.POST{}) 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: _examples/union-extension/.gqlgen.yml ================================================ schema: schema.graphql model: filename: models_gen.go exec: filename: generated.go ================================================ FILE: _examples/union-extension/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package unionextension 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 { Query() QueryResolver } type DirectiveRoot struct { } type ComplexityRoot struct { Like struct { From func(childComplexity int) int } Post struct { Message func(childComplexity int) int } Query struct { CachedEvents func(childComplexity int) int Events func(childComplexity int) int } } type QueryResolver interface { Events(ctx context.Context) ([]Event, error) CachedEvents(ctx context.Context) ([]Event, 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 "Like.from": if e.ComplexityRoot.Like.From == nil { break } return e.ComplexityRoot.Like.From(childComplexity), true case "Post.message": if e.ComplexityRoot.Post.Message == nil { break } return e.ComplexityRoot.Post.Message(childComplexity), true case "Query.cachedEvents": if e.ComplexityRoot.Query.CachedEvents == nil { break } return e.ComplexityRoot.Query.CachedEvents(childComplexity), true case "Query.events": if e.ComplexityRoot.Query.Events == nil { break } return e.ComplexityRoot.Query.Events(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___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) _Like_from(ctx context.Context, field graphql.CollectedField, obj *Like) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Like_from, func(ctx context.Context) (any, error) { return obj.From, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Like_from(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Like", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Post_message(ctx context.Context, field graphql.CollectedField, obj *Post) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Post_message, func(ctx context.Context) (any, error) { return obj.Message, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Post_message(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Post", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_events(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_events, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Events(ctx) }, nil, ec.marshalNEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋunionᚑextensionᚐEventᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_events(_ 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 Event does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_cachedEvents(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_cachedEvents, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().CachedEvents(ctx) }, nil, ec.marshalNEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋunionᚑextensionᚐEventᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_cachedEvents(_ 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 Event does not have child fields") }, } 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) ___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) _Event(ctx context.Context, sel ast.SelectionSet, obj Event) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null case Post: return ec._Post(ctx, sel, &obj) case *Post: if obj == nil { return graphql.Null } return ec._Post(ctx, sel, obj) case Like: return ec._Like(ctx, sel, &obj) case *Like: if obj == nil { return graphql.Null } return ec._Like(ctx, sel, obj) default: if typedObj, ok := obj.(graphql.Marshaler); ok { return typedObj } else { panic(fmt.Errorf("unexpected type %T; non-generated variants of Event must implement graphql.Marshaler", obj)) } } } // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var likeImplementors = []string{"Like", "Event"} func (ec *executionContext) _Like(ctx context.Context, sel ast.SelectionSet, obj *Like) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, likeImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Like") case "from": out.Values[i] = ec._Like_from(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 postImplementors = []string{"Post", "Event"} func (ec *executionContext) _Post(ctx context.Context, sel ast.SelectionSet, obj *Post) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, postImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Post") case "message": out.Values[i] = ec._Post_message(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "events": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_events(ctx, field) 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 "cachedEvents": field := field innerFunc := func(ctx 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_cachedEvents(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) case "__schema": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": out.Values[i] = ec.___Directive_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "description": out.Values[i] = ec.___Directive_description(ctx, field, obj) case "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) marshalNEvent2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋunionᚑextensionᚐEvent(ctx context.Context, sel ast.SelectionSet, v Event) 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._Event(ctx, sel, v) } func (ec *executionContext) marshalNEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋunionᚑextensionᚐEventᚄ(ctx context.Context, sel ast.SelectionSet, v []Event) 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.marshalNEvent2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋunionᚑextensionᚐEvent(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } 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) 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) 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/union-extension/models.go ================================================ package unionextension import ( "io" "github.com/99designs/gqlgen/graphql" ) type CachedLike struct{} type CachedPost struct{} func (CachedLike) IsEvent() {} func (CachedPost) IsEvent() {} var ( _ graphql.Marshaler = CachedLike{} _ graphql.Marshaler = CachedPost{} ) // This needs to be used with caution, as the returned data doesn't go through the usual field resolution process. // This will be returned for all users, no matter what fields are requested. func (CachedLike) MarshalGQL(w io.Writer) { w.Write([]byte(`{"from":"CachedLike"}`)) } // This needs to be used with caution, as the returned data doesn't go through the usual field resolution process. // This will be returned for all users, no matter what fields are requested. func (CachedPost) MarshalGQL(w io.Writer) { w.Write([]byte(`{"message":"CachedPost"}`)) } ================================================ FILE: _examples/union-extension/models_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package unionextension type Event interface { IsEvent() } type Like struct { From string `json:"from"` } func (Like) IsEvent() {} type Post struct { Message string `json:"message"` } func (Post) IsEvent() {} type Query struct { } ================================================ FILE: _examples/union-extension/readme.md ================================================ ### union-extension app This is a graphql-server example where the user extends a code-generated union, for caching / early return purposes. to run this server ```bash go run ./server/server.go ``` and open http://localhost:8086 in your browser ================================================ FILE: _examples/union-extension/schema.graphql ================================================ type Post { message: String! } type Like { from: String! } union Event = Post | Like type Query { events: [Event!]! cachedEvents: [Event!]! } ================================================ FILE: _examples/union-extension/server/server.go ================================================ package main import ( "log" "net/http" unionextension "github.com/99designs/gqlgen/_examples/union-extension" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/playground" ) func main() { srv := handler.New( unionextension.NewExecutableSchema( unionextension.Config{Resolvers: &unionextension.Resolver{}}, ), ) srv.AddTransport(transport.GET{}) srv.AddTransport(transport.POST{}) http.Handle("/", playground.Handler("Union Extension Demo", "/query")) http.Handle("/query", srv) log.Fatal(http.ListenAndServe(":8086", nil)) } ================================================ FILE: _examples/union-extension/union_extension.go ================================================ //go:generate go run ../../testdata/gqlgen.go package unionextension import ( "context" ) type Resolver struct{} func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } type queryResolver struct{ *Resolver } func (r *queryResolver) Events(ctx context.Context) ([]Event, error) { return []Event{&Like{From: "John"}, &Post{Message: "Hello"}}, nil } func (r *queryResolver) CachedEvents(ctx context.Context) ([]Event, error) { return []Event{&CachedLike{}, &CachedPost{}}, nil } ================================================ FILE: _examples/union-extension/union_extension_test.go ================================================ package unionextension 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" ) func TestEvents(t *testing.T) { srv := handler.New(NewExecutableSchema(Config{Resolvers: &Resolver{}})) srv.AddTransport(transport.POST{}) c := client.New(srv) query := `{ events { ... on Like { from } ... on Post { message } } } ` var resp struct { Events []struct { From string Message string } } c.MustPost(query, &resp) require.Equal(t, "John", resp.Events[0].From) require.Equal(t, "Hello", resp.Events[1].Message) } func TestCachedEvents(t *testing.T) { srv := handler.New(NewExecutableSchema(Config{Resolvers: &Resolver{}})) srv.AddTransport(transport.POST{}) c := client.New(srv) query := `{ cachedEvents { ... on Like { from } ... on Post { message } } } ` var resp struct { CachedEvents []struct { From string Message string } } c.MustPost(query, &resp) require.Equal(t, "CachedLike", resp.CachedEvents[0].From) require.Equal(t, "CachedPost", resp.CachedEvents[1].Message) } ================================================ FILE: _examples/uuid/gqlgen.yml ================================================ # Where are all the schema files located? globs are supported eg src/**/*.graphqls schema: - graph/*.graphqls # Where should the generated server code go? exec: filename: graph/generated.go package: graph # Uncomment to enable federation # federation: # filename: graph/federation.go # package: graph # Where should any generated models go? model: filename: graph/model/models_gen.go package: model # Where should the resolver implementations go? resolver: layout: follow-schema dir: graph package: graph filename_template: "{name}.resolvers.go" # Optional: turn on to not generate template comments above resolvers # omit_template_comment: false # Optional: turn on use ` + "`" + `gqlgen:"fieldName"` + "`" + ` tags in your models # struct_tag: json # Optional: turn on to use []Thing instead of []*Thing # omit_slice_element_pointers: false # Optional: turn on to omit Is() methods to interface and unions # omit_interface_checks : true # Optional: turn on to skip generation of ComplexityRoot struct content and Complexity function # omit_complexity: false # Optional: turn on to not generate any file notice comments in generated files # omit_gqlgen_file_notice: false # Optional: turn on to exclude the gqlgen version in the generated file notice. No effect if `omit_gqlgen_file_notice` is true. # omit_gqlgen_version_in_file_notice: false # Optional: turn off to make struct-type struct fields not use pointers # e.g. type Thing struct { FieldA OtherThing } instead of { FieldA *OtherThing } # struct_fields_always_pointers: true # Optional: turn off to make resolvers return values instead of pointers for structs # resolvers_always_return_pointers: true # Optional: turn on to return pointers instead of values in unmarshalInput # return_pointers_in_unmarshalinput: false # Optional: wrap nullable input fields with Omittable # nullable_input_omittable: true # Optional: turn on `json:",omitempty"` tags on model types, default true # enable_model_json_omitempty_tag: true # Optional: set to speed up generation time by not performing a final validation pass. # skip_validation: true # Optional: set to skip running `go mod tidy` when generating server code # skip_mod_tidy: true # gqlgen will search for any type names in the schema in these go packages # if they match it will use them, otherwise it will generate them. autobind: # - "github.com/99designs/gqlgen/_examples/uuid/graph/model" # This section declares type mapping between the GraphQL and go type systems # # The first line in each type will be used as defaults for resolver arguments and # modelgen, the others will be allowed when binding to fields. Configure them to # your liking models: ID: model: - github.com/99designs/gqlgen/graphql.ID - github.com/99designs/gqlgen/graphql.Int - github.com/99designs/gqlgen/graphql.Int64 - github.com/99designs/gqlgen/graphql.Int32 Int: model: - github.com/99designs/gqlgen/graphql.Int - github.com/99designs/gqlgen/graphql.Int64 - github.com/99designs/gqlgen/graphql.Int32 UUID: model: - github.com/99designs/gqlgen/graphql.UUID ================================================ FILE: _examples/uuid/graph/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package graph import ( "bytes" "context" "embed" "errors" "fmt" "strconv" "sync" "sync/atomic" "github.com/99designs/gqlgen/_examples/uuid/graph/model" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" "github.com/google/uuid" gqlparser "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { return &executableSchema{ schema: cfg.Schema, resolvers: cfg.Resolvers, directives: cfg.Directives, complexity: cfg.Complexity, } } type Config struct { Schema *ast.Schema Resolvers ResolverRoot Directives DirectiveRoot Complexity ComplexityRoot } type ResolverRoot interface { Mutation() MutationResolver Query() QueryResolver } type DirectiveRoot struct { } type ComplexityRoot struct { Mutation struct { CreateTodo func(childComplexity int, input model.NewTodo) int } Query struct { Todos func(childComplexity int) int } Todo struct { Done func(childComplexity int) int ID func(childComplexity int) int Text func(childComplexity int) int UID func(childComplexity int) int } } type MutationResolver interface { CreateTodo(ctx context.Context, input model.NewTodo) (*model.Todo, error) } type QueryResolver interface { Todos(ctx context.Context) ([]*model.Todo, error) } type executableSchema struct { 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 "Mutation.createTodo": if e.complexity.Mutation.CreateTodo == nil { break } args, err := ec.field_Mutation_createTodo_args(ctx, rawArgs) if err != nil { return 0, false } return e.complexity.Mutation.CreateTodo(childComplexity, args["input"].(model.NewTodo)), true case "Query.todos": if e.complexity.Query.Todos == nil { break } return e.complexity.Query.Todos(childComplexity), true case "Todo.done": if e.complexity.Todo.Done == nil { break } return e.complexity.Todo.Done(childComplexity), true case "Todo.id": if e.complexity.Todo.ID == nil { break } return e.complexity.Todo.ID(childComplexity), true case "Todo.text": if e.complexity.Todo.Text == nil { break } return e.complexity.Todo.Text(childComplexity), true case "Todo.uid": if e.complexity.Todo.UID == nil { break } return e.complexity.Todo.UID(childComplexity), true } return 0, false } func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { opCtx := graphql.GetOperationContext(ctx) ec := executionContext{opCtx, e, 0, 0, make(chan graphql.DeferredResult)} inputUnmarshalMap := graphql.BuildUnmarshalerMap( ec.unmarshalInputNewTodo, ) 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(), } } default: return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) } } type executionContext struct { *graphql.OperationContext *executableSchema deferred int32 pendingDeferred int32 deferredResults chan graphql.DeferredResult } func (ec *executionContext) processDeferredGroup(dg graphql.DeferredGroup) { atomic.AddInt32(&ec.pendingDeferred, 1) go func() { ctx := graphql.WithFreshResponseContext(dg.Context) dg.FieldSet.Dispatch(ctx) ds := graphql.DeferredResult{ Path: dg.Path, Label: dg.Label, Result: dg.FieldSet, Errors: graphql.GetErrors(ctx), } // null fields should bubble up if dg.FieldSet.Invalids > 0 { ds.Result = graphql.Null } ec.deferredResults <- ds }() } func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } return introspection.WrapSchema(ec.Schema()), nil } func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } return introspection.WrapTypeFromDef(ec.Schema(), ec.Schema().Types[name]), nil } //go:embed "schema.graphqls" var sourcesFS embed.FS func sourceData(filename string) string { data, err := sourcesFS.ReadFile(filename) if err != nil { panic(fmt.Sprintf("codegen problem: %s not available", filename)) } return string(data) } var sources = []*ast.Source{ {Name: "schema.graphqls", Input: sourceData("schema.graphqls"), BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) field_Mutation_createTodo_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Mutation_createTodo_argsInput(ctx, rawArgs) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Mutation_createTodo_argsInput( ctx context.Context, rawArgs map[string]any, ) (model.NewTodo, error) { if _, ok := rawArgs["input"]; !ok { var zeroVal model.NewTodo return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("input")) if tmp, ok := rawArgs["input"]; ok { return ec.unmarshalNNewTodo2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋuuidᚋgraphᚋmodelᚐNewTodo(ctx, tmp) } var zeroVal model.NewTodo return zeroVal, 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 := ec.field_Query___type_argsName(ctx, rawArgs) if err != nil { return nil, err } args["name"] = arg0 return args, nil } func (ec *executionContext) field_Query___type_argsName( ctx context.Context, rawArgs map[string]any, ) (string, error) { if _, ok := rawArgs["name"]; !ok { var zeroVal string return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) if tmp, ok := rawArgs["name"]; ok { return ec.unmarshalNString2string(ctx, tmp) } var zeroVal string return zeroVal, 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 := ec.field___Directive_args_argsIncludeDeprecated(ctx, rawArgs) if err != nil { return nil, err } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Directive_args_argsIncludeDeprecated( ctx context.Context, rawArgs map[string]any, ) (*bool, error) { if _, ok := rawArgs["includeDeprecated"]; !ok { var zeroVal *bool return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) if tmp, ok := rawArgs["includeDeprecated"]; ok { return ec.unmarshalOBoolean2ᚖbool(ctx, tmp) } var zeroVal *bool return zeroVal, 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 := ec.field___Field_args_argsIncludeDeprecated(ctx, rawArgs) if err != nil { return nil, err } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Field_args_argsIncludeDeprecated( ctx context.Context, rawArgs map[string]any, ) (*bool, error) { if _, ok := rawArgs["includeDeprecated"]; !ok { var zeroVal *bool return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) if tmp, ok := rawArgs["includeDeprecated"]; ok { return ec.unmarshalOBoolean2ᚖbool(ctx, tmp) } var zeroVal *bool return zeroVal, 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 := ec.field___Type_enumValues_argsIncludeDeprecated(ctx, rawArgs) if err != nil { return nil, err } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Type_enumValues_argsIncludeDeprecated( ctx context.Context, rawArgs map[string]any, ) (bool, error) { if _, ok := rawArgs["includeDeprecated"]; !ok { var zeroVal bool return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) if tmp, ok := rawArgs["includeDeprecated"]; ok { return ec.unmarshalOBoolean2bool(ctx, tmp) } var zeroVal bool return zeroVal, 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 := ec.field___Type_fields_argsIncludeDeprecated(ctx, rawArgs) if err != nil { return nil, err } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Type_fields_argsIncludeDeprecated( ctx context.Context, rawArgs map[string]any, ) (bool, error) { if _, ok := rawArgs["includeDeprecated"]; !ok { var zeroVal bool return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) if tmp, ok := rawArgs["includeDeprecated"]; ok { return ec.unmarshalOBoolean2bool(ctx, tmp) } var zeroVal bool return zeroVal, nil } // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _Mutation_createTodo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Mutation_createTodo(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Mutation().CreateTodo(rctx, fc.Args["input"].(model.NewTodo)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*model.Todo) fc.Result = res return ec.marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋuuidᚋgraphᚋmodelᚐTodo(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Mutation_createTodo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Todo_id(ctx, field) case "text": return ec.fieldContext_Todo_text(ctx, field) case "done": return ec.fieldContext_Todo_done(ctx, field) case "uid": return ec.fieldContext_Todo_uid(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_createTodo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_todos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Query_todos(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Todos(rctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]*model.Todo) fc.Result = res return ec.marshalNTodo2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋuuidᚋgraphᚋmodelᚐTodoᚄ(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Query_todos(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Todo_id(ctx, field) case "text": return ec.fieldContext_Todo_text(ctx, field) case "done": return ec.fieldContext_Todo_done(ctx, field) case "uid": return ec.fieldContext_Todo_uid(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Todo", field.Name) }, } return fc, nil } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Query___type(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (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 "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) { 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "description": return ec.fieldContext___Schema_description(ctx, field) case "types": return ec.fieldContext___Schema_types(ctx, field) case "queryType": return ec.fieldContext___Schema_queryType(ctx, field) case "mutationType": return ec.fieldContext___Schema_mutationType(ctx, field) case "subscriptionType": return ec.fieldContext___Schema_subscriptionType(ctx, field) case "directives": return ec.fieldContext___Schema_directives(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) }, } return fc, nil } func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.CollectedField, obj *model.Todo) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Todo_id(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (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_Todo_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.CollectedField, obj *model.Todo) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Todo_text(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return obj.Text, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_text(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.CollectedField, obj *model.Todo) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Todo_done(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return obj.Done, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_done(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } func (ec *executionContext) _Todo_uid(ctx context.Context, field graphql.CollectedField, obj *model.Todo) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Todo_uid(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return obj.UID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(uuid.UUID) fc.Result = res return ec.marshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Todo_uid(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Todo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type UUID does not have child fields") }, } return fc, nil } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { fc, err := ec.fieldContext___Directive_name(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (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(_ 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(_ 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) { 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(_ 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) { 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(_ 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) 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) { 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(_ 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(_ 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(_ 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(_ 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(_ 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(_ 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) 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) { 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(_ 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) { 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(_ 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(_ 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(_ 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(_ 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(_ 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) { 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(_ 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) { fc, err := ec.fieldContext___InputValue_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___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) { fc, err := ec.fieldContext___InputValue_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___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) { 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(_ 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(_ 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) { 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(_ 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) { 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(_ 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) { 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(_ 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) { 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(_ 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) { 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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) { 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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 fc, err } return fc, nil } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { fc, err := ec.fieldContext___Type_interfaces(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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) { 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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) { 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 fc, err } return fc, nil } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { fc, err := ec.fieldContext___Type_inputFields(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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) { 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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) { fc, err := ec.fieldContext___Type_isOneOf(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { 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.IsOneOf(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(bool) fc.Result = res return ec.marshalOBoolean2bool(ctx, field.Selections, res) } 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) unmarshalInputNewTodo(ctx context.Context, obj any) (model.NewTodo, error) { var it model.NewTodo asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"text", "userId", "uid"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "text": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Text = data case "userId": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userId")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.UserID = data case "uid": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("uid")) data, err := ec.unmarshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } it.UID = data } } return it, nil } // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var mutationImplementors = []string{"Mutation"} func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Mutation", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Mutation") case "createTodo": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_createTodo(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.deferred, int32(len(deferred))) for label, dfs := range deferred { ec.processDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "todos": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_todos(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) case "__schema": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.deferred, int32(len(deferred))) for label, dfs := range deferred { ec.processDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var todoImplementors = []string{"Todo"} func (ec *executionContext) _Todo(ctx context.Context, sel ast.SelectionSet, obj *model.Todo) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, todoImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Todo") case "id": out.Values[i] = ec._Todo_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "text": out.Values[i] = ec._Todo_text(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "done": out.Values[i] = ec._Todo_done(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "uid": out.Values[i] = ec._Todo_uid(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.deferred, int32(len(deferred))) for label, dfs := range deferred { ec.processDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": out.Values[i] = ec.___Directive_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "description": out.Values[i] = ec.___Directive_description(ctx, field, obj) case "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 { 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) unmarshalNNewTodo2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋuuidᚋgraphᚋmodelᚐNewTodo(ctx context.Context, v any) (model.NewTodo, error) { res, err := ec.unmarshalInputNewTodo(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } 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) marshalNTodo2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋuuidᚋgraphᚋmodelᚐTodo(ctx context.Context, sel ast.SelectionSet, v model.Todo) graphql.Marshaler { return ec._Todo(ctx, sel, &v) } func (ec *executionContext) marshalNTodo2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋuuidᚋgraphᚋmodelᚐTodoᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.Todo) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 if !isLen1 { wg.Add(len(v)) } for i := range v { i := i fc := &graphql.FieldContext{ Index: &i, Result: &v[i], } ctx := graphql.WithFieldContext(ctx, fc) f := func(i int) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = nil } }() if !isLen1 { defer wg.Done() } ret[i] = ec.marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋuuidᚋgraphᚋmodelᚐTodo(ctx, sel, v[i]) } if isLen1 { f(i) } else { go f(i) } } wg.Wait() for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalNTodo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋuuidᚋgraphᚋmodelᚐTodo(ctx context.Context, sel ast.SelectionSet, v *model.Todo) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._Todo(ctx, sel, v) } func (ec *executionContext) unmarshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx context.Context, v any) (uuid.UUID, error) { res, err := graphql.UnmarshalUUID(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx context.Context, sel ast.SelectionSet, v uuid.UUID) graphql.Marshaler { res := graphql.MarshalUUID(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } } return res } func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ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 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) 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: _examples/uuid/graph/model/models_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package model import ( "github.com/google/uuid" ) type Mutation struct { } type NewTodo struct { Text string `json:"text"` UserID string `json:"userId"` UID uuid.UUID `json:"uid"` } type Query struct { } type Todo struct { ID string `json:"id"` Text string `json:"text"` Done bool `json:"done"` UID uuid.UUID `json:"uid"` } ================================================ FILE: _examples/uuid/graph/resolver.go ================================================ package graph // This file will not be regenerated automatically. // // It serves as dependency injection for your app, add any dependencies you require here. type Resolver struct{} ================================================ FILE: _examples/uuid/graph/schema.graphqls ================================================ # GraphQL schema example # # https://gqlgen.com/getting-started/ type Todo { id: ID! text: String! done: Boolean! uid: UUID! } type Query { todos: [Todo!]! } input NewTodo { text: String! userId: String! uid: UUID! } type Mutation { createTodo(input: NewTodo!): Todo! } scalar UUID ================================================ FILE: _examples/uuid/graph/schema.resolvers.go ================================================ package graph // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. // Code generated by github.com/99designs/gqlgen version v0.17.70-dev import ( "context" "github.com/99designs/gqlgen/_examples/uuid/graph/model" "github.com/google/uuid" ) // CreateTodo is the resolver for the createTodo field. func (r *mutationResolver) CreateTodo( ctx context.Context, input model.NewTodo, ) (*model.Todo, error) { return &model.Todo{ ID: input.UserID, Text: input.Text, Done: true, UID: input.UID, }, nil } // Todos is the resolver for the todos field. func (r *queryResolver) Todos(ctx context.Context) ([]*model.Todo, error) { return []*model.Todo{ {ID: "1", Text: "hello", Done: true, UID: uuid.New()}, {ID: "2", Text: "world", Done: false, UID: uuid.New()}, }, nil } // Mutation returns MutationResolver implementation. func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } // Query returns QueryResolver implementation. func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } type ( mutationResolver struct{ *Resolver } queryResolver struct{ *Resolver } ) ================================================ FILE: _examples/uuid/server.go ================================================ package main import ( "log" "net/http" "os" "github.com/99designs/gqlgen/_examples/uuid/graph" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/playground" ) const defaultPort = "8080" func main() { port := os.Getenv("PORT") if port == "" { port = defaultPort } srv := handler.New( graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}}), ) srv.AddTransport(transport.GET{}) srv.AddTransport(transport.POST{}) 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: _examples/websocket-initfunc/graph/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package graph import ( "bytes" "context" "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{ 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 { } } 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 { } 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{} 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 := ec.field_Query___type_argsName(ctx, rawArgs) if err != nil { return nil, err } args["name"] = arg0 return args, nil } func (ec *executionContext) field_Query___type_argsName( ctx context.Context, rawArgs map[string]any, ) (string, error) { if _, ok := rawArgs["name"]; !ok { var zeroVal string return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) if tmp, ok := rawArgs["name"]; ok { return ec.unmarshalNString2string(ctx, tmp) } var zeroVal string return zeroVal, 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 := ec.field___Directive_args_argsIncludeDeprecated(ctx, rawArgs) if err != nil { return nil, err } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Directive_args_argsIncludeDeprecated( ctx context.Context, rawArgs map[string]any, ) (*bool, error) { if _, ok := rawArgs["includeDeprecated"]; !ok { var zeroVal *bool return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) if tmp, ok := rawArgs["includeDeprecated"]; ok { return ec.unmarshalOBoolean2ᚖbool(ctx, tmp) } var zeroVal *bool return zeroVal, 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 := ec.field___Field_args_argsIncludeDeprecated(ctx, rawArgs) if err != nil { return nil, err } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Field_args_argsIncludeDeprecated( ctx context.Context, rawArgs map[string]any, ) (*bool, error) { if _, ok := rawArgs["includeDeprecated"]; !ok { var zeroVal *bool return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) if tmp, ok := rawArgs["includeDeprecated"]; ok { return ec.unmarshalOBoolean2ᚖbool(ctx, tmp) } var zeroVal *bool return zeroVal, 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 := ec.field___Type_enumValues_argsIncludeDeprecated(ctx, rawArgs) if err != nil { return nil, err } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Type_enumValues_argsIncludeDeprecated( ctx context.Context, rawArgs map[string]any, ) (bool, error) { if _, ok := rawArgs["includeDeprecated"]; !ok { var zeroVal bool return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) if tmp, ok := rawArgs["includeDeprecated"]; ok { return ec.unmarshalOBoolean2bool(ctx, tmp) } var zeroVal bool return zeroVal, 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 := ec.field___Type_fields_argsIncludeDeprecated(ctx, rawArgs) if err != nil { return nil, err } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Type_fields_argsIncludeDeprecated( ctx context.Context, rawArgs map[string]any, ) (bool, error) { if _, ok := rawArgs["includeDeprecated"]; !ok { var zeroVal bool return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) if tmp, ok := rawArgs["includeDeprecated"]; ok { return ec.unmarshalOBoolean2bool(ctx, tmp) } var zeroVal bool return zeroVal, nil } // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** 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 "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) { 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "description": return ec.fieldContext___Schema_description(ctx, field) case "types": return ec.fieldContext___Schema_types(ctx, field) case "queryType": return ec.fieldContext___Schema_queryType(ctx, field) case "mutationType": return ec.fieldContext___Schema_mutationType(ctx, field) case "subscriptionType": return ec.fieldContext___Schema_subscriptionType(ctx, field) case "directives": return ec.fieldContext___Schema_directives(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) }, } return fc, nil } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { fc, err := ec.fieldContext___Directive_name(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (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(_ 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(_ 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) { 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(_ 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) { 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(_ 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) 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) { 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(_ 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(_ 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(_ 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(_ 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(_ 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(_ 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) 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) { 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(_ 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) { 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(_ 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(_ 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(_ 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(_ 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(_ 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) { 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(_ 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) { fc, err := ec.fieldContext___InputValue_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___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) { fc, err := ec.fieldContext___InputValue_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___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) { 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(_ 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(_ 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) { 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(_ 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) { 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(_ 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) { 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(_ 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) { 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(_ 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) { 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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) { 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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 fc, err } return fc, nil } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { fc, err := ec.fieldContext___Type_interfaces(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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) { 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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) { 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 fc, err } return fc, nil } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { fc, err := ec.fieldContext___Type_inputFields(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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) { 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(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, 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) { fc, err := ec.fieldContext___Type_isOneOf(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { 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.IsOneOf(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(bool) fc.Result = res return ec.marshalOBoolean2bool(ctx, field.Selections, res) } 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 "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) case "__schema": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.deferred, int32(len(deferred))) for label, dfs := range deferred { ec.processDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": out.Values[i] = ec.___Directive_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "description": out.Values[i] = ec.___Directive_description(ctx, field, obj) case "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 { res := graphql.MarshalBoolean(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } } return res } func (ec *executionContext) unmarshalNString2string(ctx context.Context, v 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) 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 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) 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: _examples/websocket-initfunc/graph/model/models_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package model type Query struct { } ================================================ FILE: _examples/websocket-initfunc/graph/resolver.go ================================================ package graph // This file will not be regenerated automatically. // // It serves as dependency injection for your app, add any dependencies you require here. type Resolver struct{} ================================================ FILE: _examples/websocket-initfunc/server/Makefile ================================================ bin_name=server build: @echo "building binary..." # go generate gives missing go sum entry for module errors # https://github.com/99designs/gqlgen/issues/1483 # you will need to first do a go get -u github.com/99designs/gqlgen go run -mod=mod github.com/99designs/gqlgen generate . go build -o ${bin_name} server.go ================================================ FILE: _examples/websocket-initfunc/server/go.mod ================================================ module github.com/gqlgen/_examples/websocket-initfunc/server go 1.25.0 require ( github.com/99designs/gqlgen v0.17.86 github.com/go-chi/chi v1.5.4 github.com/gorilla/websocket v1.5.0 github.com/rs/cors v1.11.1 github.com/vektah/gqlparser/v2 v2.5.31 ) require ( github.com/agnivade/levenshtein v1.2.1 // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/sosodev/duration v1.3.1 // indirect ) ================================================ FILE: _examples/websocket-initfunc/server/go.sum ================================================ github.com/99designs/gqlgen v0.17.86 h1:C8N3UTa5heXX6twl+b0AJyGkTwYL6dNmFrgZNLRcU6w= github.com/99designs/gqlgen v0.17.86/go.mod h1:KTrPl+vHA1IUzNlh4EYkl7+tcErL3MgKnhHrBcV74Fw= 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-chi/chi v1.5.4 h1:QHdzF2szwjqVV4wmByUnTcsbIg7UGaQ0tPF2t5GcAIs= github.com/go-chi/chi v1.5.4/go.mod h1:uaf8YgoFazUOkPBG7fxPftUylNumIev9awIWOENIuEg= github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs= github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= 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/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA= github.com/rs/cors v1.11.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= 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.3.1 h1:qtHBDMQ6lvMQsL15g4aopM4HEfOaYuhWBw3NPTtlqq4= github.com/sosodev/duration v1.3.1/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/vektah/gqlparser/v2 v2.5.31 h1:YhWGA1mfTjID7qJhd1+Vxhpk5HTgydrGU9IgkWBTJ7k= github.com/vektah/gqlparser/v2 v2.5.31/go.mod h1:c1I28gSOVNzlfc4WuDlqU7voQnsqI6OG2amkBAFmgts= golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU= golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= ================================================ FILE: _examples/websocket-initfunc/server/gqlgen.yml ================================================ # Where are all the schema files located? globs are supported eg src/**/*.graphqls schema: - graph/*.graphqls # Where should the generated server code go? exec: filename: graph/generated.go package: graph # Uncomment to enable federation # federation: # filename: graph/federation.go # package: graph # Where should any generated models go? model: filename: graph/model/models_gen.go package: model # Where should the resolver implementations go? resolver: layout: follow-schema dir: graph package: graph # Optional: turn on use `gqlgen:"fieldName"` tags in your models # struct_tag: json # Optional: turn on to use []Thing instead of []*Thing # omit_slice_element_pointers: false # Optional: turn off to make struct-type struct fields not use pointers # e.g. type Thing struct { FieldA OtherThing } instead of { FieldA *OtherThing } # struct_fields_always_pointers: true # Optional: turn off to make resolvers return values instead of pointers for structs # resolvers_always_return_pointers: true # Optional: turn on to return pointers instead of values in unmarshalInput # return_pointers_in_unmarshalinput: false # Optional: wrap nullable input fields with Omittable # nullable_input_omittable: true # Optional: set to speed up generation time by not performing a final validation pass. # skip_validation: true # gqlgen will search for any type names in the schema in these go packages # if they match it will use them, otherwise it will generate them. autobind: # - "github.com/gqlgen/_examples/websocket-initfunc/server/graph/model" # This section declares type mapping between the GraphQL and go type systems # # The first line in each type will be used as defaults for resolver arguments and # modelgen, the others will be allowed when binding to fields. Configure them to # your liking models: ID: model: - github.com/99designs/gqlgen/graphql.ID - github.com/99designs/gqlgen/graphql.Int - github.com/99designs/gqlgen/graphql.Int64 - github.com/99designs/gqlgen/graphql.Int32 Int: model: - github.com/99designs/gqlgen/graphql.Int - github.com/99designs/gqlgen/graphql.Int64 - github.com/99designs/gqlgen/graphql.Int32 ================================================ FILE: _examples/websocket-initfunc/server/graph/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package graph import ( "bytes" "context" "embed" "errors" "fmt" "io" "strconv" "sync" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" "github.com/gqlgen/_examples/websocket-initfunc/server/graph/model" gqlparser "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { return &executableSchema{ resolvers: cfg.Resolvers, directives: cfg.Directives, complexity: cfg.Complexity, } } type Config struct { Resolvers ResolverRoot Directives DirectiveRoot Complexity ComplexityRoot } type ResolverRoot interface { Mutation() MutationResolver Subscription() SubscriptionResolver } type DirectiveRoot struct { } type ComplexityRoot struct { Dummy struct { Done func(childComplexity int) int ID func(childComplexity int) int Text func(childComplexity int) int } Mutation struct { PostMessageTo func(childComplexity int, subscriber string, content string) int } Query struct { } Subscription struct { Subscribe func(childComplexity int, subscriber string) int } } type MutationResolver interface { PostMessageTo(ctx context.Context, subscriber string, content string) (string, error) } type SubscriptionResolver interface { Subscribe(ctx context.Context, subscriber string) (<-chan string, error) } type executableSchema struct { resolvers ResolverRoot directives DirectiveRoot complexity ComplexityRoot } func (e *executableSchema) Schema() *ast.Schema { return parsedSchema } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]any) (int, bool) { ec := executionContext{nil, e} _ = ec switch typeName + "." + field { case "Dummy.done": if e.complexity.Dummy.Done == nil { break } return e.complexity.Dummy.Done(childComplexity), true case "Dummy.id": if e.complexity.Dummy.ID == nil { break } return e.complexity.Dummy.ID(childComplexity), true case "Dummy.text": if e.complexity.Dummy.Text == nil { break } return e.complexity.Dummy.Text(childComplexity), true case "Mutation.postMessageTo": if e.complexity.Mutation.PostMessageTo == nil { break } args, err := ec.field_Mutation_postMessageTo_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Mutation.PostMessageTo(childComplexity, args["subscriber"].(string), args["content"].(string)), true case "Subscription.subscribe": if e.complexity.Subscription.Subscribe == nil { break } args, err := ec.field_Subscription_subscribe_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Subscription.Subscribe(childComplexity, args["subscriber"].(string)), true } return 0, false } func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { 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(), } } 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._Subscription(ctx, opCtx.Operation.SelectionSet) var buf bytes.Buffer return func(ctx context.Context) *graphql.Response { buf.Reset() data := next(ctx) if data == nil { return nil } data.MarshalGQL(&buf) return &graphql.Response{ Data: buf.Bytes(), } } default: return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) } } type executionContext struct { *graphql.OperationContext *executableSchema } func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } return introspection.WrapSchema(parsedSchema), nil } func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil } //go:embed "schema.graphqls" var sourcesFS embed.FS func sourceData(filename string) string { data, err := sourcesFS.ReadFile(filename) if err != nil { panic(fmt.Sprintf("codegen problem: %s not available", filename)) } return string(data) } var sources = []*ast.Source{ {Name: "schema.graphqls", Input: sourceData("schema.graphqls"), BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) field_Mutation_postMessageTo_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} var arg0 string if tmp, ok := rawArgs["subscriber"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("subscriber")) arg0, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } } args["subscriber"] = arg0 var arg1 string if tmp, ok := rawArgs["content"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("content")) arg1, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } } args["content"] = arg1 return args, nil } func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]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_Subscription_subscribe_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["subscriber"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("subscriber")) arg0, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } } args["subscriber"] = arg0 return args, nil } func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]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) _Dummy_id(ctx context.Context, field graphql.CollectedField, obj *model.Dummy) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Dummy_id(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (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_Dummy_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Dummy", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _Dummy_text(ctx context.Context, field graphql.CollectedField, obj *model.Dummy) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Dummy_text(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return obj.Text, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Dummy_text(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Dummy", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Dummy_done(ctx context.Context, field graphql.CollectedField, obj *model.Dummy) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Dummy_done(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return obj.Done, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) fc.Result = res return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Dummy_done(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Dummy", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } func (ec *executionContext) _Mutation_postMessageTo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Mutation_postMessageTo(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Mutation().PostMessageTo(rctx, fc.Args["subscriber"].(string), fc.Args["content"].(string)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Mutation_postMessageTo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_postMessageTo_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return } return fc, nil } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Query___type(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (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) _Subscription_subscribe(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { fc, err := ec.fieldContext_Subscription_subscribe(ctx, field) if err != nil { return nil } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = nil } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Subscription().Subscribe(rctx, fc.Args["subscriber"].(string)) }) if err != nil { ec.Error(ctx, err) return nil } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return nil } return func(ctx context.Context) graphql.Marshaler { select { case res, ok := <-resTmp.(<-chan string): if !ok { return nil } return graphql.WriterFunc(func(w io.Writer) { w.Write([]byte{'{'}) graphql.MarshalString(field.Alias).MarshalGQL(w) w.Write([]byte{':'}) ec.marshalNString2string(ctx, field.Selections, res).MarshalGQL(w) w.Write([]byte{'}'}) }) case <-ctx.Done(): return nil } } } func (ec *executionContext) fieldContext_Subscription_subscribe(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Subscription", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Subscription_subscribe_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return } return fc, nil } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { fc, err := ec.fieldContext___Directive_name(ctx, field) if err != nil { return graphql.Null } ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (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 dummyImplementors = []string{"Dummy"} func (ec *executionContext) _Dummy(ctx context.Context, sel ast.SelectionSet, obj *model.Dummy) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, dummyImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Dummy") case "id": out.Values[i] = ec._Dummy_id(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "text": out.Values[i] = ec._Dummy_text(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "done": out.Values[i] = ec._Dummy_done(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch() if invalids > 0 { return graphql.Null } return out } var mutationImplementors = []string{"Mutation"} func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Mutation", }) out := graphql.NewFieldSet(fields) var invalids uint32 for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Mutation") case "postMessageTo": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_postMessageTo(ctx, field) }) if out.Values[i] == graphql.Null { invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch() if invalids > 0 { return graphql.Null } return out } var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) out := graphql.NewFieldSet(fields) var invalids uint32 for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) case "__schema": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch() if invalids > 0 { return graphql.Null } return out } var subscriptionImplementors = []string{"Subscription"} func (ec *executionContext) _Subscription(ctx context.Context, sel ast.SelectionSet) func(ctx context.Context) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, subscriptionImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Subscription", }) if len(fields) != 1 { ec.Errorf(ctx, "must subscribe to exactly one stream") return nil } switch fields[0].Name { case "subscribe": return ec._Subscription_subscribe(ctx, fields[0]) default: panic("unknown field " + strconv.Quote(fields[0].Name)) } } var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": out.Values[i] = ec.___Directive_name(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "description": out.Values[i] = ec.___Directive_description(ctx, field, obj) case "locations": out.Values[i] = ec.___Directive_locations(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "args": out.Values[i] = ec.___Directive_args(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "isRepeatable": out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch() if invalids > 0 { return graphql.Null } return out } var __EnumValueImplementors = []string{"__EnumValue"} func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__EnumValue") case "name": out.Values[i] = ec.___EnumValue_name(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "description": out.Values[i] = ec.___EnumValue_description(ctx, field, obj) case "isDeprecated": out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "deprecationReason": out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch() if invalids > 0 { return graphql.Null } return out } var __FieldImplementors = []string{"__Field"} func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Field") case "name": out.Values[i] = ec.___Field_name(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "description": out.Values[i] = ec.___Field_description(ctx, field, obj) case "args": out.Values[i] = ec.___Field_args(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "type": out.Values[i] = ec.___Field_type(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "isDeprecated": out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "deprecationReason": out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch() if invalids > 0 { return graphql.Null } return out } var __InputValueImplementors = []string{"__InputValue"} func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__InputValue") case "name": out.Values[i] = ec.___InputValue_name(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "description": out.Values[i] = ec.___InputValue_description(ctx, field, obj) case "type": out.Values[i] = ec.___InputValue_type(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "defaultValue": out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch() if invalids > 0 { return graphql.Null } return out } var __SchemaImplementors = []string{"__Schema"} func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Schema") case "description": out.Values[i] = ec.___Schema_description(ctx, field, obj) case "types": out.Values[i] = ec.___Schema_types(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "queryType": out.Values[i] = ec.___Schema_queryType(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "mutationType": out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) case "subscriptionType": out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) case "directives": out.Values[i] = ec.___Schema_directives(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch() if invalids > 0 { return graphql.Null } return out } var __TypeImplementors = []string{"__Type"} func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Type") case "kind": out.Values[i] = ec.___Type_kind(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "name": out.Values[i] = ec.___Type_name(ctx, field, obj) case "description": out.Values[i] = ec.___Type_description(ctx, field, obj) case "fields": out.Values[i] = ec.___Type_fields(ctx, field, obj) case "interfaces": out.Values[i] = ec.___Type_interfaces(ctx, field, obj) case "possibleTypes": out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) case "enumValues": out.Values[i] = ec.___Type_enumValues(ctx, field, obj) case "inputFields": out.Values[i] = ec.___Type_inputFields(ctx, field, obj) case "ofType": out.Values[i] = ec.___Type_ofType(ctx, field, obj) case "specifiedByURL": out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch() if invalids > 0 { return graphql.Null } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v 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) 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) 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: _examples/websocket-initfunc/server/graph/model/models_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package model type Dummy struct { ID string `json:"id"` Text string `json:"text"` Done bool `json:"done"` } ================================================ FILE: _examples/websocket-initfunc/server/graph/resolver.go ================================================ package graph // This file will not be regenerated automatically. // // It serves as dependency injection for your app, add any dependencies you require here. type Resolver struct{} ================================================ FILE: _examples/websocket-initfunc/server/graph/schema.graphqls ================================================ # GraphQL schema example # type Dummy { id: ID! text: String! done: Boolean! } type Mutation { postMessageTo(subscriber: String!, content: String!): ID! } type Subscription { subscribe(subscriber: String!): String! } ================================================ FILE: _examples/websocket-initfunc/server/graph/schema.resolvers.go ================================================ package graph // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. // Code generated by github.com/99designs/gqlgen version v0.17.25 import ( "context" "fmt" ) // PostMessageTo is the resolver for the postMessageTo field. func (r *mutationResolver) PostMessageTo( ctx context.Context, subscriber string, content string, ) (string, error) { panic(fmt.Errorf("not implemented")) } // Subscribe is the resolver for the subscribe field. func (r *subscriptionResolver) Subscribe( ctx context.Context, subscriber string, ) (<-chan string, error) { panic(fmt.Errorf("not implemented")) } // Mutation returns MutationResolver implementation. func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } // Subscription returns SubscriptionResolver implementation. func (r *Resolver) Subscription() SubscriptionResolver { return &subscriptionResolver{r} } type ( mutationResolver struct{ *Resolver } subscriptionResolver struct{ *Resolver } ) ================================================ FILE: _examples/websocket-initfunc/server/readme.md ================================================ # WebSocket Init App Example server app using websocket `InitFunc`. ## Build and Run the server app First get an update from gqlgen: ```bash go mod tidy go get -u github.com/99designs/gqlgen ``` Next just make the build: ```bash make build ``` Run the server: ```bash ./server 2022/07/07 16:49:46 connect to http://localhost:8080/ for GraphQL playground ``` You may now implement a websocket client to subscribe for websocket messages. ================================================ FILE: _examples/websocket-initfunc/server/server.go ================================================ package main import ( "context" "errors" "log" "net/http" "os" "time" "github.com/go-chi/chi" "github.com/gorilla/websocket" "github.com/gqlgen/_examples/websocket-initfunc/server/graph" "github.com/rs/cors" "github.com/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 webSocketInit( ctx context.Context, initPayload transport.InitPayload, ) (context.Context, *transport.InitPayload, error) { // Get the token from payload payload := initPayload["authToken"] token, ok := payload.(string) if !ok || token == "" { return nil, nil, errors.New("authToken not found in transport payload") } // Perform token verification and authentication... userId := "john.doe" // e.g. userId, err := GetUserFromAuthentication(token) // put it in context ctxNew := context.WithValue(ctx, "username", userId) return ctxNew, nil, nil } const defaultPort = "8080" func main() { port := os.Getenv("PORT") if port == "" { port = defaultPort } router := chi.NewRouter() // CORS setup, allow any for now // https://gqlgen.com/recipes/cors/ c := cors.New(cors.Options{ AllowedOrigins: []string{"*"}, AllowCredentials: true, Debug: false, }) srv := handler.New(graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}})) srv.AddTransport(transport.POST{}) srv.AddTransport(transport.Websocket{ KeepAlivePingInterval: 10 * time.Second, Upgrader: websocket.Upgrader{ CheckOrigin: func(r *http.Request) bool { return true }, }, InitFunc: func(ctx context.Context, initPayload transport.InitPayload) (context.Context, *transport.InitPayload, error) { return webSocketInit(ctx, initPayload) }, }) srv.Use(extension.Introspection{}) router.Handle("/", playground.Handler("My GraphQL App", "/app")) router.Handle("/app", c.Handler(srv)) log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) log.Fatal(http.ListenAndServe(":"+port, router)) } ================================================ FILE: api/generate.go ================================================ package api import ( "fmt" "regexp" "syscall" "golang.org/x/tools/imports" "github.com/99designs/gqlgen/codegen" "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/internal/code" "github.com/99designs/gqlgen/plugin" "github.com/99designs/gqlgen/plugin/federation" "github.com/99designs/gqlgen/plugin/modelgen" "github.com/99designs/gqlgen/plugin/resolvergen" ) var ( urlRegex = regexp.MustCompile( `(?s)@link.*\(.*url:\s*?"(.*?)"[^)]+\)`, ) // regex to grab the url of a link directive, should it exist versionRegex = regexp.MustCompile( `v(\d+).(\d+)$`, ) // regex to grab the version number from a url ) // Generate generates GraphQL code based on the provided config. func Generate(cfg *config.Config, option ...Option) error { return generate(cfg, nil, option...) } // GenerateIncremental generates code only for schemas affected by changes. // changedSchemas should contain paths to schema files that have changed // (e.g., from git diff). If empty, performs full generation. // Use verbose to enable detailed logging of what's being regenerated. func GenerateIncremental( cfg *config.Config, changedSchemas []string, verbose bool, option ...Option, ) error { return generate(cfg, &codegen.IncrementalOptions{ ChangedSchemas: changedSchemas, Verbose: verbose, }, option...) } // generate is the shared implementation for both Generate and GenerateIncremental. // If incrementalOpts is nil, performs full generation. Otherwise, uses incremental generation. func generate( cfg *config.Config, incrementalOpts *codegen.IncrementalOptions, option ...Option, ) error { _ = syscall.Unlink(cfg.Exec.Filename) if cfg.Model.IsDefined() { _ = syscall.Unlink(cfg.Model.Filename) } plugins := []plugin.Plugin{} if cfg.Model.IsDefined() { plugins = append(plugins, modelgen.New()) } plugins = append(plugins, resolvergen.New()) if cfg.Federation.IsDefined() { if cfg.Federation.Version == 0 { // default to using the user's choice of version, but if unset, try to sort out which federation version to use // check the sources, and if one is marked as federation v2, we mark the entirety to be // generated using that format for _, v := range cfg.Sources { cfg.Federation.Version = 1 urlString := urlRegex.FindStringSubmatch(v.Input) // e.g. urlString[1] == "https://specs.apollo.dev/federation/v2.7" if urlString != nil { matches := versionRegex.FindStringSubmatch(urlString[1]) if matches[1] == "2" { cfg.Federation.Version = 2 break } } } } federationPlugin, err := federation.New(cfg.Federation.Version, cfg) if err != nil { return fmt.Errorf("failed to construct the Federation plugin: %w", err) } plugins = append([]plugin.Plugin{federationPlugin}, plugins...) } for _, o := range option { o(cfg, &plugins) } if cfg.LocalPrefix != "" { imports.LocalPrefix = cfg.LocalPrefix } for _, p := range plugins { //nolint:staticcheck // for backwards compatibility only if inj, ok := p.(plugin.EarlySourceInjector); ok { if s := inj.InjectSourceEarly(); s != nil { cfg.Sources = append(cfg.Sources, s) } } if inj, ok := p.(plugin.EarlySourcesInjector); ok { s, err := inj.InjectSourcesEarly() if err != nil { return fmt.Errorf("%s: %w", p.Name(), err) } cfg.Sources = append(cfg.Sources, s...) } } if err := cfg.LoadSchema(); err != nil { return fmt.Errorf("failed to load schema: %w", err) } for _, p := range plugins { if inj, ok := p.(plugin.LateSourceInjector); ok { if s := inj.InjectSourceLate(cfg.Schema); s != nil { cfg.Sources = append(cfg.Sources, s) } } if inj, ok := p.(plugin.LateSourcesInjector); ok { s, err := inj.InjectSourcesLate(cfg.Schema) if err != nil { return fmt.Errorf("%s: %w", p.Name(), err) } cfg.Sources = append(cfg.Sources, s...) } } // LoadSchema again now we have everything if err := cfg.LoadSchema(); err != nil { return fmt.Errorf("failed to load schema: %w", err) } codegen.ClearInlineArgsMetadata() if err := codegen.ExpandInlineArguments(cfg.Schema); err != nil { return fmt.Errorf("failed to expand inline arguments: %w", err) } if err := cfg.Init(); err != nil { return fmt.Errorf("generating core failed: %w", err) } for _, p := range plugins { if mut, ok := p.(plugin.SchemaMutator); ok { err := mut.MutateSchema(cfg.Schema) if err != nil { return fmt.Errorf("%s: %w", p.Name(), err) } } } for _, p := range plugins { if mut, ok := p.(plugin.ConfigMutator); ok { err := mut.MutateConfig(cfg) if err != nil { return fmt.Errorf("%s: %w", p.Name(), err) } } } // Merge again now that the generated models have been injected into the typemap dataPlugins := make([]any, len(plugins)) for index := range plugins { dataPlugins[index] = plugins[index] } data, err := codegen.BuildData(cfg, dataPlugins...) if err != nil { return fmt.Errorf("merging type systems failed: %w", err) } for _, p := range plugins { if mut, ok := p.(plugin.CodeGenerator); ok { err := mut.GenerateCode(data) if err != nil { return fmt.Errorf("%s: %w", p.Name(), err) } } } // Use incremental generation if options provided, otherwise full generation if incrementalOpts != nil { if err = codegen.GenerateCodeIncremental(data, *incrementalOpts); err != nil { return fmt.Errorf("generating core failed: %w", err) } } else { if err = codegen.GenerateCode(data); err != nil { return fmt.Errorf("generating core failed: %w", err) } } if !cfg.SkipModTidy { if err = cfg.Packages.ModTidy(); err != nil { return fmt.Errorf("tidy failed: %w", err) } } if !cfg.SkipValidation { if err := validate(cfg); err != nil { return fmt.Errorf("validation failed: %w", err) } } return nil } func validate(cfg *config.Config) error { roots := []string{withSubpackages(cfg.Exec.ImportPath())} if cfg.Model.IsDefined() { roots = append(roots, withSubpackages(cfg.Model.ImportPath())) } if cfg.Resolver.IsDefined() { roots = append(roots, withSubpackages(cfg.Resolver.ImportPath())) } // Use go build for validation instead of packages.Load with NeedTypes. // go build benefits from incremental compilation - only changed files // are recompiled. Since we use content-based file writing, unchanged // generated files keep their mtime, so go build skips them. // // FastValidation uses -gcflags="-N -l" to disable compiler // optimizations, making cold cache validation ~2x faster. return code.ValidateWithBuild(cfg.GetFastValidation(), roots...) } // subpackagesWildcard is the Go tooling pattern for "this package and all subpackages". // Used by go build, go test, etc. (e.g., "go build ./...") const subpackagesWildcard = "/..." // withSubpackages appends the Go wildcard pattern to include all subpackages. func withSubpackages(importPath string) string { return importPath + subpackagesWildcard } ================================================ FILE: api/generate_test.go ================================================ package api import ( "errors" "os" "path/filepath" "testing" "github.com/stretchr/testify/require" "github.com/vektah/gqlparser/v2/ast" "github.com/99designs/gqlgen/codegen/config" ) func cleanup(workDir string) { _ = os.Remove(filepath.Join(workDir, "server.go")) _ = os.Remove(filepath.Join(workDir, "graph", "generated.go")) _ = os.Remove(filepath.Join(workDir, "graph", "resolver.go")) _ = os.Remove(filepath.Join(workDir, "graph", "federation.go")) _ = os.Remove(filepath.Join(workDir, "graph", "schema.resolvers.go")) _ = os.Remove(filepath.Join(workDir, "graph", "model", "models_gen.go")) } func TestGenerate(t *testing.T) { wd, err := os.Getwd() require.NoError(t, err) tests := []struct { name string workDir string }{ { name: "default", workDir: filepath.Join(wd, "testdata", "default"), }, { name: "federation2", workDir: filepath.Join(wd, "testdata", "federation2"), }, { name: "worker_limit", workDir: filepath.Join(wd, "testdata", "workerlimit"), }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { t.Cleanup(func() { cleanup(tt.workDir) t.Chdir(wd) }) t.Chdir(tt.workDir) cfg, err := config.LoadConfigFromDefaultLocations() require.NoError(t, err, "failed to load config") err = Generate(cfg) require.NoError(t, err, "failed to generate code") }) } } type testSchemaMutator struct { name string shouldError bool } func (t *testSchemaMutator) Name() string { return t.name } func (t *testSchemaMutator) MutateSchema(schema *ast.Schema) error { if t.shouldError { return errors.New("deliberate schema mutation error") } schema.Types["TestType"] = &ast.Definition{ Kind: ast.Object, Name: "TestType", Fields: ast.FieldList{ { Name: "id", Type: ast.NamedType("ID", nil), }, }, } return nil } func TestGenerateWithSchemaMutator(t *testing.T) { wd, err := os.Getwd() require.NoError(t, err) tests := []struct { name string mutator *testSchemaMutator shouldError bool }{ { name: "successful schema mutation", mutator: &testSchemaMutator{name: "test-mutator", shouldError: false}, shouldError: false, }, { name: "failed schema mutation", mutator: &testSchemaMutator{name: "error-mutator", shouldError: true}, shouldError: true, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { workDir := filepath.Join(wd, "testdata", "default") t.Cleanup(func() { cleanup(workDir) t.Chdir(wd) }) t.Chdir(workDir) cfg, err := config.LoadConfigFromDefaultLocations() require.NoError(t, err) err = Generate(cfg, AddPlugin(tt.mutator)) if tt.shouldError { require.Error(t, err) require.Contains(t, err.Error(), "deliberate schema mutation error") } else { require.NoError(t, err) require.Contains(t, cfg.Schema.Types, "TestType") require.Equal(t, ast.Object, cfg.Schema.Types["TestType"].Kind) } }) } } ================================================ FILE: api/option.go ================================================ package api import ( "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/plugin" ) type Option func(cfg *config.Config, plugins *[]plugin.Plugin) func NoPlugins() Option { return func(cfg *config.Config, plugins *[]plugin.Plugin) { *plugins = nil } } func AddPlugin(p plugin.Plugin) Option { return func(cfg *config.Config, plugins *[]plugin.Plugin) { *plugins = append(*plugins, p) } } // PrependPlugin prepends plugin any existing plugins func PrependPlugin(p plugin.Plugin) Option { return func(cfg *config.Config, plugins *[]plugin.Plugin) { *plugins = append([]plugin.Plugin{p}, *plugins...) } } // ReplacePlugin replaces any existing plugin with a matching plugin name func ReplacePlugin(p plugin.Plugin) Option { return func(cfg *config.Config, plugins *[]plugin.Plugin) { if plugins == nil { return } found := false ps := *plugins for i, o := range ps { if p.Name() == o.Name() { ps[i] = p found = true } } if !found { ps = append(ps, p) } *plugins = ps } } ================================================ FILE: api/option_test.go ================================================ package api import ( "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/plugin" "github.com/99designs/gqlgen/plugin/federation" "github.com/99designs/gqlgen/plugin/modelgen" "github.com/99designs/gqlgen/plugin/resolvergen" ) type testPlugin struct{} // Name returns the plugin name func (t *testPlugin) Name() string { return "modelgen" } // MutateConfig mutates the configuration func (t *testPlugin) MutateConfig(_ *config.Config) error { return nil } func mustFederationPlugin(t *testing.T) plugin.Plugin { p, err := federation.New(1, &config.Config{ Federation: config.PackageConfig{}, }) if err != nil { require.Fail(t, "failed to create federation plugin") } return p } func TestReplacePlugin(t *testing.T) { t.Run("replace plugin if exists", func(t *testing.T) { pg := []plugin.Plugin{ mustFederationPlugin(t), modelgen.New(), resolvergen.New(), } expectedPlugin := &testPlugin{} ReplacePlugin(expectedPlugin)(config.DefaultConfig(), &pg) require.EqualValues(t, mustFederationPlugin(t), pg[0]) require.EqualValues(t, expectedPlugin, pg[1]) require.EqualValues(t, resolvergen.New(), pg[2]) }) t.Run("add plugin if doesn't exist", func(t *testing.T) { pg := []plugin.Plugin{ mustFederationPlugin(t), resolvergen.New(), } expectedPlugin := &testPlugin{} ReplacePlugin(expectedPlugin)(config.DefaultConfig(), &pg) require.EqualValues(t, mustFederationPlugin(t), pg[0]) require.EqualValues(t, resolvergen.New(), pg[1]) require.EqualValues(t, expectedPlugin, pg[2]) }) t.Run("do nothing if plugins is nil", func(t *testing.T) { ReplacePlugin(&testPlugin{})(config.DefaultConfig(), nil) }) } func TestPrependPlugin(t *testing.T) { modelgenPlugin := modelgen.New() pg := []plugin.Plugin{ modelgenPlugin, } expectedPlugin := &testPlugin{} PrependPlugin(expectedPlugin)(config.DefaultConfig(), &pg) require.EqualValues(t, expectedPlugin, pg[0]) require.EqualValues(t, modelgenPlugin, pg[1]) } ================================================ FILE: api/testdata/default/gqlgen.yml ================================================ # Where are all the schema files located? globs are supported eg src/**/*.graphqls schema: - graph/*.graphqls # Where should the generated server code go? exec: filename: graph/generated.go package: graph # Uncomment to enable federation # federation: # filename: graph/federation.go # package: graph # Where should any generated models go? model: filename: graph/model/models_gen.go package: model # Where should the resolver implementations go? resolver: layout: follow-schema dir: graph package: graph # Optional: turn on use `gqlgen:"fieldName"` tags in your models # struct_tag: json # Optional: turn on to use []Thing instead of []*Thing # omit_slice_element_pointers: false # Optional: turn off to make struct-type struct fields not use pointers # e.g. type Thing struct { FieldA OtherThing } instead of { FieldA *OtherThing } # struct_fields_always_pointers: true # Optional: turn off to make resolvers return values instead of pointers for structs # resolvers_always_return_pointers: true # Optional: turn on to return pointers instead of values in unmarshalInput # return_pointers_in_unmarshalinput: false # Optional: wrap nullable input fields with Omittable # nullable_input_omittable: true # Optional: set to speed up generation time by not performing a final validation pass. # skip_validation: true # gqlgen will search for any type names in the schema in these go packages # if they match it will use them, otherwise it will generate them. autobind: - "github.com/99designs/gqlgen/api/testdata/default/graph/model" # This section declares type mapping between the GraphQL and go type systems # # The first line in each type will be used as defaults for resolver arguments and # modelgen, the others will be allowed when binding to fields. Configure them to # your liking models: ID: model: - github.com/99designs/gqlgen/graphql.ID - github.com/99designs/gqlgen/graphql.Int - github.com/99designs/gqlgen/graphql.Int64 - github.com/99designs/gqlgen/graphql.Int32 Int: model: - github.com/99designs/gqlgen/graphql.Int - github.com/99designs/gqlgen/graphql.Int64 - github.com/99designs/gqlgen/graphql.Int32 ================================================ FILE: api/testdata/default/graph/model/doc.go ================================================ package model ================================================ FILE: api/testdata/default/graph/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: api/testdata/federation2/gqlgen.yml ================================================ # Where are all the schema files located? globs are supported eg src/**/*.graphqls schema: - graph/*.graphqls # Where should the generated server code go? exec: filename: graph/generated.go package: graph # Uncomment to enable federation federation: filename: graph/federation.go package: graph # Where should any generated models go? model: filename: graph/model/models_gen.go package: model # Where should the resolver implementations go? resolver: layout: follow-schema dir: graph package: graph # Optional: turn on use `gqlgen:"fieldName"` tags in your models # struct_tag: json # Optional: turn on to use []Thing instead of []*Thing # omit_slice_element_pointers: false # Optional: turn off to make struct-type struct fields not use pointers # e.g. type Thing struct { FieldA OtherThing } instead of { FieldA *OtherThing } # struct_fields_always_pointers: true # Optional: turn off to make resolvers return values instead of pointers for structs # resolvers_always_return_pointers: true # Optional: turn on to return pointers instead of values in unmarshalInput # return_pointers_in_unmarshalinput: false # Optional: wrap nullable input fields with Omittable # nullable_input_omittable: true # Optional: set to speed up generation time by not performing a final validation pass. # skip_validation: true # gqlgen will search for any type names in the schema in these go packages # if they match it will use them, otherwise it will generate them. autobind: - "github.com/99designs/gqlgen/api/testdata/default/graph/model" # This section declares type mapping between the GraphQL and go type systems # # The first line in each type will be used as defaults for resolver arguments and # modelgen, the others will be allowed when binding to fields. Configure them to # your liking models: ID: model: - github.com/99designs/gqlgen/graphql.ID - github.com/99designs/gqlgen/graphql.Int - github.com/99designs/gqlgen/graphql.Int64 - github.com/99designs/gqlgen/graphql.Int32 Int: model: - github.com/99designs/gqlgen/graphql.Int - github.com/99designs/gqlgen/graphql.Int64 - github.com/99designs/gqlgen/graphql.Int32 ================================================ FILE: api/testdata/federation2/graph/model/doc.go ================================================ package model ================================================ FILE: api/testdata/federation2/graph/schema.graphqls ================================================ # GraphQL schema example # # https://gqlgen.com/getting-started/ extend schema @link(url: "https://specs.apollo.dev/federation/v2.7", import: ["@key", "@shareable", "@provides", "@external", "@tag", "@extends", "@override", "@inaccessible"]) type Todo { id: ID! text: String! done: Boolean! user: User! } type User { id: ID! name: String! } type Query { todos: [Todo!]! } input NewTodo { text: String! userId: String! } type Mutation { createTodo(input: NewTodo!): Todo! } ================================================ FILE: api/testdata/workerlimit/gqlgen.yml ================================================ # Where are all the schema files located? globs are supported eg src/**/*.graphqls schema: - graph/*.graphqls # Where should the generated server code go? exec: filename: graph/generated.go package: graph worker_limit: 1 # Uncomment to enable federation # federation: # filename: graph/federation.go # package: graph # Where should any generated models go? model: filename: graph/model/models_gen.go package: model # Where should the resolver implementations go? resolver: layout: follow-schema dir: graph package: graph # Optional: turn on use `gqlgen:"fieldName"` tags in your models # struct_tag: json # Optional: turn on to use []Thing instead of []*Thing # omit_slice_element_pointers: false # Optional: turn off to make struct-type struct fields not use pointers # e.g. type Thing struct { FieldA OtherThing } instead of { FieldA *OtherThing } # struct_fields_always_pointers: true # Optional: turn off to make resolvers return values instead of pointers for structs # resolvers_always_return_pointers: true # Optional: turn on to return pointers instead of values in unmarshalInput # return_pointers_in_unmarshalinput: false # Optional: wrap nullable input fields with Omittable # nullable_input_omittable: true # Optional: set to speed up generation time by not performing a final validation pass. # skip_validation: true # gqlgen will search for any type names in the schema in these go packages # if they match it will use them, otherwise it will generate them. autobind: - "github.com/99designs/gqlgen/api/testdata/default/graph/model" # This section declares type mapping between the GraphQL and go type systems # # The first line in each type will be used as defaults for resolver arguments and # modelgen, the others will be allowed when binding to fields. Configure them to # your liking models: ID: model: - github.com/99designs/gqlgen/graphql.ID - github.com/99designs/gqlgen/graphql.Int - github.com/99designs/gqlgen/graphql.Int64 - github.com/99designs/gqlgen/graphql.Int32 Int: model: - github.com/99designs/gqlgen/graphql.Int - github.com/99designs/gqlgen/graphql.Int64 - github.com/99designs/gqlgen/graphql.Int32 ================================================ FILE: api/testdata/workerlimit/graph/model/doc.go ================================================ package model ================================================ FILE: api/testdata/workerlimit/graph/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: bin/_tools/apollo-sandbox-sri/README.md ================================================ It has been so long that the details slipped had my mind. See #2581 for the original history of this Apollo Sandbox playground feature. > This is a [Subresource Integrity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) check, so we can follow that the MDN documentation [Subresource Integrity - Web security | MDN](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) to get the hash value locally to specify the RSI if we need to. > > Or take the JS URL and run it through https://www.srihash.org/ with sha256 selected? > > Or maybe downloaded that script locally and did: > ``` > cat FILENAME.js | openssl dgst -sha256 -binary | openssl base64 -A > ``` > Or > ``` > shasum -b -a 256 FILENAME.js | awk '{ print $1 }' | xxd -r -p | base64 > ``` > However, that was a pain to have to continually manually this, so in #2686 @gitxiongpan we figured out: > The url https://embeddable-sandbox.cdn.apollographql.com/ will allow you to list the contents of the S3 bucket. I made a dumb script to figure out the latest one from the S3 bucket and calculate the [Subresource Integrity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity). This script is https://gist.github.com/StevenACoffman/2f15cd2e64f107d1a9a5f10f9748e1b0 and when I run it: > > CDN_FILE=https://embeddable-sandbox.cdn.apollographql.com/7212121cad97028b007e974956dc951ce89d683c/embeddable-sandbox.umd.production.min.js > curl -s $CDN_FILE | openssl dgst -sha256 -binary | openssl base64 -A; echo > > ldbSJ7EovavF815TfCN50qKB9AMvzskb9xiG71bmg2I= > So instead of setting it to "_latest" and having to forego the subresource integrity check, let's just update both to that and now we can try to remember to periodically run this dumb script and update it. Ok? And then we all forgot about it and never did anything with it ever again! 😆 Running it now, it gives me: ``` CDN_FILE=https://embeddable-sandbox.cdn.apollographql.com/02e2da0fccbe0240ef03d2396d6c98559bab5b06/embeddable-sandbox.umd.production.min.js curl -s $CDN_FILE | openssl dgst -sha256 -binary | openssl base64 -A; echo ``` ================================================ FILE: bin/_tools/apollo-sandbox-sri/main.go ================================================ // Gets the latest Apollo Embedded Sandbox Playground URL from the CDN S3 bucket // // To get the Subresource Integrity check, `go run main.go` and take what that outputs and run like // this: // CDN_FILE=https://embeddable-sandbox.cdn.apollographql.com/58165cf7452dbad480c7cb85e7acba085b3bac1d/embeddable-sandbox.umd.production.min.js // curl -s $CDN_FILE | openssl dgst -sha256 -binary | openssl base64 -A; echo package main import ( "bytes" "crypto/md5" "crypto/sha256" "crypto/sha512" "encoding/base64" "encoding/xml" "errors" "fmt" "go/ast" "go/format" "go/parser" "go/printer" "go/token" "hash" "io" "log" "net/http" "net/url" "os" "path/filepath" "strconv" "strings" "time" ) const ( apolloSandboxCdnUrl = "https://embeddable-sandbox.cdn.apollographql.com" apolloSandboxSriAlgorithm = "sha256" // md5, sha256 or sha512 ) type ListBucketResult struct { XMLName xml.Name `xml:"ListBucketResult"` Text string `xml:",chardata"` Xmlns string `xml:"xmlns,attr"` Name string `xml:"Name"` Prefix string `xml:"Prefix"` NextContinuationToken string `xml:"NextContinuationToken"` KeyCount string `xml:"KeyCount"` IsTruncated bool `xml:"IsTruncated"` Contents []struct { Text string `xml:",chardata"` Key string `xml:"Key"` Generation string `xml:"Generation"` MetaGeneration string `xml:"MetaGeneration"` LastModified time.Time `xml:"LastModified"` ETag string `xml:"ETag"` Size string `xml:"Size"` } `xml:"Contents"` } func main() { if err := updateApolloSandbox(); err != nil { log.Fatalln(err.Error()) } } // updateApolloSandbox finds the latest version of apollo sandbox js and updates the // apollo_sandbox_playground.go. func updateApolloSandbox() error { repoRootPath, err := findRepoRootPath() if err != nil { return fmt.Errorf("failed to find git directory: %w", err) } latestKey, err := findLastRelease() if err != nil { return fmt.Errorf("failed to parse base url: %w", err) } latestJsUrl, err := url.JoinPath(apolloSandboxCdnUrl, latestKey) if err != nil { return fmt.Errorf("failed to join url: %w", err) } latestJsSri, err := computeSRIHash(latestJsUrl, apolloSandboxSriAlgorithm) if err != nil { return fmt.Errorf("failed to compute latestJsSri hash: %w", err) } apolloSandBoxFile := filepath.Join( repoRootPath, "graphql", "playground", "apollo_sandbox_playground.go", ) goFileBytes, err := alterApolloSandboxContents(apolloSandBoxFile, latestJsUrl, latestJsSri) if err != nil { return fmt.Errorf("failed to alter apollo sandbox contents: %w", err) } if err := os.WriteFile(apolloSandBoxFile, goFileBytes, 0o644); err != nil { return fmt.Errorf("failed to write apollo sandbox contents: %w", err) } return nil } // findRepoRootPath returns the path that contains ".git" directory, based on the working directory. // It starts at the working directory, and walks up the filesystem hierarchy until it finds a valid // ".git" directory. If it can't retrieve the working directory, and can't find a ".git" directory // it will return an error. func findRepoRootPath() (string, error) { wd, err := os.Getwd() if err != nil { return "", fmt.Errorf("failed to get current working directory: %w", err) } dir := wd for { if fi, err := os.Stat(filepath.Join(dir, ".git")); err == nil && fi.IsDir() { return dir, nil } parent := filepath.Dir(dir) if parent == dir { return "", fmt.Errorf("failed to find a .git directory starting from %s", wd) } dir = parent } } // findLastRelease Finds the latest release from the CDN bucket. // Ignores the _latest, latest and v2 keys. func findLastRelease() (string, error) { baseUrl, err := url.Parse(apolloSandboxCdnUrl) if err != nil { return "", fmt.Errorf("failed to parse base url: %w", err) } var continuationToken string var latestKey string var latestTime time.Time for { result, err := getBucketFiles(baseUrl, continuationToken) if err != nil { return "", fmt.Errorf("failed to get latest release: %w", err) } for _, content := range result.Contents { if strings.HasSuffix(content.Key, "/embeddable-sandbox.umd.production.min.js") && !strings.HasPrefix(content.Key, "_latest/") && !strings.HasPrefix(content.Key, "latest/") && !strings.HasPrefix(content.Key, "v2/") { if latestTime.IsZero() || latestTime.Before(content.LastModified) { latestKey = content.Key latestTime = content.LastModified } } } if !result.IsTruncated { break } continuationToken = result.NextContinuationToken } return latestKey, nil } // getBucketFiles gets the file list from the CDN bucket. func getBucketFiles(baseUrl *url.URL, continuationToken string) (ListBucketResult, error) { query := baseUrl.Query() query.Set("list-type", "2") if continuationToken != "" { query.Set("continuationToken", continuationToken) } baseUrl.RawQuery = query.Encode() resp, err := http.Get(baseUrl.String()) if err != nil { return ListBucketResult{}, fmt.Errorf("client: could not make request: %w", err) } defer resp.Body.Close() data, err := io.ReadAll(resp.Body) if err != nil { return ListBucketResult{}, fmt.Errorf("client: could not read response body: %w", err) } var result ListBucketResult if err := xml.Unmarshal(data, &result); err != nil { return ListBucketResult{}, fmt.Errorf("failed to unmarshal xml response %w", err) } return result, nil } // computeSRIHash computes the SRI hash for the given URL. // See https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity func computeSRIHash(reqURL string, algo string) (string, error) { h, err := newHasher(algo) if err != nil { return "", err } resp, err := http.Get(reqURL) if err != nil { return "", fmt.Errorf("client: could not make request: %w", err) } defer resp.Body.Close() if _, err := io.Copy(h, resp.Body); err != nil { return "", fmt.Errorf("could not copy bytes into hash: %w", err) } return integrity(algo, h.Sum(nil)), nil } // newHasher creates a new hasher for the given algorithm. func newHasher(algo string) (hash.Hash, error) { switch algo { case "md5": return md5.New(), nil case "sha256": return sha256.New(), nil case "sha512": return sha512.New(), nil default: return nil, fmt.Errorf( "unsupported crypto algo: %q, use either md5, sha256 or sha512", algo, ) } } // integrity computes the SRI hash for the given bytes. func integrity(algo string, sum []byte) string { encoded := base64.StdEncoding.EncodeToString(sum) return fmt.Sprintf("%s-%s", algo, encoded) } // alterApolloSandboxContents alters the apollo sandbox source code contents to use the latest JS // URL and SRI. func alterApolloSandboxContents(filename, latestJsUrl, latestJsSri string) ([]byte, error) { tokenFileSet := token.NewFileSet() node, err := parser.ParseFile(tokenFileSet, filename, nil, parser.ParseComments) if err != nil { return nil, fmt.Errorf("failed to parse %s: %w", filename, err) } var mainJsUpdated, mainSriUpdated bool for _, decl := range node.Decls { gen, ok := decl.(*ast.GenDecl) if !ok || gen.Tok != token.CONST { continue } for _, spec := range gen.Specs { valSpec, ok := spec.(*ast.ValueSpec) if !ok { continue } for i, name := range valSpec.Names { switch name.Name { case "apolloSandboxMainJs": valSpec.Values[i] = &ast.BasicLit{ Kind: token.STRING, Value: strconv.Quote(latestJsUrl), } mainJsUpdated = true case "apolloSandboxMainSri": valSpec.Values[i] = &ast.BasicLit{ Kind: token.STRING, Value: strconv.Quote(latestJsSri), } mainSriUpdated = true } } } } if !mainJsUpdated || !mainSriUpdated { return nil, errors.New( "failed to find apolloSandboxMainJs or apolloSandboxMainSri constants", ) } var buf bytes.Buffer if err := printer.Fprint(&buf, tokenFileSet, node); err != nil { return nil, fmt.Errorf("failed to format ast: %w", err) } formatted, err := format.Source(buf.Bytes()) if err != nil { return nil, fmt.Errorf("failed to format source: %w", err) } return formatted, nil } ================================================ FILE: bin/_tools/go.mod ================================================ module github.com/99designs/bin/_tools go 1.25.1 ================================================ FILE: bin/fmt.sh ================================================ #!/bin/bash # Script to format files and regenerate 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 gci write -s standard -s default -s "prefix(github.com/99designs)" --skip-generated . gofumpt -w . go generate ./... ================================================ FILE: bin/release ================================================ #!/bin/bash set -eu if ! [ $# -eq 1 ] ; then echo "usage: ./bin/release [version]" exit 1 fi VERSION=$1 if ! git diff-index --quiet HEAD -- ; then echo "uncommitted changes on HEAD, aborting" exit 1 fi if [[ ${VERSION:0:1} != "v" ]] ; then echo "version strings must start with v" exit 1 fi git fetch origin git checkout origin/master cat > graphql/version.go < graphql/version.go <= http.StatusBadRequest { return nil, fmt.Errorf("http %d: %s", w.Code, w.Body.String()) } // decode it into map string first, let mapstructure do the final decode // because it can be much stricter about unknown fields. respDataRaw := &Response{} err = json.Unmarshal(w.Body.Bytes(), &respDataRaw) if err != nil { return nil, fmt.Errorf("decode: %w", err) } return respDataRaw, nil } var boundaryRegex = regexp.MustCompile(`multipart/form-data; ?boundary=.*`) func (p *Client) newRequest(query string, options ...Option) (*http.Request, error) { bd := &Request{ Query: query, HTTP: httptest.NewRequest(http.MethodPost, p.target, http.NoBody), } bd.HTTP.Header.Set("Content-Type", "application/json") // per client options from client.New apply first for _, option := range p.opts { option(bd) } // per request options for _, option := range options { option(bd) } contentType := bd.HTTP.Header.Get("Content-Type") switch { case boundaryRegex.MatchString(contentType): break case contentType == "application/json": requestBody, err := json.Marshal(bd) if err != nil { return nil, fmt.Errorf("encode: %w", err) } bd.HTTP.Body = io.NopCloser(bytes.NewBuffer(requestBody)) default: panic("unsupported encoding " + bd.HTTP.Header.Get("Content-Type")) } return bd.HTTP, nil } // SetCustomDecodeConfig sets a custom decode hook for the client func (p *Client) SetCustomDecodeConfig(dc *mapstructure.DecoderConfig) { p.dc = dc } // SetCustomTarget sets a custom target path for the client func (p *Client) SetCustomTarget(target string) { p.target = target } func unpack(data, into any, customDc *mapstructure.DecoderConfig) error { dc := &mapstructure.DecoderConfig{ TagName: "json", ErrorUnused: true, ZeroFields: true, } if customDc != nil { dc = customDc } dc.Result = into d, err := mapstructure.NewDecoder(dc) if err != nil { return fmt.Errorf("mapstructure: %w", err) } return d.Decode(data) } ================================================ FILE: client/client_test.go ================================================ package client_test import ( "bytes" "encoding/json" "fmt" "io" "mime/multipart" "net/http" "net/textproto" "reflect" "testing" "time" "github.com/go-viper/mapstructure/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" ) func TestClient(t *testing.T) { h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { b, err := io.ReadAll(r.Body) if assert.NoError(t, err) { assert.JSONEq(t, `{"query":"user(id:$id){name}","variables":{"id":1}}`, string(b)) err = json.NewEncoder(w).Encode(map[string]any{ "data": map[string]any{ "name": "bob", }, }) assert.NoError(t, err) } }) c := client.New(h) var resp struct { Name string } c.MustPost("user(id:$id){name}", &resp, client.Var("id", 1)) require.Equal(t, "bob", resp.Name) } func TestClientMultipartFormData(t *testing.T) { h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { bodyBytes, err := io.ReadAll(r.Body) if !assert.NoError(t, err) { return } assert.Contains(t, string(bodyBytes), `Content-Disposition: form-data; name="operations"`) assert.Contains( t, string(bodyBytes), `{"query":"mutation ($input: Input!) {}","variables":{"file":{}}`, ) assert.Contains(t, string(bodyBytes), `Content-Disposition: form-data; name="map"`) assert.Contains(t, string(bodyBytes), `{"0":["variables.file"]}`) assert.Contains( t, string(bodyBytes), `Content-Disposition: form-data; name="0"; filename="example.txt"`, ) assert.Contains(t, string(bodyBytes), `Content-Type: text/plain`) assert.Contains(t, string(bodyBytes), `Hello World`) w.Write([]byte(`{}`)) }) c := client.New(h) var resp struct{} c.MustPost("{ id }", &resp, func(bd *client.Request) { bodyBuf := &bytes.Buffer{} bodyWriter := multipart.NewWriter(bodyBuf) bodyWriter.WriteField( "operations", `{"query":"mutation ($input: Input!) {}","variables":{"file":{}}`, ) bodyWriter.WriteField("map", `{"0":["variables.file"]}`) h := make(textproto.MIMEHeader) h.Set("Content-Disposition", `form-data; name="0"; filename="example.txt"`) h.Set("Content-Type", "text/plain") ff, _ := bodyWriter.CreatePart(h) ff.Write([]byte("Hello World")) bodyWriter.Close() bd.HTTP.Body = io.NopCloser(bodyBuf) bd.HTTP.Header.Set("Content-Type", bodyWriter.FormDataContentType()) }, ) } func TestAddHeader(t *testing.T) { h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { assert.Equal(t, "ASDF", r.Header.Get("Test-Key")) w.Write([]byte(`{}`)) }) c := client.New(h) var resp struct{} c.MustPost("{ id }", &resp, client.AddHeader("Test-Key", "ASDF"), ) } func TestAddClientHeader(t *testing.T) { h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { assert.Equal(t, "ASDF", r.Header.Get("Test-Key")) w.Write([]byte(`{}`)) }) c := client.New(h, client.AddHeader("Test-Key", "ASDF")) var resp struct{} c.MustPost("{ id }", &resp) } func TestBasicAuth(t *testing.T) { h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { user, pass, ok := r.BasicAuth() assert.True(t, ok) assert.Equal(t, "user", user) assert.Equal(t, "pass", pass) w.Write([]byte(`{}`)) }) c := client.New(h) var resp struct{} c.MustPost("{ id }", &resp, client.BasicAuth("user", "pass"), ) } func TestAddCookie(t *testing.T) { h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { c, err := r.Cookie("foo") if !assert.NoError(t, err) { return } assert.Equal(t, "value", c.Value) w.Write([]byte(`{}`)) }) c := client.New(h) var resp struct{} c.MustPost("{ id }", &resp, client.AddCookie(&http.Cookie{Name: "foo", Value: "value"}), ) } func TestAddExtensions(t *testing.T) { h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { b, err := io.ReadAll(r.Body) if !assert.NoError(t, err) { return } assert.JSONEq( t, `{"query":"user(id:1){name}","extensions":{"persistedQuery":{"sha256Hash":"ceec2897e2da519612279e63f24658c3e91194cbb2974744fa9007a7e1e9f9e7","version":1}}}`, string(b), ) err = json.NewEncoder(w).Encode(map[string]any{ "data": map[string]any{ "Name": "Bob", }, }) assert.NoError(t, err) }) c := client.New(h) var resp struct { Name string } c.MustPost( "user(id:1){name}", &resp, client.Extensions( map[string]any{ "persistedQuery": map[string]any{ "version": 1, "sha256Hash": "ceec2897e2da519612279e63f24658c3e91194cbb2974744fa9007a7e1e9f9e7", }, }, ), ) } func TestSetCustomDecodeConfig(t *testing.T) { now := time.Now() h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) w.Header().Set("Content-Type", "application/json") fmt.Fprintf(w, `{"data": {"created_at":"%s"}}`, now.Format(time.RFC3339)) }) dc := &mapstructure.DecoderConfig{ TagName: "json", ErrorUnused: true, ZeroFields: true, DecodeHook: func(f reflect.Type, t reflect.Type, data any) (any, error) { if t != reflect.TypeFor[time.Time]() { return data, nil } switch f.Kind() { case reflect.String: return time.Parse(time.RFC3339, data.(string)) default: return data, nil } }, } c := client.New(h) var resp struct { CreatedAt time.Time `json:"created_at"` } err := c.Post("user(id: 1) {created_at}", &resp) require.Error(t, err) c.SetCustomDecodeConfig(dc) c.MustPost("user(id: 1) {created_at}", &resp) require.WithinDuration(t, now, resp.CreatedAt, time.Second) } func TestClientWithCustomTarget(t *testing.T) { h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { b, err := io.ReadAll(r.Body) if assert.NoError(t, err) { assert.JSONEq(t, `{"query":"user(id:$id){name}","variables":{"id":1}}`, string(b)) err = json.NewEncoder(w).Encode(map[string]any{ "data": map[string]any{ "name": "bob", }, }) assert.NoError(t, err) } }) mux := http.NewServeMux() mux.HandleFunc("/test", h) c := client.New(mux) c.SetCustomTarget("/test") var resp struct { Name string } c.MustPost("user(id:$id){name}", &resp, client.Var("id", 1)) require.Equal(t, "bob", resp.Name) } ================================================ FILE: client/errors.go ================================================ package client import "encoding/json" // RawJsonError is a json formatted error from a GraphQL server. type RawJsonError struct { json.RawMessage } func (r RawJsonError) Error() string { return string(r.RawMessage) } ================================================ FILE: client/incremental_http.go ================================================ package client import ( "context" "encoding/json" "errors" "fmt" "io" "mime" "mime/multipart" "net/http" "net/http/httptest" ) type IncrementalHandler struct { close func() error next func(response any) error } func (i *IncrementalHandler) Close() error { return i.close() } func (i *IncrementalHandler) Next(response any) error { return i.next(response) } type IncrementalInitialResponse struct { Data any `json:"data"` Label string `json:"label"` Path []any `json:"path"` HasNext bool `json:"hasNext"` Errors json.RawMessage `json:"errors"` Extensions map[string]any `json:"extensions"` } type IncrementalData struct { // Support for "items" for @stream is not yet available, only "data" for // @defer, as per the 2023 spec. Similarly, this retains a more complete // list of fields, but not "id," and represents a mid-point between the // 2022 and 2023 specs. Data any `json:"data"` Label string `json:"label"` Path []any `json:"path"` HasNext bool `json:"hasNext"` Errors json.RawMessage `json:"errors"` Extensions map[string]any `json:"extensions"` } type IncrementalResponse struct { // Does not include the pending or completed fields from the 2023 spec. Incremental []IncrementalData `json:"incremental"` HasNext bool `json:"hasNext"` Errors json.RawMessage `json:"errors"` Extensions map[string]any `json:"extensions"` } func errorIncremental(err error) *IncrementalHandler { return &IncrementalHandler{ close: func() error { return nil }, next: func(response any) error { return err }, } } // IncrementalHTTP returns a GraphQL response handler for the current // GQLGen implementation of the [incremental delivery over HTTP spec]. // The IncrementalHTTP spec provides for "streaming" responses triggered by // the use of @stream or @defer as an alternate approach to SSE. To that end, // the client retains the interface of the handler returned from // Client.SSE. // // IncrementalHTTP delivery using multipart/mixed is just the structure // of the response: the payloads are specified by the defer-stream spec, // which are in transition. For more detail, see the links in the // definition for transport.MultipartMixed. We use the name // IncrementalHTTP here to distinguish from the multipart form upload // (the term "multipart" usually referring to the latter). // // IncrementalHandler is not safe for concurrent use, or for production // use at all. // // [incremental delivery over HTTP spec]: // https://github.com/graphql/graphql-over-http/blob/main/rfcs/IncrementalDelivery.md func (p *Client) IncrementalHTTP( ctx context.Context, query string, options ...Option, ) *IncrementalHandler { r, err := p.newRequest(query, options...) if err != nil { return errorIncremental(fmt.Errorf("request: %w", err)) } r.Header.Set("Accept", "multipart/mixed") w := httptest.NewRecorder() p.h.ServeHTTP(w, r) // Remains open since we are reading from it incrementally. res := w.Result() if res.StatusCode >= http.StatusBadRequest { return errorIncremental(fmt.Errorf("http %d: %s", w.Code, w.Body.String())) } mediaType, params, err := mime.ParseMediaType(res.Header.Get("Content-Type")) if err != nil { return errorIncremental(fmt.Errorf("parse content-type: %w", err)) } if mediaType != "multipart/mixed" { return errorIncremental( fmt.Errorf("expected content-type multipart/mixed, got %s", mediaType), ) } // TODO: worth checking the deferSpec either to confirm this client // supports it exactly, or simply to make sure it is within some // expected range. deferSpec, ok := params["deferspec"] if !ok || deferSpec == "" { return errorIncremental(errors.New("expected deferSpec in content-type")) } boundary, ok := params["boundary"] if !ok || boundary == "" { return errorIncremental(errors.New("expected boundary in content-type")) } mr := multipart.NewReader(res.Body, boundary) ctx, cancel := context.WithCancelCause(ctx) initial := true return &IncrementalHandler{ close: func() error { res.Body.Close() cancel(context.Canceled) return nil }, next: func(response any) (err error) { defer func() { if err != nil { res.Body.Close() cancel(err) } }() var data any var rawErrors json.RawMessage type nextPart struct { *multipart.Part Err error } nextPartCh := make(chan nextPart) go func() { var next nextPart next.Part, next.Err = mr.NextPart() nextPartCh <- next }() var next nextPart select { case <-ctx.Done(): return ctx.Err() case next = <-nextPartCh: } if next.Err == io.EOF { res.Body.Close() cancel(context.Canceled) return nil } if err = next.Err; err != nil { return err } if ct := next.Header.Get("Content-Type"); ct != "application/json" { err = fmt.Errorf(`expected content-type "application/json", got %q`, ct) return err } if initial { initial = false data = IncrementalInitialResponse{} } else { data = IncrementalResponse{} } if err = json.NewDecoder(next.Part).Decode(&data); err != nil { return err } // We want to unpack even if there is an error, so we can see partial // responses. err = unpack(data, response, p.dc) if len(rawErrors) != 0 { err = RawJsonError{rawErrors} return err } return err }, } } ================================================ FILE: client/options.go ================================================ package client import "net/http" // Var adds a variable into the outgoing request func Var(name string, value any) Option { return func(bd *Request) { if bd.Variables == nil { bd.Variables = map[string]any{} } bd.Variables[name] = value } } // Operation sets the operation name for the outgoing request func Operation(name string) Option { return func(bd *Request) { bd.OperationName = name } } // Extensions sets the extensions to be sent with the outgoing request func Extensions(extensions map[string]any) Option { return func(bd *Request) { bd.Extensions = extensions } } // Path sets the url that this request will be made against, useful if you are mounting your entire // router // and need to specify the url to the graphql endpoint. func Path(url string) Option { return func(bd *Request) { bd.HTTP.URL.Path = url } } // AddHeader adds a header to the outgoing request. This is useful for setting expected // Authentication headers for example. func AddHeader(key, value string) Option { return func(bd *Request) { bd.HTTP.Header.Add(key, value) } } // BasicAuth authenticates the request using http basic auth. func BasicAuth(username, password string) Option { return func(bd *Request) { bd.HTTP.SetBasicAuth(username, password) } } // AddCookie adds a cookie to the outgoing request func AddCookie(cookie *http.Cookie) Option { return func(bd *Request) { bd.HTTP.AddCookie(cookie) } } ================================================ FILE: client/readme.md ================================================ This client is used internally for testing. I wanted a simple graphql client sent user specified queries. You might want to look at: - https://github.com/shurcooL/graphql: Uses reflection to build queries from structs. - https://github.com/machinebox/graphql: Probably would have been a perfect fit, but it uses form encoding instead of json... - [Khan/genqlient](https://github.com/Khan/genqlient) - Generate go GraphQL client from GraphQL query - [infiotinc/gqlgenc](https://github.com/infiotinc/gqlgenc) - Generate go GraphQL client from GraphQL query - [Yamashou/gqlgenc](https://github.com/Yamashou/gqlgenc) - Generate go GraphQL client from GraphQL query ================================================ FILE: client/sse.go ================================================ package client import ( "bufio" "context" "encoding/json" "fmt" "net/http/httptest" "net/textproto" "strings" ) type SSE struct { Close func() error Next func(response any) error } type SSEResponse struct { Data any `json:"data"` Label string `json:"label"` Path []any `json:"path"` HasNext bool `json:"hasNext"` Errors json.RawMessage `json:"errors"` Extensions map[string]any `json:"extensions"` } func errorSSE(err error) *SSE { return &SSE{ Close: func() error { return nil }, Next: func(response any) error { return err }, } } func (p *Client) SSE(ctx context.Context, query string, options ...Option) *SSE { r, err := p.newRequest(query, options...) if err != nil { return errorSSE(fmt.Errorf("request: %w", err)) } r = r.WithContext(ctx) r.Header.Set("Accept", "text/event-stream") r.Header.Set("Cache-Control", "no-cache") r.Header.Set("Connection", "keep-alive") srv := httptest.NewServer(p.h) w := httptest.NewRecorder() p.h.ServeHTTP(w, r) reader := textproto.NewReader(bufio.NewReader(w.Body)) line, err := reader.ReadLine() if err != nil { return errorSSE(fmt.Errorf("response: %w", err)) } if line != ":" { return errorSSE(fmt.Errorf("expected :, got %s", line)) } return &SSE{ Close: func() error { srv.Close() return nil }, Next: func(response any) error { for { line, err := reader.ReadLine() if err != nil { return err } kv := strings.SplitN(line, ": ", 2) switch kv[0] { case "": continue case "event": switch kv[1] { case "next": continue case "complete": return nil default: return fmt.Errorf("expected event type: %#v", kv[1]) } case "data": var respDataRaw SSEResponse if err = json.Unmarshal([]byte(kv[1]), &respDataRaw); err != nil { return fmt.Errorf("decode: %w", err) } // we want to unpack even if there is an error, so we can see partial responses unpackErr := unpack(respDataRaw, response, p.dc) if respDataRaw.Errors != nil { return RawJsonError{respDataRaw.Errors} } return unpackErr default: return fmt.Errorf("unexpected sse field %s", kv[0]) } } }, } } ================================================ FILE: client/websocket.go ================================================ package client import ( "encoding/json" "errors" "fmt" "io" "net/http/httptest" "reflect" "strings" "github.com/gorilla/websocket" ) const ( connectionInitMsg = "connection_init" // Client -> Server startMsg = "start" // Client -> Server connectionAckMsg = "connection_ack" // Server -> Client connectionKaMsg = "ka" // Server -> Client dataMsg = "data" // Server -> Client errorMsg = "error" // Server -> Client ) type operationMessage struct { Payload json.RawMessage `json:"payload,omitempty"` ID string `json:"id,omitempty"` Type string `json:"type"` } type Subscription struct { Close func() error Next func(response any) error } func errorSubscription(err error) *Subscription { return &Subscription{ Close: func() error { return nil }, Next: func(response any) error { return err }, } } func (p *Client) Websocket(query string, options ...Option) *Subscription { return p.WebsocketWithPayload(query, nil, options...) } // Grab a single response from a websocket based query func (p *Client) WebsocketOnce(query string, resp any, options ...Option) error { sock := p.Websocket(query, options...) defer func() { _ = sock.Close() }() if reflect.ValueOf(resp).Kind() == reflect.Ptr { return sock.Next(resp) } // TODO: verify this is never called and remove it return sock.Next(&resp) } func (p *Client) WebsocketWithPayload( query string, initPayload map[string]any, options ...Option, ) *Subscription { r, err := p.newRequest(query, options...) if err != nil { return errorSubscription(fmt.Errorf("request: %w", err)) } requestBody, err := io.ReadAll(r.Body) if err != nil { return errorSubscription(fmt.Errorf("parse body: %w", err)) } srv := httptest.NewServer(p.h) host := strings.ReplaceAll(srv.URL, "http://", "ws://") c, resp, err := websocket.DefaultDialer.Dial(host+r.URL.Path, r.Header) if err != nil { return errorSubscription(fmt.Errorf("dial: %w", err)) } defer resp.Body.Close() initMessage := operationMessage{Type: connectionInitMsg} if initPayload != nil { initMessage.Payload, err = json.Marshal(initPayload) if err != nil { return errorSubscription(fmt.Errorf("parse payload: %w", err)) } } if err = c.WriteJSON(initMessage); err != nil { return errorSubscription(fmt.Errorf("init: %w", err)) } var ack operationMessage if err = c.ReadJSON(&ack); err != nil { return errorSubscription(fmt.Errorf("ack: %w", err)) } if ack.Type != connectionAckMsg { return errorSubscription(fmt.Errorf("expected ack message, got %#v", ack)) } var ka operationMessage if err = c.ReadJSON(&ka); err != nil { return errorSubscription(fmt.Errorf("ack: %w", err)) } if ka.Type != connectionKaMsg { return errorSubscription(fmt.Errorf("expected ack message, got %#v", ack)) } if err = c.WriteJSON( operationMessage{Type: startMsg, ID: "1", Payload: requestBody}, ); err != nil { return errorSubscription(fmt.Errorf("start: %w", err)) } return &Subscription{ Close: func() error { srv.Close() return c.Close() }, Next: func(response any) error { for { var op operationMessage err := c.ReadJSON(&op) if err != nil { return err } switch op.Type { case dataMsg: break case connectionKaMsg: continue case errorMsg: return errors.New(string(op.Payload)) default: return fmt.Errorf("expected data message, got %#v", op) } var respDataRaw Response err = json.Unmarshal(op.Payload, &respDataRaw) if err != nil { return fmt.Errorf("decode: %w", err) } // we want to unpack even if there is an error, so we can see partial responses unpackErr := unpack(respDataRaw.Data, response, p.dc) if respDataRaw.Errors != nil { return RawJsonError{respDataRaw.Errors} } return unpackErr } }, } } ================================================ FILE: client/withfilesoption.go ================================================ package client import ( "bytes" "encoding/json" "fmt" "io" "mime/multipart" "net/http" "net/textproto" "os" "strings" ) type fileFormDataMap struct { mapKey string file *os.File } func findFiles(parentMapKey string, variables map[string]any) []*fileFormDataMap { files := []*fileFormDataMap{} for key, value := range variables { if v, ok := value.(map[string]any); ok { files = append(files, findFiles(parentMapKey+"."+key, v)...) } else if v, ok := value.([]map[string]any); ok { for i, arr := range v { files = append( files, findFiles(fmt.Sprintf(`%s.%s.%d`, parentMapKey, key, i), arr)...) } } else if v, ok := value.([]*os.File); ok { for i, file := range v { files = append(files, &fileFormDataMap{ mapKey: fmt.Sprintf(`%s.%s.%d`, parentMapKey, key, i), file: file, }) } } else if v, ok := value.(*os.File); ok { files = append(files, &fileFormDataMap{ mapKey: parentMapKey + "." + key, file: v, }) } } return files } // WithFiles encodes the outgoing request body as multipart form data for file variables func WithFiles() Option { return func(bd *Request) { bodyBuf := &bytes.Buffer{} bodyWriter := multipart.NewWriter(bodyBuf) // -b7955bd2e1d17b67ac157b9e9ddb6238888caefc6f3541920a1debad284d // Content-Disposition: form-data; name="operations" // // {"query":"mutation ($input: Input!) {}","variables":{"input":{"file":{}}} requestBody, _ := json.Marshal(bd) _ = bodyWriter.WriteField("operations", string(requestBody)) // --b7955bd2e1d17b67ac157b9e9ddb6238888caefc6f3541920a1debad284d // Content-Disposition: form-data; name="map" // // `{ "0":["variables.input.file"] }` // or // `{ "0":["variables.input.files.0"], "1":["variables.input.files.1"] }` // or // `{ "0": ["variables.input.0.file"], "1": ["variables.input.1.file"] }` // or // `{ "0": ["variables.req.0.file", "variables.req.1.file"] }` mapData := "" filesData := findFiles("variables", bd.Variables) filesGroup := [][]*fileFormDataMap{} for _, fd := range filesData { foundDuplicate := false for j, fg := range filesGroup { f1, _ := fd.file.Stat() f2, _ := fg[0].file.Stat() if os.SameFile(f1, f2) { foundDuplicate = true filesGroup[j] = append(filesGroup[j], fd) } } if !foundDuplicate { filesGroup = append(filesGroup, []*fileFormDataMap{fd}) } } if len(filesGroup) > 0 { mapDataFiles := make([]string, 0, len(filesGroup)) for i, fileData := range filesGroup { mapDataFiles = append( mapDataFiles, fmt.Sprintf( `"%d":[%s]`, i, strings.Join(collect(fileData, wrapMapKeyInQuotes), ","), ), ) } mapData = `{` + strings.Join(mapDataFiles, ",") + `}` } _ = bodyWriter.WriteField("map", mapData) // --b7955bd2e1d17b67ac157b9e9ddb6238888caefc6f3541920a1debad284d // Content-Disposition: form-data; name="0"; filename="tempFile" // Content-Type: text/plain; charset=utf-8 // or // Content-Type: application/octet-stream // for i, fileData := range filesGroup { h := make(textproto.MIMEHeader) h.Set( "Content-Disposition", fmt.Sprintf(`form-data; name="%d"; filename="%s"`, i, fileData[0].file.Name()), ) b, _ := os.ReadFile(fileData[0].file.Name()) h.Set("Content-Type", http.DetectContentType(b)) ff, _ := bodyWriter.CreatePart(h) ff.Write(b) } bodyWriter.Close() bd.HTTP.Body = io.NopCloser(bodyBuf) bd.HTTP.Header.Set("Content-Type", bodyWriter.FormDataContentType()) } } func collect(strArr []*fileFormDataMap, f func(s *fileFormDataMap) string) []string { result := make([]string, len(strArr)) for i, str := range strArr { result[i] = f(str) } return result } func wrapMapKeyInQuotes(s *fileFormDataMap) string { return fmt.Sprintf("\"%s\"", s.mapKey) } ================================================ FILE: client/withfilesoption_test.go ================================================ package client_test import ( "io" "mime" "mime/multipart" "net/http" "os" "regexp" "strings" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" ) func TestWithFiles(t *testing.T) { tempFile1, err := os.CreateTemp(t.TempDir(), "tempFile1") require.NoError(t, err) tempFile2, err := os.CreateTemp(t.TempDir(), "tempFile2") require.NoError(t, err) tempFile3, err := os.CreateTemp(t.TempDir(), "tempFile3") require.NoError(t, err) defer tempFile1.Close() defer tempFile2.Close() defer tempFile3.Close() tempFile1.WriteString(`The quick brown fox jumps over the lazy dog`) tempFile2.WriteString(`hello world`) tempFile3.WriteString(`La-Li-Lu-Le-Lo`) t.Run("with one file", func(t *testing.T) { h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { mediaType, params, err := mime.ParseMediaType(r.Header.Get("Content-Type")) if !assert.NoError(t, err) { return } assert.True(t, strings.HasPrefix(mediaType, "multipart/")) mr := multipart.NewReader(r.Body, params["boundary"]) for { p, err := mr.NextPart() if err == io.EOF { break } if !assert.NoError(t, err) { return } slurp, err := io.ReadAll(p) if !assert.NoError(t, err) { return } contentDisposition := p.Header.Get("Content-Disposition") if contentDisposition == `form-data; name="operations"` { assert.JSONEq(t, `{"query":"{ id }","variables":{"file":{}}}`, string(slurp)) } if contentDisposition == `form-data; name="map"` { assert.JSONEq(t, `{"0":["variables.file"]}`, string(slurp)) } if regexp.MustCompile(`form-data; name="0"; filename=.*`). MatchString(contentDisposition) { assert.Equal(t, `text/plain; charset=utf-8`, p.Header.Get("Content-Type")) assert.EqualValues(t, `The quick brown fox jumps over the lazy dog`, slurp) } } w.Write([]byte(`{}`)) }) c := client.New(h) var resp struct{} c.MustPost("{ id }", &resp, client.Var("file", tempFile1), client.WithFiles(), ) }) t.Run("with multiple files", func(t *testing.T) { h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { mediaType, params, err := mime.ParseMediaType(r.Header.Get("Content-Type")) if !assert.NoError(t, err) { return } assert.True(t, strings.HasPrefix(mediaType, "multipart/")) mr := multipart.NewReader(r.Body, params["boundary"]) for { p, err := mr.NextPart() if err == io.EOF { break } if !assert.NoError(t, err) { return } slurp, err := io.ReadAll(p) if !assert.NoError(t, err) { return } contentDisposition := p.Header.Get("Content-Disposition") if contentDisposition == `form-data; name="operations"` { assert.JSONEq( t, `{"query":"{ id }","variables":{"input":{"files":[{},{}]}}}`, string(slurp), ) } if contentDisposition == `form-data; name="map"` { // returns `{"0":["variables.input.files.0"],"1":["variables.input.files.1"]}` // but the order of file inputs is unpredictable between different OS systems assert.Contains(t, string(slurp), `{"0":`) assert.Contains(t, string(slurp), `["variables.input.files.0"]`) assert.Contains(t, string(slurp), `,"1":`) assert.Contains(t, string(slurp), `["variables.input.files.1"]`) assert.Contains(t, string(slurp), `}`) } if regexp.MustCompile(`form-data; name="[0,1]"; filename=.*`). MatchString(contentDisposition) { assert.Equal(t, `text/plain; charset=utf-8`, p.Header.Get("Content-Type")) assert.Contains(t, []string{ `The quick brown fox jumps over the lazy dog`, `hello world`, }, string(slurp)) } } w.Write([]byte(`{}`)) }) c := client.New(h) var resp struct{} c.MustPost("{ id }", &resp, client.Var("input", map[string]any{ "files": []*os.File{tempFile1, tempFile2}, }), client.WithFiles(), ) }) t.Run("with multiple files across multiple variables", func(t *testing.T) { h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { mediaType, params, err := mime.ParseMediaType(r.Header.Get("Content-Type")) if !assert.NoError(t, err) { return } assert.True(t, strings.HasPrefix(mediaType, "multipart/")) mr := multipart.NewReader(r.Body, params["boundary"]) for { p, err := mr.NextPart() if err == io.EOF { break } if !assert.NoError(t, err) { return } slurp, err := io.ReadAll(p) if !assert.NoError(t, err) { return } contentDisposition := p.Header.Get("Content-Disposition") if contentDisposition == `form-data; name="operations"` { assert.JSONEq( t, `{"query":"{ id }","variables":{"req":{"files":[{},{}],"foo":{"bar":{}}}}}`, string(slurp), ) } if contentDisposition == `form-data; name="map"` { // returns // `{"0":["variables.req.files.0"],"1":["variables.req.files.1"],"2":["variables.req.foo.bar"]}` // but the order of file inputs is unpredictable between different OS systems assert.Contains(t, string(slurp), `{"0":`) assert.Contains(t, string(slurp), `["variables.req.files.0"]`) assert.Contains(t, string(slurp), `,"1":`) assert.Contains(t, string(slurp), `["variables.req.files.1"]`) assert.Contains(t, string(slurp), `,"2":`) assert.Contains(t, string(slurp), `["variables.req.foo.bar"]`) assert.Contains(t, string(slurp), `}`) } if regexp.MustCompile(`form-data; name="[0,1,2]"; filename=.*`). MatchString(contentDisposition) { assert.Equal(t, `text/plain; charset=utf-8`, p.Header.Get("Content-Type")) assert.Contains(t, []string{ `The quick brown fox jumps over the lazy dog`, `La-Li-Lu-Le-Lo`, `hello world`, }, string(slurp)) } } w.Write([]byte(`{}`)) }) c := client.New(h) var resp struct{} c.MustPost("{ id }", &resp, client.Var("req", map[string]any{ "files": []*os.File{tempFile1, tempFile2}, "foo": map[string]any{ "bar": tempFile3, }, }), client.WithFiles(), ) }) t.Run("with multiple files and file reuse", func(t *testing.T) { h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { mediaType, params, err := mime.ParseMediaType(r.Header.Get("Content-Type")) if !assert.NoError(t, err) { return } assert.True(t, strings.HasPrefix(mediaType, "multipart/")) mr := multipart.NewReader(r.Body, params["boundary"]) for { p, err := mr.NextPart() if err == io.EOF { break } if !assert.NoError(t, err) { return } slurp, err := io.ReadAll(p) if !assert.NoError(t, err) { return } contentDisposition := p.Header.Get("Content-Disposition") if contentDisposition == `form-data; name="operations"` { assert.JSONEq( t, `{"query":"{ id }","variables":{"files":[{},{},{}]}}`, string(slurp), ) } if contentDisposition == `form-data; name="map"` { assert.JSONEq( t, `{"0":["variables.files.0","variables.files.2"],"1":["variables.files.1"]}`, string(slurp), ) // returns // `{"0":["variables.files.0","variables.files.2"],"1":["variables.files.1"]}` // but the order of file inputs is unpredictable between different OS systems assert.Contains(t, string(slurp), `{"0":`) assert.Contains(t, string(slurp), `["variables.files.0"`) assert.Contains(t, string(slurp), `,"1":`) assert.Contains(t, string(slurp), `"variables.files.1"]`) assert.Contains(t, string(slurp), `"variables.files.2"]`) assert.NotContains(t, string(slurp), `,"2":`) assert.Contains(t, string(slurp), `}`) } if regexp.MustCompile(`form-data; name="[0,1]"; filename=.*`). MatchString(contentDisposition) { assert.Equal(t, `text/plain; charset=utf-8`, p.Header.Get("Content-Type")) assert.Contains(t, []string{ `The quick brown fox jumps over the lazy dog`, `hello world`, }, string(slurp)) } assert.False( t, regexp.MustCompile(`form-data; name="2"; filename=.*`). MatchString(contentDisposition), ) } w.Write([]byte(`{}`)) }) c := client.New(h) var resp struct{} c.MustPost("{ id }", &resp, client.Var("files", []*os.File{tempFile1, tempFile2, tempFile1}), client.WithFiles(), ) }) } ================================================ FILE: codegen/args.go ================================================ package codegen import ( "fmt" "go/types" "strings" "github.com/vektah/gqlparser/v2/ast" "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/codegen/templates" ) type ArgSet struct { Args []*FieldArgument FuncDecl string } type FieldArgument struct { *ast.ArgumentDefinition TypeReference *config.TypeReference VarName string // The name of the var in go Object *Object // A link back to the parent object Default any // The default value Directives []*Directive Value any // value set in Data CallArgumentDirectivesWithNull bool } // ImplDirectives get not SkipRuntime and location ARGUMENT_DEFINITION directive func (f *FieldArgument) ImplDirectives() []*Directive { d := make([]*Directive, 0) for i := range f.Directives { if !f.Directives[i].SkipRuntime && f.Directives[i].IsLocation(ast.LocationArgumentDefinition) { d = append(d, f.Directives[i]) } } return d } func (f *FieldArgument) DirectiveObjName() string { return "rawArgs" } func (f *FieldArgument) Stream() bool { return f.Object != nil && f.Object.Stream } func (b *builder) buildArg(obj *Object, arg *ast.ArgumentDefinition) (*FieldArgument, error) { tr, err := b.Binder.TypeReference(arg.Type, nil) if err != nil { return nil, err } argDirs, err := b.getDirectives(arg.Directives) if err != nil { return nil, err } newArg := FieldArgument{ ArgumentDefinition: arg, TypeReference: tr, Object: obj, VarName: templates.ToGoPrivate(arg.Name), Directives: argDirs, CallArgumentDirectivesWithNull: b.Config.CallArgumentDirectivesWithNull, } if arg.DefaultValue != nil { newArg.Default, err = arg.DefaultValue.Value(nil) if err != nil { return nil, fmt.Errorf("default value is not valid: %w", err) } } return &newArg, nil } func (b *builder) bindArgs( field *Field, sig *types.Signature, params *types.Tuple, ) ([]*FieldArgument, error) { n := params.Len() newArgs := make([]*FieldArgument, 0, len(field.Args)) // Accept variadic methods (i.e. have optional parameters). if params.Len() > len(field.Args) && sig.Variadic() { n = len(field.Args) } nextArg: for j := 0; j < n; j++ { param := params.At(j) for _, oldArg := range field.Args { if strings.EqualFold(oldArg.Name, param.Name()) { tr, err := b.Binder.TypeReference(oldArg.Type, param.Type()) if err != nil { return nil, err } oldArg.TypeReference = tr newArgs = append(newArgs, oldArg) continue nextArg } } // no matching arg found, abort return nil, fmt.Errorf("arg %s not in schema", param.Name()) } return newArgs, nil } func (d *Data) Args() map[string][]*FieldArgument { ret := map[string][]*FieldArgument{} for _, o := range d.Objects { for _, f := range o.Fields { if len(f.Args) > 0 { ret[f.ArgsFunc()] = f.Args } } } for _, directive := range d.Directives() { if len(directive.Args) > 0 { ret[directive.ArgsFunc()] = directive.Args } } return ret } ================================================ FILE: codegen/args.gotpl ================================================ {{ $useFunctionSyntaxForExecutionContext := .Config.UseFunctionSyntaxForExecutionContext }} {{ range $name, $args := .Args }} {{ if $useFunctionSyntaxForExecutionContext -}} func {{ $name }}(ctx context.Context, ec *executionContext, rawArgs map[string]any) (map[string]any, error) { {{- else -}} func (ec *executionContext) {{ $name }}(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { {{- end }} var err error args := map[string]any{} {{- range $i, $arg := . }} {{ if $arg.ImplDirectives }} {{ if $useFunctionSyntaxForExecutionContext -}} arg{{$i}}, err := {{ $name }}{{$arg.Name | go}}(ctx, ec, rawArgs) {{- else -}} arg{{$i}}, err := ec.{{ $name }}{{$arg.Name | go}}(ctx, rawArgs) {{- end }} {{- else -}} {{ if $useFunctionSyntaxForExecutionContext -}} arg{{$i}}, err := graphql.ProcessArgFieldWithEC(ctx, ec, rawArgs, {{$arg.Name|quote}}, {{ $arg.TypeReference.UnmarshalFunc }}) {{- else -}} arg{{$i}}, err := graphql.ProcessArgField(ctx, rawArgs, {{$arg.Name|quote}}, ec.{{ $arg.TypeReference.UnmarshalFunc }}) {{- end }} {{- end }} if err != nil { return nil, err } args[{{$arg.Name|quote}}] = arg{{$i}} {{- end }} return args, nil } {{- range $i, $arg := . }} {{ if not $arg.ImplDirectives -}} {{- continue -}} {{- end }} {{ if $useFunctionSyntaxForExecutionContext -}} func {{ $name }}{{$arg.Name | go}}( ctx context.Context, ec *executionContext, rawArgs map[string]any, ) ({{ $arg.TypeReference.GO | ref}}, error) { {{- else -}} func (ec *executionContext) {{ $name }}{{$arg.Name | go}}( ctx context.Context, rawArgs map[string]any, ) ({{ $arg.TypeReference.GO | ref}}, error) { {{- end }} {{- if not .CallArgumentDirectivesWithNull}} {{- /* We won't call the directive if the argument is null. Set call_argument_directives_with_null to true to call directives even if the argument is null. */ -}} if _, ok := rawArgs[{{$arg.Name|quote}}]; !ok { var zeroVal {{ $arg.TypeReference.GO | ref}} return zeroVal, nil } {{end}} ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField({{$arg.Name|quote}})) {{- if $arg.ImplDirectives }} directive0 := func(ctx context.Context) (any, error) { tmp, ok := rawArgs[{{$arg.Name|quote}}] if !ok { var zeroVal {{ $arg.TypeReference.GO | ref}} return zeroVal, nil } {{ if $useFunctionSyntaxForExecutionContext -}} return {{ $arg.TypeReference.UnmarshalFunc }}(ctx, ec, tmp) {{- else -}} return ec.{{ $arg.TypeReference.UnmarshalFunc }}(ctx, tmp) {{- end }} } {{ template "implDirectives" (dict "Field" $arg "UseFunctionSyntaxForExecutionContext" $useFunctionSyntaxForExecutionContext) }} tmp, err := directive{{$arg.ImplDirectives|len}}(ctx) if err != nil { var zeroVal {{ $arg.TypeReference.GO | ref}} return zeroVal, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.({{ $arg.TypeReference.GO | ref }}) ; ok { return data, nil {{- if $arg.TypeReference.IsNilable }} } else if tmp == nil { var zeroVal {{ $arg.TypeReference.GO | ref}} return zeroVal, nil {{- end }} } else { var zeroVal {{ $arg.TypeReference.GO | ref}} return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be {{ $arg.TypeReference.GO }}`, tmp)) } {{- else }} if tmp, ok := rawArgs[{{$arg.Name|quote}}]; ok { {{ if $useFunctionSyntaxForExecutionContext -}} return {{ $arg.TypeReference.UnmarshalFunc }}(ctx, ec, tmp) {{- else -}} return ec.{{ $arg.TypeReference.UnmarshalFunc }}(ctx, tmp) {{- end }} } var zeroVal {{ $arg.TypeReference.GO | ref}} return zeroVal, nil {{- end }} } {{end}} {{ end }} ================================================ FILE: codegen/autobind_test.go ================================================ package codegen import ( "go/types" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/codegen/config" ) func TestFindBindTarget_Autobind(t *testing.T) { input := ` package test type Model struct { Name string } func (m Model) GetName() string { return m.Name } func (m Model) HasName() bool { return true } ` scope, err := parseScope(input, "test") require.NoError(t, err) model := scope.Lookup("Model").Type().(*types.Named) tests := []struct { Name string Field string AutoBindGetterHaser bool Expected string // Expected method/field name }{ { Name: "Autobind enabled, should find GetName", Field: "name", AutoBindGetterHaser: true, Expected: "GetName", }, { Name: "Autobind disabled, should find Name field", Field: "name", AutoBindGetterHaser: false, Expected: "Name", }, } for _, tt := range tests { t.Run(tt.Name, func(t *testing.T) { b := builder{Config: &config.Config{}} target, err := b.findBindTarget(model, tt.Field, tt.AutoBindGetterHaser) require.NoError(t, err) require.NotNil(t, target) require.Equal(t, tt.Expected, target.Name()) }) } } ================================================ FILE: codegen/complexity.go ================================================ package codegen func (o *Object) UniqueFields() map[string][]*Field { m := map[string][]*Field{} for _, f := range o.Fields { m[f.GoFieldName] = append(m[f.GoFieldName], f) } return m } ================================================ FILE: codegen/config/binder.go ================================================ package config import ( "errors" "fmt" "go/token" "go/types" "strings" "github.com/vektah/gqlparser/v2/ast" "golang.org/x/tools/go/packages" "github.com/99designs/gqlgen/codegen/templates" "github.com/99designs/gqlgen/internal/code" ) var ErrTypeNotFound = errors.New("unable to find type") // Binder connects graphql types to golang types using static analysis type Binder struct { pkgs *code.Packages schema *ast.Schema cfg *Config tctx *types.Context References []*TypeReference SawInvalid bool objectCache map[string]map[string]types.Object } func (c *Config) NewBinder() *Binder { return &Binder{ pkgs: c.Packages, schema: c.Schema, cfg: c, } } func (b *Binder) TypePosition(typ types.Type) token.Position { named, isNamed := code.Unalias(typ).(*types.Named) if !isNamed { return token.Position{ Filename: "unknown", } } return b.ObjectPosition(named.Obj()) } func (b *Binder) ObjectPosition(typ types.Object) token.Position { if typ == nil { return token.Position{ Filename: "unknown", } } pkg := b.pkgs.Load(typ.Pkg().Path()) return pkg.Fset.Position(typ.Pos()) } func (b *Binder) FindTypeFromName(name string) (types.Type, error) { pkgName, typeName := code.PkgAndType(name) return b.FindType(pkgName, typeName) } func (b *Binder) FindType(pkgName, typeName string) (types.Type, error) { if pkgName == "" { if typeName == "map[string]any" || typeName == "map[string]interface{}" { return MapType, nil } if typeName == "any" || typeName == "interface{}" { return InterfaceType, nil } } obj, err := b.FindObject(pkgName, typeName) if err != nil { return nil, err } t := code.Unalias(obj.Type()) if _, isFunc := obj.(*types.Func); isFunc { return code.Unalias(t.(*types.Signature).Params().At(0).Type()), nil } return t, nil } func (b *Binder) InstantiateType(orig types.Type, targs []types.Type) (types.Type, error) { if b.tctx == nil { b.tctx = types.NewContext() } return types.Instantiate(b.tctx, orig, targs, false) } var ( MapType = types.NewMap(types.Typ[types.String], types.Universe.Lookup("any").Type()) InterfaceType = types.Universe.Lookup("any").Type() ) func (b *Binder) DefaultUserObject(name string) (types.Type, error) { models := b.cfg.Models[name].Model if len(models) == 0 { return nil, fmt.Errorf("%s not found in typemap", name) } if models[0] == "map[string]any" || models[0] == "map[string]interface{}" { return MapType, nil } if models[0] == "any" || models[0] == "interface{}" { return InterfaceType, nil } pkgName, typeName := code.PkgAndType(models[0]) if pkgName == "" { return nil, fmt.Errorf("missing package name for %s", name) } obj, err := b.FindObject(pkgName, typeName) if err != nil { return nil, err } return code.Unalias(obj.Type()), nil } func (b *Binder) FindObject(pkgName, typeName string) (types.Object, error) { if pkgName == "" { return nil, fmt.Errorf("package cannot be nil in FindObject for type: %s", typeName) } pkg := b.pkgs.LoadWithTypes(pkgName) if pkg == nil { err := b.pkgs.Errors() if err != nil { return nil, fmt.Errorf("package could not be loaded: %s.%s: %w", pkgName, typeName, err) } return nil, fmt.Errorf("required package was not loaded: %s.%s", pkgName, typeName) } if b.objectCache == nil { b.objectCache = make(map[string]map[string]types.Object, b.pkgs.Count()) } defsIndex, ok := b.objectCache[pkgName] if !ok { defsIndex = indexDefs(pkg) b.objectCache[pkgName] = defsIndex } // function based marshalers take precedence if val, ok := defsIndex["Marshal"+typeName]; ok { return val, nil } if val, ok := defsIndex[typeName]; ok { return val, nil } return nil, fmt.Errorf("%w: %s.%s", ErrTypeNotFound, pkgName, typeName) } func indexDefs(pkg *packages.Package) map[string]types.Object { // Pre-allocate with capacity to avoid map rehashing res := make(map[string]types.Object, len(pkg.TypesInfo.Defs)) scope := pkg.Types.Scope() for astNode, def := range pkg.TypesInfo.Defs { // only look at defs in the top scope if def == nil { continue } parent := def.Parent() if parent == nil || parent != scope { continue } if _, ok := res[astNode.Name]; !ok { // The above check may not be really needed, it is only here to have a consistent // behavior with previous implementation of FindObject() function which only honored the // first inclusion of a def. If this is still needed, we can consider something like // sync.Map.LoadOrStore() to avoid two lookups. res[astNode.Name] = def } } return res } func (b *Binder) PointerTo(ref *TypeReference) *TypeReference { newRef := *ref newRef.GO = types.NewPointer(ref.GO) b.References = append(b.References, &newRef) return &newRef } // TypeReference is used by args and field types. The Definition can refer to both input and output // types. type TypeReference struct { Definition *ast.Definition GQL *ast.Type GO types.Type // Type of the field being bound. Could be a pointer or a value type of Target. Target types.Type // The actual type that we know how to bind to. May require pointer juggling when traversing to fields. CastType types.Type // Before calling marshalling functions cast from/to this base type Marshaler *types.Func // When using external marshalling functions this will point to the Marshal function Unmarshaler *types.Func // When using external marshalling functions this will point to the Unmarshal function IsMarshaler bool // Does the type implement graphql.Marshaler and graphql.Unmarshaler IsOmittable bool // Is the type wrapped with Omittable IsContext bool // Is the Marshaler/Unmarshaller the context version; applies to either the method or interface variety. PointersInUnmarshalInput bool // Inverse values and pointers in return. IsRoot bool // Is the type a root level definition such as Query, Mutation or Subscription EnumValues []EnumValueReference } func (ref *TypeReference) Elem() *TypeReference { if p, isPtr := ref.GO.(*types.Pointer); isPtr { newRef := *ref newRef.GO = p.Elem() return &newRef } if ref.IsSlice() { newRef := *ref newRef.GO = ref.GO.(*types.Slice).Elem() newRef.GQL = ref.GQL.Elem return &newRef } return nil } func (ref *TypeReference) IsPtr() bool { _, isPtr := ref.GO.(*types.Pointer) return isPtr } // fix for https://github.com/golang/go/issues/31103 may make it possible to remove this (may still // be useful) func (ref *TypeReference) IsPtrToPtr() bool { if p, isPtr := ref.GO.(*types.Pointer); isPtr { _, isPtr := p.Elem().(*types.Pointer) return isPtr } return false } func (ref *TypeReference) IsNilable() bool { return IsNilable(ref.GO) } func (ref *TypeReference) IsSlice() bool { _, isSlice := ref.GO.(*types.Slice) return ref.GQL.Elem != nil && isSlice } func (ref *TypeReference) IsPtrToSlice() bool { if ref.IsPtr() { _, isPointerToSlice := ref.GO.(*types.Pointer).Elem().(*types.Slice) return isPointerToSlice } return false } func (ref *TypeReference) IsPtrToIntf() bool { if ref.IsPtr() { _, isPointerToInterface := types.Unalias(ref.GO.(*types.Pointer).Elem()).(*types.Interface) return isPointerToInterface } return false } func (ref *TypeReference) IsNamed() bool { _, ok := ref.GO.(*types.Named) return ok } func (ref *TypeReference) IsStruct() bool { _, ok := ref.GO.Underlying().(*types.Struct) return ok } func (ref *TypeReference) IsScalar() bool { return ref.Definition.Kind == ast.Scalar } func (ref *TypeReference) IsMap() bool { return ref.GO == MapType } func (ref *TypeReference) UniquenessKey() string { nullability := "O" if ref.GQL.NonNull { nullability = "N" } elemNullability := "" if ref.GQL.Elem != nil && ref.GQL.Elem.NonNull { // Fix for #896 elemNullability = "ᚄ" } return nullability + ref.Definition.Name + "2" + templates.TypeIdentifier( ref.GO, ) + elemNullability } func (ref *TypeReference) MarshalFunc() string { if ref.Definition == nil { panic(errors.New("Definition missing for " + ref.GQL.Name())) } if ref.Definition.Kind == ast.InputObject { return "" } return "marshal" + ref.UniquenessKey() } func (ref *TypeReference) MarshalFuncFunctionSyntax() string { return ref.MarshalFunc() + "F" } func (ref *TypeReference) UnmarshalFunc() string { if ref.Definition == nil { panic(errors.New("Definition missing for " + ref.GQL.Name())) } if !ref.Definition.IsInputType() { return "" } return "unmarshal" + ref.UniquenessKey() } func (ref *TypeReference) UnmarshalFuncFunctionSyntax() string { return ref.UnmarshalFunc() + "F" } func (ref *TypeReference) IsTargetNilable() bool { return IsNilable(ref.Target) } func (ref *TypeReference) HasEnumValues() bool { return len(ref.EnumValues) > 0 } func (b *Binder) PushRef(ret *TypeReference) { b.References = append(b.References, ret) } func isMap(t types.Type) bool { if t == nil { return true } _, ok := t.(*types.Map) return ok } func isIntf(t types.Type) bool { if t == nil { return true } _, ok := types.Unalias(t).(*types.Interface) return ok } func unwrapOmittable(t types.Type) (types.Type, bool) { if t == nil { return nil, false } named, ok := t.(*types.Named) if !ok { return t, false } if named.Origin().String() != "github.com/99designs/gqlgen/graphql.Omittable[T any]" { return t, false } return named.TypeArgs().At(0), true } func (b *Binder) TypeReference( schemaType *ast.Type, bindTarget types.Type, ) (ret *TypeReference, err error) { if bindTarget != nil { bindTarget = code.Unalias(bindTarget) } if innerType, ok := unwrapOmittable(bindTarget); ok { if schemaType.NonNull { return nil, fmt.Errorf("%s is wrapped with Omittable but non-null", schemaType.Name()) } ref, err := b.TypeReference(schemaType, innerType) if err != nil { return nil, err } ref.IsOmittable = true return ref, err } if !isValid(bindTarget) { b.SawInvalid = true return nil, fmt.Errorf("%s has an invalid type", schemaType.Name()) } var pkgName, typeName string def := b.schema.Types[schemaType.Name()] defer func() { if err == nil && ret != nil { b.PushRef(ret) } }() if len(b.cfg.Models[schemaType.Name()].Model) == 0 { return nil, fmt.Errorf("%s was not found", schemaType.Name()) } for _, model := range b.cfg.Models[schemaType.Name()].Model { if model == "map[string]any" || model == "map[string]interface{}" { if !isMap(bindTarget) { continue } return &TypeReference{ Definition: def, GQL: schemaType, GO: b.CopyModifiersFromAst(schemaType, MapType), IsRoot: b.cfg.IsRoot(def), }, nil } if model == "any" || model == "interface{}" { if !isIntf(bindTarget) { continue } return &TypeReference{ Definition: def, GQL: schemaType, GO: b.CopyModifiersFromAst(schemaType, InterfaceType), IsRoot: b.cfg.IsRoot(def), }, nil } pkgName, typeName = code.PkgAndType(model) if pkgName == "" { return nil, fmt.Errorf("missing package name for %s", schemaType.Name()) } ref := &TypeReference{ Definition: def, GQL: schemaType, IsRoot: b.cfg.IsRoot(def), } obj, err := b.FindObject(pkgName, typeName) if err != nil { return nil, err } t := code.Unalias(obj.Type()) if values := b.enumValues(def); len(values) > 0 { err = b.enumReference(ref, obj, values) if err != nil { return nil, err } } else if fun, isFunc := obj.(*types.Func); isFunc { ref.GO = code.Unalias(t.(*types.Signature).Params().At(0).Type()) ref.IsContext = code.Unalias(t.(*types.Signature).Results().At(0).Type()). String() == "github.com/99designs/gqlgen/graphql.ContextMarshaler" ref.Marshaler = fun ref.Unmarshaler = types.NewFunc(0, fun.Pkg(), "Unmarshal"+typeName, nil) } else if hasMethod(t, "MarshalGQLContext") && hasMethod(t, "UnmarshalGQLContext") { ref.GO = t ref.IsContext = true ref.IsMarshaler = true } else if hasMethod(t, "MarshalGQL") && hasMethod(t, "UnmarshalGQL") { ref.GO = t ref.IsMarshaler = true } else if underlying := basicUnderlying(t); def.IsLeafType() && underlying != nil && underlying.Kind() == types.String { // TODO delete before v1. Backwards compatibility case for named types wrapping strings // (see #595) ref.GO = t ref.CastType = underlying underlyingRef, err := b.TypeReference(&ast.Type{NamedType: "String"}, nil) if err != nil { return nil, err } ref.Marshaler = underlyingRef.Marshaler ref.Unmarshaler = underlyingRef.Unmarshaler } else { ref.GO = t } ref.Target = ref.GO ref.GO = b.CopyModifiersFromAst(schemaType, ref.GO) if bindTarget != nil { if err = code.CompatibleTypes(ref.GO, bindTarget); err != nil { // if the bind type implements the // graphql.ContextMarshaler/graphql.ContextUnmarshaler/graphql.Marshaler/graphql.Unmarshaler // interface, we can use it if hasMethod(bindTarget, "MarshalGQLContext") && hasMethod(bindTarget, "UnmarshalGQLContext") { ref.IsContext = true ref.IsMarshaler = true ref.Marshaler = nil ref.Unmarshaler = nil } else if hasMethod(bindTarget, "MarshalGQL") && hasMethod(bindTarget, "UnmarshalGQL") { ref.IsContext = false ref.IsMarshaler = true ref.Marshaler = nil ref.Unmarshaler = nil } else { continue } } ref.GO = bindTarget } ref.PointersInUnmarshalInput = b.cfg.ReturnPointersInUnmarshalInput return ref, nil } return nil, fmt.Errorf("%s is incompatible with %s", schemaType.Name(), bindTarget.String()) } func isValid(t types.Type) bool { basic, isBasic := t.(*types.Basic) if !isBasic { return true } return basic.Kind() != types.Invalid } func (b *Binder) CopyModifiersFromAst(t *ast.Type, base types.Type) types.Type { base = types.Unalias(base) if t.Elem != nil { child := b.CopyModifiersFromAst(t.Elem, base) if _, isStruct := child.Underlying().(*types.Struct); isStruct && !b.cfg.OmitSliceElementPointers { child = types.NewPointer(child) } return types.NewSlice(child) } var isInterface bool if named, ok := base.(*types.Named); ok { _, isInterface = named.Underlying().(*types.Interface) } if !isInterface && !IsNilable(base) && !t.NonNull { return types.NewPointer(base) } return base } func IsNilable(t types.Type) bool { // Note that we use types.Unalias rather than code.Unalias here // because we want to always check the underlying type. // code.Unalias only unwraps aliases in Go 1.23 t = types.Unalias(t) if namedType, isNamed := t.(*types.Named); isNamed { return IsNilable(namedType.Underlying()) } _, isPtr := t.(*types.Pointer) _, isNilableMap := t.(*types.Map) _, isInterface := t.(*types.Interface) _, isSlice := t.(*types.Slice) _, isChan := t.(*types.Chan) return isPtr || isNilableMap || isInterface || isSlice || isChan } func hasMethod(it types.Type, name string) bool { if ptr, isPtr := it.(*types.Pointer); isPtr { it = ptr.Elem() } namedType, ok := it.(*types.Named) if !ok { return false } for method := range namedType.Methods() { if method.Name() == name { return true } } return false } func basicUnderlying(it types.Type) *types.Basic { it = types.Unalias(it) if ptr, isPtr := it.(*types.Pointer); isPtr { it = types.Unalias(ptr.Elem()) } namedType, ok := it.(*types.Named) if !ok { return nil } if basic, ok := namedType.Underlying().(*types.Basic); ok { return basic } return nil } type EnumValueReference struct { Definition *ast.EnumValueDefinition Object types.Object } func (b *Binder) enumValues(def *ast.Definition) map[string]EnumValue { if def.Kind != ast.Enum { return nil } if strings.HasPrefix(def.Name, "__") { return nil } model, ok := b.cfg.Models[def.Name] if !ok { return nil } return model.EnumValues } func (b *Binder) enumReference( ref *TypeReference, obj types.Object, values map[string]EnumValue, ) error { if len(ref.Definition.EnumValues) != len(values) { return fmt.Errorf("not all enum values are binded for %v", ref.Definition.Name) } t := code.Unalias(obj.Type()) if fn, ok := t.(*types.Signature); ok { ref.GO = code.Unalias(fn.Params().At(0).Type()) } else { ref.GO = t } str, err := b.TypeReference(&ast.Type{NamedType: "String"}, nil) if err != nil { return err } ref.Marshaler = str.Marshaler ref.Unmarshaler = str.Unmarshaler ref.EnumValues = make([]EnumValueReference, 0, len(values)) for _, value := range ref.Definition.EnumValues { v, ok := values[value.Name] if !ok { return fmt.Errorf( "enum value not found for: %v, of enum: %v", value.Name, ref.Definition.Name, ) } pkgName, typeName := code.PkgAndType(v.Value) if pkgName == "" { return fmt.Errorf("missing package name for %v", value.Name) } valueObj, err := b.FindObject(pkgName, typeName) if err != nil { return err } valueTyp := code.Unalias(valueObj.Type()) if !types.AssignableTo(valueTyp, ref.GO) { return fmt.Errorf("wrong type: %v, for enum value: %v, expected type: %v, of enum: %v", valueTyp, value.Name, ref.GO, ref.Definition.Name) } switch valueObj.(type) { case *types.Const, *types.Var: ref.EnumValues = append(ref.EnumValues, EnumValueReference{ Definition: value, Object: valueObj, }) default: return fmt.Errorf( "unsupported enum value for: %v, of enum: %v, only const and var allowed", value.Name, ref.Definition.Name, ) } } return nil } ================================================ FILE: codegen/config/binder_test.go ================================================ package config import ( "fmt" "go/token" "go/types" "testing" "github.com/stretchr/testify/require" "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" "github.com/99designs/gqlgen/internal/code" ) func TestBindingToInvalid(t *testing.T) { binder, schema := createBinder(Config{}) _, err := binder.TypeReference(schema.Query.Fields.ForName("messages").Type, &types.Basic{}) require.EqualError(t, err, "Message has an invalid type") } func TestSlicePointerBinding(t *testing.T) { t.Run("without OmitSliceElementPointers", func(t *testing.T) { binder, schema := createBinder(Config{ OmitSliceElementPointers: false, }) ta, err := binder.TypeReference(schema.Query.Fields.ForName("messages").Type, nil) require.NoError(t, err) require.Equal( t, "[]*github.com/99designs/gqlgen/codegen/config/testdata/autobinding/chat.Message", ta.GO.String(), ) }) t.Run("with OmitSliceElementPointers", func(t *testing.T) { binder, schema := createBinder(Config{ OmitSliceElementPointers: true, }) ta, err := binder.TypeReference(schema.Query.Fields.ForName("messages").Type, nil) require.NoError(t, err) require.Equal( t, "[]github.com/99designs/gqlgen/codegen/config/testdata/autobinding/chat.Message", ta.GO.String(), ) }) } func TestOmittableBinding(t *testing.T) { t.Run("bind nullable string with Omittable[string]", func(t *testing.T) { binder, schema := createBinder(Config{}) ot, err := binder.FindType("github.com/99designs/gqlgen/graphql", "Omittable") require.NoError(t, err) it, err := binder.InstantiateType(ot, []types.Type{types.Universe.Lookup("string").Type()}) require.NoError(t, err) ta, err := binder.TypeReference( schema.Types["FooInput"].Fields.ForName("nullableString").Type, it, ) require.NoError(t, err) require.True(t, ta.IsOmittable) }) t.Run("bind nullable string with Omittable[*string]", func(t *testing.T) { binder, schema := createBinder(Config{}) ot, err := binder.FindType("github.com/99designs/gqlgen/graphql", "Omittable") require.NoError(t, err) it, err := binder.InstantiateType( ot, []types.Type{types.NewPointer(types.Universe.Lookup("string").Type())}, ) require.NoError(t, err) ta, err := binder.TypeReference( schema.Types["FooInput"].Fields.ForName("nullableString").Type, it, ) require.NoError(t, err) require.True(t, ta.IsOmittable) }) t.Run("fail binding non-nullable string with Omittable[string]", func(t *testing.T) { binder, schema := createBinder(Config{}) ot, err := binder.FindType("github.com/99designs/gqlgen/graphql", "Omittable") require.NoError(t, err) it, err := binder.InstantiateType(ot, []types.Type{types.Universe.Lookup("string").Type()}) require.NoError(t, err) _, err = binder.TypeReference( schema.Types["FooInput"].Fields.ForName("nonNullableString").Type, it, ) require.Error(t, err) }) t.Run("fail binding non-nullable string with Omittable[*string]", func(t *testing.T) { binder, schema := createBinder(Config{}) ot, err := binder.FindType("github.com/99designs/gqlgen/graphql", "Omittable") require.NoError(t, err) it, err := binder.InstantiateType( ot, []types.Type{types.NewPointer(types.Universe.Lookup("string").Type())}, ) require.NoError(t, err) _, err = binder.TypeReference( schema.Types["FooInput"].Fields.ForName("nonNullableString").Type, it, ) require.Error(t, err) }) t.Run("bind nullable object with Omittable[T]", func(t *testing.T) { binder, schema := createBinder(Config{}) typ, err := binder.FindType( "github.com/99designs/gqlgen/codegen/config/testdata/autobinding/chat", "Message", ) require.NoError(t, err) ot, err := binder.FindType("github.com/99designs/gqlgen/graphql", "Omittable") require.NoError(t, err) it, err := binder.InstantiateType(ot, []types.Type{typ}) require.NoError(t, err) ta, err := binder.TypeReference( schema.Types["FooInput"].Fields.ForName("nullableObject").Type, it, ) require.NoError(t, err) require.True(t, ta.IsOmittable) }) t.Run("bind nullable object with Omittable[*T]", func(t *testing.T) { binder, schema := createBinder(Config{}) typ, err := binder.FindType( "github.com/99designs/gqlgen/codegen/config/testdata/autobinding/chat", "Message", ) require.NoError(t, err) ot, err := binder.FindType("github.com/99designs/gqlgen/graphql", "Omittable") require.NoError(t, err) it, err := binder.InstantiateType(ot, []types.Type{types.NewPointer(typ)}) require.NoError(t, err) ta, err := binder.TypeReference( schema.Types["FooInput"].Fields.ForName("nullableObject").Type, it, ) require.NoError(t, err) require.True(t, ta.IsOmittable) }) } func createBinder(cfg Config) (*Binder, *ast.Schema) { cfg.Models = TypeMap{ "Message": TypeMapEntry{ Model: []string{ "github.com/99designs/gqlgen/codegen/config/testdata/autobinding/chat.Message", }, }, "BarInput": TypeMapEntry{ Model: []string{ "github.com/99designs/gqlgen/codegen/config/testdata/autobinding/chat.Message", }, }, "String": TypeMapEntry{ Model: []string{"github.com/99designs/gqlgen/graphql.String"}, }, } cfg.Packages = code.NewPackages() cfg.Schema = gqlparser.MustLoadSchema(&ast.Source{Name: "TestAutobinding.schema", Input: ` type Message { id: ID } input FooInput { nullableString: String nonNullableString: String! nullableObject: BarInput } input BarInput { id: ID text: String! } type Query { messages: [Message!]! } `}) b := cfg.NewBinder() return b, cfg.Schema } func TestEnumBinding(t *testing.T) { cf := Config{} cf.Packages = code.NewPackages() cf.Models = TypeMap{ "Bar": TypeMapEntry{ Model: []string{"github.com/99designs/gqlgen/codegen/config/testdata/enum.Bar"}, EnumValues: map[string]EnumValue{ "ONE": {Value: "github.com/99designs/gqlgen/codegen/config/testdata/enum.BarOne"}, "TWO": {Value: "github.com/99designs/gqlgen/codegen/config/testdata/enum.BarTwo"}, }, }, "Baz": TypeMapEntry{ Model: []string{"github.com/99designs/gqlgen/graphql.Int"}, EnumValues: map[string]EnumValue{ "ONE": {Value: "github.com/99designs/gqlgen/codegen/config/testdata/enum.BazOne"}, "TWO": {Value: "github.com/99designs/gqlgen/codegen/config/testdata/enum.BazTwo"}, }, }, "String": TypeMapEntry{ Model: []string{"github.com/99designs/gqlgen/graphql.String"}, }, } cf.Schema = gqlparser.MustLoadSchema(&ast.Source{Name: "schema", Input: ` type Query { foo(arg: Bar!): Baz } enum Bar { ONE TWO } enum Baz { ONE TWO } `}) binder := cf.NewBinder() barType, err := binder.FindType( "github.com/99designs/gqlgen/codegen/config/testdata/enum", "Bar", ) require.NotNil(t, barType) require.NoError(t, err) bar, err := binder.TypeReference( cf.Schema.Query.Fields.ForName("foo").Arguments.ForName("arg").Type, nil, ) require.NotNil(t, bar) require.NoError(t, err) require.True(t, bar.HasEnumValues()) require.Len(t, bar.EnumValues, 2) barOne, err := binder.FindObject( "github.com/99designs/gqlgen/codegen/config/testdata/enum", "BarOne", ) require.NotNil(t, barOne) require.NoError(t, err) require.Equal(t, barOne, bar.EnumValues[0].Object) require.Equal(t, cf.Schema.Types["Bar"].EnumValues[0], bar.EnumValues[0].Definition) barTwo, err := binder.FindObject( "github.com/99designs/gqlgen/codegen/config/testdata/enum", "BarTwo", ) require.NotNil(t, barTwo) require.NoError(t, err) require.Equal(t, barTwo, bar.EnumValues[1].Object) require.Equal(t, cf.Schema.Types["Bar"].EnumValues[1], bar.EnumValues[1].Definition) bazType, err := binder.FindType("github.com/99designs/gqlgen/graphql", "Int") require.NotNil(t, bazType) require.NoError(t, err) baz, err := binder.TypeReference(cf.Schema.Query.Fields.ForName("foo").Type, nil) require.NotNil(t, baz) require.NoError(t, err) require.True(t, baz.HasEnumValues()) require.Len(t, baz.EnumValues, 2) bazOne, err := binder.FindObject( "github.com/99designs/gqlgen/codegen/config/testdata/enum", "BazOne", ) require.NotNil(t, bazOne) require.NoError(t, err) require.Equal(t, bazOne, baz.EnumValues[0].Object) require.Equal(t, cf.Schema.Types["Baz"].EnumValues[0], baz.EnumValues[0].Definition) bazTwo, err := binder.FindObject( "github.com/99designs/gqlgen/codegen/config/testdata/enum", "BazTwo", ) require.NotNil(t, bazTwo) require.NoError(t, err) require.Equal(t, bazTwo, baz.EnumValues[1].Object) require.Equal(t, cf.Schema.Types["Baz"].EnumValues[1], baz.EnumValues[1].Definition) } func TestTargetBinding(t *testing.T) { cf := Config{} cf.Packages = code.NewPackages() cf.Models = TypeMap{ "Int": TypeMapEntry{ Model: []string{ "github.com/99designs/gqlgen/codegen/config/testdata/binding.Number", "github.com/99designs/gqlgen/codegen/config/testdata/binding.ContextNumber", }, }, } cf.Schema = gqlparser.MustLoadSchema(&ast.Source{Name: "schema", Input: ` directive @goField( forceResolver: Boolean name: String omittable: Boolean type: String ) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION type Query { number: Int! @goField(type:"github.com/99designs/gqlgen/codegen/config/testdata/binding.Number") contextNumber: Int! @goField(type:"github.com/99designs/gqlgen/codegen/config/testdata/binding.ContextNumber") } `}) binder := cf.NewBinder() ctxTarget, err := binder.FindType( "github.com/99designs/gqlgen/codegen/config/testdata/binding", "ContextNumber", ) require.NoError(t, err) got, err := binder.TypeReference( cf.Schema.Query.Fields.ForName("contextNumber").Type, ctxTarget, ) require.NotNil(t, got) require.NoError(t, err) require.True(t, got.IsContext) require.True(t, got.IsMarshaler) require.Nil(t, got.Marshaler) require.Nil(t, got.Unmarshaler) require.Equal(t, got.GO, ctxTarget) target, err := binder.FindType( "github.com/99designs/gqlgen/codegen/config/testdata/binding", "Number", ) require.NoError(t, err) got, err = binder.TypeReference(cf.Schema.Query.Fields.ForName("number").Type, target) require.NotNil(t, got) require.NoError(t, err) require.False(t, got.IsContext) require.True(t, got.IsMarshaler) require.Nil(t, got.Marshaler) require.Nil(t, got.Unmarshaler) require.Equal(t, got.GO, target) } func createTypeAlias(name string, t types.Type) *types.Alias { var nopos token.Pos return types.NewAlias(types.NewTypeName(nopos, nil, name, nil), t) } func TestIsNilable(t *testing.T) { type aTest struct { input types.Type expected bool } theTests := []aTest{ {types.Universe.Lookup("any").Type(), true}, {types.Universe.Lookup("rune").Type(), false}, {types.Universe.Lookup("byte").Type(), false}, {types.Universe.Lookup("error").Type(), true}, {types.Typ[types.Int], false}, {types.Typ[types.String], false}, {types.NewChan(types.SendOnly, types.Typ[types.Int]), true}, {types.NewPointer(types.Typ[types.Int]), true}, {types.NewPointer(types.Typ[types.String]), true}, {types.NewMap(types.Typ[types.Int], types.Typ[types.Int]), true}, {types.NewSlice(types.Typ[types.Int]), true}, {types.NewInterfaceType(nil, nil), true}, {createTypeAlias("interfaceAlias", types.Universe.Lookup("any").Type()), true}, { createTypeAlias( "interfaceNestedAlias", createTypeAlias("interfaceAlias", types.Universe.Lookup("any").Type()), ), true, }, {createTypeAlias("intAlias", types.Typ[types.Int]), false}, { createTypeAlias("intNestedAlias", createTypeAlias("intAlias", types.Typ[types.Int])), false, }, } for _, at := range theTests { t.Run(fmt.Sprintf("nilable-%s", at.input.String()), func(t *testing.T) { require.Equal(t, at.expected, IsNilable(at.input)) }) } } ================================================ FILE: codegen/config/config.go ================================================ package config import ( "bytes" "errors" "fmt" "go/types" "io" "os" "path/filepath" "regexp" "slices" "sort" "strings" "github.com/goccy/go-yaml" "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" "golang.org/x/tools/go/packages" "github.com/99designs/gqlgen/codegen/templates" "github.com/99designs/gqlgen/internal/code" "github.com/99designs/gqlgen/internal/imports" ) type Config struct { SchemaFilename StringList `yaml:"schema,omitempty"` Exec ExecConfig `yaml:"exec"` Model PackageConfig `yaml:"model,omitempty"` Federation PackageConfig `yaml:"federation,omitempty"` Resolver ResolverConfig `yaml:"resolver,omitempty"` AutoBind []string `yaml:"autobind"` AutobindGetterHaser bool `yaml:"autobind_getter_haser,omitempty"` Models TypeMap `yaml:"models,omitempty"` StructTag string `yaml:"struct_tag,omitempty"` EmbeddedStructsPrefix string `yaml:"embedded_structs_prefix,omitempty"` Directives map[string]DirectiveConfig `yaml:"directives,omitempty"` LocalPrefix string `yaml:"local_prefix,omitempty"` GoBuildTags StringList `yaml:"go_build_tags,omitempty"` GoInitialisms GoInitialismsConfig `yaml:"go_initialisms,omitempty"` OmitSliceElementPointers bool `yaml:"omit_slice_element_pointers,omitempty"` OmitGetters bool `yaml:"omit_getters,omitempty"` OmitInterfaceChecks bool `yaml:"omit_interface_checks,omitempty"` OmitComplexity bool `yaml:"omit_complexity,omitempty"` OmitGQLGenFileNotice bool `yaml:"omit_gqlgen_file_notice,omitempty"` OmitGQLGenVersionInFileNotice bool `yaml:"omit_gqlgen_version_in_file_notice,omitempty"` OmitRootModels bool `yaml:"omit_root_models,omitempty"` OmitResolverFields bool `yaml:"omit_resolver_fields,omitempty"` OmitPanicHandler bool `yaml:"omit_panic_handler,omitempty"` OmitEnumJSONMarshalers bool `yaml:"omit_enum_json_marshalers,omitempty"` UseFunctionSyntaxForExecutionContext bool `yaml:"use_function_syntax_for_execution_context,omitempty"` // If this is set to true, argument directives that // decorate a field with a null value will still be called. // // This enables argument directives to not just mutate // argument values but to set them even if they're null. CallArgumentDirectivesWithNull bool `yaml:"call_argument_directives_with_null,omitempty"` StructFieldsAlwaysPointers bool `yaml:"struct_fields_always_pointers,omitempty"` ReturnPointersInUnmarshalInput bool `yaml:"return_pointers_in_unmarshalinput,omitempty"` ResolversAlwaysReturnPointers bool `yaml:"resolvers_always_return_pointers,omitempty"` NullableInputOmittable bool `yaml:"nullable_input_omittable,omitempty"` EnableModelJsonOmitemptyTag *bool `yaml:"enable_model_json_omitempty_tag,omitempty"` EnableModelJsonOmitzeroTag *bool `yaml:"enable_model_json_omitzero_tag,omitempty"` SkipValidation bool `yaml:"skip_validation,omitempty"` SkipModTidy bool `yaml:"skip_mod_tidy,omitempty"` // FastValidation uses -gcflags="-N -l" to disable compiler optimizations // during validation, making cold cache validation ~2x faster. The generated // code is only used for error checking, not execution. Default: false FastValidation *bool `yaml:"fast_validation,omitempty"` // SkipImportGrouping uses go/format.Source instead of imports.Process for // formatting generated code. This is faster but doesn't group imports // (stdlib/external/internal). Default: false (uses imports.Process) SkipImportGrouping *bool `yaml:"skip_import_grouping,omitempty"` // UseLightModePrefetch uses NeedName|NeedFiles|NeedModule instead of full // NeedTypes for initial package loading. This avoids triggering compilation // until types are actually needed. Default: false UseLightModePrefetch *bool `yaml:"use_light_mode_prefetch,omitempty"` // UseBufferPooling reuses byte buffers via sync.Pool during code formatting // to reduce GC pressure. Default: false UseBufferPooling *bool `yaml:"use_buffer_pooling,omitempty"` Sources []*ast.Source `yaml:"-"` Packages *code.Packages `yaml:"-"` Schema *ast.Schema `yaml:"-"` } // boolOrFalse returns the value of a *bool pointer, or false if nil. func boolOrFalse(ptr *bool) bool { return ptr != nil && *ptr } // GetFastValidation returns the value of FastValidation with default false. func (c *Config) GetFastValidation() bool { return boolOrFalse(c.FastValidation) } // GetSkipImportGrouping returns the value of SkipImportGrouping with default false. func (c *Config) GetSkipImportGrouping() bool { return boolOrFalse(c.SkipImportGrouping) } // GetUseLightModePrefetch returns the value of UseLightModePrefetch with default false. func (c *Config) GetUseLightModePrefetch() bool { return boolOrFalse(c.UseLightModePrefetch) } // GetUseBufferPooling returns the value of UseBufferPooling with default false. func (c *Config) GetUseBufferPooling() bool { return boolOrFalse(c.UseBufferPooling) } // GetPruneOptions returns the PruneOptions based on the config settings. func (c *Config) GetPruneOptions() imports.PruneOptions { return imports.PruneOptions{ SkipImportGrouping: c.GetSkipImportGrouping(), UseBufferPooling: c.GetUseBufferPooling(), } } const ( DirGoModel = "goModel" DirGoExtraField = "goExtraField" DirGoField = "goField" DirGoTag = "goTag" DirGoEnum = "goEnum" DirInlineArguments = "inlineArguments" DirArgName = "name" DirArgModel = "model" DirArgModels = "models" DirArgType = "type" DirArgValue = "value" DirArgForceGenerate = "forceGenerate" DirArgForceResolver = "forceResolver" DirArgOverrideTags = "overrideTags" DirArgDescription = "description" DirArgOmittable = "omittable" DirArgAutoBindGetterHaser = "autoBindGetterHaser" DirArgBatch = "batch" ) var cfgFilenames = []string{".gqlgen.yml", "gqlgen.yml", "gqlgen.yaml"} // templatePackageNames is a list of packages names that the default templates use, in order to // preload those for performance considerations any additional package added to the base templates // should be added here to improve performance and load all packages in bulk var templatePackageNames = []string{ "context", "fmt", "io", "strconv", "time", "sync", "strings", "sync/atomic", "embed", "golang.org/x/sync/semaphore", "errors", "bytes", "github.com/vektah/gqlparser/v2", "github.com/vektah/gqlparser/v2/ast", "github.com/99designs/gqlgen/graphql", "github.com/99designs/gqlgen/graphql/introspection", } // DefaultConfig creates a copy of the default config func DefaultConfig() *Config { falseValue := false return &Config{ SchemaFilename: StringList{"schema.graphql"}, Model: PackageConfig{Filename: "models_gen.go"}, Exec: ExecConfig{Filename: "generated.go"}, Directives: map[string]DirectiveConfig{}, Models: TypeMap{}, StructFieldsAlwaysPointers: true, ReturnPointersInUnmarshalInput: false, ResolversAlwaysReturnPointers: true, NullableInputOmittable: false, EnableModelJsonOmitzeroTag: &falseValue, EmbeddedStructsPrefix: "Base", } } // LoadDefaultConfig loads the default config so that it is ready to be used func LoadDefaultConfig() (*Config, error) { config := DefaultConfig() for _, filename := range config.SchemaFilename { filename = filepath.ToSlash(filename) var err error var schemaRaw []byte schemaRaw, err = os.ReadFile(filename) if err != nil { return nil, fmt.Errorf("unable to open schema: %w", err) } config.Sources = append( config.Sources, &ast.Source{Name: filename, Input: string(schemaRaw)}, ) } return config, nil } // LoadConfigFromDefaultLocations looks for a config file in the current directory, and all parent // directories // walking up the tree. The closest config file will be returned. func LoadConfigFromDefaultLocations() (*Config, error) { cfgFile, err := findCfg() if err != nil { return nil, err } err = os.Chdir(filepath.Dir(cfgFile)) if err != nil { return nil, fmt.Errorf("unable to enter config dir: %w", err) } return LoadConfig(cfgFile) } var path2regex = strings.NewReplacer( `.`, `\.`, `*`, `.+`, `\`, `[\\/]`, `/`, `[\\/]`, ) // LoadConfig reads the gqlgen.yml config file func LoadConfig(filename string) (*Config, error) { b, err := os.ReadFile(filename) if err != nil { return nil, fmt.Errorf("unable to read config: %w", err) } return ReadConfig(bytes.NewReader(b)) } func ReadConfig(cfgFile io.Reader) (cfg *Config, err error) { defer func() { if r := recover(); r != nil { cfg = nil err = fmt.Errorf("unable to parse config: panic during decode: %v", r) } }() config := DefaultConfig() dec := yaml.NewDecoder(cfgFile, yaml.DisallowUnknownField()) if err := dec.Decode(config); err != nil { return nil, fmt.Errorf("unable to parse config: %w", err) } if err := CompleteConfig(config); err != nil { return nil, err } return config, nil } // CompleteConfig fills in the schema and other values to a config loaded from // YAML. func CompleteConfig(config *Config) error { defaultDirectives := map[string]DirectiveConfig{ "skip": {SkipRuntime: true}, "include": {SkipRuntime: true}, "deprecated": {SkipRuntime: true}, "specifiedBy": {SkipRuntime: true}, "oneOf": {SkipRuntime: true}, } for key, value := range defaultDirectives { if _, defined := config.Directives[key]; !defined { config.Directives[key] = value } } preGlobbing := config.SchemaFilename config.SchemaFilename = StringList{} for _, f := range preGlobbing { var matches []string // for ** we want to override default globbing patterns and walk all // subdirectories to match schema files. if strings.Contains(f, "**") { pathParts := strings.SplitN(f, "**", 2) rest := strings.TrimPrefix(strings.TrimPrefix(pathParts[1], `\`), `/`) // turn the rest of the glob into a regex, anchored only at the end because ** allows // for any number of dirs in between and walk will let us match against the full path // name globRe := regexp.MustCompile(path2regex.Replace(rest) + `$`) if err := filepath.Walk( pathParts[0], func(path string, info os.FileInfo, err error) error { if err != nil { return err } if globRe.MatchString(strings.TrimPrefix(path, pathParts[0])) { matches = append(matches, path) } return nil }, ); err != nil { return fmt.Errorf("failed to walk schema at root %s: %w", pathParts[0], err) } } else { var err error matches, err = filepath.Glob(f) if err != nil { return fmt.Errorf("failed to glob schema filename %s: %w", f, err) } } for _, m := range matches { if config.SchemaFilename.Has(m) { continue } config.SchemaFilename = append(config.SchemaFilename, m) } } for _, filename := range config.SchemaFilename { filename = filepath.ToSlash(filename) var err error var schemaRaw []byte schemaRaw, err = os.ReadFile(filename) if err != nil { return fmt.Errorf("unable to open schema: %w", err) } config.Sources = append( config.Sources, &ast.Source{Name: filename, Input: string(schemaRaw)}, ) } config.GoInitialisms.setInitialisms() return nil } func (c *Config) Init() error { if c.Packages == nil { c.Packages = code.NewPackages( code.WithBuildTags(c.GoBuildTags...), code.PackagePrefixToCache("github.com/99designs/gqlgen/graphql"), code.WithPreloadNames(templatePackageNames...), code.WithLightModePrefetch(c.GetUseLightModePrefetch()), ) } if c.Schema == nil { if err := c.LoadSchema(); err != nil { return err } } err := c.injectTypesFromSchema() if err != nil { return err } // prefetch all packages with light mode (no type checking, fast) // Type info will be loaded on-demand only for packages that need it (e.g., autobind) c.Packages.LoadAllLight(c.packageList()...) err = c.autobind() if err != nil { return err } c.injectBuiltins() // check everything is valid on the way out err = c.check() if err != nil { return err } return nil } func (c *Config) packageList() []string { pkgs := []string{ "github.com/99designs/gqlgen/graphql", "github.com/99designs/gqlgen/graphql/introspection", } pkgs = append(pkgs, c.Models.ReferencedPackages()...) pkgs = append(pkgs, c.AutoBind...) return pkgs } func (c *Config) ReloadAllPackages() { c.Packages.ReloadAll(c.packageList()...) } func (c *Config) IsRoot(def *ast.Definition) bool { return def == c.Schema.Query || def == c.Schema.Mutation || def == c.Schema.Subscription } func (c *Config) injectTypesFromSchema() error { for _, d := range []string{ DirGoModel, DirGoExtraField, DirGoField, DirGoTag, DirGoEnum, DirInlineArguments, } { c.Directives[d] = DirectiveConfig{SkipRuntime: true} } for _, schemaType := range c.Schema.Types { if c.IsRoot(schemaType) { continue } c.injectGoModelDirective(schemaType) if schemaType.Kind == ast.Object || schemaType.Kind == ast.InputObject || schemaType.Kind == ast.Interface { if err := c.injectGoFieldDirectives(schemaType); err != nil { return err } if err := c.injectGoExtraFieldDirectives(schemaType); err != nil { return err } } c.injectGoEnumDirectives(schemaType) } return nil } func (c *Config) injectGoModelDirective(schemaType *ast.Definition) { bd := schemaType.Directives.ForName(DirGoModel) if bd == nil { return } if ma := bd.Arguments.ForName(DirArgModel); ma != nil { if mv, err := ma.Value.Value(nil); err == nil { c.Models.Add(schemaType.Name, mv.(string)) } } if ma := bd.Arguments.ForName(DirArgModels); ma != nil { if mvs, err := ma.Value.Value(nil); err == nil { for _, mv := range mvs.([]any) { c.Models.Add(schemaType.Name, mv.(string)) } } } if fg := bd.Arguments.ForName(DirArgForceGenerate); fg != nil { if mv, err := fg.Value.Value(nil); err == nil { c.Models.ForceGenerate(schemaType.Name, mv.(bool)) } } } func (c *Config) injectGoFieldDirectives(schemaType *ast.Definition) error { for _, field := range schemaType.Fields { fd := field.Directives.ForName(DirGoField) if fd == nil { continue } // First, copy map entry for type and field to do modifications typeMapEntry := c.Models[schemaType.Name] typeMapFieldEntry := typeMapEntry.Fields[field.Name] if ta := fd.Arguments.ForName(DirArgType); ta != nil { if c.Models.UserDefined(schemaType.Name) { return newNotApplicableError(DirGoField, DirArgType, *fd.Position) } if ft, err := ta.Value.Value(nil); err == nil { typeMapFieldEntry.Type = ft.(string) } } if ra := fd.Arguments.ForName(DirArgForceResolver); ra != nil { if fr, err := ra.Value.Value(nil); err == nil { typeMapFieldEntry.Resolver = fr.(bool) } } if na := fd.Arguments.ForName(DirArgName); na != nil { if fr, err := na.Value.Value(nil); err == nil { typeMapFieldEntry.FieldName = fr.(string) } } if arg := fd.Arguments.ForName(DirArgOmittable); arg != nil { if k, err := arg.Value.Value(nil); err == nil { val := k.(bool) typeMapFieldEntry.Omittable = &val } } if arg := fd.Arguments.ForName(DirArgAutoBindGetterHaser); arg != nil { if k, err := arg.Value.Value(nil); err == nil { val := k.(bool) typeMapFieldEntry.AutoBindGetterHaser = &val } } if arg := fd.Arguments.ForName(DirArgBatch); arg != nil { if k, err := arg.Value.Value(nil); err == nil { typeMapFieldEntry.Batch = k.(bool) } } if arg := fd.Arguments.ForName(DirArgForceGenerate); arg != nil { if c.Models.UserDefined(schemaType.Name) { return newNotApplicableError( DirGoField, DirArgForceGenerate, *fd.Position, ) } if k, err := arg.Value.Value(nil); err == nil { val := k.(bool) typeMapFieldEntry.ForceGenerate = val } } // May be uninitialized, so do it now. if typeMapEntry.Fields == nil { typeMapEntry.Fields = make(map[string]TypeMapField) } // First, copy back probably modificated field settings typeMapEntry.Fields[field.Name] = typeMapFieldEntry // And final copy back probably modificated all type map c.Models[schemaType.Name] = typeMapEntry } return nil } func (c *Config) injectGoExtraFieldDirectives(schemaType *ast.Definition) error { efds := schemaType.Directives.ForNames(DirGoExtraField) if len(efds) == 0 { return nil } for _, efd := range efds { t := efd.Arguments.ForName(DirArgType) if t == nil { continue } extraField := ModelExtraField{} if tv, err := t.Value.Value(nil); err == nil { extraField.Type = tv.(string) } if extraField.Type == "" { return newCannotBeEmptyError( DirGoExtraField, DirArgType, *efd.Position, ) } if ot := efd.Arguments.ForName(DirArgOverrideTags); ot != nil { if otv, err := ot.Value.Value(nil); err == nil { extraField.OverrideTags = otv.(string) } } if d := efd.Arguments.ForName(DirArgDescription); d != nil { if dv, err := d.Value.Value(nil); err == nil { extraField.Description = dv.(string) } } extraFieldName := "" if fn := efd.Arguments.ForName(DirArgName); fn != nil { if fnv, err := fn.Value.Value(nil); err == nil { extraFieldName = fnv.(string) } } // First copy, then modify map entry. typeMapEntry := c.Models[schemaType.Name] if extraFieldName == "" { // Embeddable fields typeMapEntry.EmbedExtraFields = append( typeMapEntry.EmbedExtraFields, extraField, ) } else { // Regular fields if typeMapEntry.ExtraFields == nil { typeMapEntry.ExtraFields = make(map[string]ModelExtraField) } typeMapEntry.ExtraFields[extraFieldName] = extraField } // Copy back modified map entry c.Models[schemaType.Name] = typeMapEntry } return nil } func (c *Config) injectGoEnumDirectives(schemaType *ast.Definition) { if schemaType.Kind != ast.Enum || strings.HasPrefix(schemaType.Name, "__") { return } values := make(map[string]EnumValue) for _, value := range schemaType.EnumValues { if directive := value.Directives.ForName(DirGoEnum); directive != nil { if arg := directive.Arguments.ForName(DirArgValue); arg != nil { if v, err := arg.Value.Value(nil); err == nil { values[value.Name] = EnumValue{ Value: v.(string), } } } } } if len(values) > 0 { model := c.Models[schemaType.Name] model.EnumValues = values c.Models[schemaType.Name] = model } } type TypeMapEntry struct { Model StringList `yaml:"model,omitempty"` ForceGenerate bool `yaml:"forceGenerate,omitempty"` Fields map[string]TypeMapField `yaml:"fields,omitempty"` EnumValues map[string]EnumValue `yaml:"enum_values,omitempty"` // Key is the Go name of the field. ExtraFields map[string]ModelExtraField `yaml:"extraFields,omitempty"` EmbedExtraFields []ModelExtraField `yaml:"embedExtraFields,omitempty"` } type TypeMapField struct { // Type is the Go type of the field. // // It supports the builtin basic types (like string or int64), named types // (qualified by the full package path), pointers to those types (prefixed // with `*`), and slices of those types (prefixed with `[]`). // // For example, the following are valid types: // string // *github.com/author/package.Type // []string // []*github.com/author/package.Type // // Note that the type will be referenced from the generated/graphql, which // means the package it lives in must not reference the generated/graphql // package to avoid circular imports. // restrictions. Type string `yaml:"type"` Resolver bool `yaml:"resolver"` FieldName string `yaml:"fieldName"` Omittable *bool `yaml:"omittable"` GeneratedMethod string `yaml:"-"` AutoBindGetterHaser *bool `yaml:"autoBindGetterHaser"` // Batch enables batch resolver generation for this field. // When true, a batch resolver method (e.g., PostsBatch) will be generated // that accepts multiple parent objects and returns ([]T, error) for all of them // in a single call, reducing N+1 query problems. For partial failures, return // a graphql.BatchErrors implementation as the error. Batch bool `yaml:"batch,omitempty"` // ForceGenerate forces the field to be generated in the model struct // even when OmitResolverFields is enabled and the field has forceResolver: true. ForceGenerate bool `yaml:"forceGenerate"` } type EnumValue struct { Value string } type ModelExtraField struct { // Type is the Go type of the field. // // It supports the builtin basic types (like string or int64), named types // (qualified by the full package path), pointers to those types (prefixed // with `*`), and slices of those types (prefixed with `[]`). // // For example, the following are valid types: // string // *github.com/author/package.Type // []string // []*github.com/author/package.Type // // Note that the type will be referenced from the generated/graphql, which // means the package it lives in must not reference the generated/graphql // package to avoid circular imports. // restrictions. Type string `yaml:"type"` // OverrideTags is an optional override of the Go field tag. OverrideTags string `yaml:"overrideTags"` // Description is an optional the Go field doc-comment. Description string `yaml:"description"` } type StringList []string func (a *StringList) UnmarshalYAML(unmarshal func(any) error) error { var single string err := unmarshal(&single) if err == nil { *a = []string{single} return nil } var multi []string err = unmarshal(&multi) if err != nil { return err } *a = multi return nil } func (a StringList) Has(file string) bool { return slices.Contains(a, file) } func (c *Config) check() error { if c.Models == nil { c.Models = TypeMap{} } type FilenamePackage struct { Filename string Package string Declaree string } fileList := map[string][]FilenamePackage{} if err := c.Models.Check(); err != nil { return fmt.Errorf("config.models: %w", err) } if err := c.Exec.Check(); err != nil { return fmt.Errorf("config.exec: %w", err) } fileList[c.Exec.ImportPath()] = append(fileList[c.Exec.ImportPath()], FilenamePackage{ Filename: c.Exec.Filename, Package: c.Exec.Package, Declaree: "exec", }) if c.Model.IsDefined() { if err := c.Model.Check(); err != nil { return fmt.Errorf("config.model: %w", err) } fileList[c.Model.ImportPath()] = append(fileList[c.Model.ImportPath()], FilenamePackage{ Filename: c.Model.Filename, Package: c.Model.Package, Declaree: "model", }) } if c.Resolver.IsDefined() { if err := c.Resolver.Check(); err != nil { return fmt.Errorf("config.resolver: %w", err) } fileList[c.Resolver.ImportPath()] = append( fileList[c.Resolver.ImportPath()], FilenamePackage{ Filename: c.Resolver.Filename, Package: c.Resolver.Package, Declaree: "resolver", }, ) } if c.Federation.IsDefined() { if err := c.Federation.Check(); err != nil { return fmt.Errorf("config.federation: %w", err) } fileList[c.Federation.ImportPath()] = append( fileList[c.Federation.ImportPath()], FilenamePackage{ Filename: c.Federation.Filename, Package: c.Federation.Package, Declaree: "federation", }, ) if c.Federation.ImportPath() != c.Exec.ImportPath() { return errors.New("federation and exec must be in the same package") } } for importPath, pkg := range fileList { for _, file1 := range pkg { for _, file2 := range pkg { if file1.Package != file2.Package { return fmt.Errorf( "%s and %s define the same import path (%s) with different package names (%s vs %s)", file1.Declaree, file2.Declaree, importPath, file1.Package, file2.Package, ) } } } } return nil } type TypeMap map[string]TypeMapEntry func (tm TypeMap) Exists(typeName string) bool { _, ok := tm[typeName] return ok } func (tm TypeMap) UserDefined(typeName string) bool { m, ok := tm[typeName] return ok && len(m.Model) > 0 } func (tm TypeMap) Check() error { for typeName, entry := range tm { for _, model := range entry.Model { if strings.LastIndex(model, ".") < strings.LastIndex(model, "/") { return fmt.Errorf( "model %s: invalid type specifier \"%s\" - you need to specify a struct to map to", typeName, entry.Model, ) } } if len(entry.Model) == 0 { for enum, v := range entry.EnumValues { if v.Value != "" { return fmt.Errorf( "model is empty for: %v, but enum value is specified for %v", typeName, enum, ) } } } } return nil } func (tm TypeMap) ReferencedPackages() []string { var pkgs []string for _, typ := range tm { for _, model := range typ.Model { if model == "map[string]any" || model == "map[string]interface{}" || model == "any" || model == "interface{}" { continue } pkg, _ := code.PkgAndType(model) if pkg == "" || slices.Contains(pkgs, pkg) { continue } pkgs = append(pkgs, code.QualifyPackagePath(pkg)) } } sort.Slice(pkgs, func(i, j int) bool { return pkgs[i] > pkgs[j] }) return pkgs } func (tm TypeMap) Add(name, goType string) { modelCfg := tm[name] modelCfg.Model = append(modelCfg.Model, goType) tm[name] = modelCfg } func (tm TypeMap) ForceGenerate(name string, forceGenerate bool) { modelCfg := tm[name] modelCfg.ForceGenerate = forceGenerate tm[name] = modelCfg } type DirectiveConfig struct { SkipRuntime bool `yaml:"skip_runtime"` // If the directive implementation is statically defined, don't provide a hook for it // in the generated server. This is useful for directives that are implemented // by plugins or the runtime itself. // // The function implemmentation should be provided here as a string. // // The function should have the following signature: // func(ctx context.Context, obj any, next graphql.Resolver[, directive arguments if any]) (res // any, err error) Implementation *string } // findCfg searches for the config file in this directory and all parents up the tree // looking for the closest match func findCfg() (string, error) { dir, err := os.Getwd() if err != nil { return "", fmt.Errorf("unable to get working dir to findCfg: %w", err) } cfg := findCfgInDir(dir) for cfg == "" && dir != filepath.Dir(dir) { dir = filepath.Dir(dir) cfg = findCfgInDir(dir) } if cfg == "" { return "", os.ErrNotExist } return cfg, nil } func findCfgInDir(dir string) string { for _, cfgName := range cfgFilenames { path := filepath.Join(dir, cfgName) if _, err := os.Stat(path); err == nil { return path } } return "" } func (c *Config) autobind() error { if len(c.AutoBind) == 0 { return nil } ps := c.Packages.LoadAll(c.AutoBind...) for _, t := range c.Schema.Types { if c.Models.UserDefined(t.Name) || c.Models[t.Name].ForceGenerate { continue } for i, p := range ps { if p == nil || p.Module == nil { return fmt.Errorf( "unable to load %s - make sure you're using an import path to a package that exists", c.AutoBind[i], ) } autobindType := c.lookupAutobindType(p, t) if autobindType != nil { c.Models.Add(t.Name, autobindType.Pkg().Path()+"."+autobindType.Name()) break } } } for i, t := range c.Models { if t.ForceGenerate { continue } for j, m := range t.Model { pkg, typename := code.PkgAndType(m) // skip anything that looks like an import path if strings.Contains(pkg, "/") { continue } for _, p := range ps { if p.Name != pkg { continue } if t := p.Types.Scope().Lookup(typename); t != nil { c.Models[i].Model[j] = t.Pkg().Path() + "." + t.Name() break } } } } return nil } func (c *Config) lookupAutobindType(p *packages.Package, schemaType *ast.Definition) types.Object { // Try binding to either the original schema type name, or the normalized go type name for _, lookupName := range []string{schemaType.Name, templates.ToGo(schemaType.Name)} { if t := p.Types.Scope().Lookup(lookupName); t != nil { return t } } return nil } func (c *Config) injectBuiltins() { builtins := TypeMap{ "__Directive": { Model: StringList{"github.com/99designs/gqlgen/graphql/introspection.Directive"}, }, "__DirectiveLocation": {Model: StringList{"github.com/99designs/gqlgen/graphql.String"}}, "__Type": { Model: StringList{"github.com/99designs/gqlgen/graphql/introspection.Type"}, }, "__TypeKind": {Model: StringList{"github.com/99designs/gqlgen/graphql.String"}}, "__Field": { Model: StringList{"github.com/99designs/gqlgen/graphql/introspection.Field"}, }, "__EnumValue": { Model: StringList{"github.com/99designs/gqlgen/graphql/introspection.EnumValue"}, }, "__InputValue": { Model: StringList{"github.com/99designs/gqlgen/graphql/introspection.InputValue"}, }, "__Schema": { Model: StringList{"github.com/99designs/gqlgen/graphql/introspection.Schema"}, }, "Float": { Model: StringList{"github.com/99designs/gqlgen/graphql.FloatContext"}, }, "String": {Model: StringList{"github.com/99designs/gqlgen/graphql.String"}}, "Boolean": {Model: StringList{"github.com/99designs/gqlgen/graphql.Boolean"}}, "Int": { // FIXME: using int / int64 for Int is not spec compliant and introduces // security risks. We should default to int32. Model: StringList{ "github.com/99designs/gqlgen/graphql.Int", "github.com/99designs/gqlgen/graphql.Int32", "github.com/99designs/gqlgen/graphql.Int64", }, }, "ID": { Model: StringList{ "github.com/99designs/gqlgen/graphql.ID", "github.com/99designs/gqlgen/graphql.IntID", }, }, } for typeName, entry := range builtins { if !c.Models.Exists(typeName) { c.Models[typeName] = entry } } // These are additional types that are injected if defined in the schema as scalars. extraBuiltins := TypeMap{ "Int64": { Model: StringList{ "github.com/99designs/gqlgen/graphql.Int", "github.com/99designs/gqlgen/graphql.Int64", }, }, "Time": {Model: StringList{"github.com/99designs/gqlgen/graphql.Time"}}, "Map": {Model: StringList{"github.com/99designs/gqlgen/graphql.Map"}}, "Upload": {Model: StringList{"github.com/99designs/gqlgen/graphql.Upload"}}, "Any": {Model: StringList{"github.com/99designs/gqlgen/graphql.Any"}}, } for typeName, entry := range extraBuiltins { if t, ok := c.Schema.Types[typeName]; !c.Models.Exists(typeName) && ok && t.Kind == ast.Scalar { c.Models[typeName] = entry } } } func (c *Config) LoadSchema() error { if c.Packages != nil { c.Packages = code.NewPackages( code.WithBuildTags(c.GoBuildTags...), code.PackagePrefixToCache("github.com/99designs/gqlgen/graphql"), code.WithPreloadNames(templatePackageNames...), code.WithLightModePrefetch(c.GetUseLightModePrefetch()), ) } if err := c.check(); err != nil { return err } schema, err := gqlparser.LoadSchema(c.Sources...) if err != nil { return err } if schema.Query == nil { schema.Query = &ast.Definition{ Kind: ast.Object, Name: "Query", } schema.Types["Query"] = schema.Query } c.Schema = schema return nil } func abs(path string) string { absPath, err := filepath.Abs(path) if err != nil { panic(err) } return filepath.ToSlash(absPath) } func newNotApplicableError(directive, argument string, pos ast.Position) error { return fmt.Errorf( "argument '%s' for directive @%s (src: %s, line: %d) not applicable for user-defined models", argument, directive, pos.Src.Name, pos.Line, ) } func newCannotBeEmptyError(directive, argument string, pos ast.Position) error { return fmt.Errorf( "argument '%s' for directive @%s (src: %s, line: %d) cannot by empty", argument, directive, pos.Src.Name, pos.Line, ) } ================================================ FILE: codegen/config/config_directive_test.go ================================================ package config import ( "testing" "github.com/stretchr/testify/require" "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" ) func TestDirectiveParsing(t *testing.T) { t.Run("autoBindGetterHaser argument in goField", func(t *testing.T) { cfg := Config{ Models: TypeMap{}, Directives: map[string]DirectiveConfig{}, } cfg.Schema = gqlparser.MustLoadSchema(&ast.Source{Name: "schema.graphql", Input: ` directive @goField( forceResolver: Boolean name: String omittable: Boolean autoBindGetterHaser: Boolean ) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION type MyType { field1: String @goField(autoBindGetterHaser: true) field2: String @goField(autoBindGetterHaser: false) field3: String } `}) err := cfg.injectTypesFromSchema() require.NoError(t, err) field1 := cfg.Models["MyType"].Fields["field1"] require.NotNil(t, field1.AutoBindGetterHaser) require.True(t, *field1.AutoBindGetterHaser) field2 := cfg.Models["MyType"].Fields["field2"] require.NotNil(t, field2.AutoBindGetterHaser) require.False(t, *field2.AutoBindGetterHaser) field3 := cfg.Models["MyType"].Fields["field3"] require.Nil(t, field3.AutoBindGetterHaser) }) } ================================================ FILE: codegen/config/config_schema_json_test.go ================================================ package config import ( "encoding/json" "os" "reflect" "strings" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) // jsonSchemaProperty represents a node in a JSON Schema tree, capturing // the three ways sub-fields can be described: direct properties, map-like // additionalProperties, and array items. type jsonSchemaProperty struct { Properties map[string]jsonSchemaProperty `json:"properties"` AdditionalProperties *jsonSchemaProperty `json:"additionalProperties"` Items *jsonSchemaProperty `json:"items"` } // extractYAMLTagName returns the yaml tag name for a struct field, // or "" if the field should be skipped (no tag, "-", or empty name). func extractYAMLTagName(field reflect.StructField) string { tag := field.Tag.Get("yaml") if tag == "" || tag == "-" { return "" } name, _, _ := strings.Cut(tag, ",") return name } // resolveSchemaProps determines which JSON Schema property map should be used // to validate sub-fields for the given Go type: // - struct / *struct → properties // - map[K]struct → additionalProperties.properties // - []struct → items.properties func resolveSchemaProps( goType reflect.Type, prop jsonSchemaProperty, ) (structType reflect.Type, schemaProps map[string]jsonSchemaProperty) { // Unwrap pointer(s). for goType.Kind() == reflect.Ptr { goType = goType.Elem() } switch goType.Kind() { case reflect.Struct: return goType, prop.Properties case reflect.Map: valType := goType.Elem() for valType.Kind() == reflect.Ptr { valType = valType.Elem() } if valType.Kind() == reflect.Struct && prop.AdditionalProperties != nil { return valType, prop.AdditionalProperties.Properties } case reflect.Slice: elemType := goType.Elem() for elemType.Kind() == reflect.Ptr { elemType = elemType.Elem() } if elemType.Kind() == reflect.Struct && prop.Items != nil { return elemType, prop.Items.Properties } } return nil, nil } // checkStructFieldsInSchema recursively verifies that every yaml-tagged field // in structType has a corresponding key in schemaProps, then recurses into // nested structs, maps-with-struct-values, and slices-of-structs. func checkStructFieldsInSchema( t *testing.T, structType reflect.Type, schemaProps map[string]jsonSchemaProperty, path string, ) { t.Helper() if len(schemaProps) == 0 { return } for i := range structType.NumField() { field := structType.Field(i) yamlName := extractYAMLTagName(field) if yamlName == "" { continue } assert.Contains(t, schemaProps, yamlName, "%s.%s (yaml:%q) is missing from gqlgen.schema.json at path %s", structType.Name(), field.Name, yamlName, path) prop, ok := schemaProps[yamlName] if !ok { continue } // Recurse into nested types. childStruct, childProps := resolveSchemaProps(field.Type, prop) if childStruct != nil && len(childProps) > 0 { checkStructFieldsInSchema(t, childStruct, childProps, path+"."+yamlName) } } } // TestConfigFieldsPresentInSchemaJSON verifies that every yaml-tagged field // in the Config struct (and all nested structs, map-value structs, slice-element // structs) has a corresponding property in the gqlgen.schema.json file. // // All nested sections are discovered via reflection — no manual list needed. func TestConfigFieldsPresentInSchemaJSON(t *testing.T) { schemaPath := "../../gqlgen.schema.json" data, err := os.ReadFile(schemaPath) require.NoError(t, err, "failed to read gqlgen.schema.json") var schema jsonSchemaProperty require.NoError(t, json.Unmarshal(data, &schema), "failed to parse gqlgen.schema.json") // Deprecated fields we intentionally do NOT require in the schema. deprecated := map[string]bool{ "federated": true, } configType := reflect.TypeOf(Config{}) for i := range configType.NumField() { field := configType.Field(i) yamlName := extractYAMLTagName(field) if yamlName == "" || deprecated[yamlName] { continue } assert.Contains(t, schema.Properties, yamlName, "Config.%s (yaml:%q) is missing from gqlgen.schema.json top-level properties", field.Name, yamlName) prop, ok := schema.Properties[yamlName] if !ok { continue } // Recurse into nested struct / map / slice types. childStruct, childProps := resolveSchemaProps(field.Type, prop) if childStruct != nil && len(childProps) > 0 { checkStructFieldsInSchema(t, childStruct, childProps, yamlName) } } } ================================================ FILE: codegen/config/config_test.go ================================================ package config import ( "io/fs" "os" "path/filepath" "runtime" "strings" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" "github.com/99designs/gqlgen/internal/code" ) func TestLoadConfig(t *testing.T) { t.Run("config does not exist", func(t *testing.T) { _, err := LoadConfig("doesnotexist.yml") require.Error(t, err) }) } func TestReadConfig(t *testing.T) { t.Run("empty config", func(t *testing.T) { _, err := ReadConfig(strings.NewReader("")) require.EqualError(t, err, "unable to parse config: EOF") }) t.Run("malformed config", func(t *testing.T) { cfgFile, err := os.Open("testdata/cfg/malformedconfig.yml") require.NoError(t, err) t.Cleanup(func() { _ = cfgFile.Close() }) _, err = ReadConfig(cfgFile) actualErr := strings.ReplaceAll(err.Error(), "\r\n", "\n") require.Equal( t, "unable to parse config: [1:1] string was used where mapping is expected\n> 1 | asdf\n ^\n", actualErr, ) }) t.Run("unknown keys", func(t *testing.T) { cfgFile, err := os.Open("testdata/cfg/unknownkeys.yml") require.NoError(t, err) t.Cleanup(func() { _ = cfgFile.Close() }) _, err = ReadConfig(cfgFile) actualErr := strings.ReplaceAll(err.Error(), "\r\n", "\n") require.Equal( t, "unable to parse config: [2:1] unknown field \"unknown\"\n 1 | schema: outer\n> 2 | unknown: foo\n ^\n", actualErr, ) }) t.Run("globbed filenames", func(t *testing.T) { cfgFile, err := os.Open("testdata/cfg/glob.yml") require.NoError(t, err) t.Cleanup(func() { _ = cfgFile.Close() }) c, err := ReadConfig(cfgFile) require.NoError(t, err) if runtime.GOOS == "windows" { require.Equal(t, `testdata\cfg\glob\bar\bar with spaces.graphql`, c.SchemaFilename[0]) require.Equal(t, `testdata\cfg\glob\foo\foo.graphql`, c.SchemaFilename[1]) } else { require.Equal(t, "testdata/cfg/glob/bar/bar with spaces.graphql", c.SchemaFilename[0]) require.Equal(t, "testdata/cfg/glob/foo/foo.graphql", c.SchemaFilename[1]) } }) t.Run("unwalkable path", func(t *testing.T) { cfgFile, err := os.Open("testdata/cfg/unwalkable.yml") require.NoError(t, err) t.Cleanup(func() { _ = cfgFile.Close() }) _, err = ReadConfig(cfgFile) if runtime.GOOS == "windows" { require.ErrorContains(t, err, "failed to walk schema at root not_walkable/: ") // TODO(steve): Now that Go 1.25 is min supported, this could be improved. // Go 1.24 and below report "CreateFile" but 1.25 and above report "GetFileAttributesEx" // in error // See https://go.dev/doc/go1.25#ospkgos require.ErrorContains( t, err, " not_walkable/: The system cannot find the file specified.", ) } else { require.EqualError( t, err, "failed to walk schema at root not_walkable/: lstat not_walkable/: no such file or directory", ) } }) } func TestLoadConfigFromDefaultLocation(t *testing.T) { testDir, err := os.Getwd() require.NoError(t, err) var cfg *Config t.Run("will find closest match", func(t *testing.T) { t.Chdir(filepath.Join(testDir, "testdata", "cfg", "subdir")) cfg, err = LoadConfigFromDefaultLocations() require.NoError(t, err) require.Equal(t, StringList{"inner"}, cfg.SchemaFilename) }) t.Run("will find config in parent dirs", func(t *testing.T) { t.Chdir(filepath.Join(testDir, "testdata", "cfg", "otherdir")) cfg, err = LoadConfigFromDefaultLocations() require.NoError(t, err) require.Equal(t, StringList{"outer"}, cfg.SchemaFilename) }) t.Run("will return error if config doesn't exist", func(t *testing.T) { t.Chdir(testDir) cfg, err = LoadConfigFromDefaultLocations() require.ErrorIs(t, err, fs.ErrNotExist) }) } func TestLoadDefaultConfig(t *testing.T) { testDir, err := os.Getwd() require.NoError(t, err) var cfg *Config t.Run("will find the schema", func(t *testing.T) { t.Chdir(filepath.Join(testDir, "testdata", "defaultconfig")) cfg, err = LoadDefaultConfig() require.NoError(t, err) require.NotEmpty(t, cfg.Sources) }) t.Run("will return error if schema doesn't exist", func(t *testing.T) { t.Chdir(testDir) cfg, err = LoadDefaultConfig() require.ErrorIs(t, err, fs.ErrNotExist) }) } func TestReferencedPackages(t *testing.T) { t.Run("valid", func(t *testing.T) { tm := TypeMap{ "Foo": {Model: StringList{"github.com/test.Foo"}}, "Bar": {Model: StringList{"github.com/test.Bar"}}, "Baz": {Model: StringList{"github.com/otherpkg.Baz"}}, "Map": {Model: StringList{"map[string]any"}}, "SkipResolver": { Fields: map[string]TypeMapField{ "field": {Resolver: false}, }, }, } pkgs := tm.ReferencedPackages() assert.Equal(t, []string{"github.com/test", "github.com/otherpkg"}, pkgs) }) } func TestTypeMapFieldBatch(t *testing.T) { t.Run("batch flag is parsed from config", func(t *testing.T) { cfg, err := ReadConfig(strings.NewReader(` schema: schema.graphql exec: filename: generated.go models: User: fields: posts: resolver: true batch: true name: resolver: false `)) require.NoError(t, err) require.True(t, cfg.Models["User"].Fields["posts"].Batch) require.True(t, cfg.Models["User"].Fields["posts"].Resolver) require.False(t, cfg.Models["User"].Fields["name"].Batch) }) t.Run("batch flag defaults to false when not specified", func(t *testing.T) { cfg, err := ReadConfig(strings.NewReader(` schema: schema.graphql exec: filename: generated.go models: User: fields: posts: resolver: true `)) require.NoError(t, err) require.False(t, cfg.Models["User"].Fields["posts"].Batch) }) } func TestConfigCheck(t *testing.T) { for _, execLayout := range []ExecLayout{ExecLayoutSingleFile, ExecLayoutFollowSchema} { t.Run(string(execLayout), func(t *testing.T) { t.Run("invalid config format due to conflicting package names", func(t *testing.T) { config := Config{ Exec: ExecConfig{ Layout: execLayout, Filename: "generated/exec.go", DirName: "generated", Package: "graphql", }, Model: PackageConfig{Filename: "generated/models.go"}, } require.EqualError( t, config.check(), "exec and model define the same import path (github.com/99designs/gqlgen/codegen/config/generated) with different package names (graphql vs generated)", ) }) t.Run("federation must be in exec package", func(t *testing.T) { config := Config{ Exec: ExecConfig{ Layout: execLayout, Filename: "generated/exec.go", DirName: "generated", }, Federation: PackageConfig{Filename: "anotherpkg/federation.go"}, } require.EqualError( t, config.check(), "federation and exec must be in the same package", ) }) t.Run("federation must have same package name as exec", func(t *testing.T) { config := Config{ Exec: ExecConfig{ Layout: execLayout, Filename: "generated/exec.go", DirName: "generated", }, Federation: PackageConfig{ Filename: "generated/federation.go", Package: "federation", }, } require.EqualError( t, config.check(), "exec and federation define the same import path (github.com/99designs/gqlgen/codegen/config/generated) with different package names (generated vs federation)", ) }) }) } } func TestAutobinding(t *testing.T) { t.Run("valid paths", func(t *testing.T) { cfg := Config{ Models: TypeMap{}, AutoBind: []string{ "github.com/99designs/gqlgen/codegen/config/testdata/autobinding/chat", "github.com/99designs/gqlgen/codegen/config/testdata/autobinding/scalars/model", }, Packages: code.NewPackages(), } cfg.Schema = gqlparser.MustLoadSchema(&ast.Source{Name: "TestAutobinding.schema", Input: ` scalar Banned type Message { id: ID } `}) require.NoError(t, cfg.autobind()) require.Equal( t, "github.com/99designs/gqlgen/codegen/config/testdata/autobinding/scalars/model.Banned", cfg.Models["Banned"].Model[0], ) require.Equal( t, "github.com/99designs/gqlgen/codegen/config/testdata/autobinding/chat.Message", cfg.Models["Message"].Model[0], ) }) t.Run("normalized type names", func(t *testing.T) { cfg := Config{ Models: TypeMap{}, AutoBind: []string{ "github.com/99designs/gqlgen/codegen/config/testdata/autobinding/chat", "github.com/99designs/gqlgen/codegen/config/testdata/autobinding/scalars/model", }, Packages: code.NewPackages(), } cfg.Schema = gqlparser.MustLoadSchema(&ast.Source{Name: "TestAutobinding.schema", Input: ` scalar Banned type Message { id: ID } enum ProductSKU { ProductSkuTrial } type ChatAPI { id: ID } `}) require.NoError(t, cfg.autobind()) require.Equal( t, "github.com/99designs/gqlgen/codegen/config/testdata/autobinding/scalars/model.Banned", cfg.Models["Banned"].Model[0], ) require.Equal( t, "github.com/99designs/gqlgen/codegen/config/testdata/autobinding/chat.Message", cfg.Models["Message"].Model[0], ) require.Equal( t, "github.com/99designs/gqlgen/codegen/config/testdata/autobinding/chat.ProductSku", cfg.Models["ProductSKU"].Model[0], ) require.Equal( t, "github.com/99designs/gqlgen/codegen/config/testdata/autobinding/chat.ChatAPI", cfg.Models["ChatAPI"].Model[0], ) }) t.Run("with file path", func(t *testing.T) { cfg := Config{ Models: TypeMap{}, AutoBind: []string{ "../chat", }, Packages: code.NewPackages(), } cfg.Schema = gqlparser.MustLoadSchema(&ast.Source{Name: "TestAutobinding.schema", Input: ` scalar Banned type Message { id: ID } `}) require.EqualError( t, cfg.autobind(), "unable to load ../chat - make sure you're using an import path to a package that exists", ) }) t.Run("protobuf getters and hasers", func(t *testing.T) { cfg := Config{ Models: TypeMap{}, AutoBind: []string{ "github.com/99designs/gqlgen/codegen/config/testdata/autobinding/protomodel", }, AutobindGetterHaser: true, // Enable protobuf getter/haser support Packages: code.NewPackages(), } cfg.Schema = gqlparser.MustLoadSchema(&ast.Source{Name: "TestAutobinding.schema", Input: ` type ProtoMessage { name: String description: String count: Int! } `}) require.NoError(t, cfg.autobind()) require.Equal( t, "github.com/99designs/gqlgen/codegen/config/testdata/autobinding/protomodel.ProtoMessage", cfg.Models["ProtoMessage"].Model[0], ) }) } func TestLoadSchema(t *testing.T) { t.Parallel() getConfig := func(t *testing.T) *Config { t.Helper() cfgFile, err := os.Open("testdata/cfg/glob.yml") require.NoError(t, err) t.Cleanup(func() { _ = cfgFile.Close() }) c, err := ReadConfig(cfgFile) require.NoError(t, err) return c } t.Run("valid schema", func(t *testing.T) { cfg := getConfig(t) cfg.Sources = []*ast.Source{ { Input: ` type Query { message: Message } type Message { id: ID } `, }, } err := cfg.LoadSchema() require.NoError(t, err) require.NotNil(t, cfg.Schema) }) t.Run("invalid schema", func(t *testing.T) { cfg := getConfig(t) cfg.Sources = []*ast.Source{ { Input: ` type Query { // should have fields here } type Message { id: ID } `, }, } err := cfg.LoadSchema() require.Error(t, err) require.Nil(t, cfg.Schema) }) } func FuzzReadConfig(f *testing.F) { f.Add([]byte(`schema: schema.graphql`)) f.Add([]byte(`schema: - "*.graphql" model: filename: models_gen.go`)) f.Add([]byte(`schema: schema.graphql exec: filename: generated.go package: graphql`)) f.Add([]byte(`schema: schema.graphql model: filename: models.go package: models exec: filename: exec.go`)) f.Add([]byte(``)) f.Add([]byte(`asdf`)) f.Add([]byte(`schema: outer unknown: foo`)) f.Fuzz(func(t *testing.T, configData []byte) { cfg, err := ReadConfig(strings.NewReader(string(configData))) if err == nil && cfg == nil { t.Fatal("ReadConfig returned nil config without error") } }) } func TestPerformanceOptions(t *testing.T) { t.Run("GetFastValidation defaults to false", func(t *testing.T) { cfg := &Config{} require.False(t, cfg.GetFastValidation()) }) t.Run("GetFastValidation returns true when set", func(t *testing.T) { val := true cfg := &Config{FastValidation: &val} require.True(t, cfg.GetFastValidation()) }) t.Run("GetSkipImportGrouping defaults to false", func(t *testing.T) { cfg := &Config{} require.False(t, cfg.GetSkipImportGrouping()) }) t.Run("GetSkipImportGrouping returns true when set", func(t *testing.T) { val := true cfg := &Config{SkipImportGrouping: &val} require.True(t, cfg.GetSkipImportGrouping()) }) t.Run("GetUseLightModePrefetch defaults to false", func(t *testing.T) { cfg := &Config{} require.False(t, cfg.GetUseLightModePrefetch()) }) t.Run("GetUseLightModePrefetch returns true when set", func(t *testing.T) { val := true cfg := &Config{UseLightModePrefetch: &val} require.True(t, cfg.GetUseLightModePrefetch()) }) t.Run("GetUseBufferPooling defaults to false", func(t *testing.T) { cfg := &Config{} require.False(t, cfg.GetUseBufferPooling()) }) t.Run("GetUseBufferPooling returns true when set", func(t *testing.T) { val := true cfg := &Config{UseBufferPooling: &val} require.True(t, cfg.GetUseBufferPooling()) }) t.Run("GetPruneOptions returns correct values", func(t *testing.T) { skipImport := true useBuffer := true cfg := &Config{SkipImportGrouping: &skipImport, UseBufferPooling: &useBuffer} opts := cfg.GetPruneOptions() require.True(t, opts.SkipImportGrouping) require.True(t, opts.UseBufferPooling) }) } ================================================ FILE: codegen/config/exec.go ================================================ package config import ( "errors" "fmt" "go/types" "path/filepath" "strings" "github.com/99designs/gqlgen/internal/code" ) type ExecConfig struct { Package string `yaml:"package,omitempty"` Layout ExecLayout `yaml:"layout,omitempty"` // Default: single-file // Only for single-file layout: Filename string `yaml:"filename,omitempty"` // Only for follow-schema layout: FilenameTemplate string `yaml:"filename_template,omitempty"` // String template with {name} as placeholder for base name. DirName string `yaml:"dir"` // Maximum number of goroutines in concurrency to use when running multiple child resolvers // Suppressing the number of goroutines generated can reduce memory consumption per request, // but processing time may increase due to the reduced number of concurrences // Default: 0 (unlimited) WorkerLimit uint `yaml:"worker_limit"` } type ExecLayout string var ( // Write all generated code to a single file. ExecLayoutSingleFile ExecLayout = "single-file" // Write generated code to a directory, generating one Go source file for each GraphQL schema // file. ExecLayoutFollowSchema ExecLayout = "follow-schema" ) func (r *ExecConfig) Check() error { if r.Layout == "" { r.Layout = ExecLayoutSingleFile } switch r.Layout { case ExecLayoutSingleFile: if r.Filename == "" { return errors.New("filename must be specified when using single-file layout") } if !strings.HasSuffix(r.Filename, ".go") { return errors.New( "filename should be path to a go source file when using single-file layout", ) } r.Filename = abs(r.Filename) case ExecLayoutFollowSchema: if r.DirName == "" { return errors.New("dir must be specified when using follow-schema layout") } r.DirName = abs(r.DirName) default: return fmt.Errorf("invalid layout %s", r.Layout) } if strings.ContainsAny(r.Package, "./\\") { return errors.New( "package should be the output package name only, do not include the output filename", ) } if r.Package == "" && r.Dir() != "" { r.Package = code.NameForDir(r.Dir()) } return nil } func (r *ExecConfig) ImportPath() string { if r.Dir() == "" { return "" } return code.ImportPathForDir(r.Dir()) } func (r *ExecConfig) Dir() string { switch r.Layout { case ExecLayoutSingleFile: if r.Filename == "" { return "" } return filepath.Dir(r.Filename) case ExecLayoutFollowSchema: return abs(r.DirName) default: panic("invalid layout " + r.Layout) } } func (r *ExecConfig) Pkg() *types.Package { if r.Dir() == "" { return nil } return types.NewPackage(r.ImportPath(), r.Package) } func (r *ExecConfig) IsDefined() bool { return r.Filename != "" || r.DirName != "" } ================================================ FILE: codegen/config/initialisms.go ================================================ package config import ( "strings" "github.com/99designs/gqlgen/codegen/templates" ) // GoInitialismsConfig allows to modify the default behavior of naming Go methods, types and // properties type GoInitialismsConfig struct { // If true, the Initialisms won't get appended to the default ones but replace them ReplaceDefaults bool `yaml:"replace_defaults"` // Custom initialisms to be added or to replace the default ones Initialisms []string `yaml:"initialisms"` } // setInitialisms adjusts GetInitialisms based on its settings. func (i GoInitialismsConfig) setInitialisms() { toUse := i.determineGoInitialisms() templates.GetInitialisms = func() map[string]bool { return toUse } } // determineGoInitialisms returns the Go initialisms to be used, based on its settings. func (i GoInitialismsConfig) determineGoInitialisms() (initialismsToUse map[string]bool) { if i.ReplaceDefaults { initialismsToUse = make(map[string]bool, len(i.Initialisms)) for _, initialism := range i.Initialisms { initialismsToUse[strings.ToUpper(initialism)] = true } } else { initialismsToUse = make( map[string]bool, len(templates.CommonInitialisms)+len(i.Initialisms), ) for initialism, value := range templates.CommonInitialisms { initialismsToUse[strings.ToUpper(initialism)] = value } for _, initialism := range i.Initialisms { initialismsToUse[strings.ToUpper(initialism)] = true } } return initialismsToUse } ================================================ FILE: codegen/config/initialisms_test.go ================================================ package config import ( "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/codegen/templates" ) func TestGoInitialismsConfig(t *testing.T) { t.Run("load go initialisms config", func(t *testing.T) { config, err := LoadConfig("testdata/cfg/goInitialisms.yml") require.NoError(t, err) require.True(t, config.GoInitialisms.ReplaceDefaults) require.Len(t, config.GoInitialisms.Initialisms, 2) }) t.Run("empty initialism config doesn't change anything", func(t *testing.T) { tt := GoInitialismsConfig{} result := tt.determineGoInitialisms() assert.Len(t, result, len(templates.CommonInitialisms)) }) t.Run("initialism config appends if desired", func(t *testing.T) { tt := GoInitialismsConfig{ReplaceDefaults: false, Initialisms: []string{"ASDF"}} result := tt.determineGoInitialisms() assert.Len(t, result, len(templates.CommonInitialisms)+1) assert.True(t, result["ASDF"]) }) t.Run("initialism config replaces if desired", func(t *testing.T) { tt := GoInitialismsConfig{ReplaceDefaults: true, Initialisms: []string{"ASDF"}} result := tt.determineGoInitialisms() assert.Len(t, result, 1) assert.True(t, result["ASDF"]) }) t.Run("initialism config uppercases the initialisms", func(t *testing.T) { tt := GoInitialismsConfig{Initialisms: []string{"asdf"}} result := tt.determineGoInitialisms() assert.True(t, result["ASDF"]) }) } ================================================ FILE: codegen/config/package.go ================================================ package config import ( "errors" "go/types" "path/filepath" "strings" "github.com/99designs/gqlgen/internal/code" ) type PackageConfig struct { Filename string `yaml:"filename,omitempty"` Package string `yaml:"package,omitempty"` Version int `yaml:"version,omitempty"` ModelTemplate string `yaml:"model_template,omitempty"` Options map[string]bool `yaml:"options,omitempty"` } func (c *PackageConfig) ImportPath() string { if !c.IsDefined() { return "" } return code.ImportPathForDir(c.Dir()) } func (c *PackageConfig) Dir() string { if !c.IsDefined() { return "" } return filepath.Dir(c.Filename) } func (c *PackageConfig) Pkg() *types.Package { if !c.IsDefined() { return nil } return types.NewPackage(c.ImportPath(), c.Package) } func (c *PackageConfig) IsDefined() bool { return c.Filename != "" } func (c *PackageConfig) Check() error { if strings.ContainsAny(c.Package, "./\\") { return errors.New( "package should be the output package name only, do not include the output filename", ) } if c.Filename == "" { return errors.New("filename must be specified") } if !strings.HasSuffix(c.Filename, ".go") { return errors.New("filename should be path to a go source file") } c.Filename = abs(c.Filename) // If Package is not set, first attempt to load the package at the output dir. If that fails // fallback to just the base dir name of the output filename. if c.Package == "" { c.Package = code.NameForDir(c.Dir()) } return nil } ================================================ FILE: codegen/config/package_test.go ================================================ package config import ( "path/filepath" "testing" "github.com/stretchr/testify/require" ) func TestPackageConfig(t *testing.T) { t.Run("when given just a filename", func(t *testing.T) { p := PackageConfig{Filename: "testdata/example.go"} require.True(t, p.IsDefined()) require.NoError(t, p.Check()) require.Equal(t, "config_test_data", p.Package) require.Equal(t, "github.com/99designs/gqlgen/codegen/config/testdata", p.ImportPath()) require.Equal(t, "config_test_data", p.Pkg().Name()) require.Equal(t, "github.com/99designs/gqlgen/codegen/config/testdata", p.Pkg().Path()) require.Contains(t, filepath.ToSlash(p.Filename), "codegen/config/testdata/example.go") require.Contains(t, filepath.ToSlash(p.Dir()), "codegen/config/testdata") }) t.Run("when given both", func(t *testing.T) { p := PackageConfig{Filename: "testdata/example.go", Package: "wololo"} require.True(t, p.IsDefined()) require.NoError(t, p.Check()) require.Equal(t, "wololo", p.Package) require.Equal(t, "github.com/99designs/gqlgen/codegen/config/testdata", p.ImportPath()) require.Equal(t, "wololo", p.Pkg().Name()) require.Equal(t, "github.com/99designs/gqlgen/codegen/config/testdata", p.Pkg().Path()) require.Contains(t, filepath.ToSlash(p.Filename), "codegen/config/testdata/example.go") require.Contains(t, filepath.ToSlash(p.Dir()), "codegen/config/testdata") }) t.Run("when given nothing", func(t *testing.T) { p := PackageConfig{} require.False(t, p.IsDefined()) require.EqualError(t, p.Check(), "filename must be specified") require.Empty(t, p.Package) require.Empty(t, p.ImportPath()) require.Nil(t, p.Pkg()) require.Empty(t, p.Filename) require.Empty(t, p.Dir()) }) t.Run("when given invalid filename", func(t *testing.T) { p := PackageConfig{Filename: "wololo.sql"} require.True(t, p.IsDefined()) require.EqualError(t, p.Check(), "filename should be path to a go source file") }) t.Run("when package includes a filename", func(t *testing.T) { p := PackageConfig{Filename: "foo.go", Package: "foo/foo.go"} require.True(t, p.IsDefined()) require.EqualError( t, p.Check(), "package should be the output package name only, do not include the output filename", ) }) } ================================================ FILE: codegen/config/resolver.go ================================================ package config import ( "errors" "fmt" "go/types" "path/filepath" "strings" "github.com/99designs/gqlgen/internal/code" ) type ResolverConfig struct { Filename string `yaml:"filename,omitempty"` FilenameTemplate string `yaml:"filename_template,omitempty"` Package string `yaml:"package,omitempty"` Type string `yaml:"type,omitempty"` Layout ResolverLayout `yaml:"layout,omitempty"` DirName string `yaml:"dir"` OmitTemplateComment bool `yaml:"omit_template_comment,omitempty"` ResolverTemplate string `yaml:"resolver_template,omitempty"` PreserveResolver bool `yaml:"preserve_resolver,omitempty"` } type ResolverLayout string var ( LayoutSingleFile ResolverLayout = "single-file" LayoutFollowSchema ResolverLayout = "follow-schema" ) func (r *ResolverConfig) Check() error { if r.Layout == "" { r.Layout = LayoutSingleFile } if r.Type == "" { r.Type = "Resolver" } switch r.Layout { case LayoutSingleFile: if r.Filename == "" { return fmt.Errorf("filename must be specified with layout=%s", r.Layout) } if !strings.HasSuffix(r.Filename, ".go") { return fmt.Errorf( "filename should be path to a go source file with layout=%s", r.Layout, ) } r.Filename = abs(r.Filename) case LayoutFollowSchema: if r.DirName == "" { return fmt.Errorf("dirname must be specified with layout=%s", r.Layout) } r.DirName = abs(r.DirName) if r.Filename == "" { r.Filename = filepath.Join(r.DirName, "resolver.go") } else { r.Filename = abs(r.Filename) } default: return fmt.Errorf( "invalid layout %s. must be %s or %s", r.Layout, LayoutSingleFile, LayoutFollowSchema, ) } if strings.ContainsAny(r.Package, "./\\") { return errors.New( "package should be the output package name only, do not include the output filename", ) } if r.Package == "" && r.Dir() != "" { r.Package = code.NameForDir(r.Dir()) } return nil } func (r *ResolverConfig) ImportPath() string { if r.Dir() == "" { return "" } return code.ImportPathForDir(r.Dir()) } func (r *ResolverConfig) Dir() string { switch r.Layout { case LayoutSingleFile: if r.Filename == "" { return "" } return filepath.Dir(r.Filename) case LayoutFollowSchema: return r.DirName default: panic("invalid layout " + r.Layout) } } func (r *ResolverConfig) Pkg() *types.Package { if r.Dir() == "" { return nil } return types.NewPackage(r.ImportPath(), r.Package) } func (r *ResolverConfig) IsDefined() bool { return r.Filename != "" || r.DirName != "" } ================================================ FILE: codegen/config/resolver_test.go ================================================ package config import ( "path/filepath" "testing" "github.com/stretchr/testify/require" ) func TestResolverConfig(t *testing.T) { t.Run("single-file", func(t *testing.T) { t.Run("when given just a filename", func(t *testing.T) { p := ResolverConfig{Filename: "testdata/example.go"} require.True(t, p.IsDefined()) require.NoError(t, p.Check()) require.NoError(t, p.Check()) require.Equal(t, "config_test_data", p.Package) require.Equal(t, "github.com/99designs/gqlgen/codegen/config/testdata", p.ImportPath()) require.Equal(t, "config_test_data", p.Pkg().Name()) require.Equal(t, "github.com/99designs/gqlgen/codegen/config/testdata", p.Pkg().Path()) require.Contains(t, filepath.ToSlash(p.Filename), "codegen/config/testdata/example.go") require.Contains(t, filepath.ToSlash(p.Dir()), "codegen/config/testdata") }) t.Run("when given both", func(t *testing.T) { p := ResolverConfig{Filename: "testdata/example.go", Package: "wololo"} require.True(t, p.IsDefined()) require.NoError(t, p.Check()) require.NoError(t, p.Check()) require.Equal(t, "wololo", p.Package) require.Equal(t, "github.com/99designs/gqlgen/codegen/config/testdata", p.ImportPath()) require.Equal(t, "wololo", p.Pkg().Name()) require.Equal(t, "github.com/99designs/gqlgen/codegen/config/testdata", p.Pkg().Path()) require.Contains(t, filepath.ToSlash(p.Filename), "codegen/config/testdata/example.go") require.Contains(t, filepath.ToSlash(p.Dir()), "codegen/config/testdata") }) t.Run("when given nothing", func(t *testing.T) { p := ResolverConfig{} require.False(t, p.IsDefined()) require.EqualError(t, p.Check(), "filename must be specified with layout=single-file") require.Empty(t, p.Package) require.Empty(t, p.ImportPath()) require.Nil(t, p.Pkg()) require.Empty(t, p.Filename) require.Empty(t, p.Dir()) }) t.Run("when given invalid filename", func(t *testing.T) { p := ResolverConfig{Filename: "wololo.sql"} require.True(t, p.IsDefined()) require.EqualError( t, p.Check(), "filename should be path to a go source file with layout=single-file", ) }) t.Run("when package includes a filename", func(t *testing.T) { p := ResolverConfig{Filename: "foo.go", Package: "foo/foo.go"} require.True(t, p.IsDefined()) require.EqualError( t, p.Check(), "package should be the output package name only, do not include the output filename", ) }) }) t.Run("follow-schema", func(t *testing.T) { t.Run("when given just a dir", func(t *testing.T) { p := ResolverConfig{Layout: LayoutFollowSchema, DirName: "testdata"} require.True(t, p.IsDefined()) require.NoError(t, p.Check()) require.NoError(t, p.Check()) require.Equal(t, "config_test_data", p.Package) require.Equal(t, "github.com/99designs/gqlgen/codegen/config/testdata", p.ImportPath()) require.Equal(t, "config_test_data", p.Pkg().Name()) require.Equal(t, "github.com/99designs/gqlgen/codegen/config/testdata", p.Pkg().Path()) require.Contains(t, filepath.ToSlash(p.Filename), "codegen/config/testdata/resolver.go") require.Contains(t, p.Dir(), "codegen/config/testdata") }) t.Run("when given dir and package name", func(t *testing.T) { p := ResolverConfig{Layout: LayoutFollowSchema, DirName: "testdata", Package: "wololo"} require.True(t, p.IsDefined()) require.NoError(t, p.Check()) require.NoError(t, p.Check()) require.Equal(t, "wololo", p.Package) require.Equal(t, "github.com/99designs/gqlgen/codegen/config/testdata", p.ImportPath()) require.Equal(t, "wololo", p.Pkg().Name()) require.Equal(t, "github.com/99designs/gqlgen/codegen/config/testdata", p.Pkg().Path()) require.Contains(t, filepath.ToSlash(p.Filename), "codegen/config/testdata/resolver.go") require.Contains(t, p.Dir(), "codegen/config/testdata") }) t.Run("when given a filename", func(t *testing.T) { p := ResolverConfig{ Layout: LayoutFollowSchema, DirName: "testdata", Filename: "testdata/asdf.go", } require.True(t, p.IsDefined()) require.NoError(t, p.Check()) require.NoError(t, p.Check()) require.Equal(t, "config_test_data", p.Package) require.Equal(t, "github.com/99designs/gqlgen/codegen/config/testdata", p.ImportPath()) require.Equal(t, "config_test_data", p.Pkg().Name()) require.Equal(t, "github.com/99designs/gqlgen/codegen/config/testdata", p.Pkg().Path()) require.Contains(t, filepath.ToSlash(p.Filename), "codegen/config/testdata/asdf.go") require.Contains(t, p.Dir(), "codegen/config/testdata") }) t.Run("when given nothing", func(t *testing.T) { p := ResolverConfig{Layout: LayoutFollowSchema} require.False(t, p.IsDefined()) require.EqualError(t, p.Check(), "dirname must be specified with layout=follow-schema") require.Empty(t, p.Package) require.Empty(t, p.ImportPath()) require.Nil(t, p.Pkg()) require.Empty(t, p.Filename) require.Empty(t, p.Dir()) }) }) t.Run("invalid layout", func(t *testing.T) { p := ResolverConfig{Layout: "pies", Filename: "asdf.go"} require.True(t, p.IsDefined()) require.EqualError( t, p.Check(), "invalid layout pies. must be single-file or follow-schema", ) }) } ================================================ FILE: codegen/config/testdata/autobinding/chat/model.go ================================================ package chat import ( "time" ) type Message struct { ID string `json:"id"` Text string `json:"text"` CreatedBy string `json:"createdBy"` CreatedAt time.Time `json:"createdAt"` } type ProductSku string const ( ProductSkuTrial ProductSku = "Trial" ) type ChatAPI struct { ID string `json:"id"` } ================================================ FILE: codegen/config/testdata/autobinding/protomodel/model.go ================================================ package protomodel // ProtoMessage simulates a protobuf editions message with getters and hasers type ProtoMessage struct { name *string description *string count int32 } // GetName is a protobuf-style getter func (m *ProtoMessage) GetName() string { if m.name == nil { return "" } return *m.name } // HasName is a protobuf-style haser func (m *ProtoMessage) HasName() bool { return m.name != nil } // GetDescription is a protobuf-style getter func (m *ProtoMessage) GetDescription() string { if m.description == nil { return "" } return *m.description } // HasDescription is a protobuf-style haser func (m *ProtoMessage) HasDescription() bool { return m.description != nil } // GetCount is a protobuf-style getter for a non-nullable field func (m *ProtoMessage) GetCount() int32 { return m.count } ================================================ FILE: codegen/config/testdata/autobinding/scalars/model/model.go ================================================ package model import ( "fmt" "io" "strings" ) type Banned bool func (b Banned) MarshalGQL(w io.Writer) { if b { w.Write([]byte("true")) } else { w.Write([]byte("false")) } } func (b *Banned) UnmarshalGQL(v any) error { switch v := v.(type) { case string: *b = strings.ToLower(v) == "true" return nil case bool: *b = Banned(v) return nil default: return fmt.Errorf("%T is not a bool", v) } } ================================================ FILE: codegen/config/testdata/binding/model.go ================================================ package binding import ( "context" "fmt" "io" "github.com/99designs/gqlgen/graphql" ) type Number int func (e *Number) UnmarshalGQL(v any) error { num, err := graphql.UnmarshalInt(v) if err != nil { return err } *e = Number(num) return nil } func (e Number) MarshalGQL(w io.Writer) error { fmt.Fprint(w, e) return nil } type ContextNumber int func (e *ContextNumber) UnmarshalGQLContext(ctx context.Context, v any) error { num, err := graphql.UnmarshalInt(v) if err != nil { return err } *e = Number(num) return nil } func (e ContextNumber) MarshalGQLContext(_ context.Context, w io.Writer) error { fmt.Fprint(w, e) return nil } ================================================ FILE: codegen/config/testdata/cfg/glob/bar/bar with spaces.graphql ================================================ type Query { todos: [Todo!]! } input NewTodo { text: String! userId: String! } type Mutation { createTodo(input: NewTodo!): Todo! } ================================================ FILE: codegen/config/testdata/cfg/glob/foo/foo.graphql ================================================ type Todo { id: ID! text: String! done: Boolean! user: User! } type User { id: ID! name: String! } ================================================ FILE: codegen/config/testdata/cfg/glob.yml ================================================ schema: - testdata/cfg/glob/**/*.graphql exec: filename: generated.go model: filename: models_gen.go resolver: filename: resolver.go type: Resolver ================================================ FILE: codegen/config/testdata/cfg/goInitialisms.yml ================================================ go_initialisms: replace_defaults: true initialisms: - 'CC' - 'BCC' ================================================ FILE: codegen/config/testdata/cfg/gqlgen.yml ================================================ schema: outer ================================================ FILE: codegen/config/testdata/cfg/malformedconfig.yml ================================================ asdf ================================================ FILE: codegen/config/testdata/cfg/otherdir/.gitkeep ================================================ ================================================ FILE: codegen/config/testdata/cfg/outer ================================================ ================================================ FILE: codegen/config/testdata/cfg/subdir/gqlgen.yaml ================================================ schema: inner ================================================ FILE: codegen/config/testdata/cfg/subdir/inner ================================================ ================================================ FILE: codegen/config/testdata/cfg/unknownkeys.yml ================================================ schema: outer unknown: foo ================================================ FILE: codegen/config/testdata/cfg/unwalkable.yml ================================================ schema: - not_walkable/**/*.graphql exec: filename: generated.go model: filename: models_gen.go resolver: filename: resolver.go type: Resolver ================================================ FILE: codegen/config/testdata/defaultconfig/schema.graphql ================================================ ================================================ FILE: codegen/config/testdata/enum/model.go ================================================ package enum type Bar int const ( BarOne Bar = iota + 1 BarTwo ) const ( BazOne = iota + 1 BazTwo ) ================================================ FILE: codegen/config/testdata/example.go ================================================ package config_test_data ================================================ FILE: codegen/config/testdata/fuzz/FuzzReadConfig/d76a9a281aa1168d ================================================ go test fuzz v1 []byte("schema: !0000\n0000000: 0000") ================================================ FILE: codegen/data.go ================================================ package codegen import ( "errors" "fmt" "os" "path/filepath" "sort" "strings" "github.com/vektah/gqlparser/v2/ast" "github.com/99designs/gqlgen/codegen/config" ) // Data is a unified model of the code to be generated. Plugins may modify this structure to do // things like implement // resolvers or directives automatically (eg grpc, validation) type Data struct { Config *config.Config Schema *ast.Schema // If a schema is broken up into multiple Data instance, each representing part of the schema, // AllDirectives should contain the directives for the entire schema. Directives() can // then be used to get the directives that were defined in this Data instance's sources. // If a single Data instance is used for the entire schema, AllDirectives and Directives() // will be identical. // AllDirectives should rarely be used directly. AllDirectives DirectiveList Objects Objects Inputs Objects Interfaces map[string]*Interface ReferencedTypes map[string]*config.TypeReference ComplexityRoots map[string]*Object QueryRoot *Object MutationRoot *Object SubscriptionRoot *Object AugmentedSources []AugmentedSource Plugins []any } func (d *Data) HasEmbeddableSources() bool { hasEmbeddableSources := false for _, s := range d.AugmentedSources { if s.Embeddable { hasEmbeddableSources = true } } return hasEmbeddableSources } func (d *Data) HasBatchResolverFields() bool { for _, obj := range d.Objects { if obj.Root { continue } for _, field := range obj.Fields { if field.IsBatch() { return true } } } return false } // AugmentedSource contains extra information about graphql schema files which is not known directly // from the Config.Sources data type AugmentedSource struct { // path relative to Config.Exec.Filename RelativePath string Embeddable bool BuiltIn bool Source string } type builder struct { Config *config.Config Schema *ast.Schema Binder *config.Binder Directives map[string]*Directive } // Get only the directives which should have a user provided definition on server instantiation func (d *Data) UserDirectives() DirectiveList { res := DirectiveList{} directives := d.Directives() for k, directive := range directives { if directive.Implementation == nil { res[k] = directive } } return res } // Get only the directives which should have a statically provided definition func (d *Data) BuiltInDirectives() DirectiveList { res := DirectiveList{} directives := d.Directives() for k, directive := range directives { if directive.Implementation != nil { res[k] = directive } } return res } // Get only the directives which are defined in the config's sources. func (d *Data) Directives() DirectiveList { res := DirectiveList{} for k, directive := range d.AllDirectives { for _, s := range d.Config.Sources { if directive.Position.Src.Name == s.Name { res[k] = directive break } } } return res } func BuildData(cfg *config.Config, plugins ...any) (*Data, error) { cfg.ReloadAllPackages() b := builder{ Config: cfg, Schema: cfg.Schema, } b.Binder = b.Config.NewBinder() var err error b.Directives, err = b.buildDirectives() if err != nil { return nil, err } dataDirectives := make(map[string]*Directive) for name, d := range b.Directives { if !d.SkipRuntime { dataDirectives[name] = d } } s := Data{ Config: cfg, AllDirectives: dataDirectives, Schema: b.Schema, Interfaces: map[string]*Interface{}, Plugins: plugins, } for _, schemaType := range b.Schema.Types { switch schemaType.Kind { case ast.Object: obj, err := b.buildObject(schemaType) if err != nil { return nil, fmt.Errorf("unable to build object definition: %w", err) } s.Objects = append(s.Objects, obj) case ast.InputObject: input, err := b.buildObject(schemaType) if err != nil { return nil, fmt.Errorf("unable to build input definition: %w", err) } s.Inputs = append(s.Inputs, input) case ast.Union, ast.Interface: s.Interfaces[schemaType.Name], err = b.buildInterface(schemaType) if err != nil { return nil, fmt.Errorf("unable to bind to interface: %w", err) } } } if s.Schema.Query != nil { s.QueryRoot = s.Objects.ByName(s.Schema.Query.Name) } else { return nil, errors.New("query entry point missing") } if s.Schema.Mutation != nil { s.MutationRoot = s.Objects.ByName(s.Schema.Mutation.Name) } if s.Schema.Subscription != nil { s.SubscriptionRoot = s.Objects.ByName(s.Schema.Subscription.Name) } if err := b.injectIntrospectionRoots(&s); err != nil { return nil, err } s.ReferencedTypes = b.buildTypes() sort.Slice(s.Objects, func(i, j int) bool { return s.Objects[i].Name < s.Objects[j].Name }) sort.Slice(s.Inputs, func(i, j int) bool { return s.Inputs[i].Name < s.Inputs[j].Name }) if b.Binder.SawInvalid { // if we have a syntax error, show it err := cfg.Packages.Errors() if len(err) > 0 { return nil, err } // otherwise show a generic error message return nil, errors.New( "invalid types were encountered while traversing the go source code, this probably means the invalid code generated isnt correct. add try adding -v to debug", ) } var sources []*ast.Source sources, err = SerializeTransformedSchema(cfg.Schema, cfg.Sources) if err != nil { return nil, fmt.Errorf("failed to serialize transformed schema: %w", err) } aSources := []AugmentedSource{} for _, s := range sources { wd, err := os.Getwd() if err != nil { return nil, fmt.Errorf("failed to get working directory: %w", err) } outputDir := cfg.Exec.Dir() sourcePath := filepath.Join(wd, s.Name) relative, err := filepath.Rel(outputDir, sourcePath) if err != nil { return nil, fmt.Errorf( "failed to compute path of %s relative to %s: %w", sourcePath, outputDir, err, ) } relative = filepath.ToSlash(relative) embeddable := true if strings.HasPrefix(relative, "..") || s.BuiltIn { embeddable = false } aSources = append(aSources, AugmentedSource{ RelativePath: relative, Embeddable: embeddable, BuiltIn: s.BuiltIn, Source: s.Input, }) } s.AugmentedSources = aSources return &s, nil } func (b *builder) injectIntrospectionRoots(s *Data) error { obj := s.Objects.ByName(b.Schema.Query.Name) if obj == nil { return errors.New("root query type must be defined") } __type, err := b.buildField(obj, &ast.FieldDefinition{ Name: "__type", Type: ast.NamedType("__Type", nil), Arguments: []*ast.ArgumentDefinition{ { Name: "name", Type: ast.NonNullNamedType("String", nil), }, }, }) if err != nil { return err } __schema, err := b.buildField(obj, &ast.FieldDefinition{ Name: "__schema", Type: ast.NamedType("__Schema", nil), }) if err != nil { return err } obj.Fields = append(obj.Fields, __type, __schema) return nil } ================================================ FILE: codegen/data_test.go ================================================ package codegen import ( "testing" "github.com/stretchr/testify/assert" "github.com/vektah/gqlparser/v2/ast" "github.com/99designs/gqlgen/codegen/config" ) func TestData_Directives(t *testing.T) { d := Data{ Config: &config.Config{ Sources: []*ast.Source{ { Name: "schema.graphql", }, }, }, AllDirectives: DirectiveList{ "includeDirective": { DirectiveDefinition: &ast.DirectiveDefinition{ Name: "includeDirective", Position: &ast.Position{ Src: &ast.Source{ Name: "schema.graphql", }, }, }, Name: "includeDirective", Args: nil, DirectiveConfig: config.DirectiveConfig{ SkipRuntime: false, }, }, "excludeDirective": { DirectiveDefinition: &ast.DirectiveDefinition{ Name: "excludeDirective", Position: &ast.Position{ Src: &ast.Source{ Name: "anothersource.graphql", }, }, }, Name: "excludeDirective", Args: nil, DirectiveConfig: config.DirectiveConfig{ SkipRuntime: false, }, }, }, } expected := DirectiveList{ "includeDirective": { DirectiveDefinition: &ast.DirectiveDefinition{ Name: "includeDirective", Position: &ast.Position{ Src: &ast.Source{ Name: "schema.graphql", }, }, }, Name: "includeDirective", Args: nil, DirectiveConfig: config.DirectiveConfig{ SkipRuntime: false, }, }, } assert.Equal(t, expected, d.Directives()) } ================================================ FILE: codegen/depgraph.go ================================================ package codegen import ( "github.com/vektah/gqlparser/v2/ast" ) // DependencyGraph tracks type definitions and their cross-schema dependencies. // This enables incremental generation by computing which schemas are affected // when a subset of schema files change. type DependencyGraph struct { // SchemaToTypes maps schema file path -> type names defined in that file SchemaToTypes map[string][]string // TypeToSchema maps type name -> schema file path where it's defined TypeToSchema map[string]string // TypeDependencies maps type name -> type names it references TypeDependencies map[string][]string // SchemaDependencies maps schema file -> schema files it depends on SchemaDependencies map[string]map[string]bool } // NewDependencyGraph creates a new empty dependency graph func NewDependencyGraph() *DependencyGraph { return &DependencyGraph{ SchemaToTypes: make(map[string][]string), TypeToSchema: make(map[string]string), TypeDependencies: make(map[string][]string), SchemaDependencies: make(map[string]map[string]bool), } } // BuildDependencyGraph constructs a dependency graph from the parsed schema func BuildDependencyGraph(schema *ast.Schema) *DependencyGraph { g := NewDependencyGraph() // First pass: map each type to its source schema file for _, typ := range schema.Types { if typ.BuiltIn || typ.Position == nil || typ.Position.Src == nil { continue } schemaFile := typ.Position.Src.Name g.TypeToSchema[typ.Name] = schemaFile g.SchemaToTypes[schemaFile] = append(g.SchemaToTypes[schemaFile], typ.Name) } // Second pass: find type dependencies for _, typ := range schema.Types { if typ.BuiltIn || typ.Position == nil || typ.Position.Src == nil { continue } if deps := g.extractTypeDependencies(typ); len(deps) > 0 { g.TypeDependencies[typ.Name] = deps } } // Third pass: build schema-level dependencies for schemaFile, types := range g.SchemaToTypes { g.SchemaDependencies[schemaFile] = make(map[string]bool) for _, typeName := range types { for _, depType := range g.TypeDependencies[typeName] { if depSchema, ok := g.TypeToSchema[depType]; ok && depSchema != schemaFile { g.SchemaDependencies[schemaFile][depSchema] = true } } } } return g } // extractTypeDependencies finds all types referenced by the given type definition func (g *DependencyGraph) extractTypeDependencies(typ *ast.Definition) []string { deps := make(map[string]bool) for _, iface := range typ.Interfaces { deps[iface] = true } for _, unionType := range typ.Types { deps[unionType] = true } for _, field := range typ.Fields { g.extractTypeRef(field.Type, deps) for _, arg := range field.Arguments { g.extractTypeRef(arg.Type, deps) } } result := make([]string, 0, len(deps)) for dep := range deps { if !isBuiltInScalar(dep) { result = append(result, dep) } } return result } func (g *DependencyGraph) extractTypeRef(t *ast.Type, deps map[string]bool) { if t == nil { return } if t.Elem != nil { g.extractTypeRef(t.Elem, deps) } else { deps[t.NamedType] = true } } func isBuiltInScalar(name string) bool { switch name { case "Int", "Float", "String", "Boolean", "ID": return true } return false } // GetAffectedSchemas returns all schema files that need regeneration when // the given schemas have changed. Computes transitive closure of dependencies. func (g *DependencyGraph) GetAffectedSchemas(changedSchemas []string) []string { affected := make(map[string]bool) for _, s := range changedSchemas { affected[s] = true } // Iterate until fixed point (transitive closure) changed := true for changed { changed = false for schema := range affected { for otherSchema, deps := range g.SchemaDependencies { if !affected[otherSchema] && deps[schema] { affected[otherSchema] = true changed = true } } } } result := make([]string, 0, len(affected)) for s := range affected { result = append(result, s) } return result } // GetTypesForSchemas returns all type names defined in the given schema files func (g *DependencyGraph) GetTypesForSchemas(schemas []string) map[string]bool { types := make(map[string]bool) for _, schema := range schemas { for _, typeName := range g.SchemaToTypes[schema] { types[typeName] = true } } return types } ================================================ FILE: codegen/depgraph_test.go ================================================ package codegen import ( "testing" "github.com/stretchr/testify/require" "github.com/vektah/gqlparser/v2/ast" ) func TestBuildDependencyGraph(t *testing.T) { schema := &ast.Schema{ Types: map[string]*ast.Definition{ "User": { Name: "User", Kind: ast.Object, Fields: ast.FieldList{ {Name: "id", Type: ast.NamedType("ID", nil)}, {Name: "posts", Type: ast.ListType(ast.NamedType("Post", nil), nil)}, }, Position: &ast.Position{Src: &ast.Source{Name: "user.graphqls"}}, }, "Post": { Name: "Post", Kind: ast.Object, Fields: ast.FieldList{ {Name: "id", Type: ast.NamedType("ID", nil)}, {Name: "author", Type: ast.NamedType("User", nil)}, {Name: "comments", Type: ast.ListType(ast.NamedType("Comment", nil), nil)}, }, Position: &ast.Position{Src: &ast.Source{Name: "post.graphqls"}}, }, "Comment": { Name: "Comment", Kind: ast.Object, Fields: ast.FieldList{ {Name: "id", Type: ast.NamedType("ID", nil)}, {Name: "text", Type: ast.NamedType("String", nil)}, }, Position: &ast.Position{Src: &ast.Source{Name: "comment.graphqls"}}, }, "String": {Name: "String", Kind: ast.Scalar, BuiltIn: true}, "ID": {Name: "ID", Kind: ast.Scalar, BuiltIn: true}, }, } graph := BuildDependencyGraph(schema) // Verify type-to-schema mapping require.Equal(t, "user.graphqls", graph.TypeToSchema["User"]) require.Equal(t, "post.graphqls", graph.TypeToSchema["Post"]) require.Equal(t, "comment.graphqls", graph.TypeToSchema["Comment"]) // Verify schema-to-types mapping require.ElementsMatch(t, []string{"User"}, graph.SchemaToTypes["user.graphqls"]) require.ElementsMatch(t, []string{"Post"}, graph.SchemaToTypes["post.graphqls"]) require.ElementsMatch(t, []string{"Comment"}, graph.SchemaToTypes["comment.graphqls"]) // Verify type dependencies (User -> Post, Post -> User + Comment) require.Contains(t, graph.TypeDependencies["User"], "Post") require.Contains(t, graph.TypeDependencies["Post"], "User") require.Contains(t, graph.TypeDependencies["Post"], "Comment") // Verify schema dependencies (cross-schema references) require.True(t, graph.SchemaDependencies["user.graphqls"]["post.graphqls"]) require.True(t, graph.SchemaDependencies["post.graphqls"]["user.graphqls"]) require.True(t, graph.SchemaDependencies["post.graphqls"]["comment.graphqls"]) // Verify built-in types are not included require.Empty(t, graph.TypeToSchema["String"]) require.Empty(t, graph.TypeToSchema["ID"]) } func TestBuildDependencyGraph_Interfaces(t *testing.T) { schema := &ast.Schema{ Types: map[string]*ast.Definition{ "Node": { Name: "Node", Kind: ast.Interface, Fields: ast.FieldList{{Name: "id", Type: ast.NamedType("ID", nil)}}, Position: &ast.Position{Src: &ast.Source{Name: "node.graphqls"}}, }, "User": { Name: "User", Kind: ast.Object, Interfaces: []string{"Node"}, Fields: ast.FieldList{{Name: "id", Type: ast.NamedType("ID", nil)}}, Position: &ast.Position{Src: &ast.Source{Name: "user.graphqls"}}, }, "ID": {Name: "ID", Kind: ast.Scalar, BuiltIn: true}, }, } graph := BuildDependencyGraph(schema) // User implements Node, so User depends on Node require.Contains(t, graph.TypeDependencies["User"], "Node") require.True(t, graph.SchemaDependencies["user.graphqls"]["node.graphqls"]) } func TestBuildDependencyGraph_Union(t *testing.T) { schema := &ast.Schema{ Types: map[string]*ast.Definition{ "SearchResult": { Name: "SearchResult", Kind: ast.Union, Types: []string{"User", "Post"}, Position: &ast.Position{Src: &ast.Source{Name: "search.graphqls"}}, }, "User": { Name: "User", Kind: ast.Object, Fields: ast.FieldList{{Name: "name", Type: ast.NamedType("String", nil)}}, Position: &ast.Position{Src: &ast.Source{Name: "user.graphqls"}}, }, "Post": { Name: "Post", Kind: ast.Object, Fields: ast.FieldList{{Name: "title", Type: ast.NamedType("String", nil)}}, Position: &ast.Position{Src: &ast.Source{Name: "post.graphqls"}}, }, "String": {Name: "String", Kind: ast.Scalar, BuiltIn: true}, }, } graph := BuildDependencyGraph(schema) // SearchResult union depends on User and Post require.Contains(t, graph.TypeDependencies["SearchResult"], "User") require.Contains(t, graph.TypeDependencies["SearchResult"], "Post") require.True(t, graph.SchemaDependencies["search.graphqls"]["user.graphqls"]) require.True(t, graph.SchemaDependencies["search.graphqls"]["post.graphqls"]) } func TestBuildDependencyGraph_FieldArguments(t *testing.T) { schema := &ast.Schema{ Types: map[string]*ast.Definition{ "Query": { Name: "Query", Kind: ast.Object, Fields: ast.FieldList{ { Name: "user", Type: ast.NamedType("User", nil), Arguments: ast.ArgumentDefinitionList{ {Name: "filter", Type: ast.NamedType("UserFilter", nil)}, }, }, }, Position: &ast.Position{Src: &ast.Source{Name: "query.graphqls"}}, }, "User": { Name: "User", Kind: ast.Object, Fields: ast.FieldList{{Name: "id", Type: ast.NamedType("ID", nil)}}, Position: &ast.Position{Src: &ast.Source{Name: "user.graphqls"}}, }, "UserFilter": { Name: "UserFilter", Kind: ast.InputObject, Fields: ast.FieldList{{Name: "name", Type: ast.NamedType("String", nil)}}, Position: &ast.Position{Src: &ast.Source{Name: "filter.graphqls"}}, }, "ID": {Name: "ID", Kind: ast.Scalar, BuiltIn: true}, "String": {Name: "String", Kind: ast.Scalar, BuiltIn: true}, }, } graph := BuildDependencyGraph(schema) // Query depends on User (return type) and UserFilter (argument type) require.Contains(t, graph.TypeDependencies["Query"], "User") require.Contains(t, graph.TypeDependencies["Query"], "UserFilter") require.True(t, graph.SchemaDependencies["query.graphqls"]["user.graphqls"]) require.True(t, graph.SchemaDependencies["query.graphqls"]["filter.graphqls"]) } func TestGetAffectedSchemas(t *testing.T) { // Build a dependency chain: C -> B -> A (C depends on B, B depends on A) graph := &DependencyGraph{ SchemaToTypes: map[string][]string{ "a.graphqls": {"TypeA"}, "b.graphqls": {"TypeB"}, "c.graphqls": {"TypeC"}, "d.graphqls": {"TypeD"}, }, TypeToSchema: map[string]string{ "TypeA": "a.graphqls", "TypeB": "b.graphqls", "TypeC": "c.graphqls", "TypeD": "d.graphqls", }, SchemaDependencies: map[string]map[string]bool{ "a.graphqls": {}, "b.graphqls": {"a.graphqls": true}, // B depends on A "c.graphqls": {"b.graphqls": true}, // C depends on B "d.graphqls": {}, // D is independent }, } tests := []struct { name string changed []string expected []string }{ { name: "change at root propagates transitively", changed: []string{"a.graphqls"}, expected: []string{"a.graphqls", "b.graphqls", "c.graphqls"}, }, { name: "change at middle propagates to dependents only", changed: []string{"b.graphqls"}, expected: []string{"b.graphqls", "c.graphqls"}, }, { name: "change at leaf affects only itself", changed: []string{"c.graphqls"}, expected: []string{"c.graphqls"}, }, { name: "independent schema affects only itself", changed: []string{"d.graphqls"}, expected: []string{"d.graphqls"}, }, { name: "multiple changes are merged", changed: []string{"a.graphqls", "d.graphqls"}, expected: []string{"a.graphqls", "b.graphqls", "c.graphqls", "d.graphqls"}, }, { name: "empty input returns empty", changed: []string{}, expected: []string{}, }, { name: "unknown schema is still included", changed: []string{"unknown.graphqls"}, expected: []string{"unknown.graphqls"}, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { affected := graph.GetAffectedSchemas(tt.changed) require.ElementsMatch(t, tt.expected, affected) }) } } func TestGetAffectedSchemas_CircularDependency(t *testing.T) { // A -> B -> C -> A (circular) graph := &DependencyGraph{ SchemaToTypes: map[string][]string{ "a.graphqls": {"TypeA"}, "b.graphqls": {"TypeB"}, "c.graphqls": {"TypeC"}, }, SchemaDependencies: map[string]map[string]bool{ "a.graphqls": {"c.graphqls": true}, // A depends on C "b.graphqls": {"a.graphqls": true}, // B depends on A "c.graphqls": {"b.graphqls": true}, // C depends on B }, } // Changing any one should affect all three affected := graph.GetAffectedSchemas([]string{"a.graphqls"}) require.ElementsMatch(t, []string{"a.graphqls", "b.graphqls", "c.graphqls"}, affected) affected = graph.GetAffectedSchemas([]string{"b.graphqls"}) require.ElementsMatch(t, []string{"a.graphqls", "b.graphqls", "c.graphqls"}, affected) } func TestGetTypesForSchemas(t *testing.T) { graph := &DependencyGraph{ SchemaToTypes: map[string][]string{ "a.graphqls": {"TypeA1", "TypeA2"}, "b.graphqls": {"TypeB"}, "c.graphqls": {}, }, } tests := []struct { name string schemas []string expected map[string]bool }{ { name: "single schema with multiple types", schemas: []string{"a.graphqls"}, expected: map[string]bool{"TypeA1": true, "TypeA2": true}, }, { name: "multiple schemas", schemas: []string{"a.graphqls", "b.graphqls"}, expected: map[string]bool{"TypeA1": true, "TypeA2": true, "TypeB": true}, }, { name: "empty schema", schemas: []string{"c.graphqls"}, expected: map[string]bool{}, }, { name: "unknown schema", schemas: []string{"unknown.graphqls"}, expected: map[string]bool{}, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { types := graph.GetTypesForSchemas(tt.schemas) require.Equal(t, tt.expected, types) }) } } func TestIsBuiltInScalar(t *testing.T) { builtIns := []string{"Int", "Float", "String", "Boolean", "ID"} for _, name := range builtIns { require.True(t, isBuiltInScalar(name), "%s should be a built-in scalar", name) } nonBuiltIns := []string{"User", "Post", "DateTime", "JSON", ""} for _, name := range nonBuiltIns { require.False(t, isBuiltInScalar(name), "%s should not be a built-in scalar", name) } } ================================================ FILE: codegen/directive.go ================================================ package codegen import ( "fmt" "slices" "strings" "github.com/vektah/gqlparser/v2/ast" "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/codegen/templates" ) type DirectiveList map[string]*Directive // LocationDirectives filter directives by location func (dl DirectiveList) LocationDirectives(location string) DirectiveList { return locationDirectives(dl, ast.DirectiveLocation(location)) } type Directive struct { *ast.DirectiveDefinition Name string Args []*FieldArgument config.DirectiveConfig } // IsLocation check location directive func (d *Directive) IsLocation(location ...ast.DirectiveLocation) bool { for _, l := range d.Locations { if slices.Contains(location, l) { return true } } return false } func locationDirectives( directives DirectiveList, location ...ast.DirectiveLocation, ) map[string]*Directive { mDirectives := make(map[string]*Directive) for name, d := range directives { if d.IsLocation(location...) { mDirectives[name] = d } } return mDirectives } func (b *builder) buildDirectives() (map[string]*Directive, error) { directives := make(map[string]*Directive, len(b.Schema.Directives)) for name, dir := range b.Schema.Directives { if _, ok := directives[name]; ok { return nil, fmt.Errorf("directive with name %s already exists", name) } var args []*FieldArgument for _, arg := range dir.Arguments { tr, err := b.Binder.TypeReference(arg.Type, nil) if err != nil { return nil, err } newArg := &FieldArgument{ ArgumentDefinition: arg, TypeReference: tr, VarName: templates.ToGoPrivate(arg.Name), } if arg.DefaultValue != nil { var err error newArg.Default, err = arg.DefaultValue.Value(nil) if err != nil { return nil, fmt.Errorf( "default value for directive argument %s(%s) is not valid: %w", dir.Name, arg.Name, err, ) } } args = append(args, newArg) } directives[name] = &Directive{ DirectiveDefinition: dir, Name: name, Args: args, DirectiveConfig: b.Config.Directives[name], } } return directives, nil } func (b *builder) getDirectives(list ast.DirectiveList) ([]*Directive, error) { dirs := make([]*Directive, len(list)) for i, d := range list { argValues := make(map[string]any, len(d.Arguments)) for _, da := range d.Arguments { val, err := da.Value.Value(nil) if err != nil { return nil, err } argValues[da.Name] = val } def, ok := b.Directives[d.Name] if !ok { return nil, fmt.Errorf("directive %s not found", d.Name) } var args []*FieldArgument for _, a := range def.Args { value := a.Default if argValue, ok := argValues[a.Name]; ok { value = argValue } args = append(args, &FieldArgument{ ArgumentDefinition: a.ArgumentDefinition, Value: value, VarName: a.VarName, TypeReference: a.TypeReference, }) } dirs[i] = &Directive{ Name: d.Name, Args: args, DirectiveDefinition: list[i].Definition, DirectiveConfig: b.Config.Directives[d.Name], } } return dirs, nil } func (d *Directive) ArgsFunc() string { if len(d.Args) == 0 { return "" } return "dir_" + d.Name + "_args" } func (d *Directive) CallArgs() string { args := []string{"ctx", "obj", "n"} for _, arg := range d.Args { args = append( args, fmt.Sprintf( "args[%q].(%s)", arg.Name, templates.CurrentImports.LookupType(arg.TypeReference.GO), ), ) } return strings.Join(args, ", ") } func (d *Directive) ResolveArgs(obj string, next int) string { args := []string{"ctx", obj, fmt.Sprintf("directive%d", next)} for _, arg := range d.Args { dArg := arg.VarName if arg.Value == nil && arg.Default == nil { dArg = "nil" } args = append(args, dArg) } return strings.Join(args, ", ") } func (d *Directive) CallName() string { return ucFirst(d.Name) } func (d *Directive) Declaration() string { res := d.CallName() + " func(ctx context.Context, obj any, next graphql.Resolver" var resSb173 strings.Builder for _, arg := range d.Args { fmt.Fprintf( &resSb173, ", %s %s", templates.ToGoPrivate(arg.Name), templates.CurrentImports.LookupType(arg.TypeReference.GO), ) } res += resSb173.String() res += ") (res any, err error)" return res } func (d *Directive) IsBuiltIn() bool { return d.Implementation != nil } func (d *Directive) CallPath() string { if d.IsBuiltIn() { return "builtInDirective" + d.CallName() } return "ec.Directives." + d.CallName() } func (d *Directive) FunctionImpl() string { if d.Implementation == nil { return "" } return d.CallPath() + " = " + *d.Implementation } ================================================ FILE: codegen/directive_test.go ================================================ package codegen import ( "go/types" "testing" "github.com/stretchr/testify/assert" "github.com/vektah/gqlparser/v2/ast" "github.com/99designs/gqlgen/codegen/config" ) func TestDirectiveCallArgs(t *testing.T) { d := &Directive{ Args: []*FieldArgument{ { ArgumentDefinition: &ast.ArgumentDefinition{ Name: "def1", }, TypeReference: &config.TypeReference{ GO: types.Default( types.NewNamed( types.NewTypeName(0, nil, "string", nil), types.Typ[types.String], nil, ), ), }, }, { ArgumentDefinition: &ast.ArgumentDefinition{ Name: "def2", }, TypeReference: &config.TypeReference{ GO: types.Default(types.NewStruct(nil, nil)), }, }, }, } got := d.CallArgs() assert.Equal(t, `ctx, obj, n, args["def1"].(string), args["def2"].(struct{})`, got) } ================================================ FILE: codegen/directives.gotpl ================================================ {{ $useFunctionSyntaxForExecutionContext := .Config.UseFunctionSyntaxForExecutionContext }} {{ define "implDirectives" }} {{ $in := .Field.DirectiveObjName }} {{ $useFunctionSyntaxForExecutionContext := .UseFunctionSyntaxForExecutionContext }} {{ $zeroVal := .Field.TypeReference.GO | ref}} {{- range $i, $directive := .Field.ImplDirectives -}} directive{{add $i 1}} := func(ctx context.Context) (any, error) { {{- range $arg := $directive.Args }} {{- if notNil "Value" $arg }} {{ if $useFunctionSyntaxForExecutionContext -}} {{ $arg.VarName }}, err := {{ $arg.TypeReference.UnmarshalFunc }}(ctx, ec, {{ $arg.Value | dump }}) {{- else -}} {{ $arg.VarName }}, err := ec.{{ $arg.TypeReference.UnmarshalFunc }}(ctx, {{ $arg.Value | dump }}) {{- end }} if err != nil{ var zeroVal {{$zeroVal}} return zeroVal, err } {{- else if notNil "Default" $arg }} {{ if $useFunctionSyntaxForExecutionContext -}} {{ $arg.VarName }}, err := {{ $arg.TypeReference.UnmarshalFunc }}(ctx, ec, {{ $arg.Default | dump }}) {{- else -}} {{ $arg.VarName }}, err := ec.{{ $arg.TypeReference.UnmarshalFunc }}(ctx, {{ $arg.Default | dump }}) {{- end }} if err != nil{ var zeroVal {{$zeroVal}} return zeroVal, err } {{- end }} {{- end }} {{- if not $directive.IsBuiltIn}} if {{$directive.CallPath}} == nil { var zeroVal {{$zeroVal}} return zeroVal, errors.New("directive {{$directive.Name}} is not implemented") } {{- end}} return {{$directive.CallPath}}({{$directive.ResolveArgs $in $i }}) } {{ end -}} {{ end }} {{define "queryDirectives"}} {{ $useFunctionSyntaxForExecutionContext := .UseFunctionSyntaxForExecutionContext }} for _, d := range obj.Directives { switch d.Name { {{- range $directive := .DirectiveList }} case "{{$directive.Name}}": {{- if $directive.Args }} rawArgs := d.ArgumentMap(ec.Variables) {{ if $useFunctionSyntaxForExecutionContext -}} args, err := {{ $directive.ArgsFunc }}(ctx,ec,rawArgs) {{- else -}} args, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs) {{- end }} if err != nil { ec.Error(ctx, err) return graphql.Null } {{- end }} n := next next = func(ctx context.Context) (any, error) { {{- template "callDirective" $directive -}} } {{- end }} } } tmp, err := next(ctx) if err != nil { ec.Error(ctx, err) return graphql.Null } if data, ok := tmp.(graphql.Marshaler); ok { return data } graphql.AddErrorf(ctx, `unexpected type %T from directive, should be graphql.Marshaler`, tmp) return graphql.Null {{end}} {{define "callDirective"}} {{- if not .IsBuiltIn}} if {{.CallPath}} == nil { return nil, errors.New("directive {{.Name}} is not implemented") } {{- end}} return {{.CallPath}}({{.CallArgs}}) {{end}} {{ if .Directives.LocationDirectives "QUERY" }} {{ if $useFunctionSyntaxForExecutionContext -}} func _queryMiddleware(ctx context.Context, ec *executionContext, obj *ast.OperationDefinition, next func(ctx context.Context) (any, error)) graphql.Marshaler { {{- else -}} func (ec *executionContext) _queryMiddleware(ctx context.Context, obj *ast.OperationDefinition, next func(ctx context.Context) (any, error)) graphql.Marshaler { {{- end }} {{ template "queryDirectives" (dict "DirectiveList" (.Directives.LocationDirectives "QUERY") "UseFunctionSyntaxForExecutionContext" $useFunctionSyntaxForExecutionContext) }} } {{ end }} {{ if .Directives.LocationDirectives "MUTATION" }} {{ if $useFunctionSyntaxForExecutionContext -}} func _mutationMiddleware(ctx context.Context, ec *executionContext, obj *ast.OperationDefinition, next func(ctx context.Context) (any, error)) graphql.Marshaler { {{- else -}} func (ec *executionContext) _mutationMiddleware(ctx context.Context, obj *ast.OperationDefinition, next func(ctx context.Context) (any, error)) graphql.Marshaler { {{- end }} {{ template "queryDirectives" (dict "DirectiveList" (.Directives.LocationDirectives "MUTATION") "UseFunctionSyntaxForExecutionContext" $useFunctionSyntaxForExecutionContext) }} } {{ end }} {{ if .Directives.LocationDirectives "SUBSCRIPTION" }} {{ if $useFunctionSyntaxForExecutionContext -}} func _subscriptionMiddleware(ctx context.Context, ec *executionContext, obj *ast.OperationDefinition, next func(ctx context.Context) (any, error)) func(ctx context.Context) graphql.Marshaler { {{- else -}} func (ec *executionContext) _subscriptionMiddleware(ctx context.Context, obj *ast.OperationDefinition, next func(ctx context.Context) (any, error)) func(ctx context.Context) graphql.Marshaler { {{- end }} for _, d := range obj.Directives { switch d.Name { {{- range $directive := .Directives.LocationDirectives "SUBSCRIPTION" }} case "{{$directive.Name}}": {{- if $directive.Args }} rawArgs := d.ArgumentMap(ec.Variables) {{ if $useFunctionSyntaxForExecutionContext -}} args, err := {{ $directive.ArgsFunc }}(ctx,ec,rawArgs) {{- else -}} args, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs) {{- end }} if err != nil { ec.Error(ctx, err) return func(ctx context.Context) graphql.Marshaler { return graphql.Null } } {{- end }} n := next next = func(ctx context.Context) (any, error) { {{- template "callDirective" $directive -}} } {{- end }} } } tmp, err := next(ctx) if err != nil { ec.Error(ctx, err) return func(ctx context.Context) graphql.Marshaler { return graphql.Null } } if data, ok := tmp.(func(ctx context.Context) graphql.Marshaler); ok { return data } graphql.AddErrorf(ctx, `unexpected type %T from directive, should be graphql.Marshaler`, tmp) return func(ctx context.Context) graphql.Marshaler { return graphql.Null } } {{ end }} {{ if .Directives.LocationDirectives "FIELD" }} {{ if $useFunctionSyntaxForExecutionContext -}} func _fieldMiddleware(ctx context.Context, ec *executionContext, obj any, next graphql.Resolver) graphql.Resolver { {{- else -}} func (ec *executionContext) _fieldMiddleware(ctx context.Context, obj any, next graphql.Resolver) graphql.Resolver { {{- end }} {{- if .Directives.LocationDirectives "FIELD" }} fc := graphql.GetFieldContext(ctx) for _, d := range fc.Field.Directives { switch d.Name { {{- range $directive := .Directives.LocationDirectives "FIELD" }} case "{{$directive.Name}}": {{- if $directive.Args }} rawArgs := d.ArgumentMap(ec.Variables) {{ if $useFunctionSyntaxForExecutionContext -}} args, err := {{ $directive.ArgsFunc }}(ctx,ec,rawArgs) {{- else -}} args, err := ec.{{ $directive.ArgsFunc }}(ctx,rawArgs) {{- end }} if err != nil { ec.Error(ctx, err) return nil } {{- end }} n := next next = func(ctx context.Context) (any, error) { {{- template "callDirective" $directive -}} } {{- end }} } } {{- end }} return next } {{ end }} ================================================ FILE: codegen/field.go ================================================ package codegen import ( "errors" "fmt" goast "go/ast" "go/types" "log" "reflect" "slices" "strconv" "strings" "github.com/vektah/gqlparser/v2/ast" "golang.org/x/text/cases" "golang.org/x/text/language" "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/codegen/templates" "github.com/99designs/gqlgen/internal/code" ) type Field struct { *ast.FieldDefinition TypeReference *config.TypeReference GoFieldType GoFieldType // The field type in go, if any GoReceiverName string // The name of method & var receiver in go, if any GoFieldName string // The name of the method or var in go, if any IsResolver bool // Does this field need a resolver Args []*FieldArgument // A list of arguments to be passed to this field MethodHasContext bool // If this is bound to a go method, does the method also take a context NoErr bool // If this is bound to a go method, does that method have an error as the second argument VOkFunc bool // If this is bound to a go method, is it of shape (any, bool) Object *Object // A link back to the parent object Default any // The default value Stream bool // does this field return a channel? Directives []*Directive HasHaser bool // Whether a haser method is available (e.g., HasName()) HaserMethodName string // Name of the haser method Batch bool // Enable batch resolver for this field } func (b *builder) buildField(obj *Object, field *ast.FieldDefinition) (*Field, error) { dirs, err := b.getDirectives(field.Directives) if err != nil { return nil, err } f := Field{ FieldDefinition: field, Object: obj, Directives: dirs, GoFieldName: templates.ToGo(field.Name), GoFieldType: GoFieldVariable, GoReceiverName: "obj", } if field.DefaultValue != nil { var err error f.Default, err = field.DefaultValue.Value(nil) if err != nil { return nil, fmt.Errorf("default value %s is not valid: %w", field.Name, err) } } for _, arg := range field.Arguments { newArg, err := b.buildArg(obj, arg) if err != nil { return nil, err } f.Args = append(f.Args, newArg) } if err = b.bindField(obj, &f); err != nil { f.IsResolver = true if errors.Is(err, config.ErrTypeNotFound) { return nil, err } log.Println(err.Error()) } // Set Batch flag from config (independent of resolver setting) if fieldCfg, ok := b.Config.Models[obj.Name]; ok { if fieldEntry, ok := fieldCfg.Fields[field.Name]; ok { f.Batch = fieldEntry.Batch if f.Batch { if f.Object.Root { return nil, fmt.Errorf( "batch resolver is not supported for root field %s.%s", obj.Name, field.Name, ) } // batch resolvers are always user-provided f.IsResolver = true } } } if f.IsResolver && b.Config.ResolversAlwaysReturnPointers && !f.TypeReference.IsPtr() && f.TypeReference.IsStruct() { f.TypeReference = b.Binder.PointerTo(f.TypeReference) } return &f, nil } func (b *builder) bindField(obj *Object, f *Field) (errret error) { defer func() { if f.TypeReference == nil { tr, err := b.Binder.TypeReference(f.Type, nil) if err != nil { errret = err } f.TypeReference = tr } if f.TypeReference != nil { dirs, err := b.getDirectives(f.TypeReference.Definition.Directives) if err != nil { errret = err } // Filter out INPUT_OBJECT directives from type references - they should // only be executed on the input object itself, not on fields that use the type. // See: https://github.com/99designs/gqlgen/issues/2281 var filteredDirs []*Directive for _, dir := range dirs { if !dir.IsLocation(ast.LocationInputObject) { filteredDirs = append(filteredDirs, dir) } } f.Directives = append(filteredDirs, f.Directives...) } }() f.Stream = obj.Stream switch { case f.Name == "__schema": f.GoFieldType = GoFieldMethod f.GoReceiverName = "ec" f.GoFieldName = "IntrospectSchema" return nil case f.Name == "__type": f.GoFieldType = GoFieldMethod f.GoReceiverName = "ec" f.GoFieldName = "IntrospectType" return nil case f.Name == "_entities": f.GoFieldType = GoFieldMethod f.GoReceiverName = "ec" f.GoFieldName = "__resolve_entities" f.MethodHasContext = true f.NoErr = true return nil case f.Name == "_service": f.GoFieldType = GoFieldMethod f.GoReceiverName = "ec" f.GoFieldName = "__resolve__service" f.MethodHasContext = true return nil case obj.Root: f.IsResolver = true return nil case b.Config.Models[obj.Name].Fields[f.Name].Resolver: f.IsResolver = true return nil case obj.Type == config.MapType: f.GoFieldType = GoFieldMap return nil case b.Config.Models[obj.Name].Fields[f.Name].FieldName != "": f.GoFieldName = b.Config.Models[obj.Name].Fields[f.Name].FieldName } // Check for protobuf-style haser method (only if enabled and field is nullable) // Use the original field name, not the bound method/field name // (e.g., for field "name" bound to "GetName()", look for "HasName" not "HasGetName") // Check for protobuf-style haser method (only if enabled and field is nullable) // Use the original field name, not the bound method/field name // (e.g., for field "name" bound to "GetName()", look for "HasName" not "HasGetName") autoBindGetterHaser := b.Config.AutobindGetterHaser if val := b.Config.Models[obj.Name].Fields[f.Name].AutoBindGetterHaser; val != nil { autoBindGetterHaser = *val } if autoBindGetterHaser && !f.Type.NonNull { haser, _ := b.findBindHaserMethod(obj.Type, f.GoFieldName) if haser != nil { f.HasHaser = true f.HaserMethodName = haser.Name() } } target, err := b.findBindTarget(obj.Type, f.GoFieldName, autoBindGetterHaser) if err != nil { return err } pos := b.Binder.ObjectPosition(target) switch target := target.(type) { case nil: // Skips creating a resolver for any root types if b.Config.IsRoot(b.Schema.Types[f.Type.Name()]) { return nil } objPos := b.Binder.TypePosition(obj.Type) return fmt.Errorf( "%s:%d adding resolver method for %s.%s, nothing matched", objPos.Filename, objPos.Line, obj.Name, f.Name, ) case *types.Func: sig := target.Type().(*types.Signature) if sig.Results().Len() == 1 { f.NoErr = true } else if s := sig.Results(); s.Len() == 2 && s.At(1).Type().String() == "bool" { f.VOkFunc = true } else if sig.Results().Len() != 2 { return errors.New("method has wrong number of args") } params := sig.Params() // If the first argument is the context, remove it from the comparison and set // the MethodHasContext flag so that the context will be passed to this model's method if params.Len() > 0 && params.At(0).Type().String() == "context.Context" { f.MethodHasContext = true vars := make([]*types.Var, params.Len()-1) for i := 1; i < params.Len(); i++ { vars[i-1] = params.At(i) } params = types.NewTuple(vars...) } // Try to match target function's arguments with GraphQL field arguments. newArgs, err := b.bindArgs(f, sig, params) if err != nil { return fmt.Errorf("%s:%d: %w", pos.Filename, pos.Line, err) } // Try to match target function's return types with GraphQL field return type result := sig.Results().At(0) tr, err := b.Binder.TypeReference(f.Type, result.Type()) if err != nil { return err } // success, args and return type match. Bind to method f.GoFieldType = GoFieldMethod f.GoReceiverName = "obj" f.GoFieldName = target.Name() f.Args = newArgs f.TypeReference = tr return nil case *types.Var: tr, err := b.Binder.TypeReference(f.Type, target.Type()) if err != nil { return err } // success, bind to var f.GoFieldType = GoFieldVariable f.GoReceiverName = "obj" f.GoFieldName = target.Name() f.TypeReference = tr return nil default: panic(fmt.Errorf("unknown bind target %T for %s", target, f.Name)) } } // findBindTarget attempts to match the name to a field or method on a Type // with the following priorities: // 1. Any Fields with a struct tag (see config.StructTag). Errors if more than one match is found // 2. If enabled, try getter pattern (GetFieldName) // 3. Any method or field with a matching name. Errors if more than one match is found // 4. Same logic again for embedded fields func (b *builder) findBindTarget( t types.Type, name string, autoBindGetterHaser bool, ) (types.Object, error) { // NOTE: a struct tag will override both methods and fields // Bind to struct tag found, err := b.findBindStructTagTarget(t, name) if found != nil || err != nil { return found, err } // If enabled, try getter pattern (GetFieldName) first var foundGetter types.Object if autoBindGetterHaser { getterName := "Get" + name foundGetter, err = b.findBindMethodTarget(t, getterName) if err != nil { return nil, err } if foundGetter != nil { return foundGetter, nil } } // Search for a method to bind to foundMethod, err := b.findBindMethodTarget(t, name) if err != nil { return nil, err } // Search for a field to bind to foundField, err := b.findBindFieldTarget(t, name) if err != nil { return nil, err } switch { case foundField == nil && foundMethod != nil: // Bind to method return foundMethod, nil case foundField != nil && foundMethod == nil: // Bind to field return foundField, nil case foundField != nil && foundMethod != nil: // Error return nil, fmt.Errorf("found more than one way to bind for %s", name) } // Search embeds return b.findBindEmbedsTarget(t, name, autoBindGetterHaser) } func (b *builder) findBindStructTagTarget(in types.Type, name string) (types.Object, error) { if b.Config.StructTag == "" { return nil, nil } switch t := in.(type) { case *types.Named: return b.findBindStructTagTarget(t.Underlying(), name) case *types.Struct: var found types.Object for i := 0; i < t.NumFields(); i++ { field := t.Field(i) if !field.Exported() || field.Embedded() { continue } tags := reflect.StructTag(t.Tag(i)) if val, ok := tags.Lookup(b.Config.StructTag); ok && equalFieldName(val, name) { if found != nil { return nil, fmt.Errorf( "tag %s is ambiguous; multiple fields have the same tag value of %s", b.Config.StructTag, val, ) } found = field } } return found, nil } return nil, nil } func (b *builder) findBindMethodTarget(in types.Type, name string) (types.Object, error) { switch t := in.(type) { case *types.Named: if _, ok := t.Underlying().(*types.Interface); ok { return b.findBindMethodTarget(t.Underlying(), name) } return b.findBindMethoderTarget(t.Method, t.NumMethods(), name) case *types.Interface: // FIX-ME: Should use ExplicitMethod here? What's the difference? return b.findBindMethoderTarget(t.Method, t.NumMethods(), name) } return nil, nil } func (b *builder) findBindMethoderTarget( methodFunc func(i int) *types.Func, methodCount int, name string, ) (types.Object, error) { var found types.Object for i := range methodCount { method := methodFunc(i) if !method.Exported() || !strings.EqualFold(method.Name(), name) { continue } if found != nil { return nil, fmt.Errorf("found more than one matching method to bind for %s", name) } found = method } return found, nil } func (b *builder) findBindFieldTarget(in types.Type, name string) (types.Object, error) { switch t := in.(type) { case *types.Named: return b.findBindFieldTarget(t.Underlying(), name) case *types.Struct: var found types.Object for field := range t.Fields() { if !field.Exported() || !equalFieldName(field.Name(), name) { continue } if found != nil { return nil, fmt.Errorf("found more than one matching field to bind for %s", name) } found = field } return found, nil } return nil, nil } func (b *builder) findBindEmbedsTarget( in types.Type, name string, autoBindGetterHaser bool, ) (types.Object, error) { switch t := in.(type) { case *types.Named: return b.findBindEmbedsTarget(t.Underlying(), name, autoBindGetterHaser) case *types.Struct: return b.findBindStructEmbedsTarget(t, name, autoBindGetterHaser) case *types.Interface: return b.findBindInterfaceEmbedsTarget(t, name, autoBindGetterHaser) } return nil, nil } func (b *builder) findBindStructEmbedsTarget( strukt *types.Struct, name string, autoBindGetterHaser bool, ) (types.Object, error) { var found types.Object for field := range strukt.Fields() { if !field.Embedded() { continue } fieldType := code.Unalias(field.Type()) if ptr, ok := fieldType.(*types.Pointer); ok { fieldType = ptr.Elem() } f, err := b.findBindTarget(fieldType, name, autoBindGetterHaser) if err != nil { return nil, err } if f != nil && found != nil { return nil, fmt.Errorf("found more than one way to bind for %s", name) } if f != nil { found = f } } return found, nil } func (b *builder) findBindInterfaceEmbedsTarget( iface *types.Interface, name string, autoBindGetterHaser bool, ) (types.Object, error) { var found types.Object for embeddedType := range iface.EmbeddedTypes() { f, err := b.findBindTarget(embeddedType, name, autoBindGetterHaser) if err != nil { return nil, err } if f != nil && found != nil { return nil, fmt.Errorf("found more than one way to bind for %s", name) } if f != nil { found = f } } return found, nil } // findBindHaserMethod looks for a protobuf-style haser method (e.g., HasName for field Name) // Haser methods are used to check if an optional field is set func (b *builder) findBindHaserMethod(in types.Type, name string) (types.Object, error) { haserName := "Has" + name switch t := in.(type) { case *types.Named: if _, ok := t.Underlying().(*types.Interface); ok { return b.findBindHaserMethod(t.Underlying(), name) } // Search for haser method method, err := b.findBindMethoderTarget(t.Method, t.NumMethods(), haserName) if err != nil || method == nil { return nil, err } // Verify haser signature: no parameters, returns bool sig := method.Type().(*types.Signature) if sig.Params().Len() != 0 || sig.Results().Len() != 1 { return nil, nil } if sig.Results().At(0).Type().String() != "bool" { return nil, nil } return method, nil case *types.Interface: method, err := b.findBindMethoderTarget(t.Method, t.NumMethods(), haserName) if err != nil || method == nil { return nil, err } // Verify haser signature sig := method.Type().(*types.Signature) if sig.Params().Len() != 0 || sig.Results().Len() != 1 { return nil, nil } if sig.Results().At(0).Type().String() != "bool" { return nil, nil } return method, nil } return nil, nil } func (f *Field) HasDirectives() bool { return len(f.ImplDirectives()) > 0 } func (f *Field) DirectiveObjName() string { if f.Object.Root { return "nil" } return f.GoReceiverName } func (f *Field) ImplDirectives() []*Directive { var d []*Directive loc := ast.LocationFieldDefinition if f.Object.IsInputType() { loc = ast.LocationInputFieldDefinition } for i := range f.Directives { if !f.Directives[i].SkipRuntime && (f.Directives[i].IsLocation(loc, ast.LocationObject) || f.Directives[i].IsLocation(loc, ast.LocationInputObject)) { d = append(d, f.Directives[i]) } } return d } func (f *Field) IsReserved() bool { return strings.HasPrefix(f.Name, "__") } func (f *Field) IsMethod() bool { return f.GoFieldType == GoFieldMethod } func (f *Field) IsVariable() bool { return f.GoFieldType == GoFieldVariable } func (f *Field) IsMap() bool { return f.GoFieldType == GoFieldMap } func (f *Field) IsConcurrent() bool { if f.Object.DisableConcurrency { return false } return f.MethodHasContext || f.IsResolver } // IsBatch returns true if this field has batch resolver enabled. func (f *Field) IsBatch() bool { return f.Batch } // ShortBatchResolverDeclaration returns the method signature for a batch resolver. // Batch resolvers accept multiple parent objects and return results for all of them. // For example, if the normal resolver is: // // Posts(ctx context.Context, obj *User) ([]*Post, error) // // The batch resolver would be: // // Posts(ctx context.Context, objs []*User) ([][]*Post, error) func (f *Field) ShortBatchResolverDeclaration() string { if f.Object.Root { // Root fields don't have a parent object, so batch doesn't make sense return "" } parentType := templates.CurrentImports.LookupType(f.Object.Reference()) res := fmt.Sprintf("(ctx context.Context, objs []%s", parentType) var resSb strings.Builder var inlineInfo *InlineArgsInfo if f.Object != nil && f.Object.Definition != nil { inlineInfo = GetInlineArgsMetadata(f.Object.Name, f.Name) } if inlineInfo != nil { goType := formatGoType(inlineInfo.GoType) fmt.Fprintf(&resSb, ", %s %s", inlineInfo.OriginalArgName, goType) for _, arg := range f.Args { if !slices.Contains(inlineInfo.ExpandedArgs, arg.Name) { fmt.Fprintf( &resSb, ", %s %s", arg.VarName, templates.CurrentImports.LookupType(arg.TypeReference.GO), ) } } } else { for _, arg := range f.Args { fmt.Fprintf( &resSb, ", %s %s", arg.VarName, templates.CurrentImports.LookupType(arg.TypeReference.GO), ) } } res += resSb.String() return fmt.Sprintf( "%s) ([]%s, error)", res, templates.CurrentImports.LookupType(f.TypeReference.GO), ) } func (f *Field) GoNameUnexported() string { return templates.ToGoPrivate(f.Name) } func (f *Field) ShortInvocation() string { caser := cases.Title(language.English, cases.NoLower) if f.Object.Kind == ast.InputObject { return fmt.Sprintf("%s().%s(ctx, &it, data)", caser.String(f.Object.Name), f.GoFieldName) } return fmt.Sprintf("%s().%s(%s)", caser.String(f.Object.Name), f.GoFieldName, f.CallArgs()) } func (f *Field) ArgsFunc() string { if len(f.Args) == 0 { return "" } return "field_" + f.Object.Name + "_" + f.Name + "_args" } func (f *Field) FieldContextFunc() string { return "fieldContext_" + f.Object.Name + "_" + f.Name } func (f *Field) ChildFieldContextFunc(name string) string { return "fieldContext_" + f.TypeReference.Definition.Name + "_" + name } func (f *Field) ResolverType() string { if !f.IsResolver { return "" } return fmt.Sprintf("%s().%s(%s)", f.Object.Name, f.GoFieldName, f.CallArgs()) } func (f *Field) IsInputObject() bool { return f.Object.Kind == ast.InputObject } func (f *Field) IsRoot() bool { return f.Object.Root } func formatGoType(goType string) string { if strings.Contains(goType, "/") { lastDot := strings.LastIndex(goType, ".") if lastDot == -1 { return goType } packagePath := goType[:lastDot] typeName := goType[lastDot+1:] alias := templates.CurrentImports.Lookup(packagePath) if alias == "" { return typeName } return alias + "." + typeName } return goType } func (f *Field) ShortResolverDeclaration() string { return f.ShortResolverSignature(nil) } // ShortResolverSignature is identical to ShortResolverDeclaration, // but respects previous naming (return) conventions, if any. func (f *Field) ShortResolverSignature(ft *goast.FuncType) string { if f.Object.Kind == ast.InputObject { return fmt.Sprintf("(ctx context.Context, obj %s, data %s) error", templates.CurrentImports.LookupType(f.Object.Reference()), templates.CurrentImports.LookupType(f.TypeReference.GO), ) } res := "(ctx context.Context" if !f.Object.Root { res += fmt.Sprintf(", obj %s", templates.CurrentImports.LookupType(f.Object.Reference())) } var resSb540 strings.Builder var inlineInfo *InlineArgsInfo if f.Object != nil && f.Object.Definition != nil { inlineInfo = GetInlineArgsMetadata(f.Object.Name, f.Name) } if inlineInfo != nil { goType := formatGoType(inlineInfo.GoType) fmt.Fprintf(&resSb540, ", %s %s", inlineInfo.OriginalArgName, goType) for _, arg := range f.Args { if !slices.Contains(inlineInfo.ExpandedArgs, arg.Name) { fmt.Fprintf( &resSb540, ", %s %s", arg.VarName, templates.CurrentImports.LookupType(arg.TypeReference.GO), ) } } } else { for _, arg := range f.Args { fmt.Fprintf( &resSb540, ", %s %s", arg.VarName, templates.CurrentImports.LookupType(arg.TypeReference.GO), ) } } res += resSb540.String() result := templates.CurrentImports.LookupType(f.TypeReference.GO) if f.Object.Stream { result = "<-chan " + result } // Named return. var namedV, namedE string if ft != nil { if ft.Results != nil && len(ft.Results.List) > 0 && len(ft.Results.List[0].Names) > 0 { namedV = ft.Results.List[0].Names[0].Name } if ft.Results != nil && len(ft.Results.List) > 1 && len(ft.Results.List[1].Names) > 0 { namedE = ft.Results.List[1].Names[0].Name } } if namedV != "" || namedE != "" { res += fmt.Sprintf(") (%s %s, %s error)", namedV, result, namedE) } else { res += fmt.Sprintf(") (%s, error)", result) } return res } func (f *Field) GoResultName() (string, bool) { name := fmt.Sprintf("%v", f.TypeReference.GO) splits := strings.Split(name, "/") return splits[len(splits)-1], strings.HasPrefix(name, "[]") } func (f *Field) ComplexitySignature() string { res := "func(childComplexity int" var resSb571 strings.Builder for _, arg := range f.Args { fmt.Fprintf( &resSb571, ", %s %s", arg.VarName, templates.CurrentImports.LookupType(arg.TypeReference.GO), ) } res += resSb571.String() res += ") int" return res } func (f *Field) ComplexityArgs() string { args := make([]string, len(f.Args)) for i, arg := range f.Args { args[i] = "args[" + strconv.Quote( arg.Name, ) + "].(" + templates.CurrentImports.LookupType( arg.TypeReference.GO, ) + ")" } return strings.Join(args, ", ") } func (f *Field) CallArgs() string { args := make([]string, 0, len(f.Args)+2) if f.IsResolver { args = append(args, "ctx") if !f.Object.Root { args = append(args, "obj") } } else if f.MethodHasContext { args = append(args, "ctx") } args = append(args, f.callArgExpressions()...) return strings.Join(args, ", ") } func (f *Field) callArgExpressions() []string { args := make([]string, 0, len(f.Args)) var inlineInfo *InlineArgsInfo if f.Object != nil && f.Object.Definition != nil { inlineInfo = GetInlineArgsMetadata(f.Object.Name, f.Name) } if inlineInfo != nil { isMap := strings.Contains(inlineInfo.GoType, "map[") var entries []string for _, argName := range inlineInfo.ExpandedArgs { var argRef *FieldArgument for _, arg := range f.Args { if arg.Name == argName { argRef = arg break } } if argRef != nil { goType := templates.CurrentImports.LookupType(argRef.TypeReference.GO) var entry string if isMap { entry = fmt.Sprintf("%q: fc.Args[%q].(%s)", argName, argName, goType) } else { fieldName := templates.ToGo(argName) entry = fmt.Sprintf("%s: fc.Args[%q].(%s)", fieldName, argName, goType) } entries = append(entries, entry) } } goType := formatGoType(inlineInfo.GoType) bundled := fmt.Sprintf("%s{\n\t\t%s,\n\t}", goType, strings.Join(entries, ",\n\t\t")) args = append(args, bundled) for _, arg := range f.Args { if !slices.Contains(inlineInfo.ExpandedArgs, arg.Name) { tmp := "fc.Args[" + strconv.Quote( arg.Name, ) + "].(" + templates.CurrentImports.LookupType( arg.TypeReference.GO, ) + ")" if iface, ok := arg.TypeReference.GO.(*types.Interface); ok && iface.Empty() { tmp = fmt.Sprintf(` func () any { if fc.Args["%s"] == nil { return nil } return fc.Args["%s"].(any) }()`, arg.Name, arg.Name, ) } args = append(args, tmp) } } } else { for _, arg := range f.Args { tmp := "fc.Args[" + strconv.Quote( arg.Name, ) + "].(" + templates.CurrentImports.LookupType( arg.TypeReference.GO, ) + ")" if iface, ok := arg.TypeReference.GO.(*types.Interface); ok && iface.Empty() { tmp = fmt.Sprintf(` func () any { if fc.Args["%s"] == nil { return nil } return fc.Args["%s"].(any) }()`, arg.Name, arg.Name, ) } args = append(args, tmp) } } return args } // BatchCallArgs returns a comma-separated list of resolver call arguments for batch resolvers. func (f *Field) BatchCallArgs(parentVar string) string { args := make([]string, 0, len(f.Args)+2) args = append(args, "ctx") if parentVar != "" { args = append(args, parentVar) } args = append(args, f.callArgExpressions()...) return strings.Join(args, ", ") } // StubCallArgs returns a comma-separated list of argument variable names for stub code. func (f *Field) StubCallArgs() string { args := make([]string, 0, len(f.Args)+2) inlineInfo := GetInlineArgsMetadata(f.Object.Name, f.Name) if inlineInfo != nil { args = append(args, inlineInfo.OriginalArgName) for _, arg := range f.Args { if !slices.Contains(inlineInfo.ExpandedArgs, arg.Name) { args = append(args, arg.VarName) } } } else { for _, arg := range f.Args { args = append(args, arg.VarName) } } return strings.Join(args, ", ") } ================================================ FILE: codegen/field.gotpl ================================================ {{ $useFunctionSyntaxForExecutionContext := .Config.UseFunctionSyntaxForExecutionContext }} {{- range $object := .Objects }}{{- range $field := $object.Fields }} {{ if $useFunctionSyntaxForExecutionContext -}} func _{{$object.Name}}_{{$field.Name}}(ctx context.Context, ec *executionContext, field graphql.CollectedField{{ if not $object.Root }}, obj {{$object.Reference | ref}}{{end}}) (ret {{ if $object.Stream }}func(ctx context.Context){{ end }}graphql.Marshaler) { {{- else -}} func (ec *executionContext) _{{$object.Name}}_{{$field.Name}}(ctx context.Context, field graphql.CollectedField{{ if not $object.Root }}, obj {{$object.Reference | ref}}{{end}}) (ret {{ if $object.Stream }}func(ctx context.Context){{ end }}graphql.Marshaler) { {{- end }} {{- $null := "graphql.Null" }} {{- if $object.Stream }} {{- $null = "nil" }} {{- end }} {{- if $field.TypeReference.IsRoot }} {{ if $useFunctionSyntaxForExecutionContext -}} fc, err := {{ $field.FieldContextFunc }}(ctx, ec, field) {{- else -}} fc, err := ec.{{ $field.FieldContextFunc }}(ctx, field) {{- end }} if err != nil { return {{ $null }} } ctx = graphql.WithFieldContext(ctx, fc) {{- if not $.Config.OmitPanicHandler }} defer func () { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = {{ $null }} } }() {{- end }} {{- if $field.TypeReference.IsPtr }} res := &{{ $field.TypeReference.Elem.GO | ref }}{} {{- else }} res := {{ $field.TypeReference.GO | ref }}{} {{- end }} fc.Result = res {{ if $useFunctionSyntaxForExecutionContext -}} return {{ $field.TypeReference.MarshalFunc }}(ctx, ec, field.Selections, res) {{- else -}} return ec.{{ $field.TypeReference.MarshalFunc }}(ctx, field.Selections, res) {{- end }} {{- else}} return graphql.ResolveField{{- if $object.Stream }}Stream{{- end }}( ctx, ec.OperationContext, field, {{ if $useFunctionSyntaxForExecutionContext -}} func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return {{ $field.FieldContextFunc }}(ctx, ec, field) }, {{- else -}} ec.{{ $field.FieldContextFunc }}, {{- end }} func(ctx context.Context) (any, error) { {{- template "fieldDefinition" $field }} }, {{if or ($.AllDirectives.LocationDirectives "FIELD") $field.HasDirectives -}} func(ctx context.Context, next graphql.Resolver) graphql.Resolver { {{- if $field.HasDirectives -}} directive0 := next {{ template "implDirectives" (dict "Field" $field "UseFunctionSyntaxForExecutionContext" $useFunctionSyntaxForExecutionContext) }} next = directive{{$field.ImplDirectives|len}} {{end}} {{- if $.AllDirectives.LocationDirectives "FIELD" -}} {{ if $useFunctionSyntaxForExecutionContext -}} return _fieldMiddleware(ctx, ec, {{if $object.Root}}nil{{else}}obj{{end}}, next) {{- else -}} return ec._fieldMiddleware(ctx, {{if $object.Root}}nil{{else}}obj{{end}}, next) {{- end }} {{- else -}} return next {{end -}} }, {{else -}} nil, {{end -}} {{ if $useFunctionSyntaxForExecutionContext -}} func(ctx context.Context, selections ast.SelectionSet, v {{ $field.TypeReference.GO | ref }}) graphql.Marshaler { return {{ $field.TypeReference.MarshalFunc }}(ctx, ec, selections, v) }, {{- else -}} ec.{{ $field.TypeReference.MarshalFunc }}, {{- end }} {{ not $.Config.OmitPanicHandler }}, {{ $field.TypeReference.GQL.NonNull }}, ) {{- end }} } {{ if $useFunctionSyntaxForExecutionContext -}} func {{ $field.FieldContextFunc }}({{ if not $field.Args }}_{{ else }}ctx{{ end }} context.Context, ec *executionContext, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { {{- else -}} func (ec *executionContext) {{ $field.FieldContextFunc }}({{ if not $field.Args }}_{{ else }}ctx{{ end }} context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { {{- end }} fc = &graphql.FieldContext{ Object: {{quote $field.Object.Name}}, Field: field, IsMethod: {{or $field.IsMethod $field.IsResolver}}, IsResolver: {{ $field.IsResolver }}, Child: func (ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { {{- if not $field.TypeReference.Definition.Fields }} return nil, errors.New("field of type {{ $field.TypeReference.Definition.Name }} does not have child fields") {{- else if ne $field.TypeReference.Definition.Kind "OBJECT" }} return nil, errors.New("FieldContext.Child cannot be called on type {{ $field.TypeReference.Definition.Kind }}") {{- else }} switch field.Name { {{- range $f := $field.TypeReference.Definition.Fields }} case "{{ $f.Name }}": {{ if $useFunctionSyntaxForExecutionContext -}} return {{ $field.ChildFieldContextFunc $f.Name }}(ctx, ec, field) {{- else -}} return ec.{{ $field.ChildFieldContextFunc $f.Name }}(ctx, field) {{- end }} {{- end }} } return nil, fmt.Errorf("no field named %q was found under type {{ $field.TypeReference.Definition.Name }}", field.Name) {{- end }} }, } {{- if $field.Args }} {{- if not $.Config.OmitPanicHandler }} defer func () { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() {{- end }} ctx = graphql.WithFieldContext(ctx, fc) {{ if $useFunctionSyntaxForExecutionContext -}} if fc.Args, err = {{ $field.ArgsFunc }}(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil { {{- else -}} if fc.Args, err = ec.{{ $field.ArgsFunc }}(ctx, field.ArgumentMap(ec.Variables)); err != nil { {{- end }} ec.Error(ctx, err) return fc, err } {{- end }} return fc, nil } {{- if and $field.IsBatch (not $object.Root) }} func (ec *executionContext) resolveBatch_{{$object.Name}}_{{$field.Name}}(ctx context.Context, field graphql.CollectedField, obj {{$object.Reference | ref}}) (any, error) { resolver := ec.Resolvers.{{ ucFirst $object.Name }}() {{- if $field.Args }} fc := graphql.GetFieldContext(ctx) {{- end }} group := graphql.GetBatchParentGroup(ctx, {{ $object.Name | quote }}) if group != nil { parents, ok := group.Parents.([]{{$object.Reference | ref}}) if ok { idx, ok := graphql.BatchParentIndex(ctx) if ok { key := field.Alias if key == "" { key = field.Name } {{/* TODO: resolveBatch_* runs per parent even when grouped; consider a single dispatch per field if the execution flow can support it. */ -}} result := group.GetFieldResult(key, func() (any, error) { return resolver.{{ $field.GoFieldName }}({{ $field.BatchCallArgs "parents" }}) }) return graphql.ResolveBatchGroupResult[{{ $field.TypeReference.GO | ref }}]( ctx, idx, len(parents), result, {{ printf "%s.%s" $object.Name $field.Name | quote }}, ) } } } results, err := resolver.{{ $field.GoFieldName }}({{ $field.BatchCallArgs (printf "[]%s{obj}" ($object.Reference | ref)) }}) return graphql.ResolveBatchSingleResult[{{ $field.TypeReference.GO | ref }}]( ctx, results, err, {{ printf "%s.%s" $object.Name $field.Name | quote }}, ) } {{- end }} {{- end }}{{- end}} {{ define "fieldDefinition" }} {{- if and .IsBatch (not .Object.Root) }} return ec.resolveBatch_{{ .Object.Name }}_{{ .Name }}(ctx, field, obj) {{- else }} {{- template "singleFieldDefinition" . }} {{- end }} {{- end }} {{ define "singleFieldDefinition" }} {{- if or .IsResolver .IsMethod -}} {{- if gt (len .Args) 0 -}} fc := graphql.GetFieldContext(ctx) {{- end }} {{ end }} {{- if .IsResolver -}} return ec.Resolvers.{{ .ShortInvocation }} {{- else if .IsMap -}} switch v := {{.GoReceiverName}}[{{.Name|quote}}].(type) { case {{if .Stream}}<-chan {{end}}{{.TypeReference.GO | ref}}: return v, nil case {{if .Stream}}<-chan {{end}}{{.TypeReference.Elem.GO | ref}}: return &v, nil case nil: return ({{.TypeReference.GO | ref}})(nil), nil default: return nil, fmt.Errorf("unexpected type %T for field %s", v, {{ .Name | quote}}) } {{- else if .IsMethod -}} {{- if .HasHaser -}} if !{{.GoReceiverName}}.{{.HaserMethodName}}() { return nil, nil } {{ end }} {{- if .VOkFunc -}} v, ok := {{.GoReceiverName}}.{{.GoFieldName}}({{ .CallArgs }}) if !ok { return nil, nil } return v, nil {{- else if .NoErr -}} return {{.GoReceiverName}}.{{.GoFieldName}}({{ .CallArgs }}), nil {{- else -}} return {{.GoReceiverName}}.{{.GoFieldName}}({{ .CallArgs }}) {{- end -}} {{- else if .IsVariable -}} {{- if .HasHaser -}} if !{{.GoReceiverName}}.{{.HaserMethodName}}() { return nil, nil } {{- end -}} return {{.GoReceiverName}}.{{.GoFieldName}}, nil {{- end }} {{- end }} ================================================ FILE: codegen/field_test.go ================================================ package codegen import ( "go/ast" "go/importer" "go/parser" "go/token" "go/types" "testing" "github.com/stretchr/testify/require" "github.com/vektah/gqlparser/v2" ast2 "github.com/vektah/gqlparser/v2/ast" "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/internal/code" ) func TestFindField(t *testing.T) { input := ` package test type Std struct { Name string Value int } type Anon struct { Name string Tags } type Tags struct { Bar string ` + "`" + `gqlgen:"foo"` + "`" + ` Foo int ` + "`" + `gqlgen:"bar"` + "`" + ` } type Amb struct { Bar string ` + "`" + `gqlgen:"foo"` + "`" + ` Foo int ` + "`" + `gqlgen:"foo"` + "`" + ` } type Embed struct { Std Test string } ` scope, err := parseScope(input, "test") require.NoError(t, err) std := scope.Lookup("Std").Type().(*types.Named) anon := scope.Lookup("Anon").Type().(*types.Named) tags := scope.Lookup("Tags").Type().(*types.Named) amb := scope.Lookup("Amb").Type().(*types.Named) embed := scope.Lookup("Embed").Type().(*types.Named) tests := []struct { Name string Named *types.Named Field string Tag string Expected string ShouldError bool }{ {"Finds a field by name with no tag", std, "name", "", "Name", false}, { "Finds a field by name when passed tag but tag not used", std, "name", "gqlgen", "Name", false, }, {"Ignores tags when not passed a tag", tags, "foo", "", "Foo", false}, { "Picks field with tag over field name when passed a tag", tags, "foo", "gqlgen", "Bar", false, }, {"Errors when ambiguous", amb, "foo", "gqlgen", "", true}, {"Finds a field that is in embedded struct", anon, "bar", "", "Bar", false}, {"Finds field that is not in embedded struct", embed, "test", "", "Test", false}, } for _, tt := range tests { b := builder{Config: &config.Config{StructTag: tt.Tag}} target, err := b.findBindTarget(tt.Named, tt.Field, false) if tt.ShouldError { require.Nil(t, target, tt.Name) require.Error(t, err, tt.Name) } else { require.NoError(t, err, tt.Name) require.Equal(t, tt.Expected, target.Name(), tt.Name) } } } func parseScope(input any, packageName string) (*types.Scope, error) { // test setup to parse the types fset := token.NewFileSet() f, err := parser.ParseFile(fset, "test.go", input, 0) if err != nil { return nil, err } conf := types.Config{Importer: importer.Default()} pkg, err := conf.Check(packageName, fset, []*ast.File{f}, nil) if err != nil { return nil, err } return pkg.Scope(), nil } func TestEqualFieldName(t *testing.T) { tt := []struct { Name string Source string Target string Expected bool }{ {Name: "words with same case", Source: "test", Target: "test", Expected: true}, {Name: "words different case", Source: "test", Target: "tEsT", Expected: true}, {Name: "different words", Source: "foo", Target: "bar", Expected: false}, {Name: "separated with underscore", Source: "the_test", Target: "TheTest", Expected: true}, {Name: "empty values", Source: "", Target: "", Expected: true}, } for _, tc := range tt { t.Run(tc.Name, func(t *testing.T) { result := equalFieldName(tc.Source, tc.Target) require.Equal(t, tc.Expected, result) }) } } func TestField_Batch(t *testing.T) { t.Run("Batch flag defaults to false", func(t *testing.T) { f := Field{} require.False(t, f.Batch) require.False(t, f.IsBatch()) }) t.Run("Batch flag can be set", func(t *testing.T) { f := Field{Batch: true} require.True(t, f.Batch) require.True(t, f.IsBatch()) }) } func TestField_BatchRootFieldUnsupported(t *testing.T) { cfg := &config.Config{ Exec: config.ExecConfig{ Layout: config.ExecLayoutSingleFile, Filename: "generated.go", Package: "generated", }, Models: config.TypeMap{ "Query": { Fields: map[string]config.TypeMapField{ "version": {Batch: true}, }, }, "Boolean": { Model: config.StringList{"github.com/99designs/gqlgen/graphql.Boolean"}, }, "Float": { Model: config.StringList{"github.com/99designs/gqlgen/graphql.Float"}, }, "ID": { Model: config.StringList{"github.com/99designs/gqlgen/graphql.ID"}, }, "Int": { Model: config.StringList{"github.com/99designs/gqlgen/graphql.Int"}, }, "String": { Model: config.StringList{"github.com/99designs/gqlgen/graphql.String"}, }, }, Directives: map[string]config.DirectiveConfig{}, Packages: code.NewPackages(), } cfg.Schema = gqlparser.MustLoadSchema(&ast2.Source{ Name: "schema.graphql", Input: ` schema { query: Query } type Query { version: String } `, }) b := builder{ Config: cfg, Schema: cfg.Schema, } b.Binder = b.Config.NewBinder() var err error b.Directives, err = b.buildDirectives() require.NoError(t, err) _, err = b.buildObject(cfg.Schema.Query) require.Error(t, err) require.Contains(t, err.Error(), "batch resolver is not supported for root field Query.version") } func TestField_CallArgs(t *testing.T) { tt := []struct { Name string Field Expected string }{ { Name: "Field with method that has context, and three args (string, interface, named interface)", Field: Field{ MethodHasContext: true, Args: []*FieldArgument{ { ArgumentDefinition: &ast2.ArgumentDefinition{ Name: "test", }, TypeReference: &config.TypeReference{ GO: (&types.Interface{}).Complete(), }, }, { ArgumentDefinition: &ast2.ArgumentDefinition{ Name: "test2", }, TypeReference: &config.TypeReference{ GO: types.NewNamed( types.NewTypeName(token.NoPos, nil, "TestInterface", nil), (&types.Interface{}).Complete(), nil, ), }, }, { ArgumentDefinition: &ast2.ArgumentDefinition{ Name: "test3", }, TypeReference: &config.TypeReference{ GO: types.Typ[types.String], }, }, }, }, Expected: `ctx, ` + ` func () any { if fc.Args["test"] == nil { return nil } return fc.Args["test"].(any) }(), fc.Args["test2"].(TestInterface), fc.Args["test3"].(string)`, }, { Name: "Resolver field that isn't root object with single int argument", Field: Field{ Object: &Object{ Root: false, }, IsResolver: true, Args: []*FieldArgument{ { ArgumentDefinition: &ast2.ArgumentDefinition{ Name: "test", }, TypeReference: &config.TypeReference{ GO: types.Typ[types.Int], }, }, }, }, Expected: `ctx, obj, fc.Args["test"].(int)`, }, } for _, tc := range tt { t.Run(tc.Name, func(t *testing.T) { require.Equal(t, tc.Expected, tc.CallArgs()) }) } } func TestField_BatchCallArgs(t *testing.T) { tt := []struct { Name string Field Field Expected string }{ { Name: "Batch args with single int argument", Field: Field{ Args: []*FieldArgument{ { ArgumentDefinition: &ast2.ArgumentDefinition{ Name: "test", }, TypeReference: &config.TypeReference{ GO: types.Typ[types.Int], }, }, }, }, Expected: `ctx, parents, fc.Args["test"].(int)`, }, { Name: "Batch args with empty interface and string", Field: Field{ Args: []*FieldArgument{ { ArgumentDefinition: &ast2.ArgumentDefinition{ Name: "test", }, TypeReference: &config.TypeReference{ GO: (&types.Interface{}).Complete(), }, }, { ArgumentDefinition: &ast2.ArgumentDefinition{ Name: "test2", }, TypeReference: &config.TypeReference{ GO: types.Typ[types.String], }, }, }, }, Expected: `ctx, parents, ` + ` func () any { if fc.Args["test"] == nil { return nil } return fc.Args["test"].(any) }(), fc.Args["test2"].(string)`, }, } for _, tc := range tt { t.Run(tc.Name, func(t *testing.T) { require.Equal(t, tc.Expected, tc.Field.BatchCallArgs("parents")) }) } } func TestField_ShortBatchResolverDeclaration(t *testing.T) { f := Field{ FieldDefinition: &ast2.FieldDefinition{ Name: "value", }, Object: &Object{ Definition: &ast2.Definition{ Name: "User", }, Type: types.Typ[types.Int], }, TypeReference: &config.TypeReference{ GO: types.Typ[types.String], }, Args: []*FieldArgument{ { ArgumentDefinition: &ast2.ArgumentDefinition{ Name: "limit", }, VarName: "limit", TypeReference: &config.TypeReference{ GO: types.Typ[types.Int], }, }, }, } require.Equal( t, "(ctx context.Context, objs []*int, limit int) ([]string, error)", f.ShortBatchResolverDeclaration(), ) } ================================================ FILE: codegen/generate.go ================================================ package codegen import ( "embed" "errors" "fmt" "path/filepath" "strings" "github.com/vektah/gqlparser/v2/ast" "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/codegen/templates" ) //go:embed *.gotpl var codegenTemplates embed.FS func GenerateCode(data *Data) error { if !data.Config.Exec.IsDefined() { return errors.New("missing exec config") } switch data.Config.Exec.Layout { case config.ExecLayoutSingleFile: return generateSingleFile(data) case config.ExecLayoutFollowSchema: return generatePerSchema(data) } return fmt.Errorf("unrecognized exec layout %s", data.Config.Exec.Layout) } func generateSingleFile(data *Data) error { return templates.Render(templates.Options{ PackageName: data.Config.Exec.Package, Filename: data.Config.Exec.Filename, Data: data, RegionTags: true, GeneratedHeader: true, Packages: data.Config.Packages, TemplateFS: codegenTemplates, PruneOptions: data.Config.GetPruneOptions(), }) } func generatePerSchema(data *Data) error { err := generateRootFile(data) if err != nil { return err } builds := map[string]*Data{} err = addObjects(data, &builds) if err != nil { return err } err = addInputs(data, &builds) if err != nil { return err } err = addInterfaces(data, &builds) if err != nil { return err } err = addReferencedTypes(data, &builds) if err != nil { return err } for filename, build := range builds { if filename == "" { continue } dir := data.Config.Exec.DirName path := filepath.Join(dir, filename) err = templates.Render(templates.Options{ PackageName: data.Config.Exec.Package, Filename: path, Data: build, RegionTags: true, GeneratedHeader: true, Packages: data.Config.Packages, TemplateFS: codegenTemplates, PruneOptions: data.Config.GetPruneOptions(), }) if err != nil { return err } } return nil } func filename(p *ast.Position, config *config.Config) string { name := "common!" if p != nil && p.Src != nil { gqlname := filepath.Base(p.Src.Name) ext := filepath.Ext(p.Src.Name) name = strings.TrimSuffix(gqlname, ext) } filenameTempl := config.Exec.FilenameTemplate if filenameTempl == "" { filenameTempl = "{name}.generated.go" } return strings.ReplaceAll(filenameTempl, "{name}", name) } func addBuild(filename string, p *ast.Position, data *Data, builds *map[string]*Data) { buildConfig := *data.Config if p != nil { buildConfig.Sources = []*ast.Source{p.Src} } (*builds)[filename] = &Data{ Config: &buildConfig, QueryRoot: data.QueryRoot, MutationRoot: data.MutationRoot, SubscriptionRoot: data.SubscriptionRoot, AllDirectives: data.AllDirectives, } } //go:embed root_.gotpl var rootTemplate string // Root file contains top-level definitions that should not be duplicated across the generated // files for each schema file. func generateRootFile(data *Data) error { dir := data.Config.Exec.DirName path := filepath.Join(dir, "root_.generated.go") return templates.Render(templates.Options{ PackageName: data.Config.Exec.Package, Template: rootTemplate, Filename: path, Data: data, RegionTags: false, GeneratedHeader: true, Packages: data.Config.Packages, TemplateFS: codegenTemplates, PruneOptions: data.Config.GetPruneOptions(), }) } func addObjects(data *Data, builds *map[string]*Data) error { for _, o := range data.Objects { filename := filename(o.Position, data.Config) if (*builds)[filename] == nil { addBuild(filename, o.Position, data, builds) } (*builds)[filename].Objects = append((*builds)[filename].Objects, o) } return nil } func addInputs(data *Data, builds *map[string]*Data) error { for _, in := range data.Inputs { filename := filename(in.Position, data.Config) if (*builds)[filename] == nil { addBuild(filename, in.Position, data, builds) } (*builds)[filename].Inputs = append((*builds)[filename].Inputs, in) } return nil } func addInterfaces(data *Data, builds *map[string]*Data) error { for k, inf := range data.Interfaces { filename := filename(inf.Position, data.Config) if (*builds)[filename] == nil { addBuild(filename, inf.Position, data, builds) } build := (*builds)[filename] if build.Interfaces == nil { build.Interfaces = map[string]*Interface{} } if build.Interfaces[k] != nil { return errors.New("conflicting interface keys") } build.Interfaces[k] = inf } return nil } func addReferencedTypes(data *Data, builds *map[string]*Data) error { for k, rt := range data.ReferencedTypes { filename := filename(rt.Definition.Position, data.Config) if (*builds)[filename] == nil { addBuild(filename, rt.Definition.Position, data, builds) } build := (*builds)[filename] if build.ReferencedTypes == nil { build.ReferencedTypes = map[string]*config.TypeReference{} } if build.ReferencedTypes[k] != nil { return errors.New("conflicting referenced type keys") } build.ReferencedTypes[k] = rt } return nil } ================================================ FILE: codegen/generated!.gotpl ================================================ {{/* Context object: codegen.Data */}} {{ reserveImport "context" }} {{ reserveImport "fmt" }} {{ reserveImport "io" }} {{ reserveImport "strconv" }} {{ reserveImport "time" }} {{ reserveImport "sync" }} {{ reserveImport "sync/atomic" }} {{ reserveImport "errors" }} {{ reserveImport "bytes" }} {{ reserveImport "embed" }} {{ reserveImport "golang.org/x/sync/semaphore"}} {{ reserveImport "github.com/vektah/gqlparser/v2" "gqlparser" }} {{ reserveImport "github.com/vektah/gqlparser/v2/ast" }} {{ reserveImport "github.com/99designs/gqlgen/graphql" }} {{ reserveImport "github.com/99designs/gqlgen/graphql/introspection" }} {{ $useFunctionSyntaxForExecutionContext := .Config.UseFunctionSyntaxForExecutionContext }} {{ if eq .Config.Exec.Layout "single-file" }} // 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 { {{- range $object := .Objects -}} {{ if $object.HasResolvers -}} {{ucFirst $object.Name}}() {{ucFirst $object.Name}}Resolver {{ end }} {{- end }} {{- range $object := .Inputs -}} {{ if $object.HasResolvers -}} {{ucFirst $object.Name}}() {{ucFirst $object.Name}}Resolver {{ end }} {{- end }} } type DirectiveRoot struct { {{ range $directive := .UserDirectives }} {{- $directive.Declaration }} {{ end }} } type ComplexityRoot struct { {{- if not .Config.OmitComplexity }} {{ range $object := .Objects }} {{ if not $object.IsReserved -}} {{ ucFirst $object.Name }} struct { {{ range $_, $fields := $object.UniqueFields }} {{- $field := index $fields 0 -}} {{ if not $field.IsReserved -}} {{ $field.GoFieldName }} {{ $field.ComplexitySignature }} {{ end }} {{- end }} } {{- end }} {{ end }} {{- end }} } {{ end }} {{ range $object := .Objects -}} {{ if $object.HasResolvers }} type {{ucFirst $object.Name}}Resolver interface { {{ range $field := $object.Fields -}} {{- if $field.IsBatch }} {{- $field.GoFieldName}}{{ $field.ShortBatchResolverDeclaration }} {{- else if $field.IsResolver }} {{- $field.GoFieldName}}{{ $field.ShortResolverDeclaration }} {{- end }} {{ end }} } {{- end }} {{- end }} {{ range $object := .Inputs -}} {{ if $object.HasResolvers }} type {{$object.Name}}Resolver interface { {{ range $field := $object.Fields -}} {{- if $field.IsResolver }} {{- $field.GoFieldName}}{{ $field.ShortResolverDeclaration }} {{- end }} {{ end }} } {{- end }} {{- end }} {{ range $directive := .BuiltInDirectives }} var ( {{- $directive.FunctionImpl }} ) {{ end }} {{ if eq .Config.Exec.Layout "single-file" }} 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 {{ if not .Config.OmitComplexity -}} switch typeName + "." + field { {{ range $object := .Objects }} {{ if not $object.IsReserved }} {{ range $_, $fields := $object.UniqueFields }} {{- $len := len $fields }} {{- range $i, $field := $fields }} {{- $last := eq (add $i 1) $len }} {{- if not $field.IsReserved }} {{- if eq $i 0 }}case {{ end }}"{{$object.Name}}.{{$field.Name}}"{{ if not $last }},{{ else }}: if e.ComplexityRoot.{{ucFirst $object.Name}}.{{$field.GoFieldName}} == nil { break } {{ if $field.Args }} {{ if $useFunctionSyntaxForExecutionContext -}} args, err := {{ $field.ArgsFunc }}(ctx, &ec, rawArgs) {{- else -}} args, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs) {{- end }} if err != nil { return 0, false } {{ end }} return e.ComplexityRoot.{{ucFirst $object.Name}}.{{$field.GoFieldName}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{ end }}), true {{- end }} {{- end }} {{- end }} {{ end }} {{ end }} {{ end }} } {{- end }} return 0, false } func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { opCtx := graphql.GetOperationContext(ctx) ec := newExecutionContext(opCtx, e, make(chan graphql.DeferredResult)) inputUnmarshalMap := graphql.BuildUnmarshalerMap( {{- range $input := .Inputs -}} {{ if not $input.HasUnmarshal }} {{ if $useFunctionSyntaxForExecutionContext -}} unmarshalInput{{ $input.Name }}, {{- else -}} ec.unmarshalInput{{ $input.Name }}, {{- end }} {{- end }} {{- end }} ) first := true switch opCtx.Operation.Operation { {{- if .QueryRoot }} case ast.Query: return func(ctx context.Context) *graphql.Response { var response graphql.Response var data graphql.Marshaler if first { first = false ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) {{ if .Directives.LocationDirectives "QUERY" -}} {{ if $useFunctionSyntaxForExecutionContext -}} data = _queryMiddleware(ctx, &ec, opCtx.Operation, func(ctx context.Context) (any, error){ return _{{.QueryRoot.Name}}(ctx, ec, opCtx.Operation.SelectionSet), nil {{- else -}} data = ec._queryMiddleware(ctx, opCtx.Operation, func(ctx context.Context) (any, error){ return ec._{{.QueryRoot.Name}}(ctx, opCtx.Operation.SelectionSet), nil {{- end }} }) {{- else -}} {{ if $useFunctionSyntaxForExecutionContext -}} data = _{{.QueryRoot.Name}}(ctx, &ec, opCtx.Operation.SelectionSet) {{- else -}} data = ec._{{.QueryRoot.Name}}(ctx, opCtx.Operation.SelectionSet) {{- end }} {{- end }} } else { if atomic.LoadInt32(&ec.PendingDeferred) > 0 { result := <-ec.DeferredResults atomic.AddInt32(&ec.PendingDeferred, -1) data = result.Result response.Path = result.Path response.Label = result.Label response.Errors = result.Errors } else { return nil } } var buf bytes.Buffer data.MarshalGQL(&buf) response.Data = buf.Bytes() if atomic.LoadInt32(&ec.Deferred) > 0 { hasNext := atomic.LoadInt32(&ec.PendingDeferred) > 0 response.HasNext = &hasNext } return &response } {{ end }} {{- if .MutationRoot }} case ast.Mutation: return func(ctx context.Context) *graphql.Response { if !first { return nil } first = false ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) {{ if .Directives.LocationDirectives "MUTATION" -}} {{ if $useFunctionSyntaxForExecutionContext -}} data := _mutationMiddleware(ctx, &ec, opCtx.Operation, func(ctx context.Context) (any, error){ return _{{.MutationRoot.Name}}(ctx, ec, opCtx.Operation.SelectionSet), nil {{- else -}} data := ec._mutationMiddleware(ctx, opCtx.Operation, func(ctx context.Context) (any, error){ return ec._{{.MutationRoot.Name}}(ctx, opCtx.Operation.SelectionSet), nil {{- end }} }) {{- else -}} {{ if $useFunctionSyntaxForExecutionContext -}} data := _{{.MutationRoot.Name}}(ctx, &ec, opCtx.Operation.SelectionSet) {{- else -}} data := ec._{{.MutationRoot.Name}}(ctx, opCtx.Operation.SelectionSet) {{- end }} {{- end }} var buf bytes.Buffer data.MarshalGQL(&buf) return &graphql.Response{ Data: buf.Bytes(), } } {{ end }} {{- if .SubscriptionRoot }} case ast.Subscription: {{ if .Directives.LocationDirectives "SUBSCRIPTION" -}} {{ if $useFunctionSyntaxForExecutionContext -}} next := _subscriptionMiddleware(ctx, &ec, opCtx.Operation, func(ctx context.Context) (any, error){ return _{{.SubscriptionRoot.Name}}(ctx, ec, opCtx.Operation.SelectionSet),nil {{- else -}} next := ec._subscriptionMiddleware(ctx, opCtx.Operation, func(ctx context.Context) (any, error){ return ec._{{.SubscriptionRoot.Name}}(ctx, opCtx.Operation.SelectionSet),nil {{- end }} }) {{- else -}} {{ if $useFunctionSyntaxForExecutionContext -}} next := _{{.SubscriptionRoot.Name}}(ctx, &ec, opCtx.Operation.SelectionSet) {{- else -}} next := ec._{{.SubscriptionRoot.Name}}(ctx, opCtx.Operation.SelectionSet) {{- end }} {{- end }} var buf bytes.Buffer return func(ctx context.Context) *graphql.Response { buf.Reset() data := next(ctx) if data == nil { return nil } data.MarshalGQL(&buf) return &graphql.Response{ Data: buf.Bytes(), } } {{ end }} default: return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) } } type executionContext struct { *graphql.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, ), } } {{if .HasEmbeddableSources }} //go:embed{{- range $source := .AugmentedSources }}{{if $source.Embeddable}} {{$source.RelativePath|quote}}{{end}}{{- end }} var sourcesFS embed.FS func sourceData(filename string) string { data, err := sourcesFS.ReadFile(filename) if err != nil { panic(fmt.Sprintf("codegen problem: %s not available", filename)) } return string(data) } {{- end }} var sources = []*ast.Source{ {{- range $source := .AugmentedSources }} {Name: {{$source.RelativePath|quote}}, Input: {{if (not $source.Embeddable)}}{{$source.Source|rawQuote}}{{else}}sourceData({{$source.RelativePath|quote}}){{end}}, BuiltIn: {{$source.BuiltIn}}}, {{- end }} } var parsedSchema = gqlparser.MustLoadSchema(sources...) {{ end }} ================================================ FILE: codegen/incremental.go ================================================ package codegen import ( "errors" "log" ) // IncrementalOptions configures incremental generation type IncrementalOptions struct { // ChangedSchemas is the list of schema file paths that have changed. // If empty, performs full generation. ChangedSchemas []string // Verbose enables detailed logging Verbose bool } // GenerateCodeIncremental generates code with content-based file writing. // Files are only written if their content has changed, preserving mtimes // for unchanged files and allowing Go's build cache to remain valid. // // The changedSchemas parameter is used for logging purposes to show what // triggered the regeneration. The actual optimization comes from the // content-based file writing in templates.write(). func GenerateCodeIncremental(data *Data, opts IncrementalOptions) error { if !data.Config.Exec.IsDefined() { return errors.New("missing exec config") } if opts.Verbose && len(opts.ChangedSchemas) > 0 { // Build dependency graph for informational logging depGraph := BuildDependencyGraph(data.Config.Schema) affectedSchemas := depGraph.GetAffectedSchemas(opts.ChangedSchemas) affectedTypes := depGraph.GetTypesForSchemas(affectedSchemas) log.Printf("[incremental] Changed: %d, Affected: %d schemas, %d types\n", len(opts.ChangedSchemas), len(affectedSchemas), len(affectedTypes)) } // Perform full generation - the content-based write() in templates // will skip writing files whose content hasn't changed, preserving // their mtime and keeping Go's build cache valid. return GenerateCode(data) } ================================================ FILE: codegen/incremental_test.go ================================================ package codegen import ( "testing" "github.com/stretchr/testify/require" "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" "github.com/99designs/gqlgen/codegen/config" ) // TestGenerateCodeIncremental_SelectiveGeneration verifies that incremental generation // only regenerates files for affected schemas (the core optimization). func TestGenerateCodeIncremental_SelectiveGeneration(t *testing.T) { // Create temp directory for generated files _ = t.TempDir() // Create schema with multiple files that have dependencies: // user.graphqls: User type // post.graphqls: Post type (references User) // comment.graphqls: Comment type (independent) userSchema := &ast.Source{ Name: "user.graphqls", Input: `type User { id: ID! name: String! }`, } postSchema := &ast.Source{ Name: "post.graphqls", Input: `type Post { id: ID! title: String! author: User! }`, } commentSchema := &ast.Source{ Name: "comment.graphqls", Input: `type Comment { id: ID! text: String! }`, } querySchema := &ast.Source{ Name: "schema.graphqls", Input: `type Query { user: User post: Post comment: Comment }`, } schema, err := gqlparser.LoadSchema(userSchema, postSchema, commentSchema, querySchema) require.NoError(t, err) // Build dependency graph depGraph := BuildDependencyGraph(schema) // Test 1: Changing user.graphqls should affect post.graphqls (Post references User) affected := depGraph.GetAffectedSchemas([]string{"user.graphqls"}) require.Contains(t, affected, "user.graphqls", "changed schema should be affected") require.Contains(t, affected, "post.graphqls", "post depends on user") require.NotContains( t, affected, "comment.graphqls", "comment is independent", ) // Test 2: Changing comment.graphqls affects itself and schema.graphqls affected = depGraph.GetAffectedSchemas([]string{"comment.graphqls"}) require.Contains(t, affected, "comment.graphqls", "changed schema should be affected") require.Contains(t, affected, "schema.graphqls", "Query references Comment") require.NotContains(t, affected, "user.graphqls", "user is independent") require.NotContains(t, affected, "post.graphqls", "post is independent") // Test 3: Verify the type filtering works correctly affectedTypes := depGraph.GetTypesForSchemas([]string{"user.graphqls"}) require.True(t, affectedTypes["User"], "User should be in affected types") require.False( t, affectedTypes["Post"], "Post should NOT be in affected types for user schema only", ) require.False(t, affectedTypes["Comment"], "Comment should NOT be in affected types") } // TestGenerateCodeIncremental_CorrectnessWithRealSchema verifies that incremental // generation produces the same filtering behavior as expected with real Data structures. func TestGenerateCodeIncremental_CorrectnessWithRealSchema(t *testing.T) { // Create a schema with cross-file dependencies sources := []*ast.Source{ {Name: "user.graphqls", Input: `type User { id: ID!, name: String! }`}, {Name: "post.graphqls", Input: `type Post { id: ID!, author: User! }`}, {Name: "tag.graphqls", Input: `type Tag { id: ID!, label: String! }`}, } schema, err := gqlparser.LoadSchema(sources...) require.NoError(t, err) depGraph := BuildDependencyGraph(schema) // Verify dependency detection require.Contains(t, depGraph.TypeDependencies["Post"], "User", "Post should depend on User") require.Empty(t, depGraph.TypeDependencies["Tag"], "Tag should have no dependencies (only uses built-in scalars)") // Verify schema-level dependencies require.True(t, depGraph.SchemaDependencies["post.graphqls"]["user.graphqls"], "post.graphqls should depend on user.graphqls") require.Empty(t, depGraph.SchemaDependencies["tag.graphqls"], "tag.graphqls should have no schema dependencies") // Test transitive closure affected := depGraph.GetAffectedSchemas([]string{"user.graphqls"}) require.Contains(t, affected, "post.graphqls", "post should be affected when user changes") require.NotContains(t, affected, "tag.graphqls", "tag should NOT be affected when user changes") } // TestGenerateCodeIncremental_DiamondDependency tests a diamond dependency pattern: // D depends on B and C, both B and C depend on A. // Changing A should affect all four. func TestGenerateCodeIncremental_DiamondDependency(t *testing.T) { sources := []*ast.Source{ {Name: "a.graphqls", Input: `type TypeA { id: ID! }`}, {Name: "b.graphqls", Input: `type TypeB { id: ID!, a: TypeA! }`}, {Name: "c.graphqls", Input: `type TypeC { id: ID!, a: TypeA! }`}, {Name: "d.graphqls", Input: `type TypeD { id: ID!, b: TypeB!, c: TypeC! }`}, } schema, err := gqlparser.LoadSchema(sources...) require.NoError(t, err) depGraph := BuildDependencyGraph(schema) // Changing A should affect B, C, and D (all depend on A directly or transitively) affected := depGraph.GetAffectedSchemas([]string{"a.graphqls"}) require.ElementsMatch(t, []string{"a.graphqls", "b.graphqls", "c.graphqls", "d.graphqls"}, affected, "diamond dependency: all should be affected when root changes") // Changing B should only affect B and D affected = depGraph.GetAffectedSchemas([]string{"b.graphqls"}) require.ElementsMatch(t, []string{"b.graphqls", "d.graphqls"}, affected, "changing B should affect B and D only") // Changing D should only affect D affected = depGraph.GetAffectedSchemas([]string{"d.graphqls"}) require.ElementsMatch(t, []string{"d.graphqls"}, affected, "changing leaf D should only affect itself") } // TestGenerateCodeIncremental_InputTypes verifies that input type dependencies // are correctly tracked (important for mutations with input arguments). func TestGenerateCodeIncremental_InputTypes(t *testing.T) { sources := []*ast.Source{ {Name: "input.graphqls", Input: `input CreateUserInput { name: String!, email: String! }`}, {Name: "mutation.graphqls", Input: ` type Mutation { createUser(input: CreateUserInput!): User! } type User { id: ID!, name: String! } `}, } schema, err := gqlparser.LoadSchema(sources...) require.NoError(t, err) depGraph := BuildDependencyGraph(schema) // Mutation schema should depend on input schema require.True(t, depGraph.SchemaDependencies["mutation.graphqls"]["input.graphqls"], "mutation should depend on input type schema") // Changing input should affect mutation affected := depGraph.GetAffectedSchemas([]string{"input.graphqls"}) require.Contains(t, affected, "mutation.graphqls", "mutation should be affected when input type changes") } func TestGenerateCodeIncremental_FallbackToFullGeneration(t *testing.T) { tests := []struct { name string layout config.ExecLayout changed []string }{ { name: "single-file layout falls back to full generation", layout: config.ExecLayoutSingleFile, changed: []string{"user.graphqls"}, }, { name: "no changed schemas falls back to full generation", layout: config.ExecLayoutFollowSchema, changed: []string{}, }, { name: "nil changed schemas falls back to full generation", layout: config.ExecLayoutFollowSchema, changed: nil, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { // Create minimal data with missing exec config to trigger early error // This validates that the fallback path is taken (GenerateCode is called) data := &Data{ Config: &config.Config{ Exec: config.ExecConfig{ Layout: tt.layout, }, }, } opts := IncrementalOptions{ ChangedSchemas: tt.changed, Verbose: false, } // Both incremental and full generation will fail with "missing exec config" // This confirms the code path is working (we're not testing actual generation here) err := GenerateCodeIncremental(data, opts) require.Error(t, err) require.Contains(t, err.Error(), "missing exec config") }) } } func TestGenerateCodeIncremental_MissingExecConfig(t *testing.T) { data := &Data{ Config: &config.Config{}, } err := GenerateCodeIncremental(data, IncrementalOptions{}) require.Error(t, err) require.Contains(t, err.Error(), "missing exec config") } func TestIncrementalOptions(t *testing.T) { // Test that IncrementalOptions struct works as expected opts := IncrementalOptions{ ChangedSchemas: []string{"a.graphqls", "b.graphqls"}, Verbose: true, } require.Len(t, opts.ChangedSchemas, 2) require.True(t, opts.Verbose) // Empty options emptyOpts := IncrementalOptions{} require.Nil(t, emptyOpts.ChangedSchemas) require.False(t, emptyOpts.Verbose) } ================================================ FILE: codegen/inline_arguments.go ================================================ package codegen import ( "bytes" "fmt" "github.com/vektah/gqlparser/v2/ast" "github.com/vektah/gqlparser/v2/formatter" ) // InlineArgsInfo stores metadata about arguments that were inlined. // Used during codegen to bundle expanded arguments back into a single resolver parameter. type InlineArgsInfo struct { OriginalArgName string OriginalType string OriginalASTType *ast.Type GoType string ExpandedArgs []string } // inlineArgsMetadata maps "TypeName.FieldName" to inline args metadata. var inlineArgsMetadata = make(map[string]*InlineArgsInfo) // ExpandInlineArguments expands arguments marked with @inlineArguments // and stores metadata for later codegen phase. func ExpandInlineArguments(schema *ast.Schema) error { for typeName, typeDef := range schema.Types { if typeDef.Kind != ast.Object && typeDef.Kind != ast.Interface { continue } for _, field := range typeDef.Fields { var inlinedIndices []int var expandedArguments [][]*ast.ArgumentDefinition for i, arg := range field.Arguments { if arg.Directives.ForName("inlineArguments") == nil { continue } argTypeName := arg.Type.Name() inputType := schema.Types[argTypeName] if inputType == nil { return fmt.Errorf( "@inlineArguments on %s.%s(%s): type %s not found in schema", typeName, field.Name, arg.Name, argTypeName, ) } if inputType.Kind != ast.InputObject { return fmt.Errorf( "@inlineArguments on %s.%s(%s): type %s must be an INPUT_OBJECT (input types only), got %s. The directive can only expand input object types into individual arguments", typeName, field.Name, arg.Name, argTypeName, inputType.Kind, ) } var expanded []*ast.ArgumentDefinition var expandedNames []string for _, inputField := range inputType.Fields { expandedArg := &ast.ArgumentDefinition{ Name: inputField.Name, Type: inputField.Type, Description: inputField.Description, DefaultValue: inputField.DefaultValue, Directives: inputField.Directives, Position: inputField.Position, } expanded = append(expanded, expandedArg) expandedNames = append(expandedNames, inputField.Name) } goType := argTypeName if goModelDir := inputType.Directives.ForName("goModel"); goModelDir != nil { if modelArg := goModelDir.Arguments.ForName("model"); modelArg != nil { if modelValue, err := modelArg.Value.Value(nil); err == nil { goType = modelValue.(string) } } } key := fmt.Sprintf("%s.%s", typeName, field.Name) inlineArgsMetadata[key] = &InlineArgsInfo{ OriginalArgName: arg.Name, OriginalType: argTypeName, OriginalASTType: arg.Type, GoType: goType, ExpandedArgs: expandedNames, } inlinedIndices = append(inlinedIndices, i) expandedArguments = append(expandedArguments, expanded) } if len(inlinedIndices) > 0 { var newArgs ast.ArgumentDefinitionList for i, arg := range field.Arguments { inlinedIdx := -1 for idx, inlined := range inlinedIndices { if inlined == i { inlinedIdx = idx break } } if inlinedIdx >= 0 { newArgs = append(newArgs, expandedArguments[inlinedIdx]...) } else { newArgs = append(newArgs, arg) } } field.Arguments = newArgs } } } return nil } // GetInlineArgsMetadata retrieves metadata for a given type and field. func GetInlineArgsMetadata(typeName, fieldName string) *InlineArgsInfo { key := fmt.Sprintf("%s.%s", typeName, fieldName) return inlineArgsMetadata[key] } // ClearInlineArgsMetadata clears all stored metadata. func ClearInlineArgsMetadata() { inlineArgsMetadata = make(map[string]*InlineArgsInfo) } func SerializeTransformedSchema( schema *ast.Schema, originalSources []*ast.Source, ) ([]*ast.Source, error) { if len(inlineArgsMetadata) == 0 { return originalSources, nil } var buf bytes.Buffer f := formatter.NewFormatter(&buf) f.FormatSchema(schema) return []*ast.Source{ { Name: "inline_arguments_transformed_schema.graphql", Input: buf.String(), BuiltIn: true, }, }, nil } ================================================ FILE: codegen/inline_arguments_test.go ================================================ package codegen import ( "testing" "github.com/stretchr/testify/require" "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" ) func TestExpandInlineArguments(t *testing.T) { ClearInlineArgsMetadata() schemaDoc := ` directive @inlineArguments on ARGUMENT_DEFINITION directive @goModel(model: String) on INPUT_OBJECT input SearchArgs @goModel(model: "map[string]any") { query: String category: String minPrice: Float } type Product { id: ID! name: String! } type Query { searchProducts(args: SearchArgs @inlineArguments): [Product!]! } ` schema, err := gqlparser.LoadSchema(&ast.Source{Input: schemaDoc}) require.NoError(t, err) queryType := schema.Types["Query"] require.NotNil(t, queryType) // Find searchProducts field (gqlparser adds introspection fields) var searchField *ast.FieldDefinition for _, f := range queryType.Fields { if f.Name == "searchProducts" { searchField = f break } } require.NotNil(t, searchField) require.Len(t, searchField.Arguments, 1) require.Equal(t, "args", searchField.Arguments[0].Name) err = ExpandInlineArguments(schema) require.NoError(t, err) queryType = schema.Types["Query"] searchField = nil for _, f := range queryType.Fields { if f.Name == "searchProducts" { searchField = f break } } require.NotNil(t, searchField) // Should now have 3 arguments instead of 1 require.Len(t, searchField.Arguments, 3, "Arguments should be expanded") require.Equal(t, "query", searchField.Arguments[0].Name) require.Equal(t, "category", searchField.Arguments[1].Name) require.Equal(t, "minPrice", searchField.Arguments[2].Name) metadata := GetInlineArgsMetadata("Query", "searchProducts") require.NotNil(t, metadata) require.Equal(t, "args", metadata.OriginalArgName) require.Equal(t, "SearchArgs", metadata.OriginalType) require.Equal(t, "map[string]any", metadata.GoType) require.Equal(t, []string{"query", "category", "minPrice"}, metadata.ExpandedArgs) } func TestExpandInlineArgumentsError(t *testing.T) { ClearInlineArgsMetadata() schemaDoc := ` directive @inlineArguments on ARGUMENT_DEFINITION type Query { test(arg: String @inlineArguments): String } ` schema, err := gqlparser.LoadSchema(&ast.Source{Input: schemaDoc}) require.NoError(t, err) err = ExpandInlineArguments(schema) require.Error(t, err) require.Contains(t, err.Error(), "must be an INPUT_OBJECT") } ================================================ FILE: codegen/input.gotpl ================================================ {{ $useFunctionSyntaxForExecutionContext := .Config.UseFunctionSyntaxForExecutionContext }} {{- range $input := .Inputs }} {{- if not .HasUnmarshal }} {{- $it := "it" }} {{- if .PointersInUnmarshalInput }} {{- $it = "&it" }} {{- end }} {{ if $useFunctionSyntaxForExecutionContext -}} func unmarshalInput{{ .Name }}(ctx context.Context, ec *executionContext, obj any) ({{ if .PointersInUnmarshalInput }}*{{ end }}{{.Type | ref}}, error) { {{- else -}} func (ec *executionContext) unmarshalInput{{ .Name }}(ctx context.Context, obj any) ({{ if .PointersInUnmarshalInput }}*{{ end }}{{.Type | ref}}, error) { {{- end }} var it {{.Type | ref}} if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } {{ range $field := .Fields}} {{- if notNil "Default" $field }} if _, present := asMap[{{$field.Name|quote}}] ; !present { asMap[{{$field.Name|quote}}] = {{ $field.Default | dump }} } {{- end}} {{- end }} fieldsInOrder := [...]string{ {{ range .Fields }}{{ quote .Name }},{{ end }} } {{- if $input.IsMap }} it = make(map[string]any, len(asMap)) {{- end }} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { {{- range $field := .Fields }} case {{$field.Name|quote}}: {{- $lhs := (printf "it.%s" $field.GoFieldName) }} {{- if $input.IsMap }} {{- $lhs = (printf "it[%q]" $field.Name) }} {{- end }} ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField({{$field.Name|quote}})) {{- if $field.ImplDirectives }} {{ if $useFunctionSyntaxForExecutionContext -}} directive0 := func(ctx context.Context) (any, error) { return {{ $field.TypeReference.UnmarshalFunc }}(ctx, ec, v) } {{- else -}} directive0 := func(ctx context.Context) (any, error) { return ec.{{ $field.TypeReference.UnmarshalFunc }}(ctx, v) } {{- end }} {{ template "implDirectives" (dict "Field" $field "UseFunctionSyntaxForExecutionContext" $useFunctionSyntaxForExecutionContext) }} tmp, err := directive{{$field.ImplDirectives|len}}(ctx) if err != nil { return {{$it}}, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.({{ $field.TypeReference.GO | ref }}) ; ok { {{- if $field.IsResolver }} if err = ec.Resolvers.{{ $field.ShortInvocation }}; err != nil { return {{$it}}, err } {{- else }} {{- if $field.TypeReference.IsOmittable }} {{ $lhs }} = graphql.OmittableOf(data) {{- else }} {{ $lhs }} = data {{- end }} {{- end }} {{- if $field.TypeReference.IsNilable }} {{- if not $field.IsResolver }} } else if tmp == nil { {{- if $field.TypeReference.IsOmittable }} {{ $lhs }} = graphql.OmittableOf[{{ $field.TypeReference.GO | ref }}](nil) {{- else }} {{ $lhs }} = nil {{- end }} {{- end }} {{- end }} } else { err := fmt.Errorf(`unexpected type %T from directive, should be {{ $field.TypeReference.GO }}`, tmp) return {{$it}}, graphql.ErrorOnPath(ctx, err) } {{- else }} {{- if $field.IsResolver }} {{ if $useFunctionSyntaxForExecutionContext -}} data, err := {{ $field.TypeReference.UnmarshalFunc }}(ctx, ec, v) {{- else -}} data, err := ec.{{ $field.TypeReference.UnmarshalFunc }}(ctx, v) {{- end }} if err != nil { return {{$it}}, err } if err = ec.Resolvers.{{ $field.ShortInvocation }}; err != nil { return {{$it}}, err } {{- else }} {{ if $useFunctionSyntaxForExecutionContext -}} data, err := {{ $field.TypeReference.UnmarshalFunc }}(ctx, ec, v) {{- else -}} data, err := ec.{{ $field.TypeReference.UnmarshalFunc }}(ctx, v) {{- end }} if err != nil { return {{$it}}, err } {{- if $field.TypeReference.IsOmittable }} {{ $lhs }} = graphql.OmittableOf(data) {{- else }} {{ $lhs }} = data {{- end }} {{- end }} {{- end }} {{- end }} } } {{- if $input.InputObjectDirectives }} // Execute INPUT_OBJECT level directives (e.g., @oneOf, @directive3) // These run after all fields have been unmarshaled {{ if $useFunctionSyntaxForExecutionContext -}} directive0 := func(ctx context.Context) (any, error) { return {{$it}}, nil } {{- else -}} directive0 := func(ctx context.Context) (any, error) { return {{$it}}, nil } {{- end }} {{- range $i, $directive := $input.InputObjectDirectives }} directive{{add $i 1}} := func(ctx context.Context) (any, error) { {{- range $arg := $directive.Args }} {{- if notNil "Value" $arg }} {{ if $useFunctionSyntaxForExecutionContext -}} {{ $arg.VarName }}, err := {{ $arg.TypeReference.UnmarshalFunc }}(ctx, ec, {{ $arg.Value | dump }}) {{- else -}} {{ $arg.VarName }}, err := ec.{{ $arg.TypeReference.UnmarshalFunc }}(ctx, {{ $arg.Value | dump }}) {{- end }} if err != nil { return {{$it}}, graphql.ErrorOnPath(ctx, err) } {{- else if notNil "Default" $arg }} {{ if $useFunctionSyntaxForExecutionContext -}} {{ $arg.VarName }}, err := {{ $arg.TypeReference.UnmarshalFunc }}(ctx, ec, {{ $arg.Default | dump }}) {{- else -}} {{ $arg.VarName }}, err := ec.{{ $arg.TypeReference.UnmarshalFunc }}(ctx, {{ $arg.Default | dump }}) {{- end }} if err != nil { return {{$it}}, graphql.ErrorOnPath(ctx, err) } {{- end }} {{- end }} {{- if not $directive.IsBuiltIn}} if {{$directive.CallPath}} == nil { return {{$it}}, errors.New("directive {{$directive.Name}} is not implemented") } {{- end}} return {{$directive.CallPath}}(ctx, asMap, directive{{$i}}) } {{- end }} tmp, err := directive{{$input.InputObjectDirectives|len}}(ctx) if err != nil { return {{$it}}, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.({{ if $input.PointersInUnmarshalInput }}*{{ end }}{{$input.Type | ref}}) ; ok { return data, nil } return {{$it}}, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from INPUT_OBJECT directive, should be {{ if $input.PointersInUnmarshalInput }}*{{ end }}{{$input.Type | ref}}`, tmp)) {{- else }} return {{$it}}, nil {{- end }} } {{- end }} {{ end }} ================================================ FILE: codegen/interface.go ================================================ package codegen import ( "fmt" "go/types" "sort" "github.com/vektah/gqlparser/v2/ast" "github.com/99designs/gqlgen/codegen/config" ) type Interface struct { *ast.Definition Type types.Type Implementors []InterfaceImplementor InTypemap bool } type InterfaceImplementor struct { *ast.Definition Type types.Type TakeRef bool } func (b *builder) buildInterface(typ *ast.Definition) (*Interface, error) { obj, err := b.Binder.DefaultUserObject(typ.Name) if err != nil { panic(err) } i := &Interface{ Definition: typ, Type: obj, InTypemap: b.Config.Models.UserDefined(typ.Name), } interfaceType, err := findGoInterface(i.Type) if interfaceType == nil || err != nil { return nil, fmt.Errorf("%s is not an interface", i.Type) } // Sort so that more specific types are evaluated first. implementors := b.Schema.GetPossibleTypes(typ) sort.SliceStable(implementors, func(i, j int) bool { if len(implementors[i].Interfaces) != len(implementors[j].Interfaces) { return len(implementors[i].Interfaces) > len(implementors[j].Interfaces) } // if they have the same name, they probably ARE the same // so we need to rely on SliceStable or else order is // non-deterministic and causes test failures return implementors[i].Name > implementors[j].Name }) for _, implementor := range implementors { obj, err := b.Binder.DefaultUserObject(implementor.Name) if err != nil { return nil, fmt.Errorf("%s has no backing go type", implementor.Name) } implementorType, err := findGoNamedType(obj) if err != nil { return nil, fmt.Errorf("can not find backing go type %s: %w", obj.String(), err) } else if implementorType == nil { return nil, fmt.Errorf("can not find backing go type %s", obj.String()) } anyValid := false // first check if the value receiver can be nil, eg can we type switch on case Thing: if types.Implements(implementorType, interfaceType) { i.Implementors = append(i.Implementors, InterfaceImplementor{ Definition: implementor, Type: obj, TakeRef: !types.IsInterface(obj), }) anyValid = true } // then check if the pointer receiver can be nil, eg can we type switch on case *Thing: if types.Implements(types.NewPointer(implementorType), interfaceType) { i.Implementors = append(i.Implementors, InterfaceImplementor{ Definition: implementor, Type: types.NewPointer(obj), }) anyValid = true } if !anyValid { return nil, fmt.Errorf( "%s does not satisfy the interface %s", implementorType.String(), i.Type.String(), ) } } return i, nil } func (i *InterfaceImplementor) CanBeNil() bool { return config.IsNilable(i.Type) } ================================================ FILE: codegen/interface.gotpl ================================================ {{ $useFunctionSyntaxForExecutionContext := .Config.UseFunctionSyntaxForExecutionContext }} {{- range $interface := .Interfaces }} {{ if $useFunctionSyntaxForExecutionContext -}} func _{{$interface.Name}}(ctx context.Context, ec *executionContext, sel ast.SelectionSet, obj {{$interface.Type | ref}}) graphql.Marshaler { {{- else -}} func (ec *executionContext) _{{$interface.Name}}(ctx context.Context, sel ast.SelectionSet, obj {{$interface.Type | ref}}) graphql.Marshaler { {{- end }} switch obj := (obj).(type) { case nil: return graphql.Null {{- range $implementor := $interface.Implementors }} case {{$implementor.Type | ref}}: {{- if $implementor.CanBeNil }} if obj == nil { return graphql.Null } {{- end }} {{ if $useFunctionSyntaxForExecutionContext -}} return _{{$implementor.Name}}(ctx, ec, sel, {{ if $implementor.TakeRef }}&{{ end }}obj) {{- else -}} return ec._{{$implementor.Name}}(ctx, sel, {{ if $implementor.TakeRef }}&{{ end }}obj) {{- end }} {{- end }} default: if typedObj, ok := obj.(graphql.Marshaler); ok { return typedObj } else { panic(fmt.Errorf("unexpected type %T; non-generated variants of {{$interface.Name}} must implement graphql.Marshaler", obj)) } } } {{- end }} ================================================ FILE: codegen/object.go ================================================ package codegen import ( "fmt" "go/types" "strconv" "strings" "unicode" "github.com/vektah/gqlparser/v2/ast" "golang.org/x/text/cases" "golang.org/x/text/language" "github.com/99designs/gqlgen/codegen/config" ) type GoFieldType int const ( GoFieldUndefined GoFieldType = iota GoFieldMethod GoFieldVariable GoFieldMap ) type Object struct { *ast.Definition Type types.Type ResolverInterface types.Type Root bool Fields []*Field Implements []*ast.Definition DisableConcurrency bool Stream bool Directives []*Directive PointersInUnmarshalInput bool } func (b *builder) buildObject(typ *ast.Definition) (*Object, error) { dirs, err := b.getDirectives(typ.Directives) if err != nil { return nil, fmt.Errorf("%s: %w", typ.Name, err) } caser := cases.Title(language.English, cases.NoLower) obj := &Object{ Definition: typ, Root: b.Config.IsRoot(typ), DisableConcurrency: typ == b.Schema.Mutation, Stream: typ == b.Schema.Subscription, Directives: dirs, PointersInUnmarshalInput: b.Config.ReturnPointersInUnmarshalInput, ResolverInterface: types.NewNamed( types.NewTypeName(0, b.Config.Exec.Pkg(), caser.String(typ.Name)+"Resolver", nil), nil, nil, ), } if !obj.Root { goObject, err := b.Binder.DefaultUserObject(typ.Name) if err != nil { return nil, err } obj.Type = goObject } for _, intf := range b.Schema.GetImplements(typ) { obj.Implements = append(obj.Implements, b.Schema.Types[intf.Name]) } for _, field := range typ.Fields { if strings.HasPrefix(field.Name, "__") { continue } var f *Field f, err = b.buildField(obj, field) if err != nil { return nil, err } obj.Fields = append(obj.Fields, f) } return obj, nil } func (o *Object) Reference() types.Type { if config.IsNilable(o.Type) { return o.Type } return types.NewPointer(o.Type) } type Objects []*Object func (o *Object) Implementors() string { satisfiedBy := strconv.Quote(o.Name) var satisfiedBySb100 strings.Builder for _, s := range o.Implements { satisfiedBySb100.WriteString(", " + strconv.Quote(s.Name)) } satisfiedBy += satisfiedBySb100.String() return "[]string{" + satisfiedBy + "}" } func (o *Object) HasResolvers() bool { for _, f := range o.Fields { if f.IsResolver || f.IsBatch() { return true } } return false } func (o *Object) HasUnmarshal() bool { if o.IsMap() { return false } for method := range o.Type.(*types.Named).Methods() { if method.Name() == "UnmarshalGQL" { return true } } return false } func (o *Object) HasDirectives() bool { if len(o.Directives) > 0 { return true } for _, f := range o.Fields { if f.HasDirectives() { return true } } return false } // InputObjectDirectives returns directives that should be executed at the INPUT_OBJECT level. // This is used for input types to execute @directives placed on the input object itself, // after all fields have been unmarshaled. // See: https://github.com/99designs/gqlgen/issues/2281 func (o *Object) InputObjectDirectives() []*Directive { if o.Kind != ast.InputObject { return nil } var d []*Directive for _, dir := range o.Directives { if !dir.SkipRuntime && dir.IsLocation(ast.LocationInputObject) { d = append(d, dir) } } return d } func (o *Object) IsConcurrent() bool { for _, f := range o.Fields { if f.IsConcurrent() { return true } } return false } func (o *Object) IsReserved() bool { return strings.HasPrefix(o.Name, "__") } func (o *Object) IsMap() bool { return o.Type == config.MapType } func (o *Object) Description() string { return o.Definition.Description } func (o *Object) HasField(name string) bool { for _, f := range o.Fields { if f.Name == name { return true } } return false } func (os Objects) ByName(name string) *Object { for i, o := range os { if strings.EqualFold(o.Name, name) { return os[i] } } return nil } func ucFirst(s string) string { if s == "" { return "" } r := []rune(s) r[0] = unicode.ToUpper(r[0]) return string(r) } ================================================ FILE: codegen/object.gotpl ================================================ {{ $useFunctionSyntaxForExecutionContext := .Config.UseFunctionSyntaxForExecutionContext }} {{- range $object := .Objects }} var {{ $object.Name|lcFirst}}Implementors = {{$object.Implementors}} {{- if .Stream }} {{ if $useFunctionSyntaxForExecutionContext -}} func _{{$object.Name}}(ctx context.Context, ec *executionContext, sel ast.SelectionSet) func(ctx context.Context) graphql.Marshaler { {{- else -}} func (ec *executionContext) _{{$object.Name}}(ctx context.Context, sel ast.SelectionSet) func(ctx context.Context) graphql.Marshaler { {{- end }} fields := graphql.CollectFields(ec.OperationContext, sel, {{$object.Name|lcFirst}}Implementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: {{$object.Name|quote}}, }) if len(fields) != 1 { graphql.AddErrorf(ctx, "must subscribe to exactly one stream") return nil } switch fields[0].Name { {{- range $field := $object.Fields }} case "{{$field.Name}}": {{ if $useFunctionSyntaxForExecutionContext -}} return _{{$object.Name}}_{{$field.Name}}(ctx, ec, fields[0]) {{- else -}} return ec._{{$object.Name}}_{{$field.Name}}(ctx, fields[0]) {{- end }} {{- end }} default: panic("unknown field " + strconv.Quote(fields[0].Name)) } } {{- else }} {{ if $useFunctionSyntaxForExecutionContext -}} func _{{$object.Name}}(ctx context.Context, ec *executionContext, sel ast.SelectionSet{{ if not $object.Root }},obj {{$object.Reference | ref }}{{ end }}) graphql.Marshaler { {{- else -}} func (ec *executionContext) _{{$object.Name}}(ctx context.Context, sel ast.SelectionSet{{ if not $object.Root }},obj {{$object.Reference | ref }}{{ end }}) graphql.Marshaler { {{- end }} fields := graphql.CollectFields(ec.OperationContext, sel, {{$object.Name|lcFirst}}Implementors) {{- if $object.Root }} ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: {{$object.Name|quote}}, }) {{end}} out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { {{- if $object.Root }} innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) {{end}} switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString({{$object.Name|quote}}) {{- range $field := $object.Fields }} case "{{$field.Name}}": {{- if $field.IsConcurrent }} field := field innerFunc := func(ctx context.Context, {{ if $field.TypeReference.GQL.NonNull }}fs{{ else }}_{{ end }} *graphql.FieldSet) (res graphql.Marshaler) { {{- if not $.Config.OmitPanicHandler }} defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() {{- end }} {{ if $useFunctionSyntaxForExecutionContext -}} res = _{{$object.Name}}_{{$field.Name}}(ctx, ec, field{{if not $object.Root}}, obj{{end}}) {{- else -}} res = ec._{{$object.Name}}_{{$field.Name}}(ctx, field{{if not $object.Root}}, obj{{end}}) {{- end }} {{- if $field.TypeReference.GQL.NonNull }} if res == graphql.Null { {{- if $object.IsConcurrent }} atomic.AddUint32(&fs.Invalids, 1) {{- else }} fs.Invalids++ {{- end }} } {{- end }} return res } {{if $object.Root}} rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } {{end}} {{if not $object.Root}} if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } {{end}} out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { {{- if $object.Root -}} return rrm(innerCtx) {{- else -}} return innerFunc(ctx, out) {{- end -}} }) {{- else }} {{- if $object.Root -}} out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { {{ if $useFunctionSyntaxForExecutionContext -}} return _{{$object.Name}}_{{$field.Name}}(ctx, ec, field) {{- else -}} return ec._{{$object.Name}}_{{$field.Name}}(ctx, field) {{- end }} }) {{- else -}} {{ if $useFunctionSyntaxForExecutionContext -}} out.Values[i] = _{{$object.Name}}_{{$field.Name}}(ctx, ec, field, obj) {{- else -}} out.Values[i] = ec._{{$object.Name}}_{{$field.Name}}(ctx, field, obj) {{- end }} {{- end -}} {{- if $field.TypeReference.GQL.NonNull }} if out.Values[i] == graphql.Null { {{- if $object.IsConcurrent }} atomic.AddUint32(&out.Invalids, 1) {{- else }} out.Invalids++ {{- end }} } {{- end }} {{- end }} {{- end }} default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } {{- end }} {{- end }} ================================================ FILE: codegen/root_.gotpl ================================================ {{/* Context object: codegen.Data */}} {{ reserveImport "context" }} {{ reserveImport "fmt" }} {{ reserveImport "io" }} {{ reserveImport "strconv" }} {{ reserveImport "time" }} {{ reserveImport "sync" }} {{ reserveImport "sync/atomic" }} {{ reserveImport "bytes" }} {{ reserveImport "embed" }} {{ reserveImport "github.com/vektah/gqlparser/v2" "gqlparser" }} {{ reserveImport "github.com/vektah/gqlparser/v2/ast" }} {{ reserveImport "github.com/99designs/gqlgen/graphql" }} {{ $useFunctionSyntaxForExecutionContext := .Config.UseFunctionSyntaxForExecutionContext }} // 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 { {{- range $object := .Objects -}} {{ if $object.HasResolvers -}} {{ucFirst $object.Name}}() {{ucFirst $object.Name}}Resolver {{ end }} {{- end }} {{- range $object := .Inputs -}} {{ if $object.HasResolvers -}} {{ucFirst $object.Name}}() {{ucFirst $object.Name}}Resolver {{ end }} {{- end }} } type DirectiveRoot struct { {{ range $directive := .UserDirectives }} {{- $directive.Declaration }} {{ end }} } type ComplexityRoot struct { {{- if not .Config.OmitComplexity }} {{ range $object := .Objects }} {{ if not $object.IsReserved -}} {{ ucFirst $object.Name }} struct { {{ range $_, $fields := $object.UniqueFields }} {{- $field := index $fields 0 -}} {{ if not $field.IsReserved -}} {{ $field.GoFieldName }} {{ $field.ComplexitySignature }} {{ end }} {{- end }} } {{- end }} {{ end }} {{- end }} } {{ range $directive := .BuiltInDirectives }} var ( {{- $directive.FunctionImpl }} ) {{ end }} 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 {{- if not .Config.OmitComplexity }} switch typeName + "." + field { {{ range $object := .Objects }} {{ if not $object.IsReserved }} {{ range $_, $fields := $object.UniqueFields }} {{- $len := len $fields }} {{- range $i, $field := $fields }} {{- $last := eq (add $i 1) $len }} {{- if not $field.IsReserved }} {{- if eq $i 0 }}case {{ end }}"{{$object.Name}}.{{$field.Name}}"{{ if not $last }},{{ else }}: if e.ComplexityRoot.{{ucFirst $object.Name }}.{{$field.GoFieldName}} == nil { break } {{ if $field.Args }} {{ if $useFunctionSyntaxForExecutionContext -}} args, err := {{ $field.ArgsFunc }}(ctx, &ec, rawArgs) {{- else -}} args, err := ec.{{ $field.ArgsFunc }}(ctx,rawArgs) {{- end }} if err != nil { return 0, false } {{ end }} return e.ComplexityRoot.{{ucFirst $object.Name}}.{{$field.GoFieldName}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{ end }}), true {{ end }} {{- end }} {{- end }} {{ end }} {{ end }} {{ end }} } {{- end }} return 0, false } func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { opCtx := graphql.GetOperationContext(ctx) ec := newExecutionContext(opCtx, e, make(chan graphql.DeferredResult)) inputUnmarshalMap := graphql.BuildUnmarshalerMap( {{- range $input := .Inputs -}} {{ if not $input.HasUnmarshal }} {{ if $useFunctionSyntaxForExecutionContext -}} unmarshalInput{{ $input.Name }}, {{- else -}} ec.unmarshalInput{{ $input.Name }}, {{- end }} {{- end }} {{- end }} ) first := true switch opCtx.Operation.Operation { {{- if .QueryRoot }} case ast.Query: return func(ctx context.Context) *graphql.Response { var response graphql.Response var data graphql.Marshaler if first { first = false ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) {{ if .Directives.LocationDirectives "QUERY" -}} {{ if $useFunctionSyntaxForExecutionContext -}} data = _queryMiddleware(ctx, ec, opCtx.Operation, func(ctx context.Context) (any, error){ return _{{.QueryRoot.Name}}(ctx, &ec, opCtx.Operation.SelectionSet), nil {{- else -}} data = ec._queryMiddleware(ctx, opCtx.Operation, func(ctx context.Context) (any, error){ return ec._{{.QueryRoot.Name}}(ctx, opCtx.Operation.SelectionSet), nil {{- end }} }) {{- else -}} {{ if $useFunctionSyntaxForExecutionContext -}} data = _{{.QueryRoot.Name}}(ctx, &ec, opCtx.Operation.SelectionSet) {{- else -}} data = ec._{{.QueryRoot.Name}}(ctx, opCtx.Operation.SelectionSet) {{- end }} {{- end }} } else { if atomic.LoadInt32(&ec.PendingDeferred) > 0 { result := <-ec.DeferredResults atomic.AddInt32(&ec.PendingDeferred, -1) data = result.Result response.Path = result.Path response.Label = result.Label response.Errors = result.Errors } else { return nil } } var buf bytes.Buffer data.MarshalGQL(&buf) response.Data = buf.Bytes() if atomic.LoadInt32(&ec.Deferred) > 0 { hasNext := atomic.LoadInt32(&ec.PendingDeferred) > 0 response.HasNext = &hasNext } return &response } {{ end }} {{- if .MutationRoot }} case ast.Mutation: return func(ctx context.Context) *graphql.Response { if !first { return nil } first = false ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) {{ if .Directives.LocationDirectives "MUTATION" -}} {{ if $useFunctionSyntaxForExecutionContext -}} data := _mutationMiddleware(ctx, &ec, opCtx.Operation, func(ctx context.Context) (any, error){ return _{{.MutationRoot.Name}}(ctx, ec, opCtx.Operation.SelectionSet), nil {{- else -}} data := ec._mutationMiddleware(ctx, opCtx.Operation, func(ctx context.Context) (any, error){ return ec._{{.MutationRoot.Name}}(ctx, opCtx.Operation.SelectionSet), nil {{- end }} }) {{- else -}} {{ if $useFunctionSyntaxForExecutionContext -}} data := _{{.MutationRoot.Name}}(ctx, &ec, opCtx.Operation.SelectionSet) {{- else -}} data := ec._{{.MutationRoot.Name}}(ctx, opCtx.Operation.SelectionSet) {{- end }} {{- end }} var buf bytes.Buffer data.MarshalGQL(&buf) return &graphql.Response{ Data: buf.Bytes(), } } {{ end }} {{- if .SubscriptionRoot }} case ast.Subscription: {{ if .Directives.LocationDirectives "SUBSCRIPTION" -}} {{ if $useFunctionSyntaxForExecutionContext -}} next := _subscriptionMiddleware(ctx, &ec, opCtx.Operation, func(ctx context.Context) (any, error){ return _{{.SubscriptionRoot.Name}}(ctx, ec, opCtx.Operation.SelectionSet),nil {{- else -}} next := ec._subscriptionMiddleware(ctx, opCtx.Operation, func(ctx context.Context) (any, error){ return ec._{{.SubscriptionRoot.Name}}(ctx, opCtx.Operation.SelectionSet),nil {{- end }} }) {{- else -}} {{ if $useFunctionSyntaxForExecutionContext -}} next := _{{.SubscriptionRoot.Name}}(ctx, &ec, opCtx.Operation.SelectionSet) {{- else -}} next := ec._{{.SubscriptionRoot.Name}}(ctx, opCtx.Operation.SelectionSet) {{- end }} {{- end }} var buf bytes.Buffer return func(ctx context.Context) *graphql.Response { buf.Reset() data := next(ctx) if data == nil { return nil } data.MarshalGQL(&buf) return &graphql.Response{ Data: buf.Bytes(), } } {{ end }} default: return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) } } type executionContext struct { *graphql.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, ), } } {{if .HasEmbeddableSources }} //go:embed{{- range $source := .AugmentedSources }}{{if $source.Embeddable}} {{$source.RelativePath|quote}}{{end}}{{- end }} var sourcesFS embed.FS func sourceData(filename string) string { data, err := sourcesFS.ReadFile(filename) if err != nil { panic(fmt.Sprintf("codegen problem: %s not available", filename)) } return string(data) } {{- end}} var sources = []*ast.Source{ {{- range $source := .AugmentedSources }} {Name: {{$source.RelativePath|quote}}, Input: {{if (not $source.Embeddable)}}{{$source.Source|rawQuote}}{{else}}sourceData({{$source.RelativePath|quote}}){{end}}, BuiltIn: {{$source.BuiltIn}}}, {{- end }} } var parsedSchema = gqlparser.MustLoadSchema(sources...) ================================================ FILE: codegen/templates/import.go ================================================ package templates import ( "errors" "fmt" "go/types" "strconv" "strings" "github.com/99designs/gqlgen/internal/code" ) type Import struct { Name string Path string Alias string } type Imports struct { imports []*Import destDir string packages *code.Packages } func (i *Import) String() string { if strings.HasSuffix(i.Path, i.Alias) && i.Alias == i.Name { return strconv.Quote(i.Path) } return i.Alias + " " + strconv.Quote(i.Path) } func (s *Imports) String() string { res := "" var resSb35 strings.Builder for i, imp := range s.imports { if i != 0 { resSb35.WriteString("\n") } resSb35.WriteString(imp.String()) } res += resSb35.String() return res } func (s *Imports) Reserve(path string, aliases ...string) (string, error) { if path == "" { panic("empty ambient import") } // if we are referencing our own package we don't need an import if code.ImportPathForDir(s.destDir) == path { return "", nil } name := s.packages.NameForPackage(path) var alias string if len(aliases) != 1 { alias = name } else { alias = aliases[0] } if existing := s.findByPath(path); existing != nil { if existing.Alias == alias { return "", nil } return "", errors.New("ambient import already exists") } if alias := s.findByAlias(alias); alias != nil { return "", errors.New("ambient import collides on an alias") } s.imports = append(s.imports, &Import{ Name: name, Path: path, Alias: alias, }) return "", nil } func (s *Imports) Lookup(path string) string { if path == "" { return "" } path = code.NormalizeVendor(path) // if we are referencing our own package we don't need an import if code.ImportPathForDir(s.destDir) == path { return "" } if existing := s.findByPath(path); existing != nil { return existing.Alias } imp := &Import{ Name: s.packages.NameForPackage(path), Path: path, } s.imports = append(s.imports, imp) alias := imp.Name i := 1 for s.findByAlias(alias) != nil { alias = imp.Name + strconv.Itoa(i) i++ if i > 1000 { panic(fmt.Errorf("too many collisions, last attempt was %s", alias)) } } imp.Alias = alias return imp.Alias } func (s *Imports) LookupType(t types.Type) string { return types.TypeString(t, func(i *types.Package) string { return s.Lookup(i.Path()) }) } func (s Imports) findByPath(importPath string) *Import { for _, imp := range s.imports { if imp.Path == importPath { return imp } } return nil } func (s Imports) findByAlias(alias string) *Import { for _, imp := range s.imports { if imp.Alias == alias { return imp } } return nil } ================================================ FILE: codegen/templates/import_test.go ================================================ package templates import ( "fmt" "go/types" "os" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/internal/code" ) func TestImports(t *testing.T) { wd, err := os.Getwd() require.NoError(t, err) aBar := "github.com/99designs/gqlgen/codegen/templates/testdata/a/bar" bBar := "github.com/99designs/gqlgen/codegen/templates/testdata/b/bar" mismatch := "github.com/99designs/gqlgen/codegen/templates/testdata/pkg_mismatch" t.Run("multiple lookups is ok", func(t *testing.T) { a := Imports{destDir: wd, packages: code.NewPackages()} require.Equal(t, "bar", a.Lookup(aBar)) require.Equal(t, "bar", a.Lookup(aBar)) }) t.Run("lookup by type", func(t *testing.T) { a := Imports{destDir: wd, packages: code.NewPackages()} pkg := types.NewPackage( "github.com/99designs/gqlgen/codegen/templates/testdata/b/bar", "bar", ) typ := types.NewNamed( types.NewTypeName(0, pkg, "Boolean", types.Typ[types.Bool]), types.Typ[types.Bool], nil, ) require.Equal(t, "bar.Boolean", a.LookupType(typ)) }) t.Run("duplicates are decollisioned", func(t *testing.T) { a := Imports{destDir: wd, packages: code.NewPackages()} require.Equal(t, "bar", a.Lookup(aBar)) require.Equal(t, "bar1", a.Lookup(bBar)) t.Run("additional calls get decollisioned name", func(t *testing.T) { require.Equal(t, "bar1", a.Lookup(bBar)) }) }) t.Run("duplicates above 10 are decollisioned", func(t *testing.T) { a := Imports{destDir: wd, packages: code.NewPackages()} for i := range 100 { cBar := fmt.Sprintf("github.com/99designs/gqlgen/codegen/templates/testdata/%d/bar", i) if i > 0 { require.Equal(t, fmt.Sprintf("bar%d", i), a.Lookup(cBar)) } else { require.Equal(t, "bar", a.Lookup(cBar)) } } }) t.Run("package name defined in code will be used", func(t *testing.T) { a := Imports{destDir: wd, packages: code.NewPackages()} require.Equal(t, "turtles", a.Lookup(mismatch)) }) t.Run("string printing for import block", func(t *testing.T) { a := Imports{destDir: wd, packages: code.NewPackages()} a.Lookup(aBar) a.Lookup(bBar) a.Lookup(mismatch) require.Equal( t, `"github.com/99designs/gqlgen/codegen/templates/testdata/a/bar" bar1 "github.com/99designs/gqlgen/codegen/templates/testdata/b/bar" turtles "github.com/99designs/gqlgen/codegen/templates/testdata/pkg_mismatch"`, a.String(), ) }) t.Run("aliased imports will not collide", func(t *testing.T) { a := Imports{destDir: wd, packages: code.NewPackages()} _, _ = a.Reserve(aBar, "abar") _, _ = a.Reserve(bBar, "bbar") require.Equal(t, `abar "github.com/99designs/gqlgen/codegen/templates/testdata/a/bar" bbar "github.com/99designs/gqlgen/codegen/templates/testdata/b/bar"`, a.String()) }) } ================================================ FILE: codegen/templates/templates.go ================================================ package templates import ( "bytes" "errors" "fmt" "go/types" "io/fs" "maps" "os" "path/filepath" "reflect" "regexp" "runtime" "slices" "sort" "strconv" "strings" "sync" "text/template" "unicode" "github.com/99designs/gqlgen/internal/code" "github.com/99designs/gqlgen/internal/imports" ) // CurrentImports keeps track of all the import declarations that are needed during the execution of // a plugin. this is done with a global because subtemplates currently get called in functions. Lets // aim to remove this eventually. var CurrentImports *Imports // Options specify various parameters to rendering a template. type Options struct { // PackageName is a helper that specifies the package header declaration. // In other words, when you write the template you don't need to specify `package X` // at the top of the file. By providing PackageName in the Options, the Render // function will do that for you. PackageName string // Template is a string of the entire template that // will be parsed and rendered. If it's empty, // the plugin processor will look for .gotpl files // in the same directory of where you wrote the plugin. Template string // Use the go:embed API to collect all the template files you want to pass into Render // this is an alternative to passing the Template option TemplateFS fs.FS // Filename is the name of the file that will be // written to the system disk once the template is rendered. Filename string RegionTags bool GeneratedHeader bool // PackageDoc is documentation written above the package line PackageDoc string // FileNotice is notice written below the package line FileNotice string // Data will be passed to the template execution. Data any Funcs template.FuncMap // Packages cache, you can find me on config.Config Packages *code.Packages // PruneOptions configures import pruning and formatting behavior. PruneOptions imports.PruneOptions } var ( modelNamesMu sync.Mutex modelNames = make(map[string]string, 0) goNameRe = regexp.MustCompile("[^a-zA-Z0-9_]") ) // Render renders a gql plugin template from the given Options. Render is an // abstraction of the text/template package that makes it easier to write gqlgen // plugins. If Options.Template is empty, the Render function will look for `.gotpl` // files inside the directory where you wrote the plugin. func Render(cfg Options) error { if CurrentImports != nil { panic(errors.New("recursive or concurrent call to RenderToFile detected")) } CurrentImports = &Imports{packages: cfg.Packages, destDir: filepath.Dir(cfg.Filename)} funcs := Funcs() maps.Copy(funcs, cfg.Funcs) t := template.New("").Funcs(funcs) t, err := parseTemplates(cfg, t) if err != nil { return err } roots := make([]string, 0, len(t.Templates())) for _, templ := range t.Templates() { // templates that end with _.gotpl are special files we don't want to include if strings.HasSuffix(templ.Name(), "_.gotpl") || // filter out templates added with {{ template xxx }} syntax inside the template file !strings.HasSuffix(templ.Name(), ".gotpl") { continue } roots = append(roots, templ.Name()) } // then execute all the important looking ones in order, adding them to the same file sort.SliceStable(roots, func(i, j int) bool { // important files go first if strings.HasSuffix(roots[i], "!.gotpl") && !strings.HasSuffix(roots[j], "!.gotpl") { return true } if strings.HasSuffix(roots[j], "!.gotpl") && !strings.HasSuffix(roots[i], "!.gotpl") { return false } // files that have identical names are sorted dependent on input order // so we rely on SliceStable here to ensure deterministic results // to avoid test failures return roots[i] < roots[j] }) var buf bytes.Buffer for _, root := range roots { if cfg.RegionTags { buf.WriteString("\n// region " + center(70, "*", " "+root+" ") + "\n") } err := t.Lookup(root).Execute(&buf, cfg.Data) if err != nil { return fmt.Errorf("%s: %w", root, err) } if cfg.RegionTags { buf.WriteString("\n// endregion " + center(70, "*", " "+root+" ") + "\n") } } var result bytes.Buffer if cfg.GeneratedHeader { result.WriteString("// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.\n\n") } if cfg.PackageDoc != "" { result.WriteString(cfg.PackageDoc + "\n") } result.WriteString("package ") result.WriteString(cfg.PackageName) result.WriteString("\n\n") if cfg.FileNotice != "" { result.WriteString(cfg.FileNotice) result.WriteString("\n\n") } result.WriteString("import (\n") result.WriteString(CurrentImports.String()) result.WriteString(")\n") _, err = buf.WriteTo(&result) if err != nil { return err } CurrentImports = nil if err = write(cfg.Filename, result.Bytes(), cfg.Packages, cfg.PruneOptions); err != nil { return err } cfg.Packages.Evict(code.ImportPathForDir(filepath.Dir(cfg.Filename))) return nil } func parseTemplates(cfg Options, t *template.Template) (*template.Template, error) { if cfg.Template != "" { var err error t, err = t.New("template.gotpl").Parse(cfg.Template) if err != nil { return nil, fmt.Errorf("error with provided template: %w", err) } return t, nil } var fileSystem fs.FS if cfg.TemplateFS != nil { fileSystem = cfg.TemplateFS } else { // load path relative to calling source file _, callerFile, _, _ := runtime.Caller(2) rootDir := filepath.Dir(callerFile) fileSystem = os.DirFS(rootDir) } t, err := t.ParseFS(fileSystem, "*.gotpl") if err != nil { return nil, fmt.Errorf("locating templates: %w", err) } return t, nil } func center(width int, pad, s string) string { if len(s)+2 > width { return s } lpad := (width - len(s)) / 2 rpad := width - (lpad + len(s)) return strings.Repeat(pad, lpad) + s + strings.Repeat(pad, rpad) } func Funcs() template.FuncMap { return template.FuncMap{ "ucFirst": UcFirst, "lcFirst": LcFirst, "quote": strconv.Quote, "rawQuote": rawQuote, "dump": Dump, "ref": ref, "obj": obj, "ts": TypeIdentifier, "call": Call, "dict": dict, "prefixLines": prefixLines, "notNil": notNil, "strSplit": StrSplit, "reserveImport": CurrentImports.Reserve, "lookupImport": CurrentImports.Lookup, "go": ToGo, "goPrivate": ToGoPrivate, "goModelName": ToGoModelName, "goPrivateModelName": ToGoPrivateModelName, "add": func(a, b int) int { return a + b }, "render": func(filename string, tpldata any) (*bytes.Buffer, error) { return render(resolveName(filename, 0), tpldata) }, } } func UcFirst(s string) string { if s == "" { return "" } r := []rune(s) r[0] = unicode.ToUpper(r[0]) return string(r) } func LcFirst(s string) string { if s == "" { return "" } r := []rune(s) r[0] = unicode.ToLower(r[0]) return string(r) } func isDelimiter(c rune) bool { return c == '-' || c == '_' || unicode.IsSpace(c) } func ref(p types.Type) string { typeString := CurrentImports.LookupType(p) // TODO(steve): figure out why this is needed // otherwise inconsistent sometimes // see https://github.com/99designs/gqlgen/issues/3414#issuecomment-2822856422 if typeString == "interface{}" { return "any" } if typeString == "map[string]interface{}" { return "map[string]any" } // assuming that some other container interface{} type // like []interface{} or something needs coercion to any if strings.Contains(typeString, "interface{}") { return strings.ReplaceAll(typeString, "interface{}", "any") } return typeString } func obj(obj types.Object) string { pkg := CurrentImports.Lookup(obj.Pkg().Path()) if pkg != "" { pkg += "." } return pkg + obj.Name() } func Call(p *types.Func) string { pkg := CurrentImports.Lookup(p.Pkg().Path()) if pkg != "" { pkg += "." } if p.Type() != nil { // make sure the returned type is listed in our imports. ref(p.Type().(*types.Signature).Results().At(0).Type()) } return pkg + p.Name() } func dict(values ...any) (map[string]any, error) { if len(values)%2 != 0 { return nil, errors.New("invalid dict call: arguments must be key-value pairs") } m := make(map[string]any, len(values)/2) for i := 0; i < len(values); i += 2 { key, ok := values[i].(string) if !ok { return nil, errors.New("dict keys must be strings") } m[key] = values[i+1] } return m, nil } func resetModelNames() { modelNamesMu.Lock() defer modelNamesMu.Unlock() modelNames = make(map[string]string, 0) } func buildGoModelNameKey(parts []string) string { const sep = ":" return strings.Join(parts, sep) } func goModelName(primaryToGoFunc func(string) string, parts []string) string { modelNamesMu.Lock() defer modelNamesMu.Unlock() var ( goNameKey string partLen int nameExists = func(n string) bool { for _, v := range modelNames { if n == v { return true } } return false } applyToGoFunc = func(parts []string) string { switch len(parts) { case 0: return "" case 1: return primaryToGoFunc(parts[0]) default: var out strings.Builder out.WriteString(primaryToGoFunc(parts[0])) for _, p := range parts[1:] { out.WriteString(ToGo(p)) } return out.String() } } applyValidGoName = func(parts []string) string { var out strings.Builder for _, p := range parts { out.WriteString(replaceInvalidCharacters(p)) } return out.String() } ) // build key for this entity goNameKey = buildGoModelNameKey(parts) // determine if we've seen this entity before, and reuse if so if goName, ok := modelNames[goNameKey]; ok { return goName } // attempt first pass if goName := applyToGoFunc(parts); !nameExists(goName) { modelNames[goNameKey] = goName return goName } // determine number of parts partLen = len(parts) // if there is only 1 part, append incrementing number until no conflict if partLen == 1 { base := applyToGoFunc(parts) for i := 0; ; i++ { tmp := fmt.Sprintf("%s%d", base, i) if !nameExists(tmp) { modelNames[goNameKey] = tmp return tmp } } } // best effort "pretty" name for i := partLen - 1; i >= 1; i-- { tmp := fmt.Sprintf("%s%s", applyToGoFunc(parts[0:i]), applyValidGoName(parts[i:])) if !nameExists(tmp) { modelNames[goNameKey] = tmp return tmp } } // finally, fallback to just adding an incrementing number base := applyToGoFunc(parts) for i := 0; ; i++ { tmp := fmt.Sprintf("%s%d", base, i) if !nameExists(tmp) { modelNames[goNameKey] = tmp return tmp } } } func ToGoModelName(parts ...string) string { return goModelName(ToGo, parts) } func ToGoPrivateModelName(parts ...string) string { return goModelName(ToGoPrivate, parts) } func replaceInvalidCharacters(in string) string { return goNameRe.ReplaceAllLiteralString(in, "_") } func wordWalkerFunc(private bool, nameRunes *[]rune) func(*wordInfo) { return func(info *wordInfo) { word := info.Word switch { case private && info.WordOffset == 0: if strings.ToUpper(word) == word || strings.ToLower(word) == word { // ID → id, CAMEL → camel word = strings.ToLower(info.Word) } else { // ITicket → iTicket word = LcFirst(info.Word) } case info.MatchCommonInitial: word = strings.ToUpper(word) case !info.HasCommonInitial && (strings.ToUpper(word) == word || strings.ToLower(word) == word): // FOO or foo → Foo // FOo → FOo word = UcFirst(strings.ToLower(word)) } *nameRunes = append(*nameRunes, []rune(word)...) } } func ToGo(name string) string { if name == "_" { return "_" } runes := make([]rune, 0, len(name)) wordWalker(name, wordWalkerFunc(false, &runes)) return string(runes) } func ToGoPrivate(name string) string { if name == "_" { return "_" } runes := make([]rune, 0, len(name)) wordWalker(name, wordWalkerFunc(true, &runes)) return sanitizeKeywords(string(runes)) } type wordInfo struct { WordOffset int Word string MatchCommonInitial bool HasCommonInitial bool } // This function is based on the following code. // https://github.com/golang/lint/blob/06c8688daad7faa9da5a0c2f163a3d14aac986ca/lint.go#L679 func wordWalker(str string, f func(*wordInfo)) { runes := []rune(strings.TrimFunc(str, isDelimiter)) w, i, wo := 0, 0, 0 // index of start of word, scan, word offset hasCommonInitial := false for i+1 <= len(runes) { eow := false // whether we hit the end of a word switch { case i+1 == len(runes): eow = true case isDelimiter(runes[i+1]): // underscore; shift the remainder forward over any run of underscores eow = true n := 1 for i+n+1 < len(runes) && isDelimiter(runes[i+n+1]) { n++ } // Leave at most one underscore if the underscore is between two digits if i+n+1 < len(runes) && unicode.IsDigit(runes[i]) && unicode.IsDigit(runes[i+n+1]) { n-- } copy(runes[i+1:], runes[i+n+1:]) runes = runes[:len(runes)-n] case unicode.IsLower(runes[i]) && !unicode.IsLower(runes[i+1]): // lower->non-lower eow = true } i++ initialisms := GetInitialisms() // [w,i) is a word. word := string(runes[w:i]) if !eow && initialisms[word] && !unicode.IsLower(runes[i]) { // through // split IDFoo → ID, Foo // but URLs → URLs } else if !eow { if initialisms[word] { hasCommonInitial = true } continue } matchCommonInitial := false upperWord := strings.ToUpper(word) if initialisms[upperWord] { // If the uppercase word (string(runes[w:i]) is "ID" or "IP" // AND // the word is the first two characters of the current word // AND // that is not the end of the word // AND // the length of the remaining string is greater than 3 // AND // the third rune is an uppercase one // THEN // do NOT count this as an initialism. switch upperWord { case "ID", "IP": if remainingRunes := runes[w:]; word == string(remainingRunes[:2]) && !eow && len(remainingRunes) > 3 && unicode.IsUpper(remainingRunes[3]) { continue } } hasCommonInitial = true matchCommonInitial = true } f(&wordInfo{ WordOffset: wo, Word: word, MatchCommonInitial: matchCommonInitial, HasCommonInitial: hasCommonInitial, }) hasCommonInitial = false w = i wo++ } } var keywords = []string{ "break", "default", "func", "interface", "select", "case", "defer", "go", "map", "struct", "chan", "else", "goto", "package", "switch", "const", "fallthrough", "if", "range", "type", "continue", "for", "import", "return", "var", "_", } // sanitizeKeywords prevents collisions with go keywords for arguments to resolver functions func sanitizeKeywords(name string) string { if slices.Contains(keywords, name) { return name + "Arg" } return name } func rawQuote(s string) string { return "`" + strings.ReplaceAll(s, "`", "`+\"`\"+`") + "`" } func notNil(field string, data any) bool { v := reflect.ValueOf(data) if v.Kind() == reflect.Ptr { v = v.Elem() } if v.Kind() != reflect.Struct { return false } val := v.FieldByName(field) return val.IsValid() && !val.IsNil() } func StrSplit(s, sep string) []string { return strings.Split(s, sep) } func Dump(val any) string { switch val := val.(type) { case int: return strconv.Itoa(val) case int64: return strconv.FormatInt(val, 10) case float64: return fmt.Sprintf("%f", val) case string: return strconv.Quote(val) case bool: return strconv.FormatBool(val) case nil: return "nil" case []any: var parts []string for _, part := range val { parts = append(parts, Dump(part)) } return "[]any{" + strings.Join(parts, ",") + "}" case map[string]any: buf := bytes.Buffer{} buf.WriteString("map[string]any{") var keys []string for key := range val { keys = append(keys, key) } sort.Strings(keys) for _, key := range keys { data := val[key] buf.WriteString(strconv.Quote(key)) buf.WriteString(":") buf.WriteString(Dump(data)) buf.WriteString(",") } buf.WriteString("}") return buf.String() default: panic(fmt.Errorf("unsupported type %T", val)) } } func prefixLines(prefix, s string) string { return prefix + strings.ReplaceAll(s, "\n", "\n"+prefix) } func resolveName(name string, skip int) string { if name[0] == '.' { // load path relative to calling source file _, callerFile, _, _ := runtime.Caller(skip + 1) return filepath.Join(filepath.Dir(callerFile), name[1:]) } // load path relative to this directory _, callerFile, _, _ := runtime.Caller(0) return filepath.Join(filepath.Dir(callerFile), name) } func render(filename string, tpldata any) (*bytes.Buffer, error) { t := template.New("").Funcs(Funcs()) b, err := os.ReadFile(filename) if err != nil { return nil, err } t, err = t.New(filepath.Base(filename)).Parse(string(b)) if err != nil { panic(err) } buf := &bytes.Buffer{} return buf, t.Execute(buf, tpldata) } func write(filename string, b []byte, packages *code.Packages, opts imports.PruneOptions) error { err := os.MkdirAll(filepath.Dir(filename), 0o755) if err != nil { return fmt.Errorf("failed to create directory: %w", err) } formatted, err := imports.Prune(filename, b, packages, opts) if err != nil { fmt.Fprintf(os.Stderr, "gofmt failed on %s: %s\n", filepath.Base(filename), err.Error()) formatted = b } // Skip write if content is unchanged - preserves mtime for Go build cache existing, readErr := os.ReadFile(filename) if readErr == nil && bytes.Equal(existing, formatted) { return nil } return os.WriteFile(filename, formatted, 0o644) } var pkgReplacer = strings.NewReplacer( "/", "ᚋ", ".", "ᚗ", "-", "ᚑ", "~", "א", ) func TypeIdentifier(t types.Type) string { res := "" for { switch it := code.Unalias(t).(type) { case *types.Pointer: t.Underlying() res += "ᚖ" t = it.Elem() case *types.Slice: res += "ᚕ" t = it.Elem() case *types.Named: res += pkgReplacer.Replace(it.Obj().Pkg().Path()) res += "ᚐ" res += it.Obj().Name() return res case *types.Basic: res += it.Name() return res case *types.Map: res += "map" return res case *types.Interface: res += "interface" return res default: panic(fmt.Errorf("unexpected type %T", it)) } } } // CommonInitialisms is a set of common initialisms. // Only add entries that are highly unlikely to be non-initialisms. // For instance, "ID" is fine (Freudian code is rare), but "AND" is not. var CommonInitialisms = map[string]bool{ "ACL": true, "API": true, "ASCII": true, "CPU": true, "CSS": true, "CSV": true, "DNS": true, "EOF": true, "GUID": true, "HTML": true, "HTTP": true, "HTTPS": true, "ICMP": true, "ID": true, "IP": true, "JSON": true, "KVK": true, "LHS": true, "PDF": true, "PGP": true, "QPS": true, "QR": true, "RAM": true, "RHS": true, "RPC": true, "SLA": true, "SMTP": true, "SQL": true, "SSH": true, "SVG": true, "TCP": true, "TLS": true, "TTL": true, "UDP": true, "UI": true, "UID": true, "URI": true, "URL": true, "UTF8": true, "UUID": true, "VM": true, "XML": true, "XMPP": true, "XSRF": true, "XSS": true, "AWS": true, "GCP": true, } // GetInitialisms returns the initialisms to capitalize in Go names. If unchanged, default // initialisms will be returned var GetInitialisms = func() map[string]bool { return CommonInitialisms } ================================================ FILE: codegen/templates/templates_test.go ================================================ package templates import ( "embed" "fmt" "os" "path/filepath" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/internal/code" ) //go:embed *.gotpl var templateFS embed.FS func TestToGo(t *testing.T) { require.Equal(t, "ToCamel", ToGo("TO_CAMEL")) require.Equal(t, "ToCamel", ToGo("to_camel")) require.Equal(t, "ToCamel", ToGo("toCamel")) require.Equal(t, "ToCamel", ToGo("ToCamel")) require.Equal(t, "ToCamel", ToGo("to-camel")) require.Equal(t, "ToCamel", ToGo("-to-camel")) require.Equal(t, "ToCamel", ToGo("_to-camel")) require.Equal(t, "_", ToGo("_")) require.Equal(t, "RelatedURLs", ToGo("RelatedURLs")) require.Equal(t, "ImageIDs", ToGo("ImageIDs")) require.Equal(t, "FooID", ToGo("FooID")) require.Equal(t, "IDFoo", ToGo("IDFoo")) require.Equal(t, "FooASCII", ToGo("FooASCII")) require.Equal(t, "ASCIIFoo", ToGo("ASCIIFoo")) require.Equal(t, "FooUTF8", ToGo("FooUTF8")) require.Equal(t, "UTF8Foo", ToGo("UTF8Foo")) require.Equal(t, "JSONEncoding", ToGo("JSONEncoding")) require.Equal(t, "A", ToGo("A")) require.Equal(t, "ID", ToGo("ID")) require.Equal(t, "ID", ToGo("id")) require.Empty(t, ToGo("")) require.Equal(t, "RelatedUrls", ToGo("RelatedUrls")) require.Equal(t, "ITicket", ToGo("ITicket")) require.Equal(t, "FooTicket", ToGo("fooTicket")) require.Equal(t, "Idle", ToGo("IDLE")) require.Equal(t, "Idle", ToGo("Idle")) require.Equal(t, "Idle", ToGo("idle")) require.Equal(t, "Identities", ToGo("IDENTITIES")) require.Equal(t, "Identities", ToGo("Identities")) require.Equal(t, "Identities", ToGo("identities")) require.Equal(t, "Iphone", ToGo("IPHONE")) require.Equal(t, "IPhone", ToGo("iPHONE")) require.Equal(t, "UserIdentity", ToGo("USER_IDENTITY")) require.Equal(t, "UserIdentity", ToGo("UserIdentity")) require.Equal(t, "UserIdentity", ToGo("userIdentity")) } func TestToGoPrivate(t *testing.T) { require.Equal(t, "toCamel", ToGoPrivate("TO_CAMEL")) require.Equal(t, "toCamel", ToGoPrivate("to_camel")) require.Equal(t, "toCamel", ToGoPrivate("toCamel")) require.Equal(t, "toCamel", ToGoPrivate("ToCamel")) require.Equal(t, "toCamel", ToGoPrivate("to-camel")) require.Equal(t, "relatedURLs", ToGoPrivate("RelatedURLs")) require.Equal(t, "imageIDs", ToGoPrivate("ImageIDs")) require.Equal(t, "fooID", ToGoPrivate("FooID")) require.Equal(t, "idFoo", ToGoPrivate("IDFoo")) require.Equal(t, "fooASCII", ToGoPrivate("FooASCII")) require.Equal(t, "asciiFoo", ToGoPrivate("ASCIIFoo")) require.Equal(t, "fooUTF8", ToGoPrivate("FooUTF8")) require.Equal(t, "utf8Foo", ToGoPrivate("UTF8Foo")) require.Equal(t, "jsonEncoding", ToGoPrivate("JSONEncoding")) require.Equal(t, "relatedUrls", ToGoPrivate("RelatedUrls")) require.Equal(t, "iTicket", ToGoPrivate("ITicket")) require.Equal(t, "rangeArg", ToGoPrivate("Range")) require.Equal(t, "a", ToGoPrivate("A")) require.Equal(t, "id", ToGoPrivate("ID")) require.Equal(t, "id", ToGoPrivate("id")) require.Empty(t, ToGoPrivate("")) require.Equal(t, "_", ToGoPrivate("_")) require.Equal(t, "idle", ToGoPrivate("IDLE")) require.Equal(t, "idle", ToGoPrivate("Idle")) require.Equal(t, "idle", ToGoPrivate("idle")) require.Equal(t, "identities", ToGoPrivate("IDENTITIES")) require.Equal(t, "identities", ToGoPrivate("Identities")) require.Equal(t, "identities", ToGoPrivate("identities")) require.Equal(t, "iphone", ToGoPrivate("IPHONE")) require.Equal(t, "iPhone", ToGoPrivate("iPHONE")) } func TestToGoModelName(t *testing.T) { type aTest struct { input [][]string expected []string } theTests := []aTest{ { input: [][]string{{"MyValue"}}, expected: []string{"MyValue"}, }, { input: [][]string{{"MyValue"}, {"myValue"}}, expected: []string{"MyValue", "MyValue0"}, }, { input: [][]string{{"MyValue"}, {"YourValue"}}, expected: []string{"MyValue", "YourValue"}, }, { input: [][]string{{"MyEnumName", "Value"}}, expected: []string{"MyEnumNameValue"}, }, { input: [][]string{{"MyEnumName", "Value"}, {"MyEnumName", "value"}}, expected: []string{"MyEnumNameValue", "MyEnumNamevalue"}, }, { input: [][]string{{"MyEnumName", "value"}, {"MyEnumName", "Value"}}, expected: []string{"MyEnumNameValue", "MyEnumNameValue0"}, }, { input: [][]string{ {"MyEnumName", "Value"}, {"MyEnumName", "value"}, {"MyEnumName", "vALue"}, {"MyEnumName", "VALue"}, }, expected: []string{ "MyEnumNameValue", "MyEnumNamevalue", "MyEnumNameVALue", "MyEnumNameVALue0", }, }, { input: [][]string{ {"MyEnumName", "TitleValue"}, {"MyEnumName", "title_value"}, {"MyEnumName", "title_Value"}, {"MyEnumName", "Title_Value"}, }, expected: []string{ "MyEnumNameTitleValue", "MyEnumNametitle_value", "MyEnumNametitle_Value", "MyEnumNameTitle_Value", }, }, { input: [][]string{{"MyEnumName", "TitleValue", "OtherValue"}}, expected: []string{"MyEnumNameTitleValueOtherValue"}, }, { input: [][]string{ {"MyEnumName", "TitleValue", "OtherValue"}, {"MyEnumName", "title_value", "OtherValue"}, }, expected: []string{"MyEnumNameTitleValueOtherValue", "MyEnumNametitle_valueOtherValue"}, }, } for ti, at := range theTests { resetModelNames() t.Run(fmt.Sprintf("modelname-%d", ti), func(t *testing.T) { at := at for i, n := range at.input { require.Equal(t, at.expected[i], ToGoModelName(n...)) } }) } } func TestToGoPrivateModelName(t *testing.T) { type aTest struct { input [][]string expected []string } theTests := []aTest{ { input: [][]string{{"MyValue"}}, expected: []string{"myValue"}, }, { input: [][]string{{"MyValue"}, {"myValue"}}, expected: []string{"myValue", "myValue0"}, }, { input: [][]string{{"MyValue"}, {"YourValue"}}, expected: []string{"myValue", "yourValue"}, }, { input: [][]string{{"MyEnumName", "Value"}}, expected: []string{"myEnumNameValue"}, }, { input: [][]string{{"MyEnumName", "Value"}, {"MyEnumName", "value"}}, expected: []string{"myEnumNameValue", "myEnumNamevalue"}, }, { input: [][]string{{"MyEnumName", "value"}, {"MyEnumName", "Value"}}, expected: []string{"myEnumNameValue", "myEnumNameValue0"}, }, { input: [][]string{ {"MyEnumName", "Value"}, {"MyEnumName", "value"}, {"MyEnumName", "vALue"}, {"MyEnumName", "VALue"}, }, expected: []string{ "myEnumNameValue", "myEnumNamevalue", "myEnumNameVALue", "myEnumNameVALue0", }, }, { input: [][]string{ {"MyEnumName", "TitleValue"}, {"MyEnumName", "title_value"}, {"MyEnumName", "title_Value"}, {"MyEnumName", "Title_Value"}, }, expected: []string{ "myEnumNameTitleValue", "myEnumNametitle_value", "myEnumNametitle_Value", "myEnumNameTitle_Value", }, }, { input: [][]string{{"MyEnumName", "TitleValue", "OtherValue"}}, expected: []string{"myEnumNameTitleValueOtherValue"}, }, { input: [][]string{ {"MyEnumName", "TitleValue", "OtherValue"}, {"MyEnumName", "title_value", "OtherValue"}, }, expected: []string{"myEnumNameTitleValueOtherValue", "myEnumNametitle_valueOtherValue"}, }, } for ti, at := range theTests { resetModelNames() t.Run(fmt.Sprintf("modelname-%d", ti), func(t *testing.T) { at := at for i, n := range at.input { require.Equal(t, at.expected[i], ToGoPrivateModelName(n...)) } }) } } func Test_wordWalker(t *testing.T) { makeInput := func(str string) []*wordInfo { resultList := make([]*wordInfo, 0) wordWalker(str, func(info *wordInfo) { resultList = append(resultList, info) }) return resultList } type aTest struct { expected []*wordInfo input []*wordInfo } theTests := []aTest{ { input: makeInput("TO_CAMEL"), expected: []*wordInfo{{Word: "TO"}, {WordOffset: 1, Word: "CAMEL"}}, }, { input: makeInput("to_camel"), expected: []*wordInfo{{Word: "to"}, {WordOffset: 1, Word: "camel"}}, }, { input: makeInput("toCamel"), expected: []*wordInfo{{Word: "to"}, {WordOffset: 1, Word: "Camel"}}, }, { input: makeInput("ToCamel"), expected: []*wordInfo{{Word: "To"}, {WordOffset: 1, Word: "Camel"}}, }, { input: makeInput("to-camel"), expected: []*wordInfo{{Word: "to"}, {WordOffset: 1, Word: "camel"}}, }, { input: makeInput("RelatedURLs"), expected: []*wordInfo{ {Word: "Related"}, {WordOffset: 1, Word: "URLs", HasCommonInitial: true}, }, }, { input: makeInput("ImageIDs"), expected: []*wordInfo{ {Word: "Image"}, {WordOffset: 1, Word: "IDs", HasCommonInitial: true}, }, }, { input: makeInput("FooID"), expected: []*wordInfo{ {Word: "Foo"}, {WordOffset: 1, Word: "ID", HasCommonInitial: true, MatchCommonInitial: true}, }, }, { input: makeInput("IDFoo"), expected: []*wordInfo{ {Word: "ID", HasCommonInitial: true, MatchCommonInitial: true}, {WordOffset: 1, Word: "Foo"}, }, }, { input: makeInput("FooASCII"), expected: []*wordInfo{ {Word: "Foo"}, {WordOffset: 1, Word: "ASCII", HasCommonInitial: true, MatchCommonInitial: true}, }, }, { input: makeInput("ASCIIFoo"), expected: []*wordInfo{ {Word: "ASCII", HasCommonInitial: true, MatchCommonInitial: true}, {WordOffset: 1, Word: "Foo"}, }, }, { input: makeInput("FooUTF8"), expected: []*wordInfo{ {Word: "Foo"}, {WordOffset: 1, Word: "UTF8", HasCommonInitial: true, MatchCommonInitial: true}, }, }, { input: makeInput("UTF8Foo"), expected: []*wordInfo{ {Word: "UTF8", HasCommonInitial: true, MatchCommonInitial: true}, {WordOffset: 1, Word: "Foo"}, }, }, { input: makeInput("A"), expected: []*wordInfo{{Word: "A"}}, }, { input: makeInput("ID"), expected: []*wordInfo{{Word: "ID", HasCommonInitial: true, MatchCommonInitial: true}}, }, { input: makeInput("id"), expected: []*wordInfo{{Word: "id", HasCommonInitial: true, MatchCommonInitial: true}}, }, { input: makeInput(""), expected: make([]*wordInfo, 0), }, { input: makeInput("RelatedUrls"), expected: []*wordInfo{{Word: "Related"}, {WordOffset: 1, Word: "Urls"}}, }, { input: makeInput("USER_IDENTITY"), expected: []*wordInfo{{Word: "USER"}, {WordOffset: 1, Word: "IDENTITY"}}, }, { input: makeInput("ITicket"), expected: []*wordInfo{{Word: "ITicket"}}, }, } for i, at := range theTests { t.Run(fmt.Sprintf("wordWalker-%d", i), func(t *testing.T) { require.Equal(t, at.expected, at.input) }) } } func TestCenter(t *testing.T) { require.Equal(t, "fffff", center(3, "#", "fffff")) require.Equal(t, "##fffff###", center(10, "#", "fffff")) require.Equal(t, "###fffff###", center(11, "#", "fffff")) } func TestTemplateOverride(t *testing.T) { f, err := os.CreateTemp(t.TempDir(), "gqlgen") if err != nil { t.Fatal(err) } defer f.Close() err = Render(Options{Template: "hello", Filename: f.Name(), Packages: code.NewPackages()}) if err != nil { t.Fatal(err) } } func TestRenderFS(t *testing.T) { tempDir := t.TempDir() outDir := filepath.Join(tempDir, "output") _ = os.Mkdir(outDir, 0o755) f, err := os.CreateTemp(outDir, "gqlgen.go") if err != nil { t.Fatal(err) } defer f.Close() err = Render(Options{TemplateFS: templateFS, Filename: f.Name(), Packages: code.NewPackages()}) if err != nil { t.Fatal(err) } expectedString := "package \n\nimport (\n)\nthis is my test package" actualContents, _ := os.ReadFile(f.Name()) actualContentsStr := string(actualContents) // don't look at last character since it's \n on Linux and \r\n on Windows assert.Equal(t, expectedString, actualContentsStr[:len(expectedString)]) } func TestDict(t *testing.T) { tests := []struct { name string input []any expected map[string]any expectErr bool }{ { name: "valid key-value pairs", input: []any{"key1", "value1", "key2", "value2"}, expected: map[string]any{"key1": "value1", "key2": "value2"}, expectErr: false, }, { name: "odd number of arguments", input: []any{"key1", "value1", "key2"}, expected: nil, expectErr: true, }, { name: "non-string key", input: []any{"key1", "value1", 123, "value2"}, expected: nil, expectErr: true, }, { name: "empty input", input: []any{}, expected: map[string]any{}, expectErr: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { result, err := dict(tt.input...) if tt.expectErr { require.Error(t, err) } else { require.NoError(t, err) assert.Equal(t, tt.expected, result) } }) } } ================================================ FILE: codegen/templates/test.gotpl ================================================ this is my test package ================================================ FILE: codegen/templates/test_.gotpl ================================================ this will not be included ================================================ FILE: codegen/templates/testdata/a/bar/bar.go ================================================ package bar ================================================ FILE: codegen/templates/testdata/b/bar/bar.go ================================================ package bar ================================================ FILE: codegen/templates/testdata/pkg_mismatch/turtles.go ================================================ package turtles ================================================ FILE: codegen/testserver/benchmark/benchmark_test.go ================================================ //go:generate go run ../../../testdata/gqlgen.go -config gqlgen.yml -stub stub.go package benchmark import ( "context" "testing" "github.com/99designs/gqlgen/codegen/testserver/benchmark/generated" "github.com/99designs/gqlgen/codegen/testserver/benchmark/generated/models" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/executor" ) func BenchmarkResolvers(b *testing.B) { b.StopTimer() resolvers := &Stub{} resolvers.QueryResolver.Users = func(ctx context.Context, query *string, first *int, last *int, before *string, after *string, orderBy models.UserOrderBy) (*models.UserConnection, error) { return &models.UserConnection{ Edges: []*models.UserEdge{ { Cursor: "abc", Node: &models.User{ FirstName: "John", LastName: "Doe", Email: "johndoe@acme.inc", }, }, }, PageInfo: &models.PageInfo{ HasNextPage: false, HasPreviousPage: false, StartCursor: "abc", EndCursor: "abc", }, TotalCount: 1, }, nil } exec := executor.New(generated.NewExecutableSchema(generated.Config{ Resolvers: resolvers, })) fragment := `fragment userConnection on UserConnection { edges { cursor node { firstName lastName email } } pageInfo { hasNextPage hasPreviousPage startCursor endCursor } totalCount}` benchmarks := []struct { name string params *graphql.RawParams }{ { name: "query_no_params", params: &graphql.RawParams{ Query: fragment + ` query GetUsersConnection { users { ... userConnection } } `, OperationName: "GetUsersConnection", Variables: nil, }, }, { name: "query_1_param", params: &graphql.RawParams{ Query: fragment + ` query GetUsersConnection($first: Int) { users(first: $first) { ... userConnection } } `, OperationName: "GetUsersConnection", Variables: map[string]any{ "first": 1, }, }, }, { name: "query_2_params", params: &graphql.RawParams{ Query: fragment + ` query GetUsersConnection($query: String, $first: Int) { users(query: $query, first: $first) { ... userConnection } } `, OperationName: "GetUsersConnection", Variables: map[string]any{ "first": 1, "query": "john", }, }, }, { name: "query_3_params", params: &graphql.RawParams{ Query: fragment + ` query GetUsersConnection($query: String, $first: Int, $orderBy: UserOrderBy!) { users(query: $query, first: $first, orderBy: $orderBy) { ... userConnection } } `, OperationName: "GetUsersConnection", Variables: map[string]any{ "first": 1, "query": "john", "orderBy": map[string]any{ "orderByField": "FIRST_NAME", "orderByDirection": "DESCENDING", }, }, }, }, { name: "query_4_params", params: &graphql.RawParams{ Query: fragment + ` query GetUsersConnection($query: String, $first: Int, $before: String, $orderBy: UserOrderBy!) { users(query: $query, first: $first, before: $before, orderBy: $orderBy) { ... userConnection } } `, OperationName: "GetUsersConnection", Variables: map[string]any{ "first": 1, "query": "john", "before": "abc", "orderBy": map[string]any{ "orderByField": "FIRST_NAME", "orderByDirection": "DESCENDING", }, }, }, }, } b.StartTimer() for _, benchmark := range benchmarks { b.Run(benchmark.name, func(b *testing.B) { for i := 0; i < b.N; i++ { ctx := graphql.StartOperationTrace(context.Background()) opCtx, errs := exec.CreateOperationContext(ctx, benchmark.params) if errs != nil { b.Fatal(errs) } resultHandler, ctx := exec.DispatchOperation(ctx, opCtx) _ = resultHandler(ctx) } }) } } ================================================ FILE: codegen/testserver/benchmark/generated/models/models-gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package models import ( "bytes" "fmt" "io" "strconv" ) type PageInfo struct { HasNextPage bool `json:"hasNextPage"` HasPreviousPage bool `json:"hasPreviousPage"` StartCursor string `json:"startCursor"` EndCursor string `json:"endCursor"` } type Query struct { } type User struct { FirstName string `json:"firstName"` LastName string `json:"lastName"` Email string `json:"email"` } type UserConnection struct { Edges []*UserEdge `json:"edges"` PageInfo *PageInfo `json:"pageInfo"` TotalCount int `json:"totalCount"` } type UserEdge struct { Cursor string `json:"cursor"` Node *User `json:"node"` } type UserOrderBy struct { OrderByField UserOrderField `json:"orderByField"` OrderByDirection OrderDirection `json:"orderByDirection"` } type OrderDirection string const ( OrderDirectionAscending OrderDirection = "ASCENDING" OrderDirectionDescending OrderDirection = "DESCENDING" ) var AllOrderDirection = []OrderDirection{ OrderDirectionAscending, OrderDirectionDescending, } func (e OrderDirection) IsValid() bool { switch e { case OrderDirectionAscending, OrderDirectionDescending: return true } return false } func (e OrderDirection) String() string { return string(e) } func (e *OrderDirection) UnmarshalGQL(v any) error { str, ok := v.(string) if !ok { return fmt.Errorf("enums must be strings") } *e = OrderDirection(str) if !e.IsValid() { return fmt.Errorf("%s is not a valid OrderDirection", str) } return nil } func (e OrderDirection) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } func (e *OrderDirection) UnmarshalJSON(b []byte) error { s, err := strconv.Unquote(string(b)) if err != nil { return err } return e.UnmarshalGQL(s) } func (e OrderDirection) MarshalJSON() ([]byte, error) { var buf bytes.Buffer e.MarshalGQL(&buf) return buf.Bytes(), nil } type UserOrderField string const ( UserOrderFieldFirstName UserOrderField = "FIRST_NAME" UserOrderFieldLastName UserOrderField = "LAST_NAME" UserOrderFieldEmail UserOrderField = "EMAIL" ) var AllUserOrderField = []UserOrderField{ UserOrderFieldFirstName, UserOrderFieldLastName, UserOrderFieldEmail, } func (e UserOrderField) IsValid() bool { switch e { case UserOrderFieldFirstName, UserOrderFieldLastName, UserOrderFieldEmail: return true } return false } func (e UserOrderField) String() string { return string(e) } func (e *UserOrderField) UnmarshalGQL(v any) error { str, ok := v.(string) if !ok { return fmt.Errorf("enums must be strings") } *e = UserOrderField(str) if !e.IsValid() { return fmt.Errorf("%s is not a valid UserOrderField", str) } return nil } func (e UserOrderField) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } func (e *UserOrderField) UnmarshalJSON(b []byte) error { s, err := strconv.Unquote(string(b)) if err != nil { return err } return e.UnmarshalGQL(s) } func (e UserOrderField) MarshalJSON() ([]byte, error) { var buf bytes.Buffer e.MarshalGQL(&buf) return buf.Bytes(), nil } ================================================ FILE: codegen/testserver/benchmark/generated/prelude.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package generated import ( "context" "errors" "fmt" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) dir_defer_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, "if", ec.unmarshalOBoolean2ᚖbool) if err != nil { return nil, err } args["if"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "label", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["label"] = arg1 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) ___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 __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) 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) 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) 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) 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) 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: codegen/testserver/benchmark/generated/resolvers/resolver.go ================================================ package resolver // 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" "github.com/99designs/gqlgen/codegen/testserver/benchmark/generated" "github.com/99designs/gqlgen/codegen/testserver/benchmark/generated/models" ) type Resolver struct{} // Users is the resolver for the users field. func (r *queryResolver) Users(ctx context.Context, query *string, first *int, last *int, before *string, after *string, orderBy models.UserOrderBy) (*models.UserConnection, error) { panic("not implemented") } // Query returns generated.QueryResolver implementation. func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } type queryResolver struct{ *Resolver } // !!! 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. /* type Resolver struct{} */ ================================================ FILE: codegen/testserver/benchmark/generated/root_.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package generated import ( "bytes" "context" "sync/atomic" "github.com/99designs/gqlgen/codegen/testserver/benchmark/generated/models" "github.com/99designs/gqlgen/graphql" gqlparser "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" ) // NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { return &executableSchema{SchemaData: cfg.Schema, Resolvers: cfg.Resolvers, Directives: cfg.Directives, ComplexityRoot: cfg.Complexity} } type Config = graphql.Config[ResolverRoot, DirectiveRoot, ComplexityRoot] type ResolverRoot interface { Query() QueryResolver } type DirectiveRoot struct { } type ComplexityRoot struct { PageInfo struct { EndCursor func(childComplexity int) int HasNextPage func(childComplexity int) int HasPreviousPage func(childComplexity int) int StartCursor func(childComplexity int) int } Query struct { Users func(childComplexity int, query *string, first *int, last *int, before *string, after *string, orderBy models.UserOrderBy) int } User struct { Email func(childComplexity int) int FirstName func(childComplexity int) int LastName func(childComplexity int) int } UserConnection struct { Edges func(childComplexity int) int PageInfo func(childComplexity int) int TotalCount func(childComplexity int) int } UserEdge struct { Cursor func(childComplexity int) int Node func(childComplexity int) int } } 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 "PageInfo.endCursor": if e.ComplexityRoot.PageInfo.EndCursor == nil { break } return e.ComplexityRoot.PageInfo.EndCursor(childComplexity), true case "PageInfo.hasNextPage": if e.ComplexityRoot.PageInfo.HasNextPage == nil { break } return e.ComplexityRoot.PageInfo.HasNextPage(childComplexity), true case "PageInfo.hasPreviousPage": if e.ComplexityRoot.PageInfo.HasPreviousPage == nil { break } return e.ComplexityRoot.PageInfo.HasPreviousPage(childComplexity), true case "PageInfo.startCursor": if e.ComplexityRoot.PageInfo.StartCursor == nil { break } return e.ComplexityRoot.PageInfo.StartCursor(childComplexity), true case "Query.users": if e.ComplexityRoot.Query.Users == nil { break } args, err := ec.field_Query_users_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.Users(childComplexity, args["query"].(*string), args["first"].(*int), args["last"].(*int), args["before"].(*string), args["after"].(*string), args["orderBy"].(models.UserOrderBy)), true case "User.email": if e.ComplexityRoot.User.Email == nil { break } return e.ComplexityRoot.User.Email(childComplexity), true case "User.firstName": if e.ComplexityRoot.User.FirstName == nil { break } return e.ComplexityRoot.User.FirstName(childComplexity), true case "User.lastName": if e.ComplexityRoot.User.LastName == nil { break } return e.ComplexityRoot.User.LastName(childComplexity), true case "UserConnection.edges": if e.ComplexityRoot.UserConnection.Edges == nil { break } return e.ComplexityRoot.UserConnection.Edges(childComplexity), true case "UserConnection.pageInfo": if e.ComplexityRoot.UserConnection.PageInfo == nil { break } return e.ComplexityRoot.UserConnection.PageInfo(childComplexity), true case "UserConnection.totalCount": if e.ComplexityRoot.UserConnection.TotalCount == nil { break } return e.ComplexityRoot.UserConnection.TotalCount(childComplexity), true case "UserEdge.cursor": if e.ComplexityRoot.UserEdge.Cursor == nil { break } return e.ComplexityRoot.UserEdge.Cursor(childComplexity), true case "UserEdge.node": if e.ComplexityRoot.UserEdge.Node == nil { break } return e.ComplexityRoot.UserEdge.Node(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.unmarshalInputUserOrderBy, ) 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: `type PageInfo { hasNextPage: Boolean! hasPreviousPage: Boolean! startCursor: String! endCursor: String! } enum OrderDirection { ASCENDING DESCENDING } enum UserOrderField { FIRST_NAME LAST_NAME EMAIL } input UserOrderBy { orderByField: UserOrderField! orderByDirection: OrderDirection! } type User { firstName: String! lastName: String! email: String! } type UserEdge { cursor: String! node: User! } type UserConnection { edges: [UserEdge!]! pageInfo: PageInfo! totalCount: Int! } type Query { users( query: String first: Int last: Int before: String after: String orderBy: UserOrderBy! = { orderByField: FIRST_NAME orderByDirection: ASCENDING } ): UserConnection } `, BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) ================================================ FILE: codegen/testserver/benchmark/generated/schema.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package generated import ( "context" "errors" "fmt" "strconv" "sync/atomic" "github.com/99designs/gqlgen/codegen/testserver/benchmark/generated/models" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** type QueryResolver interface { Users(ctx context.Context, query *string, first *int, last *int, before *string, after *string, orderBy models.UserOrderBy) (*models.UserConnection, error) } // 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_Query_users_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, "query", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["query"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "first", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["first"] = arg1 arg2, err := graphql.ProcessArgField(ctx, rawArgs, "last", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["last"] = arg2 arg3, err := graphql.ProcessArgField(ctx, rawArgs, "before", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["before"] = arg3 arg4, err := graphql.ProcessArgField(ctx, rawArgs, "after", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["after"] = arg4 arg5, err := graphql.ProcessArgField(ctx, rawArgs, "orderBy", ec.unmarshalNUserOrderBy2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋbenchmarkᚋgeneratedᚋmodelsᚐUserOrderBy) if err != nil { return nil, err } args["orderBy"] = arg5 return args, nil } // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *models.PageInfo) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PageInfo_hasNextPage, func(ctx context.Context) (any, error) { return obj.HasNextPage, nil }, nil, ec.marshalNBoolean2bool, true, true, ) } func (ec *executionContext) fieldContext_PageInfo_hasNextPage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PageInfo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField, obj *models.PageInfo) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PageInfo_hasPreviousPage, func(ctx context.Context) (any, error) { return obj.HasPreviousPage, nil }, nil, ec.marshalNBoolean2bool, true, true, ) } func (ec *executionContext) fieldContext_PageInfo_hasPreviousPage(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PageInfo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *models.PageInfo) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PageInfo_startCursor, func(ctx context.Context) (any, error) { return obj.StartCursor, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_PageInfo_startCursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PageInfo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *models.PageInfo) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PageInfo_endCursor, func(ctx context.Context) (any, error) { return obj.EndCursor, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_PageInfo_endCursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PageInfo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String 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) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().Users(ctx, fc.Args["query"].(*string), fc.Args["first"].(*int), fc.Args["last"].(*int), fc.Args["before"].(*string), fc.Args["after"].(*string), fc.Args["orderBy"].(models.UserOrderBy)) }, nil, ec.marshalOUserConnection2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋbenchmarkᚋgeneratedᚋmodelsᚐUserConnection, true, false, ) } func (ec *executionContext) fieldContext_Query_users(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 "edges": return ec.fieldContext_UserConnection_edges(ctx, field) case "pageInfo": return ec.fieldContext_UserConnection_pageInfo(ctx, field) case "totalCount": return ec.fieldContext_UserConnection_totalCount(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type UserConnection", field.Name) }, } defer func() { if 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_users_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) _User_firstName(ctx context.Context, field graphql.CollectedField, obj *models.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_firstName, func(ctx context.Context) (any, error) { return obj.FirstName, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_User_firstName(_ 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_lastName(ctx context.Context, field graphql.CollectedField, obj *models.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_lastName, func(ctx context.Context) (any, error) { return obj.LastName, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_User_lastName(_ 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_email(ctx context.Context, field graphql.CollectedField, obj *models.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_email, func(ctx context.Context) (any, error) { return obj.Email, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_User_email(_ 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) _UserConnection_edges(ctx context.Context, field graphql.CollectedField, obj *models.UserConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_UserConnection_edges, func(ctx context.Context) (any, error) { return obj.Edges, nil }, nil, ec.marshalNUserEdge2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋbenchmarkᚋgeneratedᚋmodelsᚐUserEdgeᚄ, true, true, ) } func (ec *executionContext) fieldContext_UserConnection_edges(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "UserConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "cursor": return ec.fieldContext_UserEdge_cursor(ctx, field) case "node": return ec.fieldContext_UserEdge_node(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type UserEdge", field.Name) }, } return fc, nil } func (ec *executionContext) _UserConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *models.UserConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_UserConnection_pageInfo, func(ctx context.Context) (any, error) { return obj.PageInfo, nil }, nil, ec.marshalNPageInfo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋbenchmarkᚋgeneratedᚋmodelsᚐPageInfo, true, true, ) } func (ec *executionContext) fieldContext_UserConnection_pageInfo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "UserConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "hasNextPage": return ec.fieldContext_PageInfo_hasNextPage(ctx, field) case "hasPreviousPage": return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) case "startCursor": return ec.fieldContext_PageInfo_startCursor(ctx, field) case "endCursor": return ec.fieldContext_PageInfo_endCursor(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } func (ec *executionContext) _UserConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *models.UserConnection) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_UserConnection_totalCount, func(ctx context.Context) (any, error) { return obj.TotalCount, nil }, nil, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_UserConnection_totalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "UserConnection", 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) _UserEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *models.UserEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_UserEdge_cursor, func(ctx context.Context) (any, error) { return obj.Cursor, nil }, nil, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_UserEdge_cursor(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "UserEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _UserEdge_node(ctx context.Context, field graphql.CollectedField, obj *models.UserEdge) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_UserEdge_node, func(ctx context.Context) (any, error) { return obj.Node, nil }, nil, ec.marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋbenchmarkᚋgeneratedᚋmodelsᚐUser, true, true, ) } func (ec *executionContext) fieldContext_UserEdge_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "UserEdge", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "firstName": return ec.fieldContext_User_firstName(ctx, field) case "lastName": return ec.fieldContext_User_lastName(ctx, field) case "email": return ec.fieldContext_User_email(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** func (ec *executionContext) unmarshalInputUserOrderBy(ctx context.Context, obj any) (models.UserOrderBy, error) { var it models.UserOrderBy if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"orderByField", "orderByDirection"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "orderByField": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderByField")) data, err := ec.unmarshalNUserOrderField2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋbenchmarkᚋgeneratedᚋmodelsᚐUserOrderField(ctx, v) if err != nil { return it, err } it.OrderByField = data case "orderByDirection": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("orderByDirection")) data, err := ec.unmarshalNOrderDirection2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋbenchmarkᚋgeneratedᚋmodelsᚐOrderDirection(ctx, v) if err != nil { return it, err } it.OrderByDirection = data } } return it, nil } // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var pageInfoImplementors = []string{"PageInfo"} func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *models.PageInfo) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, pageInfoImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("PageInfo") case "hasNextPage": out.Values[i] = ec._PageInfo_hasNextPage(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "hasPreviousPage": out.Values[i] = ec._PageInfo_hasPreviousPage(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "startCursor": out.Values[i] = ec._PageInfo_startCursor(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "endCursor": out.Values[i] = ec._PageInfo_endCursor(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(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, _ *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) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(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 *models.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 "firstName": out.Values[i] = ec._User_firstName(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "lastName": out.Values[i] = ec._User_lastName(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "email": out.Values[i] = ec._User_email(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var userConnectionImplementors = []string{"UserConnection"} func (ec *executionContext) _UserConnection(ctx context.Context, sel ast.SelectionSet, obj *models.UserConnection) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, userConnectionImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("UserConnection") case "edges": out.Values[i] = ec._UserConnection_edges(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "pageInfo": out.Values[i] = ec._UserConnection_pageInfo(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "totalCount": out.Values[i] = ec._UserConnection_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 userEdgeImplementors = []string{"UserEdge"} func (ec *executionContext) _UserEdge(ctx context.Context, sel ast.SelectionSet, obj *models.UserEdge) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, userEdgeImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("UserEdge") case "cursor": out.Values[i] = ec._UserEdge_cursor(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "node": out.Values[i] = ec._UserEdge_node(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) unmarshalNOrderDirection2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋbenchmarkᚋgeneratedᚋmodelsᚐOrderDirection(ctx context.Context, v any) (models.OrderDirection, error) { var res models.OrderDirection err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNOrderDirection2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋbenchmarkᚋgeneratedᚋmodelsᚐOrderDirection(ctx context.Context, sel ast.SelectionSet, v models.OrderDirection) graphql.Marshaler { return v } func (ec *executionContext) marshalNPageInfo2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋbenchmarkᚋgeneratedᚋmodelsᚐPageInfo(ctx context.Context, sel ast.SelectionSet, v *models.PageInfo) 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._PageInfo(ctx, sel, v) } func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋbenchmarkᚋgeneratedᚋmodelsᚐUser(ctx context.Context, sel ast.SelectionSet, v *models.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) marshalNUserEdge2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋbenchmarkᚋgeneratedᚋmodelsᚐUserEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.UserEdge) 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.marshalNUserEdge2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋbenchmarkᚋgeneratedᚋmodelsᚐUserEdge(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalNUserEdge2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋbenchmarkᚋgeneratedᚋmodelsᚐUserEdge(ctx context.Context, sel ast.SelectionSet, v *models.UserEdge) 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._UserEdge(ctx, sel, v) } func (ec *executionContext) unmarshalNUserOrderBy2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋbenchmarkᚋgeneratedᚋmodelsᚐUserOrderBy(ctx context.Context, v any) (models.UserOrderBy, error) { res, err := ec.unmarshalInputUserOrderBy(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalNUserOrderField2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋbenchmarkᚋgeneratedᚋmodelsᚐUserOrderField(ctx context.Context, v any) (models.UserOrderField, error) { var res models.UserOrderField err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNUserOrderField2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋbenchmarkᚋgeneratedᚋmodelsᚐUserOrderField(ctx context.Context, sel ast.SelectionSet, v models.UserOrderField) graphql.Marshaler { return v } func (ec *executionContext) marshalOUserConnection2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋbenchmarkᚋgeneratedᚋmodelsᚐUserConnection(ctx context.Context, sel ast.SelectionSet, v *models.UserConnection) graphql.Marshaler { if v == nil { return graphql.Null } return ec._UserConnection(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/benchmark/gqlgen.yml ================================================ schema: - "*.graphql" skip_validation: true exec: layout: follow-schema dir: generated package: generated model: filename: generated/models/models-gen.go package: models resolver: filename: generated/resolvers/resolver.go package: resolver type: Resolver ================================================ FILE: codegen/testserver/benchmark/schema.graphql ================================================ type PageInfo { hasNextPage: Boolean! hasPreviousPage: Boolean! startCursor: String! endCursor: String! } enum OrderDirection { ASCENDING DESCENDING } enum UserOrderField { FIRST_NAME LAST_NAME EMAIL } input UserOrderBy { orderByField: UserOrderField! orderByDirection: OrderDirection! } type User { firstName: String! lastName: String! email: String! } type UserEdge { cursor: String! node: User! } type UserConnection { edges: [UserEdge!]! pageInfo: PageInfo! totalCount: Int! } type Query { users( query: String first: Int last: Int before: String after: String orderBy: UserOrderBy! = { orderByField: FIRST_NAME orderByDirection: ASCENDING } ): UserConnection } ================================================ FILE: codegen/testserver/benchmark/stub.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package benchmark import ( "context" "github.com/99designs/gqlgen/codegen/testserver/benchmark/generated" "github.com/99designs/gqlgen/codegen/testserver/benchmark/generated/models" ) type Stub struct { QueryResolver struct { Users func(ctx context.Context, query *string, first *int, last *int, before *string, after *string, orderBy models.UserOrderBy) (*models.UserConnection, error) } } func (r *Stub) Query() generated.QueryResolver { return &stubQuery{r} } type stubQuery struct{ *Stub } func (r *stubQuery) Users(ctx context.Context, query *string, first *int, last *int, before *string, after *string, orderBy models.UserOrderBy) (*models.UserConnection, error) { return r.QueryResolver.Users(ctx, query, first, last, before, after, orderBy) } ================================================ FILE: codegen/testserver/compliant-int/compliant_int_test.go ================================================ //go:generate go run ../../../testdata/gqlgen.go -config gqlgen_default.yml -stub generated-default/stub.go //go:generate go run ../../../testdata/gqlgen.go -config gqlgen_compliant_strict.yml -stub generated-compliant-strict/stub.go package compliant_int import ( "bytes" "context" "fmt" "go/ast" "go/format" "go/parser" "go/token" "path/filepath" "slices" "strings" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" gencompliant "github.com/99designs/gqlgen/codegen/testserver/compliant-int/generated-compliant-strict" gendefault "github.com/99designs/gqlgen/codegen/testserver/compliant-int/generated-default" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestCodegen(t *testing.T) { cases := []struct { name string pkgPath string signature map[string]string models map[string][]string }{ { name: "no model configuration default generation", pkgPath: "generated-default", signature: map[string]string{ "EchoIntToInt": "func(ctx context.Context, n *int) (int, error)", "EchoInt64ToInt64": "func(ctx context.Context, n *int) (int, error)", }, models: map[string][]string{ "Input": {"N *int"}, "Result": {"N int"}, "Input64": {"N *int"}, "Result64": {"N int"}, }, }, { name: "strict compliant model configuration in yaml", pkgPath: "generated-compliant-strict", signature: map[string]string{ "EchoIntToInt": "func(ctx context.Context, n *int32) (int32, error)", "EchoInt64ToInt64": "func(ctx context.Context, n *int) (int, error)", }, models: map[string][]string{ "Input": {"N *int32"}, "Result": {"N int32"}, "Input64": {"N *int"}, "Result64": {"N int"}, }, }, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { path, err := filepath.Abs(tc.pkgPath) require.NoError(t, err) //nolint:staticcheck // SA1019 help wanted to golang.org/x/tools/go/packages pkgs, err := parser.ParseDir(token.NewFileSet(), path, nil, parser.AllErrors) require.NoError(t, err) pkg, ok := pkgs["generated"] require.True(t, ok, fmt.Sprintf("invalid package found at %v", tc.pkgPath)) modelsMap := make(map[string][]string) signatureMap := make(map[string]string) ast.Inspect(pkg, func(node ast.Node) bool { switch node := node.(type) { case *ast.FuncDecl: if slices.Contains( []string{"EchoIntToInt", "EchoInt64ToInt64"}, node.Name.Name, ) { signatureMap[node.Name.Name] = printNode(t, node.Type) } case *ast.TypeSpec: s, ok := node.Type.(*ast.StructType) if !ok { return true } if slices.Contains( []string{"Input", "Input64", "Result", "Result64"}, node.Name.Name, ) { var fields []string for _, field := range s.Fields.List { fields = append(fields, join(field.Names)+" "+printNode(t, field.Type)) } modelsMap[node.Name.Name] = fields } return true default: } return true }) t.Run("resolver signature", func(t *testing.T) { require.Equal(t, tc.signature, signatureMap) }) t.Run("models", func(t *testing.T) { require.Equal(t, tc.models, modelsMap) }) }) } } func TestIntegration(t *testing.T) { defaultStub := &gendefault.Stub{} defaultStub.QueryResolver.EchoIntToInt = func(_ context.Context, n *int) (int, error) { if n == nil { return 0, nil } return *n, nil } strictCompliantStub := &gencompliant.Stub{} strictCompliantStub.QueryResolver.EchoIntToInt = func(_ context.Context, n *int32) (int32, error) { if n == nil { return 0, nil } return *n, nil } cases := []struct { name string exec graphql.ExecutableSchema willError bool }{ { name: "default generation allows int32 overflow inputs", exec: gendefault.NewExecutableSchema(gendefault.Config{Resolvers: defaultStub}), willError: false, }, { name: "strict compliant generation does not allow int32 overflow inputs", exec: gencompliant.NewExecutableSchema( gencompliant.Config{Resolvers: strictCompliantStub}, ), willError: true, }, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { srv := handler.New(tc.exec) srv.AddTransport(transport.POST{}) c := client.New(srv) var resp struct { EchoIntToInt int } err := c.Post(`query { echoIntToInt(n: 2147483648) }`, &resp) if tc.willError { require.EqualError( t, err, `[{"message":"2147483648 overflows signed 32-bit integer","path":["echoIntToInt","n"]}]`, ) require.Equal(t, 0, resp.EchoIntToInt) return } require.NoError(t, err) require.Equal(t, 2147483648, resp.EchoIntToInt) }) } } func printNode(t *testing.T, node any) string { t.Helper() buf := &bytes.Buffer{} err := format.Node(buf, token.NewFileSet(), node) require.NoError(t, err) return buf.String() } func join[T fmt.Stringer](s []T) string { var sb strings.Builder for _, v := range s { sb.WriteString(v.String()) } return sb.String() } ================================================ FILE: codegen/testserver/compliant-int/generated-compliant-strict/models.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package generated type Input struct { N *int32 `json:"n,omitempty"` } type Input64 struct { N *int `json:"n,omitempty"` } type Query struct { } type Result struct { N int32 `json:"n"` } type Result64 struct { N int `json:"n"` } ================================================ FILE: codegen/testserver/compliant-int/generated-compliant-strict/resolver.go ================================================ package generated // 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 Resolver struct{} // EchoIntToInt is the resolver for the echoIntToInt field. func (r *queryResolver) EchoIntToInt(ctx context.Context, n *int32) (int32, error) { panic("not implemented") } // EchoInt64ToInt64 is the resolver for the echoInt64ToInt64 field. func (r *queryResolver) EchoInt64ToInt64(ctx context.Context, n *int) (int, error) { panic("not implemented") } // EchoIntInputToIntObject is the resolver for the echoIntInputToIntObject field. func (r *queryResolver) EchoIntInputToIntObject(ctx context.Context, input Input) (*Result, error) { panic("not implemented") } // EchoInt64InputToInt64Object is the resolver for the echoInt64InputToInt64Object field. func (r *queryResolver) EchoInt64InputToInt64Object(ctx context.Context, input Input64) (*Result64, error) { panic("not implemented") } // Query returns QueryResolver implementation. func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } type queryResolver struct{ *Resolver } // !!! 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. /* type Resolver struct{} */ ================================================ FILE: codegen/testserver/compliant-int/generated-compliant-strict/schema.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" 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 { Query() QueryResolver } type DirectiveRoot struct { } type ComplexityRoot struct { Query struct { EchoInt64InputToInt64Object func(childComplexity int, input Input64) int EchoInt64ToInt64 func(childComplexity int, n *int) int EchoIntInputToIntObject func(childComplexity int, input Input) int EchoIntToInt func(childComplexity int, n *int32) int } Result struct { N func(childComplexity int) int } Result64 struct { N func(childComplexity int) int } } type QueryResolver interface { EchoIntToInt(ctx context.Context, n *int32) (int32, error) EchoInt64ToInt64(ctx context.Context, n *int) (int, error) EchoIntInputToIntObject(ctx context.Context, input Input) (*Result, error) EchoInt64InputToInt64Object(ctx context.Context, input Input64) (*Result64, 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 "Query.echoInt64InputToInt64Object": if e.ComplexityRoot.Query.EchoInt64InputToInt64Object == nil { break } args, err := ec.field_Query_echoInt64InputToInt64Object_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.EchoInt64InputToInt64Object(childComplexity, args["input"].(Input64)), true case "Query.echoInt64ToInt64": if e.ComplexityRoot.Query.EchoInt64ToInt64 == nil { break } args, err := ec.field_Query_echoInt64ToInt64_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.EchoInt64ToInt64(childComplexity, args["n"].(*int)), true case "Query.echoIntInputToIntObject": if e.ComplexityRoot.Query.EchoIntInputToIntObject == nil { break } args, err := ec.field_Query_echoIntInputToIntObject_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.EchoIntInputToIntObject(childComplexity, args["input"].(Input)), true case "Query.echoIntToInt": if e.ComplexityRoot.Query.EchoIntToInt == nil { break } args, err := ec.field_Query_echoIntToInt_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.EchoIntToInt(childComplexity, args["n"].(*int32)), true case "Result.n": if e.ComplexityRoot.Result.N == nil { break } return e.ComplexityRoot.Result.N(childComplexity), true case "Result64.n": if e.ComplexityRoot.Result64.N == nil { break } return e.ComplexityRoot.Result64.N(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.unmarshalInputInput, ec.unmarshalInputInput64, ) 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: `scalar Int64 input Input { n: Int } input Input64 { n: Int64 } type Result { n: Int! } type Result64 { n: Int64! } type Query { echoIntToInt(n: Int): Int! echoInt64ToInt64(n: Int64): Int64! echoIntInputToIntObject(input: Input!): Result echoInt64InputToInt64Object(input: Input64!): Result64 } `, 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_Query_echoInt64InputToInt64Object_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, "input", ec.unmarshalNInput642githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋcompliantᚑintᚋgeneratedᚑcompliantᚑstrictᚐInput64) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Query_echoInt64ToInt64_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, "n", ec.unmarshalOInt642ᚖint) if err != nil { return nil, err } args["n"] = arg0 return args, nil } func (ec *executionContext) field_Query_echoIntInputToIntObject_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, "input", ec.unmarshalNInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋcompliantᚑintᚋgeneratedᚑcompliantᚑstrictᚐInput) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Query_echoIntToInt_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, "n", ec.unmarshalOInt2ᚖint32) if err != nil { return nil, err } args["n"] = 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_echoIntToInt(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_echoIntToInt, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().EchoIntToInt(ctx, fc.Args["n"].(*int32)) }, nil, ec.marshalNInt2int32, true, true, ) } func (ec *executionContext) fieldContext_Query_echoIntToInt(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 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_Query_echoIntToInt_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_echoInt64ToInt64(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_echoInt64ToInt64, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().EchoInt64ToInt64(ctx, fc.Args["n"].(*int)) }, nil, ec.marshalNInt642int, true, true, ) } func (ec *executionContext) fieldContext_Query_echoInt64ToInt64(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 Int64 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_echoInt64ToInt64_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_echoIntInputToIntObject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_echoIntInputToIntObject, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().EchoIntInputToIntObject(ctx, fc.Args["input"].(Input)) }, nil, ec.marshalOResult2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋcompliantᚑintᚋgeneratedᚑcompliantᚑstrictᚐResult, true, false, ) } func (ec *executionContext) fieldContext_Query_echoIntInputToIntObject(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 "n": return ec.fieldContext_Result_n(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Result", field.Name) }, } defer func() { if 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_echoIntInputToIntObject_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_echoInt64InputToInt64Object(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_echoInt64InputToInt64Object, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().EchoInt64InputToInt64Object(ctx, fc.Args["input"].(Input64)) }, nil, ec.marshalOResult642ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋcompliantᚑintᚋgeneratedᚑcompliantᚑstrictᚐResult64, true, false, ) } func (ec *executionContext) fieldContext_Query_echoInt64InputToInt64Object(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 "n": return ec.fieldContext_Result64_n(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Result64", field.Name) }, } defer func() { if 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_echoInt64InputToInt64Object_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) _Result_n(ctx context.Context, field graphql.CollectedField, obj *Result) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Result_n, func(ctx context.Context) (any, error) { return obj.N, nil }, nil, ec.marshalNInt2int32, true, true, ) } func (ec *executionContext) fieldContext_Result_n(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Result", 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) _Result64_n(ctx context.Context, field graphql.CollectedField, obj *Result64) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Result64_n, func(ctx context.Context) (any, error) { return obj.N, nil }, nil, ec.marshalNInt642int, true, true, ) } func (ec *executionContext) fieldContext_Result64_n(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Result64", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int64 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) unmarshalInputInput(ctx context.Context, obj any) (Input, error) { var it Input if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"n"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "n": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("n")) data, err := ec.unmarshalOInt2ᚖint32(ctx, v) if err != nil { return it, err } it.N = data } } return it, nil } func (ec *executionContext) unmarshalInputInput64(ctx context.Context, obj any) (Input64, error) { var it Input64 if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"n"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "n": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("n")) data, err := ec.unmarshalOInt642ᚖint(ctx, v) if err != nil { return it, err } it.N = data } } return it, nil } // 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 "echoIntToInt": field := field innerFunc := func(ctx 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_echoIntToInt(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 "echoInt64ToInt64": field := field innerFunc := func(ctx 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_echoInt64ToInt64(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 "echoIntInputToIntObject": 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_echoIntInputToIntObject(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 "echoInt64InputToInt64Object": 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_echoInt64InputToInt64Object(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 resultImplementors = []string{"Result"} func (ec *executionContext) _Result(ctx context.Context, sel ast.SelectionSet, obj *Result) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, resultImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Result") case "n": out.Values[i] = ec._Result_n(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 result64Implementors = []string{"Result64"} func (ec *executionContext) _Result64(ctx context.Context, sel ast.SelectionSet, obj *Result64) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, result64Implementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Result64") case "n": out.Values[i] = ec._Result64_n(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": out.Values[i] = ec.___Directive_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "description": out.Values[i] = ec.___Directive_description(ctx, field, obj) case "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) unmarshalNInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋcompliantᚑintᚋgeneratedᚑcompliantᚑstrictᚐInput(ctx context.Context, v any) (Input, error) { res, err := ec.unmarshalInputInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalNInput642githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋcompliantᚑintᚋgeneratedᚑcompliantᚑstrictᚐInput64(ctx context.Context, v any) (Input64, error) { res, err := ec.unmarshalInputInput64(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalNInt2int32(ctx context.Context, v any) (int32, error) { res, err := graphql.UnmarshalInt32(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNInt2int32(ctx context.Context, sel ast.SelectionSet, v int32) graphql.Marshaler { _ = sel res := graphql.MarshalInt32(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) unmarshalNInt642int(ctx context.Context, v any) (int, error) { res, err := graphql.UnmarshalInt(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNInt642int(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) 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) 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) unmarshalOInt2ᚖint32(ctx context.Context, v any) (*int32, error) { if v == nil { return nil, nil } res, err := graphql.UnmarshalInt32(v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOInt2ᚖint32(ctx context.Context, sel ast.SelectionSet, v *int32) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel _ = ctx res := graphql.MarshalInt32(*v) return res } func (ec *executionContext) unmarshalOInt642ᚖ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) marshalOInt642ᚖ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) marshalOResult2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋcompliantᚑintᚋgeneratedᚑcompliantᚑstrictᚐResult(ctx context.Context, sel ast.SelectionSet, v *Result) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Result(ctx, sel, v) } func (ec *executionContext) marshalOResult642ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋcompliantᚑintᚋgeneratedᚑcompliantᚑstrictᚐResult64(ctx context.Context, sel ast.SelectionSet, v *Result64) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Result64(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: codegen/testserver/compliant-int/generated-compliant-strict/stub.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package generated import ( "context" ) type Stub struct { QueryResolver struct { EchoIntToInt func(ctx context.Context, n *int32) (int32, error) EchoInt64ToInt64 func(ctx context.Context, n *int) (int, error) EchoIntInputToIntObject func(ctx context.Context, input Input) (*Result, error) EchoInt64InputToInt64Object func(ctx context.Context, input Input64) (*Result64, error) } } func (r *Stub) Query() QueryResolver { return &stubQuery{r} } type stubQuery struct{ *Stub } func (r *stubQuery) EchoIntToInt(ctx context.Context, n *int32) (int32, error) { return r.QueryResolver.EchoIntToInt(ctx, n) } func (r *stubQuery) EchoInt64ToInt64(ctx context.Context, n *int) (int, error) { return r.QueryResolver.EchoInt64ToInt64(ctx, n) } func (r *stubQuery) EchoIntInputToIntObject(ctx context.Context, input Input) (*Result, error) { return r.QueryResolver.EchoIntInputToIntObject(ctx, input) } func (r *stubQuery) EchoInt64InputToInt64Object(ctx context.Context, input Input64) (*Result64, error) { return r.QueryResolver.EchoInt64InputToInt64Object(ctx, input) } ================================================ FILE: codegen/testserver/compliant-int/generated-default/models.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package generated type Input struct { N *int `json:"n,omitempty"` } type Input64 struct { N *int `json:"n,omitempty"` } type Query struct { } type Result struct { N int `json:"n"` } type Result64 struct { N int `json:"n"` } ================================================ FILE: codegen/testserver/compliant-int/generated-default/resolver.go ================================================ package generated // 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 Resolver struct{} // EchoIntToInt is the resolver for the echoIntToInt field. func (r *queryResolver) EchoIntToInt(ctx context.Context, n *int) (int, error) { panic("not implemented") } // EchoInt64ToInt64 is the resolver for the echoInt64ToInt64 field. func (r *queryResolver) EchoInt64ToInt64(ctx context.Context, n *int) (int, error) { panic("not implemented") } // EchoIntInputToIntObject is the resolver for the echoIntInputToIntObject field. func (r *queryResolver) EchoIntInputToIntObject(ctx context.Context, input Input) (*Result, error) { panic("not implemented") } // EchoInt64InputToInt64Object is the resolver for the echoInt64InputToInt64Object field. func (r *queryResolver) EchoInt64InputToInt64Object(ctx context.Context, input Input64) (*Result64, error) { panic("not implemented") } // Query returns QueryResolver implementation. func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } type queryResolver struct{ *Resolver } // !!! 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. /* type Resolver struct{} */ ================================================ FILE: codegen/testserver/compliant-int/generated-default/schema.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" 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 { Query() QueryResolver } type DirectiveRoot struct { } type ComplexityRoot struct { Query struct { EchoInt64InputToInt64Object func(childComplexity int, input Input64) int EchoInt64ToInt64 func(childComplexity int, n *int) int EchoIntInputToIntObject func(childComplexity int, input Input) int EchoIntToInt func(childComplexity int, n *int) int } Result struct { N func(childComplexity int) int } Result64 struct { N func(childComplexity int) int } } type QueryResolver interface { EchoIntToInt(ctx context.Context, n *int) (int, error) EchoInt64ToInt64(ctx context.Context, n *int) (int, error) EchoIntInputToIntObject(ctx context.Context, input Input) (*Result, error) EchoInt64InputToInt64Object(ctx context.Context, input Input64) (*Result64, 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 "Query.echoInt64InputToInt64Object": if e.ComplexityRoot.Query.EchoInt64InputToInt64Object == nil { break } args, err := ec.field_Query_echoInt64InputToInt64Object_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.EchoInt64InputToInt64Object(childComplexity, args["input"].(Input64)), true case "Query.echoInt64ToInt64": if e.ComplexityRoot.Query.EchoInt64ToInt64 == nil { break } args, err := ec.field_Query_echoInt64ToInt64_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.EchoInt64ToInt64(childComplexity, args["n"].(*int)), true case "Query.echoIntInputToIntObject": if e.ComplexityRoot.Query.EchoIntInputToIntObject == nil { break } args, err := ec.field_Query_echoIntInputToIntObject_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.EchoIntInputToIntObject(childComplexity, args["input"].(Input)), true case "Query.echoIntToInt": if e.ComplexityRoot.Query.EchoIntToInt == nil { break } args, err := ec.field_Query_echoIntToInt_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.EchoIntToInt(childComplexity, args["n"].(*int)), true case "Result.n": if e.ComplexityRoot.Result.N == nil { break } return e.ComplexityRoot.Result.N(childComplexity), true case "Result64.n": if e.ComplexityRoot.Result64.N == nil { break } return e.ComplexityRoot.Result64.N(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.unmarshalInputInput, ec.unmarshalInputInput64, ) 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: `scalar Int64 input Input { n: Int } input Input64 { n: Int64 } type Result { n: Int! } type Result64 { n: Int64! } type Query { echoIntToInt(n: Int): Int! echoInt64ToInt64(n: Int64): Int64! echoIntInputToIntObject(input: Input!): Result echoInt64InputToInt64Object(input: Input64!): Result64 } `, 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_Query_echoInt64InputToInt64Object_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, "input", ec.unmarshalNInput642githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋcompliantᚑintᚋgeneratedᚑdefaultᚐInput64) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Query_echoInt64ToInt64_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, "n", ec.unmarshalOInt642ᚖint) if err != nil { return nil, err } args["n"] = arg0 return args, nil } func (ec *executionContext) field_Query_echoIntInputToIntObject_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, "input", ec.unmarshalNInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋcompliantᚑintᚋgeneratedᚑdefaultᚐInput) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Query_echoIntToInt_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, "n", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["n"] = 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_echoIntToInt(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_echoIntToInt, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().EchoIntToInt(ctx, fc.Args["n"].(*int)) }, nil, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_Query_echoIntToInt(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 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_Query_echoIntToInt_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_echoInt64ToInt64(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_echoInt64ToInt64, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().EchoInt64ToInt64(ctx, fc.Args["n"].(*int)) }, nil, ec.marshalNInt642int, true, true, ) } func (ec *executionContext) fieldContext_Query_echoInt64ToInt64(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 Int64 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_echoInt64ToInt64_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_echoIntInputToIntObject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_echoIntInputToIntObject, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().EchoIntInputToIntObject(ctx, fc.Args["input"].(Input)) }, nil, ec.marshalOResult2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋcompliantᚑintᚋgeneratedᚑdefaultᚐResult, true, false, ) } func (ec *executionContext) fieldContext_Query_echoIntInputToIntObject(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 "n": return ec.fieldContext_Result_n(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Result", field.Name) }, } defer func() { if 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_echoIntInputToIntObject_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_echoInt64InputToInt64Object(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_echoInt64InputToInt64Object, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().EchoInt64InputToInt64Object(ctx, fc.Args["input"].(Input64)) }, nil, ec.marshalOResult642ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋcompliantᚑintᚋgeneratedᚑdefaultᚐResult64, true, false, ) } func (ec *executionContext) fieldContext_Query_echoInt64InputToInt64Object(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 "n": return ec.fieldContext_Result64_n(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Result64", field.Name) }, } defer func() { if 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_echoInt64InputToInt64Object_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) _Result_n(ctx context.Context, field graphql.CollectedField, obj *Result) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Result_n, func(ctx context.Context) (any, error) { return obj.N, nil }, nil, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_Result_n(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Result", 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) _Result64_n(ctx context.Context, field graphql.CollectedField, obj *Result64) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Result64_n, func(ctx context.Context) (any, error) { return obj.N, nil }, nil, ec.marshalNInt642int, true, true, ) } func (ec *executionContext) fieldContext_Result64_n(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Result64", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int64 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) unmarshalInputInput(ctx context.Context, obj any) (Input, error) { var it Input if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"n"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "n": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("n")) data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } it.N = data } } return it, nil } func (ec *executionContext) unmarshalInputInput64(ctx context.Context, obj any) (Input64, error) { var it Input64 if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"n"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "n": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("n")) data, err := ec.unmarshalOInt642ᚖint(ctx, v) if err != nil { return it, err } it.N = data } } return it, nil } // 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 "echoIntToInt": field := field innerFunc := func(ctx 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_echoIntToInt(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 "echoInt64ToInt64": field := field innerFunc := func(ctx 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_echoInt64ToInt64(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 "echoIntInputToIntObject": 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_echoIntInputToIntObject(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 "echoInt64InputToInt64Object": 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_echoInt64InputToInt64Object(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 resultImplementors = []string{"Result"} func (ec *executionContext) _Result(ctx context.Context, sel ast.SelectionSet, obj *Result) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, resultImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Result") case "n": out.Values[i] = ec._Result_n(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 result64Implementors = []string{"Result64"} func (ec *executionContext) _Result64(ctx context.Context, sel ast.SelectionSet, obj *Result64) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, result64Implementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Result64") case "n": out.Values[i] = ec._Result64_n(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": out.Values[i] = ec.___Directive_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "description": out.Values[i] = ec.___Directive_description(ctx, field, obj) case "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) unmarshalNInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋcompliantᚑintᚋgeneratedᚑdefaultᚐInput(ctx context.Context, v any) (Input, error) { res, err := ec.unmarshalInputInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalNInput642githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋcompliantᚑintᚋgeneratedᚑdefaultᚐInput64(ctx context.Context, v any) (Input64, error) { res, err := ec.unmarshalInputInput64(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } 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) unmarshalNInt642int(ctx context.Context, v any) (int, error) { res, err := graphql.UnmarshalInt(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNInt642int(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) 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) 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) 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) unmarshalOInt642ᚖ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) marshalOInt642ᚖ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) marshalOResult2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋcompliantᚑintᚋgeneratedᚑdefaultᚐResult(ctx context.Context, sel ast.SelectionSet, v *Result) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Result(ctx, sel, v) } func (ec *executionContext) marshalOResult642ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋcompliantᚑintᚋgeneratedᚑdefaultᚐResult64(ctx context.Context, sel ast.SelectionSet, v *Result64) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Result64(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: codegen/testserver/compliant-int/generated-default/stub.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package generated import ( "context" ) type Stub struct { QueryResolver struct { EchoIntToInt func(ctx context.Context, n *int) (int, error) EchoInt64ToInt64 func(ctx context.Context, n *int) (int, error) EchoIntInputToIntObject func(ctx context.Context, input Input) (*Result, error) EchoInt64InputToInt64Object func(ctx context.Context, input Input64) (*Result64, error) } } func (r *Stub) Query() QueryResolver { return &stubQuery{r} } type stubQuery struct{ *Stub } func (r *stubQuery) EchoIntToInt(ctx context.Context, n *int) (int, error) { return r.QueryResolver.EchoIntToInt(ctx, n) } func (r *stubQuery) EchoInt64ToInt64(ctx context.Context, n *int) (int, error) { return r.QueryResolver.EchoInt64ToInt64(ctx, n) } func (r *stubQuery) EchoIntInputToIntObject(ctx context.Context, input Input) (*Result, error) { return r.QueryResolver.EchoIntInputToIntObject(ctx, input) } func (r *stubQuery) EchoInt64InputToInt64Object(ctx context.Context, input Input64) (*Result64, error) { return r.QueryResolver.EchoInt64InputToInt64Object(ctx, input) } ================================================ FILE: codegen/testserver/compliant-int/gqlgen_compliant_strict.yml ================================================ schema: - "*.graphql" skip_validation: true exec: package: generated filename: generated-compliant-strict/schema.go model: package: generated filename: generated-compliant-strict/models.go resolver: package: generated filename: generated-compliant-strict/resolver.go models: Int: model: - github.com/99designs/gqlgen/graphql.Int32 Int64: model: - github.com/99designs/gqlgen/graphql.Int - github.com/99designs/gqlgen/graphql.Int64 ================================================ FILE: codegen/testserver/compliant-int/gqlgen_default.yml ================================================ schema: - "*.graphql" skip_validation: true exec: package: generated filename: generated-default/schema.go model: package: generated filename: generated-default/models.go resolver: package: generated filename: generated-default/resolver.go ================================================ FILE: codegen/testserver/compliant-int/schema.graphql ================================================ scalar Int64 input Input { n: Int } input Input64 { n: Int64 } type Result { n: Int! } type Result64 { n: Int64! } type Query { echoIntToInt(n: Int): Int! echoInt64ToInt64(n: Int64): Int64! echoIntInputToIntObject(input: Input!): Result echoInt64InputToInt64Object(input: Input64!): Result64 } ================================================ FILE: codegen/testserver/empty.go ================================================ package testserver // Empty file to silence go build error complaining that codegen/testserver/ has no non-test Go // source files. ================================================ FILE: codegen/testserver/followschema/builtinscalar.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _Map_id(ctx context.Context, field graphql.CollectedField, obj *Map) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Map_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_Map_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Map", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var mapImplementors = []string{"Map"} func (ec *executionContext) _Map(ctx context.Context, sel ast.SelectionSet, obj *Map) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, mapImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Map") case "id": out.Values[i] = ec._Map_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/builtinscalar.graphql ================================================ """ Since gqlgen defines default implementation for a Map scalar, this tests that the builtin is _not_ added to the TypeMap """ type Map { id: ID! } ================================================ FILE: codegen/testserver/followschema/bytes.go ================================================ package followschema import ( "fmt" "io" "github.com/99designs/gqlgen/graphql" ) func MarshalBytes(b []byte) graphql.Marshaler { return graphql.WriterFunc(func(w io.Writer) { _, _ = fmt.Fprintf(w, "%q", string(b)) }) } func UnmarshalBytes(v any) ([]byte, error) { switch v := v.(type) { case string: return []byte(v), nil case *string: return []byte(*v), nil case []byte: return v, nil default: return nil, fmt.Errorf("%T is not []byte", v) } } ================================================ FILE: codegen/testserver/followschema/complexity.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** type OverlappingFieldsResolver interface { OldFoo(ctx context.Context, obj *OverlappingFields) (int, error) } // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _OverlappingFields_oneFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_OverlappingFields_oneFoo, func(ctx context.Context) (any, error) { return obj.Foo, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_OverlappingFields_oneFoo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "OverlappingFields", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _OverlappingFields_twoFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_OverlappingFields_twoFoo, func(ctx context.Context) (any, error) { return obj.Foo, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_OverlappingFields_twoFoo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "OverlappingFields", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _OverlappingFields_oldFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_OverlappingFields_oldFoo, func(ctx context.Context) (any, error) { return ec.Resolvers.OverlappingFields().OldFoo(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_OverlappingFields_oldFoo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "OverlappingFields", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _OverlappingFields_newFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_OverlappingFields_newFoo, func(ctx context.Context) (any, error) { return obj.NewFoo, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_OverlappingFields_newFoo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "OverlappingFields", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _OverlappingFields_new_foo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_OverlappingFields_new_foo, func(ctx context.Context) (any, error) { return obj.NewFoo, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_OverlappingFields_new_foo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "OverlappingFields", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var overlappingFieldsImplementors = []string{"OverlappingFields"} func (ec *executionContext) _OverlappingFields(ctx context.Context, sel ast.SelectionSet, obj *OverlappingFields) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, overlappingFieldsImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("OverlappingFields") case "oneFoo": out.Values[i] = ec._OverlappingFields_oneFoo(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "twoFoo": out.Values[i] = ec._OverlappingFields_twoFoo(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "oldFoo": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._OverlappingFields_oldFoo(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "newFoo": out.Values[i] = ec._OverlappingFields_newFoo(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "new_foo": out.Values[i] = ec._OverlappingFields_new_foo(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshalOOverlappingFields2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOverlappingFields(ctx context.Context, sel ast.SelectionSet, v *OverlappingFields) graphql.Marshaler { if v == nil { return graphql.Null } return ec._OverlappingFields(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/complexity.graphql ================================================ extend type Query { overlapping: OverlappingFields } type OverlappingFields { oneFoo: Int! @goField(name: "foo") twoFoo: Int! @goField(name: "foo") oldFoo: Int! @goField(name: "foo", forceResolver: true) newFoo: Int! new_foo: Int! } ================================================ FILE: codegen/testserver/followschema/complexity_test.go ================================================ package followschema import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/extension" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestComplexityCollisions(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) resolvers.QueryResolver.Overlapping = func(ctx context.Context) (fields *OverlappingFields, e error) { return &OverlappingFields{ Foo: 2, NewFoo: 3, }, nil } resolvers.OverlappingFieldsResolver.OldFoo = func(ctx context.Context, obj *OverlappingFields) (i int, e error) { return obj.Foo, nil } var resp struct { Overlapping struct { OneFoo int `json:"oneFoo"` TwoFoo int `json:"twoFoo"` OldFoo int `json:"oldFoo"` NewFoo int `json:"newFoo"` New_foo int `json:"new_foo"` } } c.MustPost(`query { overlapping { oneFoo, twoFoo, oldFoo, newFoo, new_foo } }`, &resp) require.Equal(t, 2, resp.Overlapping.OneFoo) require.Equal(t, 2, resp.Overlapping.TwoFoo) require.Equal(t, 2, resp.Overlapping.OldFoo) require.Equal(t, 3, resp.Overlapping.NewFoo) require.Equal(t, 3, resp.Overlapping.New_foo) } func TestComplexityFuncs(t *testing.T) { resolvers := &Stub{} cfg := Config{Resolvers: resolvers} cfg.Complexity.OverlappingFields.Foo = func(childComplexity int) int { return 1000 } cfg.Complexity.OverlappingFields.NewFoo = func(childComplexity int) int { return 5 } srv := handler.New(NewExecutableSchema(cfg)) srv.AddTransport(transport.POST{}) srv.Use(extension.FixedComplexityLimit(10)) c := client.New(srv) resolvers.QueryResolver.Overlapping = func(ctx context.Context) (fields *OverlappingFields, e error) { return &OverlappingFields{ Foo: 2, NewFoo: 3, }, nil } t.Run("with high complexity limit will not run", func(t *testing.T) { ran := false resolvers.OverlappingFieldsResolver.OldFoo = func(ctx context.Context, obj *OverlappingFields) (i int, e error) { ran = true return obj.Foo, nil } var resp struct { Overlapping any } err := c.Post(`query { overlapping { oneFoo, twoFoo, oldFoo, newFoo, new_foo } }`, &resp) require.EqualError( t, err, `[{"message":"operation has complexity 2012, which exceeds the limit of 10","extensions":{"code":"COMPLEXITY_LIMIT_EXCEEDED"}}]`, ) require.False(t, ran) }) t.Run("with low complexity will run", func(t *testing.T) { ran := false resolvers.QueryResolver.Overlapping = func(ctx context.Context) (fields *OverlappingFields, e error) { ran = true return &OverlappingFields{ Foo: 2, NewFoo: 3, }, nil } var resp struct { Overlapping any } c.MustPost(`query { overlapping { newFoo } }`, &resp) require.True(t, ran) }) t.Run("with multiple low complexity will not run", func(t *testing.T) { ran := false resolvers.QueryResolver.Overlapping = func(ctx context.Context) (fields *OverlappingFields, e error) { ran = true return &OverlappingFields{ Foo: 2, NewFoo: 3, }, nil } var resp any err := c.Post(`query { a: overlapping { newFoo }, b: overlapping { newFoo }, c: overlapping { newFoo }, }`, &resp) require.EqualError( t, err, `[{"message":"operation has complexity 18, which exceeds the limit of 10","extensions":{"code":"COMPLEXITY_LIMIT_EXCEEDED"}}]`, ) require.False(t, ran) }) } ================================================ FILE: codegen/testserver/followschema/defaults.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "fmt" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** type MutationResolver interface { DefaultInput(ctx context.Context, input DefaultInput) (*DefaultParametersMirror, error) OverrideValueViaInput(ctx context.Context, input FieldsOrderInput) (*FieldsOrderPayload, error) UpdateProduct(ctx context.Context, input map[string]interface{}) (string, error) Issue4053(ctx context.Context, input *Issue4053Input1) (bool, error) UpdateSomething(ctx context.Context, input SpecialInput) (string, error) UpdatePtrToPtr(ctx context.Context, input UpdatePtrToPtrOuter) (*PtrToPtrOuter, error) } // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) field_Mutation_defaultInput_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalNDefaultInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultInput) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Mutation_issue4053_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, "input", ec.unmarshalOIssue4053Input12ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐIssue4053Input1) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Mutation_overrideValueViaInput_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalNFieldsOrderInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFieldsOrderInput) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Mutation_updateProduct_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.unmarshalNID2string) if err != nil { return nil, err } args["id"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["name"] = arg1 arg2, err := graphql.ProcessArgField(ctx, rawArgs, "price", ec.unmarshalOFloat2ᚖfloat64) if err != nil { return nil, err } args["price"] = arg2 return args, nil } func (ec *executionContext) field_Mutation_updatePtrToPtr_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, "input", ec.unmarshalNUpdatePtrToPtrOuter2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrOuter) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Mutation_updateSomething_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalNSpecialInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSpecialInput) if err != nil { return nil, err } args["input"] = arg0 return args, nil } // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _DefaultParametersMirror_falsyBoolean(ctx context.Context, field graphql.CollectedField, obj *DefaultParametersMirror) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_DefaultParametersMirror_falsyBoolean, func(ctx context.Context) (any, error) { return obj.FalsyBoolean, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOBoolean2ᚖbool, true, false, ) } func (ec *executionContext) fieldContext_DefaultParametersMirror_falsyBoolean(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "DefaultParametersMirror", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } func (ec *executionContext) _DefaultParametersMirror_truthyBoolean(ctx context.Context, field graphql.CollectedField, obj *DefaultParametersMirror) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_DefaultParametersMirror_truthyBoolean, func(ctx context.Context) (any, error) { return obj.TruthyBoolean, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOBoolean2ᚖbool, true, false, ) } func (ec *executionContext) fieldContext_DefaultParametersMirror_truthyBoolean(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "DefaultParametersMirror", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } func (ec *executionContext) _Mutation_defaultInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Mutation_defaultInput, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Mutation().DefaultInput(ctx, fc.Args["input"].(DefaultInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNDefaultParametersMirror2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultParametersMirror, true, true, ) } func (ec *executionContext) fieldContext_Mutation_defaultInput(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "falsyBoolean": return ec.fieldContext_DefaultParametersMirror_falsyBoolean(ctx, field) case "truthyBoolean": return ec.fieldContext_DefaultParametersMirror_truthyBoolean(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type DefaultParametersMirror", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_defaultInput_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Mutation_overrideValueViaInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Mutation_overrideValueViaInput, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Mutation().OverrideValueViaInput(ctx, fc.Args["input"].(FieldsOrderInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNFieldsOrderPayload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFieldsOrderPayload, true, true, ) } func (ec *executionContext) fieldContext_Mutation_overrideValueViaInput(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "firstFieldValue": return ec.fieldContext_FieldsOrderPayload_firstFieldValue(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type FieldsOrderPayload", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_overrideValueViaInput_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Mutation_updateProduct(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Mutation_updateProduct, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Mutation().UpdateProduct(ctx, map[string]interface{}{ "id": fc.Args["id"].(string), "name": fc.Args["name"].(*string), "price": fc.Args["price"].(*float64), }) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Mutation_updateProduct(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_updateProduct_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Mutation_issue4053(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Mutation_issue4053, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Mutation().Issue4053(ctx, fc.Args["input"].(*Issue4053Input1)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNBoolean2bool, true, true, ) } func (ec *executionContext) fieldContext_Mutation_issue4053(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type 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_Mutation_issue4053_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Mutation_updateSomething(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Mutation_updateSomething, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Mutation().UpdateSomething(ctx, fc.Args["input"].(SpecialInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Mutation_updateSomething(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_updateSomething_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Mutation_updatePtrToPtr(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Mutation_updatePtrToPtr, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Mutation().UpdatePtrToPtr(ctx, fc.Args["input"].(UpdatePtrToPtrOuter)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNPtrToPtrOuter2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrOuter, true, true, ) } func (ec *executionContext) fieldContext_Mutation_updatePtrToPtr(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "name": return ec.fieldContext_PtrToPtrOuter_name(ctx, field) case "inner": return ec.fieldContext_PtrToPtrOuter_inner(ctx, field) case "stupidInner": return ec.fieldContext_PtrToPtrOuter_stupidInner(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type PtrToPtrOuter", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_updatePtrToPtr_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** func (ec *executionContext) unmarshalInputDefaultInput(ctx context.Context, obj any) (DefaultInput, error) { var it DefaultInput if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } if _, present := asMap["falsyBoolean"]; !present { asMap["falsyBoolean"] = false } if _, present := asMap["truthyBoolean"]; !present { asMap["truthyBoolean"] = true } fieldsInOrder := [...]string{"falsyBoolean", "truthyBoolean"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "falsyBoolean": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("falsyBoolean")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } it.FalsyBoolean = data case "truthyBoolean": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("truthyBoolean")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } it.TruthyBoolean = data } } return it, nil } // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var defaultParametersMirrorImplementors = []string{"DefaultParametersMirror"} func (ec *executionContext) _DefaultParametersMirror(ctx context.Context, sel ast.SelectionSet, obj *DefaultParametersMirror) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, defaultParametersMirrorImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("DefaultParametersMirror") case "falsyBoolean": out.Values[i] = ec._DefaultParametersMirror_falsyBoolean(ctx, field, obj) case "truthyBoolean": out.Values[i] = ec._DefaultParametersMirror_truthyBoolean(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var mutationImplementors = []string{"Mutation"} func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Mutation", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Mutation") case "defaultInput": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_defaultInput(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } case "overrideValueViaInput": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_overrideValueViaInput(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } case "updateProduct": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_updateProduct(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } case "issue4053": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_issue4053(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } case "updateSomething": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_updateSomething(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } case "updatePtrToPtr": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_updatePtrToPtr(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) unmarshalNDefaultInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultInput(ctx context.Context, v any) (DefaultInput, error) { res, err := ec.unmarshalInputDefaultInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNDefaultParametersMirror2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultParametersMirror(ctx context.Context, sel ast.SelectionSet, v DefaultParametersMirror) graphql.Marshaler { return ec._DefaultParametersMirror(ctx, sel, &v) } func (ec *executionContext) marshalNDefaultParametersMirror2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultParametersMirror(ctx context.Context, sel ast.SelectionSet, v *DefaultParametersMirror) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._DefaultParametersMirror(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/defaults.graphql ================================================ extend type Query { defaultParameters( falsyBoolean: Boolean = false truthyBoolean: Boolean = true ): DefaultParametersMirror! } extend type Mutation { defaultInput(input: DefaultInput!): DefaultParametersMirror! } input DefaultInput { falsyBoolean: Boolean = false truthyBoolean: Boolean = true } type DefaultParametersMirror { falsyBoolean: Boolean truthyBoolean: Boolean } ================================================ FILE: codegen/testserver/followschema/defaults_test.go ================================================ package followschema import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func assertDefaults(t *testing.T, ret *DefaultParametersMirror) { require.NotNil(t, ret) require.NotNil(t, ret.FalsyBoolean) require.False(t, *ret.FalsyBoolean) require.NotNil(t, ret.TruthyBoolean) require.True(t, *ret.TruthyBoolean) } func TestDefaults(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("default field parameters", func(t *testing.T) { resolvers.QueryResolver.DefaultParameters = func( ctx context.Context, falsyBoolean, truthyBoolean *bool, ) (*DefaultParametersMirror, error) { return &DefaultParametersMirror{ FalsyBoolean: falsyBoolean, TruthyBoolean: truthyBoolean, }, nil } var resp struct{ DefaultParameters *DefaultParametersMirror } err := c.Post(`query { defaultParameters { falsyBoolean truthyBoolean } }`, &resp) require.NoError(t, err) assertDefaults(t, resp.DefaultParameters) }) t.Run("default input fields", func(t *testing.T) { resolvers.MutationResolver.DefaultInput = func( ctx context.Context, input DefaultInput, ) (*DefaultParametersMirror, error) { return &DefaultParametersMirror{ FalsyBoolean: input.FalsyBoolean, TruthyBoolean: input.TruthyBoolean, }, nil } var resp struct{ DefaultInput *DefaultParametersMirror } err := c.Post(`mutation { defaultInput(input: {}) { falsyBoolean truthyBoolean } }`, &resp) require.NoError(t, err) assertDefaults(t, resp.DefaultInput) }) } ================================================ FILE: codegen/testserver/followschema/defer.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** type DeferModelResolver interface { Values(ctx context.Context, obj *DeferModel) ([]string, error) } // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _DeferModel_id(ctx context.Context, field graphql.CollectedField, obj *DeferModel) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_DeferModel_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_DeferModel_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "DeferModel", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _DeferModel_name(ctx context.Context, field graphql.CollectedField, obj *DeferModel) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_DeferModel_name, func(ctx context.Context) (any, error) { return obj.Name, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_DeferModel_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "DeferModel", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _DeferModel_values(ctx context.Context, field graphql.CollectedField, obj *DeferModel) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_DeferModel_values, func(ctx context.Context) (any, error) { return ec.Resolvers.DeferModel().Values(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2ᚕstringᚄ, true, true, ) } func (ec *executionContext) fieldContext_DeferModel_values(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "DeferModel", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var deferModelImplementors = []string{"DeferModel"} func (ec *executionContext) _DeferModel(ctx context.Context, sel ast.SelectionSet, obj *DeferModel) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, deferModelImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("DeferModel") case "id": out.Values[i] = ec._DeferModel_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "name": out.Values[i] = ec._DeferModel_name(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "values": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._DeferModel_values(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshalNDeferModel2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDeferModel(ctx context.Context, sel ast.SelectionSet, v *DeferModel) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._DeferModel(ctx, sel, v) } func (ec *executionContext) marshalODeferModel2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDeferModelᚄ(ctx context.Context, sel ast.SelectionSet, v []*DeferModel) 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.marshalNDeferModel2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDeferModel(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalODeferModel2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDeferModel(ctx context.Context, sel ast.SelectionSet, v *DeferModel) graphql.Marshaler { if v == nil { return graphql.Null } return ec._DeferModel(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/defer.graphql ================================================ extend type Query { deferSingle: DeferModel deferMultiple: [DeferModel!] } type DeferModel { id: ID! name: String! values: [String!]! @goField(forceResolver: true) } ================================================ FILE: codegen/testserver/followschema/directive.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "fmt" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) dir_length_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "min", ec.unmarshalNInt2int) if err != nil { return nil, err } args["min"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "max", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["max"] = arg1 arg2, err := graphql.ProcessArgField(ctx, rawArgs, "message", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["message"] = arg2 return args, nil } func (ec *executionContext) dir_logged_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.unmarshalNUUID2string) if err != nil { return nil, err } args["id"] = arg0 return args, nil } func (ec *executionContext) dir_order1_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, "location", ec.unmarshalNString2string) if err != nil { return nil, err } args["location"] = arg0 return args, nil } func (ec *executionContext) dir_order2_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, "location", ec.unmarshalNString2string) if err != nil { return nil, err } args["location"] = arg0 return args, nil } func (ec *executionContext) dir_populate_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.unmarshalNString2string) if err != nil { return nil, err } args["value"] = arg0 return args, nil } func (ec *executionContext) dir_range_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, "min", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["min"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "max", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["max"] = arg1 return args, nil } // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** func (ec *executionContext) _fieldMiddleware(ctx context.Context, obj any, next graphql.Resolver) graphql.Resolver { fc := graphql.GetFieldContext(ctx) for _, d := range fc.Field.Directives { switch d.Name { case "logged": rawArgs := d.ArgumentMap(ec.Variables) args, err := ec.dir_logged_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return nil } n := next next = func(ctx context.Context) (any, error) { if ec.Directives.Logged == nil { return nil, errors.New("directive logged is not implemented") } return ec.Directives.Logged(ctx, obj, n, args["id"].(string)) } } } return next } // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _ObjectDirectives_text(ctx context.Context, field graphql.CollectedField, obj *ObjectDirectives) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ObjectDirectives_text, func(ctx context.Context) (any, error) { return obj.Text, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { min, err := ec.unmarshalNInt2int(ctx, 0) if err != nil { var zeroVal string return zeroVal, err } max, err := ec.unmarshalOInt2ᚖint(ctx, 7) if err != nil { var zeroVal string return zeroVal, err } message, err := ec.unmarshalOString2ᚖstring(ctx, "not valid") if err != nil { var zeroVal string return zeroVal, err } if ec.Directives.Length == nil { var zeroVal string return zeroVal, errors.New("directive length is not implemented") } return ec.Directives.Length(ctx, obj, directive0, min, max, message) } next = directive1 return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_ObjectDirectives_text(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ObjectDirectives", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _ObjectDirectives_nullableText(ctx context.Context, field graphql.CollectedField, obj *ObjectDirectives) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ObjectDirectives_nullableText, func(ctx context.Context) (any, error) { return obj.NullableText, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { if ec.Directives.ToNull == nil { var zeroVal *string return zeroVal, errors.New("directive toNull is not implemented") } return ec.Directives.ToNull(ctx, obj, directive0) } next = directive1 return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_ObjectDirectives_nullableText(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ObjectDirectives", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _ObjectDirectives_order(ctx context.Context, field graphql.CollectedField, obj *ObjectDirectives) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ObjectDirectives_order, func(ctx context.Context) (any, error) { return obj.Order, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2ᚕstringᚄ, true, true, ) } func (ec *executionContext) fieldContext_ObjectDirectives_order(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ObjectDirectives", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _ObjectDirectivesWithCustomGoModel_nullableText(ctx context.Context, field graphql.CollectedField, obj *ObjectDirectivesWithCustomGoModel) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ObjectDirectivesWithCustomGoModel_nullableText, func(ctx context.Context) (any, error) { return obj.NullableText, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { if ec.Directives.ToNull == nil { var zeroVal string return zeroVal, errors.New("directive toNull is not implemented") } return ec.Directives.ToNull(ctx, obj, directive0) } next = directive1 return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2string, true, false, ) } func (ec *executionContext) fieldContext_ObjectDirectivesWithCustomGoModel_nullableText(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ObjectDirectivesWithCustomGoModel", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** func (ec *executionContext) unmarshalInputInnerDirectives(ctx context.Context, obj any) (InnerDirectives, error) { var it InnerDirectives if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"message"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "message": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("message")) directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalNString2string(ctx, v) } directive1 := func(ctx context.Context) (any, error) { min, err := ec.unmarshalNInt2int(ctx, 1) if err != nil { var zeroVal string return zeroVal, err } message, err := ec.unmarshalOString2ᚖstring(ctx, "not valid") if err != nil { var zeroVal string return zeroVal, err } if ec.Directives.Length == nil { var zeroVal string return zeroVal, errors.New("directive length is not implemented") } return ec.Directives.Length(ctx, obj, directive0, min, nil, message) } tmp, err := directive1(ctx) if err != nil { return it, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(string); ok { it.Message = data } else { err := fmt.Errorf(`unexpected type %T from directive, should be string`, tmp) return it, graphql.ErrorOnPath(ctx, err) } } } return it, nil } func (ec *executionContext) unmarshalInputInputDirectives(ctx context.Context, obj any) (InputDirectives, error) { var it InputDirectives if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"text", "nullableText", "inner", "innerNullable", "thirdParty"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "text": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalNString2string(ctx, v) } directive1 := func(ctx context.Context) (any, error) { min, err := ec.unmarshalNInt2int(ctx, 0) if err != nil { var zeroVal string return zeroVal, err } max, err := ec.unmarshalOInt2ᚖint(ctx, 7) if err != nil { var zeroVal string return zeroVal, err } message, err := ec.unmarshalOString2ᚖstring(ctx, "not valid") if err != nil { var zeroVal string return zeroVal, err } if ec.Directives.Length == nil { var zeroVal string return zeroVal, errors.New("directive length is not implemented") } return ec.Directives.Length(ctx, obj, directive0, min, max, message) } tmp, err := directive1(ctx) if err != nil { return it, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(string); ok { it.Text = data } else { err := fmt.Errorf(`unexpected type %T from directive, should be string`, tmp) return it, graphql.ErrorOnPath(ctx, err) } case "nullableText": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nullableText")) directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOString2ᚖstring(ctx, v) } directive1 := func(ctx context.Context) (any, error) { if ec.Directives.ToNull == nil { var zeroVal *string return zeroVal, errors.New("directive toNull is not implemented") } return ec.Directives.ToNull(ctx, obj, directive0) } tmp, err := directive1(ctx) if err != nil { return it, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(*string); ok { it.NullableText = data } else if tmp == nil { it.NullableText = nil } else { err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) return it, graphql.ErrorOnPath(ctx, err) } case "inner": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("inner")) data, err := ec.unmarshalNInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInnerDirectives(ctx, v) if err != nil { return it, err } it.Inner = data case "innerNullable": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("innerNullable")) data, err := ec.unmarshalOInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInnerDirectives(ctx, v) if err != nil { return it, err } it.InnerNullable = data case "thirdParty": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("thirdParty")) directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOThirdParty2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐThirdParty(ctx, v) } directive1 := func(ctx context.Context) (any, error) { min, err := ec.unmarshalNInt2int(ctx, 0) if err != nil { var zeroVal *ThirdParty return zeroVal, err } max, err := ec.unmarshalOInt2ᚖint(ctx, 7) if err != nil { var zeroVal *ThirdParty return zeroVal, err } if ec.Directives.Length == nil { var zeroVal *ThirdParty return zeroVal, errors.New("directive length is not implemented") } return ec.Directives.Length(ctx, obj, directive0, min, max, nil) } tmp, err := directive1(ctx) if err != nil { return it, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(*ThirdParty); ok { it.ThirdParty = data } else if tmp == nil { it.ThirdParty = nil } else { err := fmt.Errorf(`unexpected type %T from directive, should be *github.com/99designs/gqlgen/codegen/testserver/followschema.ThirdParty`, tmp) return it, graphql.ErrorOnPath(ctx, err) } } } // Execute INPUT_OBJECT level directives (e.g., @oneOf, @directive3) // These run after all fields have been unmarshaled directive0 := func(ctx context.Context) (any, error) { return it, nil } directive1 := func(ctx context.Context) (any, error) { if ec.Directives.Directive3 == nil { return it, errors.New("directive directive3 is not implemented") } return ec.Directives.Directive3(ctx, asMap, directive0) } tmp, err := directive1(ctx) if err != nil { return it, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(InputDirectives); ok { return data, nil } return it, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from INPUT_OBJECT directive, should be InputDirectives`, tmp)) } func (ec *executionContext) unmarshalInputOuterWrapperInput(ctx context.Context, obj any) (OuterWrapperInput, error) { var it OuterWrapperInput if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"inner"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "inner": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("inner")) data, err := ec.unmarshalNInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInputDirectives(ctx, v) if err != nil { return it, err } it.Inner = data } } return it, nil } // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var objectDirectivesImplementors = []string{"ObjectDirectives"} func (ec *executionContext) _ObjectDirectives(ctx context.Context, sel ast.SelectionSet, obj *ObjectDirectives) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, objectDirectivesImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("ObjectDirectives") case "text": out.Values[i] = ec._ObjectDirectives_text(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "nullableText": out.Values[i] = ec._ObjectDirectives_nullableText(ctx, field, obj) case "order": out.Values[i] = ec._ObjectDirectives_order(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var objectDirectivesWithCustomGoModelImplementors = []string{"ObjectDirectivesWithCustomGoModel"} func (ec *executionContext) _ObjectDirectivesWithCustomGoModel(ctx context.Context, sel ast.SelectionSet, obj *ObjectDirectivesWithCustomGoModel) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, objectDirectivesWithCustomGoModelImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("ObjectDirectivesWithCustomGoModel") case "nullableText": out.Values[i] = ec._ObjectDirectivesWithCustomGoModel_nullableText(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) unmarshalNInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInnerDirectives(ctx context.Context, v any) (*InnerDirectives, error) { res, err := ec.unmarshalInputInnerDirectives(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalNInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInputDirectives(ctx context.Context, v any) (InputDirectives, error) { res, err := ec.unmarshalInputInputDirectives(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalNInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInputDirectives(ctx context.Context, v any) (*InputDirectives, error) { res, err := ec.unmarshalInputInputDirectives(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalNOuterWrapperInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterWrapperInput(ctx context.Context, v any) (OuterWrapperInput, error) { res, err := ec.unmarshalInputOuterWrapperInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalOInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInnerDirectives(ctx context.Context, v any) (*InnerDirectives, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputInnerDirectives(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalOInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInputDirectives(ctx context.Context, v any) (*InputDirectives, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputInputDirectives(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOObjectDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐObjectDirectives(ctx context.Context, sel ast.SelectionSet, v *ObjectDirectives) graphql.Marshaler { if v == nil { return graphql.Null } return ec._ObjectDirectives(ctx, sel, v) } func (ec *executionContext) marshalOObjectDirectivesWithCustomGoModel2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐObjectDirectivesWithCustomGoModel(ctx context.Context, sel ast.SelectionSet, v *ObjectDirectivesWithCustomGoModel) graphql.Marshaler { if v == nil { return graphql.Null } return ec._ObjectDirectivesWithCustomGoModel(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/directive.graphql ================================================ directive @length(min: Int!, max: Int, message: String) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | FIELD_DEFINITION directive @range(min: Int = 0, max: Int) on ARGUMENT_DEFINITION directive @custom on ARGUMENT_DEFINITION directive @logged(id: UUID!) on FIELD directive @toNull on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | FIELD_DEFINITION directive @populate(value: String!) on ARGUMENT_DEFINITION directive @directive1 on FIELD_DEFINITION directive @directive2 on FIELD_DEFINITION directive @directive3 on INPUT_OBJECT directive @unimplemented on FIELD_DEFINITION directive @order1(location: String!) repeatable on FIELD_DEFINITION | OBJECT directive @order2(location: String!) on OBJECT directive @noop on ARGUMENT_DEFINITION extend type Query { directiveArg(arg: String! @length(min:1, max: 255, message: "invalid length")): String directiveNullableArg(arg: Int @range(min:0), arg2: Int @range, arg3: String @toNull): String directiveSingleNullableArg( arg1: String @populate(value: "test") @noop, ): String directiveInputNullable(arg: InputDirectives): String directiveInput(arg: InputDirectives!): String directiveInputType(arg: InnerInput! @custom): String directiveInputOuter(arg: OuterWrapperInput!): String directiveObject: ObjectDirectives @order1(location: "Query_field") directiveObjectWithCustomGoModel: ObjectDirectivesWithCustomGoModel directiveFieldDef(ret: String!): String! @length(min: 1, message: "not valid") directiveField: String directiveDouble: String @directive1 @directive2 directiveUnimplemented: String @unimplemented } extend type Subscription { directiveArg(arg: String! @length(min:1, max: 255, message: "invalid length")): String directiveNullableArg(arg: Int @range(min:0), arg2: Int @range, arg3: String @toNull): String directiveDouble: String @directive1 @directive2 directiveUnimplemented: String @unimplemented } input OuterWrapperInput { inner: InputDirectives! } input InputDirectives @directive3 { text: String! @length(min: 0, max: 7, message: "not valid") nullableText: String @toNull inner: InnerDirectives! innerNullable: InnerDirectives thirdParty: ThirdParty @length(min: 0, max: 7) } input InnerDirectives { message: String! @length(min: 1, message: "not valid") } type ObjectDirectives @order1(location: "order1_1") @order1(location: "order1_2") @order2(location: "order2_1") { text: String! @length(min: 0, max: 7, message: "not valid") nullableText: String @toNull order: [String!]! } type ObjectDirectivesWithCustomGoModel { nullableText: String @toNull } ================================================ FILE: codegen/testserver/followschema/directive_test.go ================================================ package followschema import ( "context" "errors" "fmt" "reflect" "sync" "testing" "time" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) // isNil checks if the given value is nil func isNil(input any) bool { if input == nil { return true } // Using reflect to check if the value is nil. This is necessary for // any types that are not nil types but have a nil value (e.g. *string). value := reflect.ValueOf(input) return value.IsNil() } type ckey string type callStore struct { mu sync.Mutex calls map[string][]directiveCall } func (s *callStore) getCalls(directiveName string) []directiveCall { s.mu.Lock() defer s.mu.Unlock() if s.calls == nil { s.calls = make(map[string][]directiveCall) } return s.calls[directiveName] } func (s *callStore) addCall(directiveName string, call directiveCall) { s.mu.Lock() defer s.mu.Unlock() if s.calls == nil { s.calls = make(map[string][]directiveCall) } s.calls[directiveName] = append(s.calls[directiveName], call) } func (s *callStore) reset(directiveName string) { s.mu.Lock() defer s.mu.Unlock() if s.calls == nil { s.calls = make(map[string][]directiveCall) } s.calls[directiveName] = nil } type directiveCall struct { TypeName string Value any } func TestDirectives(t *testing.T) { resolvers := &Stub{} ok := "Ok" resolvers.QueryResolver.DirectiveArg = func(ctx context.Context, arg string) (i *string, e error) { return &ok, nil } resolvers.QueryResolver.DirectiveInput = func(ctx context.Context, arg InputDirectives) (i *string, e error) { return &ok, nil } resolvers.QueryResolver.DirectiveInputNullable = func(ctx context.Context, arg *InputDirectives) (i *string, e error) { return &ok, nil } resolvers.QueryResolver.DirectiveNullableArg = func(ctx context.Context, arg *int, arg2 *int, arg3 *string) (*string, error) { return &ok, nil } resolvers.QueryResolver.DirectiveSingleNullableArg = func(ctx context.Context, arg1 *string) (*string, error) { if arg1 != nil { return arg1, nil } return &ok, nil } resolvers.QueryResolver.DirectiveInputType = func(ctx context.Context, arg InnerInput) (i *string, e error) { return &ok, nil } resolvers.QueryResolver.DirectiveInputOuter = func(ctx context.Context, arg OuterWrapperInput) (i *string, e error) { return &ok, nil } resolvers.QueryResolver.DirectiveObject = func(ctx context.Context) (*ObjectDirectives, error) { return &ObjectDirectives{ Text: ok, NullableText: &ok, }, nil } resolvers.QueryResolver.DirectiveObjectWithCustomGoModel = func(ctx context.Context) (*ObjectDirectivesWithCustomGoModel, error) { return &ObjectDirectivesWithCustomGoModel{ NullableText: ok, }, nil } resolvers.QueryResolver.DirectiveField = func(ctx context.Context) (*string, error) { if s, ok := ctx.Value(ckey("request_id")).(*string); ok { return s, nil } return nil, nil } resolvers.QueryResolver.DirectiveDouble = func(ctx context.Context) (*string, error) { return &ok, nil } resolvers.QueryResolver.DirectiveUnimplemented = func(ctx context.Context) (*string, error) { return &ok, nil } okchan := func() (<-chan *string, error) { //nolint:unparam // interface purposes res := make(chan *string, 1) res <- &ok close(res) return res, nil } resolvers.SubscriptionResolver.DirectiveArg = func(ctx context.Context, arg string) (strings <-chan *string, e error) { return okchan() } resolvers.SubscriptionResolver.DirectiveNullableArg = func(ctx context.Context, arg *int, arg2 *int, arg3 *string) (strings <-chan *string, e error) { return okchan() } resolvers.SubscriptionResolver.DirectiveDouble = func(ctx context.Context) (strings <-chan *string, e error) { return okchan() } resolvers.SubscriptionResolver.DirectiveUnimplemented = func(ctx context.Context) (<-chan *string, error) { return okchan() } callStore := callStore{} srv := handler.New(NewExecutableSchema(Config{ Resolvers: resolvers, Directives: DirectiveRoot{ //nolint:revive // can't rename min, max because it's generated code Length: func(ctx context.Context, obj any, next graphql.Resolver, min int, max *int, message *string) (any, error) { e := func(msg string) error { if message == nil { return errors.New(msg) } return errors.New(*message) } res, err := next(ctx) if err != nil { return nil, err } s := res.(string) if len(s) < min { return nil, e("too short") } if max != nil && len(s) > *max { return nil, e("too long") } return res, nil }, //nolint:revive // can't rename min, max because it's generated code Range: func(ctx context.Context, obj any, next graphql.Resolver, min *int, max *int) (any, error) { res, err := next(ctx) if err != nil { return nil, err } switch res := res.(type) { case int: if min != nil && res < *min { return nil, errors.New("too small") } if max != nil && res > *max { return nil, errors.New("too large") } return next(ctx) case int64: if min != nil && int(res) < *min { return nil, errors.New("too small") } if max != nil && int(res) > *max { return nil, errors.New("too large") } return next(ctx) case *int: if min != nil && *res < *min { return nil, errors.New("too small") } if max != nil && *res > *max { return nil, errors.New("too large") } return next(ctx) } return nil, fmt.Errorf("unsupported type %T", res) }, Custom: func(ctx context.Context, obj any, next graphql.Resolver) (any, error) { return next(ctx) }, Logged: func(ctx context.Context, obj any, next graphql.Resolver, id string) (any, error) { return next(context.WithValue(ctx, ckey("request_id"), &id)) }, ToNull: func(ctx context.Context, obj any, next graphql.Resolver) (any, error) { return nil, nil }, Populate: func(ctx context.Context, obj any, next graphql.Resolver, value string) (any, error) { res, err := next(ctx) if err != nil { return nil, err } if !isNil(res) { return res, err } return &value, nil }, Noop: func(ctx context.Context, obj any, next graphql.Resolver) (any, error) { return next(ctx) }, Directive1: func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) { return next(ctx) }, Directive2: func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) { return next(ctx) }, Directive3: func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) { call := directiveCall{} typedObj, err := next(ctx) if typedObj != nil { call.TypeName = (reflect.TypeOf(typedObj).String()) call.Value = typedObj } callStore.addCall("Directive3", call) return typedObj, err }, Order1: func(ctx context.Context, obj any, next graphql.Resolver, location string) (res any, err error) { order := []string{location} res, err = next(ctx) od := res.(*ObjectDirectives) od.Order = append(order, od.Order...) return od, err }, Order2: func(ctx context.Context, obj any, next graphql.Resolver, location string) (res any, err error) { order := []string{location} res, err = next(ctx) od := res.(*ObjectDirectives) od.Order = append(order, od.Order...) return od, err }, Unimplemented: nil, }, })) srv.AddTransport(transport.Websocket{ KeepAlivePingInterval: time.Second, }) srv.AddTransport(transport.POST{}) srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res any, err error) { path, _ := ctx.Value(ckey("path")).([]int) return next(context.WithValue(ctx, ckey("path"), append(path, 1))) }) srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res any, err error) { path, _ := ctx.Value(ckey("path")).([]int) return next(context.WithValue(ctx, ckey("path"), append(path, 2))) }) c := client.New(srv) t.Run("arg directives", func(t *testing.T) { t.Run("when function errors on directives", func(t *testing.T) { var resp struct { DirectiveArg *string } err := c.Post(`query { directiveArg(arg: "") }`, &resp) require.EqualError( t, err, `[{"message":"invalid length","path":["directiveArg","arg"]}]`, ) require.Nil(t, resp.DirectiveArg) }) t.Run("when function errors on nullable arg directives", func(t *testing.T) { var resp struct { DirectiveNullableArg *string } err := c.Post(`query { directiveNullableArg(arg: -100) }`, &resp) require.EqualError( t, err, `[{"message":"too small","path":["directiveNullableArg","arg"]}]`, ) require.Nil(t, resp.DirectiveNullableArg) }) t.Run("when function success on nullable arg directives", func(t *testing.T) { var resp struct { DirectiveNullableArg *string } err := c.Post(`query { directiveNullableArg }`, &resp) require.NoError(t, err) require.Equal(t, "Ok", *resp.DirectiveNullableArg) }) t.Run("when function success on valid nullable arg directives", func(t *testing.T) { var resp struct { DirectiveNullableArg *string } err := c.Post(`query { directiveNullableArg(arg: 1) }`, &resp) require.NoError(t, err) require.Equal(t, "Ok", *resp.DirectiveNullableArg) }) t.Run("when function success", func(t *testing.T) { var resp struct { DirectiveArg *string } err := c.Post(`query { directiveArg(arg: "test") }`, &resp) require.NoError(t, err) require.Equal(t, "Ok", *resp.DirectiveArg) }) t.Run("directive is not called with null arguments", func(t *testing.T) { var resp struct { DirectiveSingleNullableArg *string } err := c.Post(`query { directiveSingleNullableArg }`, &resp) require.NoError(t, err) require.Equal(t, "Ok", *resp.DirectiveSingleNullableArg) }) }) t.Run("field definition directives", func(t *testing.T) { resolvers.QueryResolver.DirectiveFieldDef = func(ctx context.Context, ret string) (i string, e error) { return ret, nil } t.Run("too short", func(t *testing.T) { var resp struct { DirectiveFieldDef string } err := c.Post(`query { directiveFieldDef(ret: "") }`, &resp) require.EqualError(t, err, `[{"message":"not valid","path":["directiveFieldDef"]}]`) }) t.Run("has 2 directives", func(t *testing.T) { var resp struct { DirectiveDouble string } c.MustPost(`query { directiveDouble }`, &resp) require.Equal(t, "Ok", resp.DirectiveDouble) }) t.Run("directive is not implemented", func(t *testing.T) { var resp struct { DirectiveUnimplemented string } err := c.Post(`query { directiveUnimplemented }`, &resp) require.EqualError( t, err, `[{"message":"directive unimplemented is not implemented","path":["directiveUnimplemented"]}]`, ) }) t.Run("ok", func(t *testing.T) { var resp struct { DirectiveFieldDef string } c.MustPost(`query { directiveFieldDef(ret: "aaa") }`, &resp) require.Equal(t, "aaa", resp.DirectiveFieldDef) }) }) t.Run("field directives", func(t *testing.T) { t.Run("add field directive", func(t *testing.T) { var resp struct { DirectiveField string } c.MustPost(`query { directiveField@logged(id:"testes_id") }`, &resp) require.Equal(t, `testes_id`, resp.DirectiveField) }) t.Run("without field directive", func(t *testing.T) { var resp struct { DirectiveField *string } c.MustPost(`query { directiveField }`, &resp) require.Nil(t, resp.DirectiveField) }) }) t.Run("input field directives", func(t *testing.T) { t.Run("when function errors on directives", func(t *testing.T) { var resp struct { DirectiveInputNullable *string } err := c.Post( `query { directiveInputNullable(arg: {text:"invalid text",inner:{message:"123"}}) }`, &resp, ) require.EqualError( t, err, `[{"message":"not valid","path":["directiveInputNullable","arg","text"]}]`, ) require.Nil(t, resp.DirectiveInputNullable) }) t.Run("when function errors on inner directives", func(t *testing.T) { var resp struct { DirectiveInputNullable *string } err := c.Post( `query { directiveInputNullable(arg: {text:"2",inner:{message:""}}) }`, &resp, ) require.EqualError( t, err, `[{"message":"not valid","path":["directiveInputNullable","arg","inner","message"]}]`, ) require.Nil(t, resp.DirectiveInputNullable) }) t.Run("when function errors on nullable inner directives", func(t *testing.T) { var resp struct { DirectiveInputNullable *string } err := c.Post( `query { directiveInputNullable(arg: {text:"success",inner:{message:"1"},innerNullable:{message:""}}) }`, &resp, ) require.EqualError( t, err, `[{"message":"not valid","path":["directiveInputNullable","arg","innerNullable","message"]}]`, ) require.Nil(t, resp.DirectiveInputNullable) }) t.Run("when function success", func(t *testing.T) { var resp struct { DirectiveInputNullable *string } err := c.Post( `query { directiveInputNullable(arg: {text:"23",inner:{message:"1"}}) }`, &resp, ) require.NoError(t, err) require.Equal(t, "Ok", *resp.DirectiveInputNullable) }) t.Run("when function inner nullable success", func(t *testing.T) { var resp struct { DirectiveInputNullable *string } err := c.Post( `query { directiveInputNullable(arg: {text:"23",nullableText:"23",inner:{message:"1"},innerNullable:{message:"success"}}) }`, &resp, ) require.NoError(t, err) require.Equal(t, "Ok", *resp.DirectiveInputNullable) }) t.Run("when arg has directive", func(t *testing.T) { var resp struct { DirectiveInputType *string } err := c.Post(`query { directiveInputType(arg: {id: 1}) }`, &resp) require.NoError(t, err) require.Equal(t, "Ok", *resp.DirectiveInputType) }) t.Run("directives run as expected for X times", func(t *testing.T) { callStore.reset("Directive3") var resp struct { DirectiveInputOuter *string } query := `query { directiveInputOuter(arg: {inner: {text:"test", inner:{message:"msg"}}}) }` err := c.Post(query, &resp) require.NoError(t, err) calls := callStore.getCalls("Directive3") t.Logf("directive3 was called %d time(s)", len(calls)) require.Len(t, calls, 1, "@directive3 should be called exactly once, but was called %d times", len(calls)) require.Equal(t, "followschema.InputDirectives", calls[0].TypeName, "@directive3 should receive type InputDirectives, but received %s", calls[0].TypeName) require.Equal(t, "test", calls[0].Value.(InputDirectives).Text) }) }) t.Run("object field directives", func(t *testing.T) { t.Run("when function success", func(t *testing.T) { var resp struct { DirectiveObject *struct { Text string NullableText *string Order []string } } err := c.Post(`query { directiveObject{ text nullableText order} }`, &resp) require.NoError(t, err) require.Equal(t, "Ok", resp.DirectiveObject.Text) require.Nil(t, resp.DirectiveObject.NullableText) require.Equal(t, "Query_field", resp.DirectiveObject.Order[0]) require.Equal(t, "order2_1", resp.DirectiveObject.Order[1]) require.Equal(t, "order1_2", resp.DirectiveObject.Order[2]) require.Equal(t, "order1_1", resp.DirectiveObject.Order[3]) }) t.Run("when directive returns nil & custom go field is not nilable", func(t *testing.T) { var resp struct { DirectiveObjectWithCustomGoModel *struct { NullableText *string } } err := c.Post(`query { directiveObjectWithCustomGoModel{ nullableText } }`, &resp) require.NoError(t, err) require.Nil(t, resp.DirectiveObjectWithCustomGoModel.NullableText) }) }) t.Run("Subscription directives", func(t *testing.T) { t.Run("arg directives", func(t *testing.T) { t.Run("when function errors on directives", func(t *testing.T) { var resp struct { DirectiveArg *string } err := c.WebsocketOnce(`subscription { directiveArg(arg: "") }`, &resp) require.EqualError( t, err, `[{"message":"invalid length","path":["directiveArg","arg"]}]`, ) require.Nil(t, resp.DirectiveArg) }) t.Run("when function errors on nullable arg directives", func(t *testing.T) { var resp struct { DirectiveNullableArg *string } err := c.WebsocketOnce(`subscription { directiveNullableArg(arg: -100) }`, &resp) require.EqualError( t, err, `[{"message":"too small","path":["directiveNullableArg","arg"]}]`, ) require.Nil(t, resp.DirectiveNullableArg) }) t.Run("when function success on nullable arg directives", func(t *testing.T) { var resp struct { DirectiveNullableArg *string } err := c.WebsocketOnce(`subscription { directiveNullableArg }`, &resp) require.NoError(t, err) require.Equal(t, "Ok", *resp.DirectiveNullableArg) }) t.Run("when function success on valid nullable arg directives", func(t *testing.T) { var resp struct { DirectiveNullableArg *string } err := c.WebsocketOnce(`subscription { directiveNullableArg(arg: 1) }`, &resp) require.NoError(t, err) require.Equal(t, "Ok", *resp.DirectiveNullableArg) }) t.Run("when function success", func(t *testing.T) { var resp struct { DirectiveArg *string } err := c.WebsocketOnce(`subscription { directiveArg(arg: "test") }`, &resp) require.NoError(t, err) require.Equal(t, "Ok", *resp.DirectiveArg) }) }) }) } ================================================ FILE: codegen/testserver/followschema/embedded.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _EmbeddedCase1_exportedEmbeddedPointerExportedMethod(ctx context.Context, field graphql.CollectedField, obj *EmbeddedCase1) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_EmbeddedCase1_exportedEmbeddedPointerExportedMethod, func(ctx context.Context) (any, error) { return obj.ExportedEmbeddedPointerExportedMethod(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_EmbeddedCase1_exportedEmbeddedPointerExportedMethod(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "EmbeddedCase1", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _EmbeddedCase2_unexportedEmbeddedPointerExportedMethod(ctx context.Context, field graphql.CollectedField, obj *EmbeddedCase2) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_EmbeddedCase2_unexportedEmbeddedPointerExportedMethod, func(ctx context.Context) (any, error) { return obj.UnexportedEmbeddedPointerExportedMethod(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_EmbeddedCase2_unexportedEmbeddedPointerExportedMethod(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "EmbeddedCase2", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _EmbeddedCase3_unexportedEmbeddedInterfaceExportedMethod(ctx context.Context, field graphql.CollectedField, obj *EmbeddedCase3) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_EmbeddedCase3_unexportedEmbeddedInterfaceExportedMethod, func(ctx context.Context) (any, error) { return obj.UnexportedEmbeddedInterfaceExportedMethod(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_EmbeddedCase3_unexportedEmbeddedInterfaceExportedMethod(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "EmbeddedCase3", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var embeddedCase1Implementors = []string{"EmbeddedCase1"} func (ec *executionContext) _EmbeddedCase1(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedCase1) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, embeddedCase1Implementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("EmbeddedCase1") case "exportedEmbeddedPointerExportedMethod": out.Values[i] = ec._EmbeddedCase1_exportedEmbeddedPointerExportedMethod(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var embeddedCase2Implementors = []string{"EmbeddedCase2"} func (ec *executionContext) _EmbeddedCase2(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedCase2) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, embeddedCase2Implementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("EmbeddedCase2") case "unexportedEmbeddedPointerExportedMethod": out.Values[i] = ec._EmbeddedCase2_unexportedEmbeddedPointerExportedMethod(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var embeddedCase3Implementors = []string{"EmbeddedCase3"} func (ec *executionContext) _EmbeddedCase3(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedCase3) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, embeddedCase3Implementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("EmbeddedCase3") case "unexportedEmbeddedInterfaceExportedMethod": out.Values[i] = ec._EmbeddedCase3_unexportedEmbeddedInterfaceExportedMethod(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshalOEmbeddedCase12ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEmbeddedCase1(ctx context.Context, sel ast.SelectionSet, v *EmbeddedCase1) graphql.Marshaler { if v == nil { return graphql.Null } return ec._EmbeddedCase1(ctx, sel, v) } func (ec *executionContext) marshalOEmbeddedCase22ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEmbeddedCase2(ctx context.Context, sel ast.SelectionSet, v *EmbeddedCase2) graphql.Marshaler { if v == nil { return graphql.Null } return ec._EmbeddedCase2(ctx, sel, v) } func (ec *executionContext) marshalOEmbeddedCase32ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEmbeddedCase3(ctx context.Context, sel ast.SelectionSet, v *EmbeddedCase3) graphql.Marshaler { if v == nil { return graphql.Null } return ec._EmbeddedCase3(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/embedded.go ================================================ package followschema // EmbeddedCase1 model type EmbeddedCase1 struct { Empty *ExportedEmbeddedPointerAfterInterface } // Empty interface type Empty any // ExportedEmbeddedPointerAfterInterface model type ExportedEmbeddedPointerAfterInterface struct{} // ExportedEmbeddedPointerExportedMethod method func (*ExportedEmbeddedPointerAfterInterface) ExportedEmbeddedPointerExportedMethod() string { return "ExportedEmbeddedPointerExportedMethodResponse" } // EmbeddedCase2 model type EmbeddedCase2 struct { *unexportedEmbeddedPointer } type unexportedEmbeddedPointer struct{} // UnexportedEmbeddedPointerExportedMethod method func (*unexportedEmbeddedPointer) UnexportedEmbeddedPointerExportedMethod() string { return "UnexportedEmbeddedPointerExportedMethodResponse" } // EmbeddedCase3 model type EmbeddedCase3 struct { unexportedEmbeddedInterface } type unexportedEmbeddedInterface interface { nestedInterface } type nestedInterface interface { UnexportedEmbeddedInterfaceExportedMethod() string } ================================================ FILE: codegen/testserver/followschema/embedded.graphql ================================================ extend type Query { embeddedCase1: EmbeddedCase1 embeddedCase2: EmbeddedCase2 embeddedCase3: EmbeddedCase3 } type EmbeddedCase1 @goModel(model:"followschema.EmbeddedCase1") { exportedEmbeddedPointerExportedMethod: String! } type EmbeddedCase2 @goModel(model:"followschema.EmbeddedCase2") { unexportedEmbeddedPointerExportedMethod: String! } type EmbeddedCase3 @goModel(model:"followschema.EmbeddedCase3") { unexportedEmbeddedInterfaceExportedMethod: String! } ================================================ FILE: codegen/testserver/followschema/embedded_test.go ================================================ package followschema import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) type fakeUnexportedEmbeddedInterface struct{} func (*fakeUnexportedEmbeddedInterface) UnexportedEmbeddedInterfaceExportedMethod() string { return "UnexportedEmbeddedInterfaceExportedMethod" } func TestEmbedded(t *testing.T) { resolver := &Stub{} resolver.QueryResolver.EmbeddedCase1 = func(ctx context.Context) (*EmbeddedCase1, error) { return &EmbeddedCase1{}, nil } resolver.QueryResolver.EmbeddedCase2 = func(ctx context.Context) (*EmbeddedCase2, error) { return &EmbeddedCase2{&unexportedEmbeddedPointer{}}, nil } resolver.QueryResolver.EmbeddedCase3 = func(ctx context.Context) (*EmbeddedCase3, error) { return &EmbeddedCase3{&fakeUnexportedEmbeddedInterface{}}, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolver})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("embedded case 1", func(t *testing.T) { var resp struct { EmbeddedCase1 struct { ExportedEmbeddedPointerExportedMethod string } } err := c.Post(`query { embeddedCase1 { exportedEmbeddedPointerExportedMethod } }`, &resp) require.NoError(t, err) require.Equal( t, "ExportedEmbeddedPointerExportedMethodResponse", resp.EmbeddedCase1.ExportedEmbeddedPointerExportedMethod, ) }) t.Run("embedded case 2", func(t *testing.T) { var resp struct { EmbeddedCase2 struct { UnexportedEmbeddedPointerExportedMethod string } } err := c.Post(`query { embeddedCase2 { unexportedEmbeddedPointerExportedMethod } }`, &resp) require.NoError(t, err) require.Equal( t, "UnexportedEmbeddedPointerExportedMethodResponse", resp.EmbeddedCase2.UnexportedEmbeddedPointerExportedMethod, ) }) t.Run("embedded case 3", func(t *testing.T) { var resp struct { EmbeddedCase3 struct { UnexportedEmbeddedInterfaceExportedMethod string } } err := c.Post( `query { embeddedCase3 { unexportedEmbeddedInterfaceExportedMethod } }`, &resp, ) require.NoError(t, err) require.Equal( t, "UnexportedEmbeddedInterfaceExportedMethod", resp.EmbeddedCase3.UnexportedEmbeddedInterfaceExportedMethod, ) }) } ================================================ FILE: codegen/testserver/followschema/enum.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** func (ec *executionContext) unmarshalInputInputWithEnumValue(ctx context.Context, obj any) (InputWithEnumValue, error) { var it InputWithEnumValue if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"enum"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "enum": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("enum")) data, err := ec.unmarshalNEnumTest2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEnumTest(ctx, v) if err != nil { return it, err } it.Enum = data } } return it, nil } // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) unmarshalNEnumTest2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEnumTest(ctx context.Context, v any) (EnumTest, error) { var res EnumTest err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNEnumTest2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEnumTest(ctx context.Context, sel ast.SelectionSet, v EnumTest) graphql.Marshaler { return v } func (ec *executionContext) unmarshalOInputWithEnumValue2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInputWithEnumValue(ctx context.Context, v any) (*InputWithEnumValue, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputInputWithEnumValue(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/enum.graphql ================================================ enum EnumTest { OK NG } input InputWithEnumValue { enum: EnumTest! } extend type Query { enumInInput(input: InputWithEnumValue): EnumTest! } ================================================ FILE: codegen/testserver/followschema/enums_test.go ================================================ package followschema import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestEnumsResolver(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.EnumInInput = func(ctx context.Context, input *InputWithEnumValue) (EnumTest, error) { return input.Enum, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("input with valid enum value", func(t *testing.T) { var resp struct { EnumInInput EnumTest } c.MustPost(`query { enumInInput(input: {enum: OK}) } `, &resp) require.Equal(t, EnumTestOk, resp.EnumInInput) }) t.Run("input with invalid enum value", func(t *testing.T) { var resp struct { EnumInInput EnumTest } err := c.Post(`query { enumInInput(input: {enum: INVALID}) } `, &resp) require.EqualError( t, err, `http 422: {"errors":[{"message":"Value \"INVALID\" does not exist in \"EnumTest!\" enum.","locations":[{"line":2,"column":30}],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}],"data":null}`, ) }) t.Run("input with invalid enum value via vars", func(t *testing.T) { var resp struct { EnumInInput EnumTest } err := c.Post(`query ($input: InputWithEnumValue) { enumInInput(input: $input) } `, &resp, client.Var("input", map[string]any{"enum": "INVALID"})) require.EqualError( t, err, `http 422: {"errors":[{"message":"INVALID is not a valid EnumTest","path":["variable","input","enum"],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}],"data":null}`, ) }) } ================================================ FILE: codegen/testserver/followschema/fields_order.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** type FieldsOrderInputResolver interface { OverrideFirstField(ctx context.Context, obj *FieldsOrderInput, data *string) error } // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _FieldsOrderPayload_firstFieldValue(ctx context.Context, field graphql.CollectedField, obj *FieldsOrderPayload) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_FieldsOrderPayload_firstFieldValue, func(ctx context.Context) (any, error) { return obj.FirstFieldValue, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_FieldsOrderPayload_firstFieldValue(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "FieldsOrderPayload", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** func (ec *executionContext) unmarshalInputFieldsOrderInput(ctx context.Context, obj any) (FieldsOrderInput, error) { var it FieldsOrderInput if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"firstField", "overrideFirstField"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "firstField": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("firstField")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it.FirstField = data case "overrideFirstField": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("overrideFirstField")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } if err = ec.Resolvers.FieldsOrderInput().OverrideFirstField(ctx, &it, data); err != nil { return it, err } } } return it, nil } // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var fieldsOrderPayloadImplementors = []string{"FieldsOrderPayload"} func (ec *executionContext) _FieldsOrderPayload(ctx context.Context, sel ast.SelectionSet, obj *FieldsOrderPayload) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, fieldsOrderPayloadImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("FieldsOrderPayload") case "firstFieldValue": out.Values[i] = ec._FieldsOrderPayload_firstFieldValue(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) unmarshalNFieldsOrderInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFieldsOrderInput(ctx context.Context, v any) (FieldsOrderInput, error) { res, err := ec.unmarshalInputFieldsOrderInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNFieldsOrderPayload2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFieldsOrderPayload(ctx context.Context, sel ast.SelectionSet, v FieldsOrderPayload) graphql.Marshaler { return ec._FieldsOrderPayload(ctx, sel, &v) } func (ec *executionContext) marshalNFieldsOrderPayload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFieldsOrderPayload(ctx context.Context, sel ast.SelectionSet, v *FieldsOrderPayload) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._FieldsOrderPayload(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/fields_order.go ================================================ package followschema type FieldsOrderInput struct { FirstField *string `json:"firstField"` } ================================================ FILE: codegen/testserver/followschema/fields_order.graphql ================================================ type FieldsOrderPayload { firstFieldValue: String } input FieldsOrderInput { firstField: String overrideFirstField: String } extend type Mutation { overrideValueViaInput(input: FieldsOrderInput!): FieldsOrderPayload! } ================================================ FILE: codegen/testserver/followschema/fields_order_test.go ================================================ package followschema import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) type FieldsOrderPayloadResults struct { OverrideValueViaInput struct { FirstFieldValue *string `json:"firstFieldValue"` } `json:"overrideValueViaInput"` } func TestFieldsOrder(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) resolvers.FieldsOrderInputResolver.OverrideFirstField = func(ctx context.Context, in *FieldsOrderInput, data *string) error { if data != nil { in.FirstField = data } return nil } resolvers.MutationResolver.OverrideValueViaInput = func(ctx context.Context, in FieldsOrderInput) (ret *FieldsOrderPayload, err error) { ret = &FieldsOrderPayload{ FirstFieldValue: in.FirstField, } return ret, nil } t.Run("firstField", func(t *testing.T) { var resp FieldsOrderPayloadResults err := c.Post(`mutation { overrideValueViaInput(input: { firstField:"newName" }) { firstFieldValue } }`, &resp) require.NoError(t, err) require.NotNil(t, resp.OverrideValueViaInput.FirstFieldValue) require.Equal(t, "newName", *resp.OverrideValueViaInput.FirstFieldValue) }) t.Run("firstField/override", func(t *testing.T) { var resp FieldsOrderPayloadResults err := c.Post(`mutation { overrideValueViaInput(input: { firstField:"newName", overrideFirstField: "override" }) { firstFieldValue } }`, &resp) require.NoError(t, err) require.NotNil(t, resp.OverrideValueViaInput.FirstFieldValue) require.NotEqual(t, "newName", *resp.OverrideValueViaInput.FirstFieldValue) require.Equal(t, "override", *resp.OverrideValueViaInput.FirstFieldValue) }) } ================================================ FILE: codegen/testserver/followschema/generated_test.go ================================================ //go:generate rm -f resolver.go //go:generate go run ../../../testdata/gqlgen.go -config gqlgen.yml -stub stub.go package followschema import ( "context" "reflect" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestForcedResolverFieldIsPointer(t *testing.T) { field, ok := reflect.TypeFor[ForcedResolverResolver]().MethodByName("Field") require.True(t, ok) require.Equal(t, "*followschema.Circle", field.Type.Out(0).String()) } func TestEnums(t *testing.T) { t.Run("list of enums", func(t *testing.T) { require.Equal(t, StatusOk, AllStatus[0]) require.Equal(t, StatusError, AllStatus[1]) }) t.Run("invalid enum values", func(t *testing.T) { require.Equal(t, StatusOk, AllStatus[0]) require.Equal(t, StatusError, AllStatus[1]) }) } func TestUnionFragments(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.ShapeUnion = func(ctx context.Context) (ShapeUnion, error) { return &Circle{Radius: 32}, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("inline fragment on union", func(t *testing.T) { var resp struct { ShapeUnion struct { Radius float64 } } c.MustPost(`query { shapeUnion { ... on Circle { radius } } } `, &resp) require.NotEmpty(t, resp.ShapeUnion.Radius) }) t.Run("named fragment", func(t *testing.T) { var resp struct { ShapeUnion struct { Radius float64 } } c.MustPost(`query { shapeUnion { ...C } } fragment C on ShapeUnion { ... on Circle { radius } } `, &resp) require.NotEmpty(t, resp.ShapeUnion.Radius) }) } ================================================ FILE: codegen/testserver/followschema/gqlgen.yml ================================================ schema: - "*.graphql" skip_validation: true exec: layout: follow-schema dir: . package: followschema model: filename: models-gen.go package: followschema resolver: filename: resolver.go package: followschema type: Resolver autobind: - "github.com/99designs/gqlgen/codegen/testserver" - "github.com/99designs/gqlgen/codegen/testserver/followschema" - "github.com/99designs/gqlgen/codegen/testserver/followschema/introspection" - "github.com/99designs/gqlgen/codegen/testserver/followschema/invalid-packagename" models: Email: model: "github.com/99designs/gqlgen/codegen/testserver/followschema.Email" StringFromContextFunction: model: "github.com/99designs/gqlgen/codegen/testserver/followschema.StringFromContextFunction" ================================================ FILE: codegen/testserver/followschema/inline_arguments_error_test.go ================================================ package followschema import ( "context" "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" ) // TestInlineArgumentsErrorMessages verifies that validation errors reference // the inline argument names (what clients wrote), not the bundled parameter name func TestInlineArgumentsErrorMessages(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.SearchProducts = func(ctx context.Context, filters map[string]any) ([]string, error) { return []string{}, nil } resolvers.QueryResolver.SearchRequired = func(ctx context.Context, filters map[string]any) ([]string, error) { return []string{}, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("error references inline arg name when using wrong argument name", func(t *testing.T) { var resp struct { SearchProducts []string } // Try to use the bundled parameter name "filters" instead of inline args err := c.Post(`query { searchProducts(filters: {query: "test"}) }`, &resp) require.Error(t, err) t.Logf("Error when using bundled parameter name: %v", err) // Error should mention that "filters" is unknown // because the schema has been transformed to use query, category, minPrice require.Contains(t, err.Error(), "filters", "Error should mention 'filters' as unknown argument") }) t.Run("error references inline arg name when using undefined argument", func(t *testing.T) { var resp struct { SearchProducts []string } // Try to use an argument that doesn't exist in the input type err := c.Post(`query { searchProducts(query: "test", unknownArg: "value") }`, &resp) require.Error(t, err) t.Logf("Error when using unknown inline argument: %v", err) // Error should mention "unknownArg" (the inline arg that doesn't exist) require.Contains(t, err.Error(), "unknownArg", "Error should mention 'unknownArg' as the unknown argument") }) t.Run("error references inline arg name when missing required argument", func(t *testing.T) { var resp struct { SearchRequired []string } // Try to call searchRequired without the required 'name' field err := c.Post(`query { searchRequired(age: 30) }`, &resp) require.Error(t, err) t.Logf("Error when missing required inline argument: %v", err) // Error should mention "name" (the missing inline argument) // NOT "filters" (the bundled parameter that doesn't exist in the query) require.Contains(t, err.Error(), "name", "Error should mention 'name' as the required argument") require.NotContains(t, err.Error(), "filters", "Error should NOT mention 'filters' (the bundled parameter name)") }) t.Run("error occurs when wrong type provided for inline arg", func(t *testing.T) { var resp struct { SearchProducts []string } // Try to provide wrong type for minPrice (string instead of int) err := c.Post(`query { searchProducts(minPrice: "not a number") }`, &resp) require.Error(t, err) t.Logf("Error when providing wrong type: %v", err) require.Contains(t, err.Error(), "Int cannot represent", "Error should be a scalar coercion error for Int type") }) t.Run("error uses inline arg name when required field missing entirely", func(t *testing.T) { var resp struct { SearchRequired []string } // Try to call searchRequired with no arguments at all err := c.Post(`query { searchRequired }`, &resp) require.Error(t, err) t.Logf("Error when all required arguments missing: %v", err) // Error should mention the inline argument names (name, age) // that are required, NOT the bundled "filters" parameter errorMsg := err.Error() hasInlineArgName := strings.Contains(errorMsg, "name") || strings.Contains(errorMsg, "age") require.True(t, hasInlineArgName, "Error should mention required inline argument names (name or age), got: %s", errorMsg) }) } ================================================ FILE: codegen/testserver/followschema/inline_arguments_integration_test.go ================================================ package followschema import ( "context" "fmt" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/extension" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestInlineArguments(t *testing.T) { resolvers := &Stub{} // Implement the SearchProducts resolver using the Stub resolvers.QueryResolver.SearchProducts = func(ctx context.Context, filters map[string]any) ([]string, error) { results := []string{} if query, ok := filters["query"].(*string); ok && query != nil { results = append(results, "query:"+*query) } if category, ok := filters["category"].(*string); ok && category != nil { results = append(results, "category:"+*category) } if minPrice, ok := filters["minPrice"].(*int); ok && minPrice != nil { results = append(results, fmt.Sprintf("minPrice:%d", *minPrice)) } return results, nil } // Implement the SearchProductsNormal resolver using the Stub resolvers.QueryResolver.SearchProductsNormal = func(ctx context.Context, filters map[string]any) ([]string, error) { results := []string{} if query, ok := filters["query"].(*string); ok && query != nil { results = append(results, "query:"+*query) } if category, ok := filters["category"].(*string); ok && category != nil { results = append(results, "category:"+*category) } if minPrice, ok := filters["minPrice"].(*int); ok && minPrice != nil { results = append(results, fmt.Sprintf("minPrice:%d", *minPrice)) } return results, nil } // Implement the SearchRequired resolver for testing required arguments resolvers.QueryResolver.SearchRequired = func(ctx context.Context, filters map[string]any) ([]string, error) { results := []string{} if name, ok := filters["name"].(string); ok { results = append(results, "name:"+name) } if age, ok := filters["age"].(int); ok { results = append(results, fmt.Sprintf("age:%d", age)) } return results, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) srv.Use(extension.Introspection{}) c := client.New(srv) t.Run("with @inlineArguments directive - flat query syntax", func(t *testing.T) { var resp struct { SearchProducts []string } // Note: With @inlineArguments, we can use flat argument syntax c.MustPost(`query { searchProducts(query: "laptop", category: "electronics", minPrice: 500) }`, &resp) require.Len(t, resp.SearchProducts, 3) require.Contains(t, resp.SearchProducts, "query:laptop") require.Contains(t, resp.SearchProducts, "category:electronics") require.Contains(t, resp.SearchProducts, "minPrice:500") }) t.Run("without @inlineArguments directive - wrapped query syntax", func(t *testing.T) { var resp struct { SearchProductsNormal []string } // Note: Without @inlineArguments, we must use nested input object syntax c.MustPost(`query { searchProductsNormal(filters: {query: "laptop", category: "electronics", minPrice: 500}) }`, &resp) require.Len(t, resp.SearchProductsNormal, 3) require.Contains(t, resp.SearchProductsNormal, "query:laptop") require.Contains(t, resp.SearchProductsNormal, "category:electronics") require.Contains(t, resp.SearchProductsNormal, "minPrice:500") }) t.Run("with @inlineArguments - partial arguments", func(t *testing.T) { var resp struct { SearchProducts []string } // Only provide some of the optional arguments c.MustPost(`query { searchProducts(query: "phone") }`, &resp) require.Len(t, resp.SearchProducts, 1) require.Contains(t, resp.SearchProducts, "query:phone") }) t.Run("with @inlineArguments - no arguments", func(t *testing.T) { var resp struct { SearchProducts []string } // Call with no arguments at all c.MustPost(`query { searchProducts }`, &resp) require.Empty(t, resp.SearchProducts) }) t.Run( "with @inlineArguments - required input type with all required fields", func(t *testing.T) { var resp struct { SearchRequired []string } // Required fields must be provided as individual arguments c.MustPost(`query { searchRequired(name: "John", age: 30) }`, &resp) require.Len(t, resp.SearchRequired, 2) require.Contains(t, resp.SearchRequired, "name:John") require.Contains(t, resp.SearchRequired, "age:30") }, ) t.Run("mutation with @inlineArguments", func(t *testing.T) { // Implement the UpdateProduct mutation resolver resolvers.MutationResolver.UpdateProduct = func(ctx context.Context, input map[string]any) (string, error) { result := "Updated product" if id, ok := input["id"].(string); ok { result += " ID:" + id } if name, ok := input["name"].(*string); ok && name != nil { result += " Name:" + *name } if price, ok := input["price"].(*float64); ok && price != nil { result += fmt.Sprintf(" Price:%.2f", *price) } return result, nil } var resp struct { UpdateProduct string } // Mutation with flat argument syntax c.MustPost(`mutation { updateProduct(id: "123", name: "New Product", price: 99.99) }`, &resp) require.Contains(t, resp.UpdateProduct, "ID:123") require.Contains(t, resp.UpdateProduct, "Name:New Product") require.Contains(t, resp.UpdateProduct, "Price:99.99") }) t.Run("default values on inlined arguments", func(t *testing.T) { // Implement the SearchWithDefaults resolver resolvers.QueryResolver.SearchWithDefaults = func(ctx context.Context, filters map[string]any) ([]string, error) { results := []string{} if query, ok := filters["query"].(*string); ok && query != nil { results = append(results, "query:"+*query) } if limit, ok := filters["limit"].(*int); ok && limit != nil { results = append(results, fmt.Sprintf("limit:%d", *limit)) } if includeArchived, ok := filters["includeArchived"].(*bool); ok && includeArchived != nil { results = append(results, fmt.Sprintf("includeArchived:%v", *includeArchived)) } return results, nil } var resp struct { SearchWithDefaults []string } // Test 1: Call with no arguments - should receive defaults c.MustPost(`query { searchWithDefaults }`, &resp) require.Len(t, resp.SearchWithDefaults, 3) require.Contains(t, resp.SearchWithDefaults, "query:default search") require.Contains(t, resp.SearchWithDefaults, "limit:20") require.Contains(t, resp.SearchWithDefaults, "includeArchived:false") // Test 2: Partial arguments - should merge provided + defaults c.MustPost(`query { searchWithDefaults(query: "laptop") }`, &resp) require.Len(t, resp.SearchWithDefaults, 3) require.Contains(t, resp.SearchWithDefaults, "query:laptop") require.Contains(t, resp.SearchWithDefaults, "limit:20") // default require.Contains(t, resp.SearchWithDefaults, "includeArchived:false") // default // Test 3: Override all defaults c.MustPost(`query { searchWithDefaults(query: "phone", limit: 50, includeArchived: true) }`, &resp) require.Len(t, resp.SearchWithDefaults, 3) require.Contains(t, resp.SearchWithDefaults, "query:phone") require.Contains(t, resp.SearchWithDefaults, "limit:50") require.Contains(t, resp.SearchWithDefaults, "includeArchived:true") }) t.Run("mixed inline and regular arguments", func(t *testing.T) { // Implement the SearchMixed resolver resolvers.QueryResolver.SearchMixed = func(ctx context.Context, filters map[string]any, limit *int, offset *int, sortBy *string) ([]string, error) { results := []string{} // Process inlined filters if query, ok := filters["query"].(*string); ok && query != nil { results = append(results, "query:"+*query) } if category, ok := filters["category"].(*string); ok && category != nil { results = append(results, "category:"+*category) } // Process regular arguments if limit != nil { results = append(results, fmt.Sprintf("limit:%d", *limit)) } if offset != nil { results = append(results, fmt.Sprintf("offset:%d", *offset)) } if sortBy != nil { results = append(results, "sortBy:"+*sortBy) } return results, nil } var resp struct { SearchMixed []string } // Test 1: All arguments (inlined + regular) c.MustPost(`query { searchMixed(query: "laptop", category: "electronics", limit: 5, offset: 10, sortBy: "price") }`, &resp) require.Len(t, resp.SearchMixed, 5) require.Contains(t, resp.SearchMixed, "query:laptop") require.Contains(t, resp.SearchMixed, "category:electronics") require.Contains(t, resp.SearchMixed, "limit:5") require.Contains(t, resp.SearchMixed, "offset:10") require.Contains(t, resp.SearchMixed, "sortBy:price") // Test 2: Only inlined arguments c.MustPost(`query { searchMixed(query: "phone") }`, &resp) require.Len(t, resp.SearchMixed, 3) // query + default limit + default offset require.Contains(t, resp.SearchMixed, "query:phone") require.Contains(t, resp.SearchMixed, "limit:10") // default require.Contains(t, resp.SearchMixed, "offset:0") // default // Test 3: Only regular arguments (no inlined) c.MustPost(`query { searchMixed(limit: 100, sortBy: "name") }`, &resp) require.Len(t, resp.SearchMixed, 3) // limit + offset default + sortBy require.Contains(t, resp.SearchMixed, "limit:100") require.Contains(t, resp.SearchMixed, "offset:0") // default require.Contains(t, resp.SearchMixed, "sortBy:name") }) t.Run("schema reuse - same input type on multiple fields", func(t *testing.T) { resolvers.QueryResolver.SearchProducts = func(ctx context.Context, filters map[string]any) ([]string, error) { if query, ok := filters["query"].(*string); ok && query != nil { return []string{"searchProducts:" + *query}, nil } return []string{}, nil } resolvers.QueryResolver.FilterProducts = func(ctx context.Context, filters map[string]any) ([]string, error) { if query, ok := filters["query"].(*string); ok && query != nil { return []string{"filterProducts:" + *query}, nil } return []string{}, nil } resolvers.QueryResolver.FindProducts = func(ctx context.Context, filters map[string]any) ([]string, error) { if query, ok := filters["query"].(*string); ok && query != nil { return []string{"findProducts:" + *query}, nil } return []string{}, nil } // Test all three fields in a single query var resp struct { SearchProducts []string FilterProducts []string FindProducts []string } c.MustPost(`query { searchProducts(query: "laptop") filterProducts(query: "phone") findProducts(query: "tablet") }`, &resp) require.Len(t, resp.SearchProducts, 1) require.Contains(t, resp.SearchProducts[0], "laptop") require.Len(t, resp.FilterProducts, 1) require.Contains(t, resp.FilterProducts[0], "phone") require.Len(t, resp.FindProducts, 1) require.Contains(t, resp.FindProducts[0], "tablet") }) t.Run("introspection shows flat arguments (not bundled input)", func(t *testing.T) { var resp struct { Schema struct { QueryType struct { Fields []struct { Name string Args []struct { Name string Type struct { Kind string Name *string OfType *struct { Kind string Name *string } } } } } } `json:"__schema"` } // Query introspection to see what arguments are exposed c.MustPost(`{ __schema { queryType { fields { name args { name type { kind name ofType { kind name } } } } } } }`, &resp) // Find the searchProducts field var searchField *struct { Name string Args []struct { Name string Type struct { Kind string Name *string OfType *struct { Kind string Name *string } } } } for i := range resp.Schema.QueryType.Fields { if resp.Schema.QueryType.Fields[i].Name == "searchProducts" { searchField = &resp.Schema.QueryType.Fields[i] break } } require.NotNil(t, searchField, "searchProducts field should exist in introspection") // Verify we see the FLAT arguments (query, category, minPrice) // NOT a single bundled 'filters' argument expectedArgs := map[string]bool{ "query": true, "category": true, "minPrice": true, } actualArgs := make(map[string]bool) for _, arg := range searchField.Args { actualArgs[arg.Name] = true } require.Equal( t, expectedArgs, actualArgs, "Introspection should show individual arguments (query, category, minPrice), not bundled 'filters' input", ) // Verify we DON'T see the original 'filters' argument for _, arg := range searchField.Args { require.NotEqual(t, "filters", arg.Name, "Should not see the original bundled 'filters' argument in introspection") } }) t.Run("fields with deprecated directive can be inlined", func(t *testing.T) { resolvers.QueryResolver.SearchWithDirectives = func(ctx context.Context, input map[string]any) ([]string, error) { results := []string{} if oldField, ok := input["oldField"].(*string); ok && oldField != nil { results = append(results, "oldField:"+*oldField) } if newField, ok := input["newField"].(*string); ok && newField != nil { results = append(results, "newField:"+*newField) } return results, nil } var queryResp struct { SearchWithDirectives []string } c.MustPost(`query { searchWithDirectives(oldField: "old", newField: "new") }`, &queryResp) require.Len(t, queryResp.SearchWithDirectives, 2) require.Contains(t, queryResp.SearchWithDirectives, "oldField:old") require.Contains(t, queryResp.SearchWithDirectives, "newField:new") }) } ================================================ FILE: codegen/testserver/followschema/inline_arguments_test.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "github.com/99designs/gqlgen/graphql" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** func (ec *executionContext) unmarshalInputDirectiveInput(ctx context.Context, obj any) (map[string]any, error) { var it map[string]any if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"oldField", "newField"} it = make(map[string]any, len(asMap)) for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "oldField": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("oldField")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it["oldField"] = data case "newField": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("newField")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it["newField"] = data } } return it, nil } func (ec *executionContext) unmarshalInputRequiredFilters(ctx context.Context, obj any) (map[string]any, error) { var it map[string]any if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"name", "age"} it = make(map[string]any, len(asMap)) 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 case "age": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("age")) data, err := ec.unmarshalNInt2int(ctx, v) if err != nil { return it, err } it["age"] = data } } return it, nil } func (ec *executionContext) unmarshalInputSearchFilters(ctx context.Context, obj any) (map[string]any, error) { var it map[string]any if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"query", "category", "minPrice"} it = make(map[string]any, len(asMap)) for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "query": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("query")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it["query"] = data case "category": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("category")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it["category"] = data case "minPrice": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("minPrice")) data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } it["minPrice"] = data } } return it, nil } func (ec *executionContext) unmarshalInputSearchWithDefaults(ctx context.Context, obj any) (map[string]any, error) { var it map[string]any if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } if _, present := asMap["query"]; !present { asMap["query"] = "default search" } if _, present := asMap["limit"]; !present { asMap["limit"] = 20 } if _, present := asMap["includeArchived"]; !present { asMap["includeArchived"] = false } fieldsInOrder := [...]string{"query", "limit", "includeArchived"} it = make(map[string]any, len(asMap)) for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "query": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("query")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it["query"] = data case "limit": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("limit")) data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } it["limit"] = data case "includeArchived": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeArchived")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } it["includeArchived"] = data } } return it, nil } func (ec *executionContext) unmarshalInputUpdateProductInput(ctx context.Context, obj any) (map[string]any, error) { var it map[string]any if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"id", "name", "price"} it = make(map[string]any, len(asMap)) for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "id": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) data, err := ec.unmarshalNID2string(ctx, v) if err != nil { return it, err } it["id"] = data case "name": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it["name"] = data case "price": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("price")) data, err := ec.unmarshalOFloat2ᚖfloat64(ctx, v) if err != nil { return it, err } it["price"] = data } } return it, nil } // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) unmarshalOSearchFilters2map(ctx context.Context, v any) (map[string]any, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputSearchFilters(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/inline_arguments_test.graphql ================================================ directive @inlineArguments on ARGUMENT_DEFINITION input SearchFilters @goModel(model: "map[string]interface{}") { query: String category: String minPrice: Int } input RequiredFilters @goModel(model: "map[string]interface{}") { name: String! age: Int! } input UpdateProductInput @goModel(model: "map[string]interface{}") { id: ID! name: String price: Float } input SearchWithDefaults @goModel(model: "map[string]interface{}") { query: String = "default search" limit: Int = 20 includeArchived: Boolean = false } input DirectiveInput @goModel(model: "map[string]interface{}") { oldField: String @deprecated(reason: "Use newField instead") newField: String } extend type Query { searchProducts(filters: SearchFilters @inlineArguments): [String!]! searchRequired(filters: RequiredFilters! @inlineArguments): [String!]! searchProductsNormal(filters: SearchFilters): [String!]! searchWithDefaults(filters: SearchWithDefaults @inlineArguments): [String!]! searchMixed( filters: SearchFilters @inlineArguments, limit: Int = 10, offset: Int = 0, sortBy: String ): [String!]! filterProducts(filters: SearchFilters @inlineArguments): [String!]! findProducts(filters: SearchFilters @inlineArguments): [String!]! searchWithDirectives(input: DirectiveInput @inlineArguments): [String!]! } extend type Mutation { updateProduct(input: UpdateProductInput @inlineArguments): String! } ================================================ FILE: codegen/testserver/followschema/input_test.go ================================================ package followschema import ( "context" "strconv" "testing" "time" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestInput(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("when function errors on directives", func(t *testing.T) { resolvers.QueryResolver.InputSlice = func(ctx context.Context, arg []string) (b bool, e error) { return true, nil } var resp struct { DirectiveArg *string } err := c.Post(`query { inputSlice(arg: ["ok", 1, 2, "ok"]) }`, &resp) require.EqualError( t, err, `http 422: {"errors":[{"message":"String cannot represent a non string value: 1","locations":[{"line":1,"column":32}],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}},{"message":"String cannot represent a non string value: 2","locations":[{"line":1,"column":35}],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}],"data":null}`, ) require.Nil(t, resp.DirectiveArg) }) t.Run("when input slice nullable", func(t *testing.T) { resolvers.QueryResolver.InputNullableSlice = func(ctx context.Context, arg []string) (b bool, e error) { return arg == nil, nil } var resp struct { InputNullableSlice bool } var err error err = c.Post(`query { inputNullableSlice(arg: null) }`, &resp) require.NoError(t, err) require.True(t, resp.InputNullableSlice) err = c.Post(`query { inputNullableSlice(arg: []) }`, &resp) require.NoError(t, err) require.False(t, resp.InputNullableSlice) }) t.Run("coerce single value to slice", func(t *testing.T) { check := func(ctx context.Context, arg []string) (b bool, e error) { return len(arg) == 1 && arg[0] == "coerced", nil } resolvers.QueryResolver.InputSlice = check resolvers.QueryResolver.InputNullableSlice = check var resp struct { Coerced bool } var err error err = c.Post(`query { coerced: inputSlice(arg: "coerced") }`, &resp) require.NoError(t, err) require.True(t, resp.Coerced) err = c.Post(`query { coerced: inputNullableSlice(arg: "coerced") }`, &resp) require.NoError(t, err) require.True(t, resp.Coerced) }) } func TestInputOmittable(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("id field", func(t *testing.T) { resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { value, isSet := arg.ID.ValueOK() if !isSet { return "", nil } if value == nil { return "", nil } return *value, nil } var resp struct { InputOmittable string } var err error err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { id: null }) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { id: "foo" }) }`, &resp) require.NoError(t, err) require.Equal(t, "foo", resp.InputOmittable) }) t.Run("bool field", func(t *testing.T) { resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { value, isSet := arg.Bool.ValueOK() if !isSet { return "", nil } if value == nil { return "", nil } return strconv.FormatBool(*value), nil } var resp struct { InputOmittable string } var err error err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { bool: null }) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { bool: false }) }`, &resp) require.NoError(t, err) require.Equal(t, "false", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { bool: true }) }`, &resp) require.NoError(t, err) require.Equal(t, "true", resp.InputOmittable) }) t.Run("str field", func(t *testing.T) { resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { value, isSet := arg.Str.ValueOK() if !isSet { return "", nil } if value == nil { return "", nil } return *value, nil } var resp struct { InputOmittable string } var err error err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { str: null }) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { str: "bar" }) }`, &resp) require.NoError(t, err) require.Equal(t, "bar", resp.InputOmittable) }) t.Run("int field", func(t *testing.T) { resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { value, isSet := arg.Int.ValueOK() if !isSet { return "", nil } if value == nil { return "", nil } return strconv.Itoa(*value), nil } var resp struct { InputOmittable string } var err error err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { int: null }) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { int: 42 }) }`, &resp) require.NoError(t, err) require.Equal(t, "42", resp.InputOmittable) }) t.Run("time field", func(t *testing.T) { resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { value, isSet := arg.Time.ValueOK() if !isSet { return "", nil } if value == nil { return "", nil } return value.UTC().Format(time.RFC3339), nil } var resp struct { InputOmittable string } var err error err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { time: null }) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { time: "2011-04-05T16:01:33Z" }) }`, &resp) require.NoError(t, err) require.Equal(t, "2011-04-05T16:01:33Z", resp.InputOmittable) }) t.Run("enum field", func(t *testing.T) { resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { value, isSet := arg.Enum.ValueOK() if !isSet { return "", nil } if value == nil { return "", nil } return value.String(), nil } var resp struct { InputOmittable string } var err error err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { enum: null }) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { enum: OK }) }`, &resp) require.NoError(t, err) require.Equal(t, "OK", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { enum: ERROR }) }`, &resp) require.NoError(t, err) require.Equal(t, "ERROR", resp.InputOmittable) }) t.Run("scalar field", func(t *testing.T) { resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { value, isSet := arg.Scalar.ValueOK() if !isSet { return "", nil } if value == nil { return "", nil } return value.str, nil } var resp struct { InputOmittable string } var err error err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { scalar: null }) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { scalar: "baz" }) }`, &resp) require.NoError(t, err) require.Equal(t, "baz", resp.InputOmittable) }) t.Run("object field", func(t *testing.T) { resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { value, isSet := arg.Object.ValueOK() if !isSet { return "", nil } if value == nil { return "", nil } return strconv.Itoa(value.Inner.ID), nil } var resp struct { InputOmittable string } var err error err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { object: null }) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { object: { inner: { id: 21 } } }) }`, &resp) require.NoError(t, err) require.Equal(t, "21", resp.InputOmittable) }) } ================================================ FILE: codegen/testserver/followschema/interfaces.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "fmt" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** type BackedByInterfaceResolver interface { ID(ctx context.Context, obj BackedByInterface) (string, error) } // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _BackedByInterface_id(ctx context.Context, field graphql.CollectedField, obj BackedByInterface) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_BackedByInterface_id, func(ctx context.Context) (any, error) { return ec.Resolvers.BackedByInterface().ID(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_BackedByInterface_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "BackedByInterface", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _BackedByInterface_thisShouldBind(ctx context.Context, field graphql.CollectedField, obj BackedByInterface) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_BackedByInterface_thisShouldBind, func(ctx context.Context) (any, error) { return obj.ThisShouldBind(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_BackedByInterface_thisShouldBind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "BackedByInterface", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _BackedByInterface_thisShouldBindWithError(ctx context.Context, field graphql.CollectedField, obj BackedByInterface) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_BackedByInterface_thisShouldBindWithError, func(ctx context.Context) (any, error) { return obj.ThisShouldBindWithError() }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_BackedByInterface_thisShouldBindWithError(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "BackedByInterface", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Cat_species(ctx context.Context, field graphql.CollectedField, obj *Cat) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Cat_species, func(ctx context.Context) (any, error) { return obj.Species, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Cat_species(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Cat", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Cat_size(ctx context.Context, field graphql.CollectedField, obj *Cat) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Cat_size, func(ctx context.Context) (any, error) { return obj.Size, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNSize2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSize, true, true, ) } func (ec *executionContext) fieldContext_Cat_size(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Cat", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "height": return ec.fieldContext_Size_height(ctx, field) case "weight": return ec.fieldContext_Size_weight(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Size", field.Name) }, } return fc, nil } func (ec *executionContext) _Cat_catBreed(ctx context.Context, field graphql.CollectedField, obj *Cat) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Cat_catBreed, func(ctx context.Context) (any, error) { return obj.CatBreed, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Cat_catBreed(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Cat", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.CollectedField, obj *Circle) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Circle_radius, func(ctx context.Context) (any, error) { return obj.Radius, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOFloat2float64, true, false, ) } func (ec *executionContext) fieldContext_Circle_radius(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Circle", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Float does not have child fields") }, } return fc, nil } func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.CollectedField, obj *Circle) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Circle_area, func(ctx context.Context) (any, error) { return obj.Area(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOFloat2float64, true, false, ) } func (ec *executionContext) fieldContext_Circle_area(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Circle", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Float does not have child fields") }, } return fc, nil } func (ec *executionContext) _Circle_coordinates(ctx context.Context, field graphql.CollectedField, obj *Circle) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Circle_coordinates, func(ctx context.Context) (any, error) { return obj.Coordinates, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOCoordinates2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCoordinates, true, false, ) } func (ec *executionContext) fieldContext_Circle_coordinates(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Circle", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "x": return ec.fieldContext_Coordinates_x(ctx, field) case "y": return ec.fieldContext_Coordinates_y(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Coordinates", field.Name) }, } return fc, nil } func (ec *executionContext) _ConcreteNodeA_id(ctx context.Context, field graphql.CollectedField, obj *ConcreteNodeA) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ConcreteNodeA_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_ConcreteNodeA_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ConcreteNodeA", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _ConcreteNodeA_child(ctx context.Context, field graphql.CollectedField, obj *ConcreteNodeA) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ConcreteNodeA_child, func(ctx context.Context) (any, error) { return obj.Child() }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNode, true, true, ) } func (ec *executionContext) fieldContext_ConcreteNodeA_child(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ConcreteNodeA", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } return fc, nil } func (ec *executionContext) _ConcreteNodeA_name(ctx context.Context, field graphql.CollectedField, obj *ConcreteNodeA) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ConcreteNodeA_name, func(ctx context.Context) (any, error) { return obj.Name, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_ConcreteNodeA_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ConcreteNodeA", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _ConcreteNodeInterface_id(ctx context.Context, field graphql.CollectedField, obj ConcreteNodeInterface) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ConcreteNodeInterface_id, func(ctx context.Context) (any, error) { return obj.ID(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_ConcreteNodeInterface_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ConcreteNodeInterface", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _ConcreteNodeInterface_child(ctx context.Context, field graphql.CollectedField, obj ConcreteNodeInterface) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ConcreteNodeInterface_child, func(ctx context.Context) (any, error) { return obj.Child() }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNode, true, true, ) } func (ec *executionContext) fieldContext_ConcreteNodeInterface_child(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ConcreteNodeInterface", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } return fc, nil } func (ec *executionContext) _Coordinates_x(ctx context.Context, field graphql.CollectedField, obj *Coordinates) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Coordinates_x, func(ctx context.Context) (any, error) { return obj.X, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNFloat2float64, true, true, ) } func (ec *executionContext) fieldContext_Coordinates_x(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Coordinates", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Float does not have child fields") }, } return fc, nil } func (ec *executionContext) _Coordinates_y(ctx context.Context, field graphql.CollectedField, obj *Coordinates) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Coordinates_y, func(ctx context.Context) (any, error) { return obj.Y, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNFloat2float64, true, true, ) } func (ec *executionContext) fieldContext_Coordinates_y(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Coordinates", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Float does not have child fields") }, } return fc, nil } func (ec *executionContext) _Dog_species(ctx context.Context, field graphql.CollectedField, obj *Dog) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Dog_species, func(ctx context.Context) (any, error) { return obj.Species, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Dog_species(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Dog", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Dog_size(ctx context.Context, field graphql.CollectedField, obj *Dog) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Dog_size, func(ctx context.Context) (any, error) { return obj.Size, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNSize2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSize, true, true, ) } func (ec *executionContext) fieldContext_Dog_size(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Dog", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "height": return ec.fieldContext_Size_height(ctx, field) case "weight": return ec.fieldContext_Size_weight(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Size", field.Name) }, } return fc, nil } func (ec *executionContext) _Dog_dogBreed(ctx context.Context, field graphql.CollectedField, obj *Dog) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Dog_dogBreed, func(ctx context.Context) (any, error) { return obj.DogBreed, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Dog_dogBreed(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Dog", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Horse_species(ctx context.Context, field graphql.CollectedField, obj *Horse) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Horse_species, func(ctx context.Context) (any, error) { return obj.Species, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Horse_species(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Horse", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Horse_size(ctx context.Context, field graphql.CollectedField, obj *Horse) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Horse_size, func(ctx context.Context) (any, error) { return obj.Size, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNSize2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSize, true, true, ) } func (ec *executionContext) fieldContext_Horse_size(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Horse", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "height": return ec.fieldContext_Size_height(ctx, field) case "weight": return ec.fieldContext_Size_weight(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Size", field.Name) }, } return fc, nil } func (ec *executionContext) _Horse_horseBreed(ctx context.Context, field graphql.CollectedField, obj *Horse) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Horse_horseBreed, func(ctx context.Context) (any, error) { return obj.HorseBreed, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Horse_horseBreed(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Horse", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Rectangle_length, func(ctx context.Context) (any, error) { return obj.Length, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOFloat2float64, true, false, ) } func (ec *executionContext) fieldContext_Rectangle_length(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Rectangle", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Float does not have child fields") }, } return fc, nil } func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Rectangle_width, func(ctx context.Context) (any, error) { return obj.Width, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOFloat2float64, true, false, ) } func (ec *executionContext) fieldContext_Rectangle_width(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Rectangle", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Float does not have child fields") }, } return fc, nil } func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Rectangle_area, func(ctx context.Context) (any, error) { return obj.Area(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOFloat2float64, true, false, ) } func (ec *executionContext) fieldContext_Rectangle_area(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Rectangle", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Float does not have child fields") }, } return fc, nil } func (ec *executionContext) _Rectangle_coordinates(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Rectangle_coordinates, func(ctx context.Context) (any, error) { return obj.Coordinates, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOCoordinates2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCoordinates, true, false, ) } func (ec *executionContext) fieldContext_Rectangle_coordinates(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Rectangle", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "x": return ec.fieldContext_Coordinates_x(ctx, field) case "y": return ec.fieldContext_Coordinates_y(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Coordinates", field.Name) }, } return fc, nil } func (ec *executionContext) _Size_height(ctx context.Context, field graphql.CollectedField, obj *Size) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Size_height, func(ctx context.Context) (any, error) { return obj.Height, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_Size_height(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Size", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _Size_weight(ctx context.Context, field graphql.CollectedField, obj *Size) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Size_weight, func(ctx context.Context) (any, error) { return obj.Weight, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_Size_weight(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Size", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** func (ec *executionContext) _Animal(ctx context.Context, sel ast.SelectionSet, obj Animal) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null case Horse: return ec._Horse(ctx, sel, &obj) case *Horse: if obj == nil { return graphql.Null } return ec._Horse(ctx, sel, obj) case Mammalian: if obj == nil { return graphql.Null } return ec._Mammalian(ctx, sel, obj) case Dog: return ec._Dog(ctx, sel, &obj) case *Dog: if obj == nil { return graphql.Null } return ec._Dog(ctx, sel, obj) case Cat: return ec._Cat(ctx, sel, &obj) case *Cat: if obj == nil { return graphql.Null } return ec._Cat(ctx, sel, obj) default: if typedObj, ok := obj.(graphql.Marshaler); ok { return typedObj } else { panic(fmt.Errorf("unexpected type %T; non-generated variants of Animal must implement graphql.Marshaler", obj)) } } } func (ec *executionContext) _Mammalian(ctx context.Context, sel ast.SelectionSet, obj Mammalian) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null case Horse: return ec._Horse(ctx, sel, &obj) case *Horse: if obj == nil { return graphql.Null } return ec._Horse(ctx, sel, obj) default: if typedObj, ok := obj.(graphql.Marshaler); ok { return typedObj } else { panic(fmt.Errorf("unexpected type %T; non-generated variants of Mammalian must implement graphql.Marshaler", obj)) } } } func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj Node) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null case ConcreteNodeInterface: if obj == nil { return graphql.Null } return ec._ConcreteNodeInterface(ctx, sel, obj) case *ConcreteNodeA: if obj == nil { return graphql.Null } return ec._ConcreteNodeA(ctx, sel, obj) default: if typedObj, ok := obj.(graphql.Marshaler); ok { return typedObj } else { panic(fmt.Errorf("unexpected type %T; non-generated variants of Node must implement graphql.Marshaler", obj)) } } } func (ec *executionContext) _Shape(ctx context.Context, sel ast.SelectionSet, obj Shape) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null case *Rectangle: if obj == nil { return graphql.Null } return ec._Rectangle(ctx, sel, obj) case *Circle: if obj == nil { return graphql.Null } return ec._Circle(ctx, sel, obj) default: if typedObj, ok := obj.(graphql.Marshaler); ok { return typedObj } else { panic(fmt.Errorf("unexpected type %T; non-generated variants of Shape must implement graphql.Marshaler", obj)) } } } func (ec *executionContext) _ShapeUnion(ctx context.Context, sel ast.SelectionSet, obj ShapeUnion) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null case *Rectangle: if obj == nil { return graphql.Null } return ec._Rectangle(ctx, sel, obj) case *Circle: if obj == nil { return graphql.Null } return ec._Circle(ctx, sel, obj) default: if typedObj, ok := obj.(graphql.Marshaler); ok { return typedObj } else { panic(fmt.Errorf("unexpected type %T; non-generated variants of ShapeUnion must implement graphql.Marshaler", obj)) } } } // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var backedByInterfaceImplementors = []string{"BackedByInterface"} func (ec *executionContext) _BackedByInterface(ctx context.Context, sel ast.SelectionSet, obj BackedByInterface) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, backedByInterfaceImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("BackedByInterface") case "id": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._BackedByInterface_id(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "thisShouldBind": out.Values[i] = ec._BackedByInterface_thisShouldBind(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "thisShouldBindWithError": out.Values[i] = ec._BackedByInterface_thisShouldBindWithError(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var catImplementors = []string{"Cat", "Animal"} func (ec *executionContext) _Cat(ctx context.Context, sel ast.SelectionSet, obj *Cat) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, catImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Cat") case "species": out.Values[i] = ec._Cat_species(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "size": out.Values[i] = ec._Cat_size(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "catBreed": out.Values[i] = ec._Cat_catBreed(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var circleImplementors = []string{"Circle", "Shape", "ShapeUnion"} func (ec *executionContext) _Circle(ctx context.Context, sel ast.SelectionSet, obj *Circle) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, circleImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Circle") case "radius": out.Values[i] = ec._Circle_radius(ctx, field, obj) case "area": out.Values[i] = ec._Circle_area(ctx, field, obj) case "coordinates": out.Values[i] = ec._Circle_coordinates(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var concreteNodeAImplementors = []string{"ConcreteNodeA", "Node"} func (ec *executionContext) _ConcreteNodeA(ctx context.Context, sel ast.SelectionSet, obj *ConcreteNodeA) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, concreteNodeAImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("ConcreteNodeA") case "id": out.Values[i] = ec._ConcreteNodeA_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "child": out.Values[i] = ec._ConcreteNodeA_child(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "name": out.Values[i] = ec._ConcreteNodeA_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var concreteNodeInterfaceImplementors = []string{"ConcreteNodeInterface", "Node"} func (ec *executionContext) _ConcreteNodeInterface(ctx context.Context, sel ast.SelectionSet, obj ConcreteNodeInterface) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, concreteNodeInterfaceImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("ConcreteNodeInterface") case "id": out.Values[i] = ec._ConcreteNodeInterface_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "child": out.Values[i] = ec._ConcreteNodeInterface_child(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var coordinatesImplementors = []string{"Coordinates"} func (ec *executionContext) _Coordinates(ctx context.Context, sel ast.SelectionSet, obj *Coordinates) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, coordinatesImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Coordinates") case "x": out.Values[i] = ec._Coordinates_x(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "y": out.Values[i] = ec._Coordinates_y(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var dogImplementors = []string{"Dog", "Animal"} func (ec *executionContext) _Dog(ctx context.Context, sel ast.SelectionSet, obj *Dog) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, dogImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Dog") case "species": out.Values[i] = ec._Dog_species(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "size": out.Values[i] = ec._Dog_size(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "dogBreed": out.Values[i] = ec._Dog_dogBreed(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var horseImplementors = []string{"Horse", "Mammalian", "Animal"} func (ec *executionContext) _Horse(ctx context.Context, sel ast.SelectionSet, obj *Horse) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, horseImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Horse") case "species": out.Values[i] = ec._Horse_species(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "size": out.Values[i] = ec._Horse_size(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "horseBreed": out.Values[i] = ec._Horse_horseBreed(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var rectangleImplementors = []string{"Rectangle", "Shape", "ShapeUnion"} func (ec *executionContext) _Rectangle(ctx context.Context, sel ast.SelectionSet, obj *Rectangle) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, rectangleImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Rectangle") case "length": out.Values[i] = ec._Rectangle_length(ctx, field, obj) case "width": out.Values[i] = ec._Rectangle_width(ctx, field, obj) case "area": out.Values[i] = ec._Rectangle_area(ctx, field, obj) case "coordinates": out.Values[i] = ec._Rectangle_coordinates(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var sizeImplementors = []string{"Size"} func (ec *executionContext) _Size(ctx context.Context, sel ast.SelectionSet, obj *Size) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, sizeImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Size") case "height": out.Values[i] = ec._Size_height(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "weight": out.Values[i] = ec._Size_weight(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNode(ctx context.Context, sel ast.SelectionSet, v Node) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._Node(ctx, sel, v) } func (ec *executionContext) marshalNShapeUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShapeUnion(ctx context.Context, sel ast.SelectionSet, v ShapeUnion) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._ShapeUnion(ctx, sel, v) } func (ec *executionContext) marshalNSize2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSize(ctx context.Context, sel ast.SelectionSet, v *Size) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._Size(ctx, sel, v) } func (ec *executionContext) marshalOAnimal2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐAnimal(ctx context.Context, sel ast.SelectionSet, v Animal) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Animal(ctx, sel, v) } func (ec *executionContext) marshalOBackedByInterface2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐBackedByInterface(ctx context.Context, sel ast.SelectionSet, v BackedByInterface) graphql.Marshaler { if v == nil { return graphql.Null } return ec._BackedByInterface(ctx, sel, v) } func (ec *executionContext) marshalOCircle2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCircle(ctx context.Context, sel ast.SelectionSet, v *Circle) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Circle(ctx, sel, v) } func (ec *executionContext) marshalOCoordinates2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCoordinates(ctx context.Context, sel ast.SelectionSet, v Coordinates) graphql.Marshaler { return ec._Coordinates(ctx, sel, &v) } func (ec *executionContext) marshalODog2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDog(ctx context.Context, sel ast.SelectionSet, v *Dog) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Dog(ctx, sel, v) } func (ec *executionContext) marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShape(ctx context.Context, sel ast.SelectionSet, v Shape) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Shape(ctx, sel, v) } func (ec *executionContext) marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShape(ctx context.Context, sel ast.SelectionSet, v []Shape) graphql.Marshaler { if v == nil { return graphql.Null } ret := 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.marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShape(ctx, sel, v[i]) }) return ret } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/interfaces.go ================================================ package followschema import "math" type Shape interface { Area() float64 isShape() } type ShapeUnion interface { Area() float64 isShapeUnion() } type Circle struct { Radius float64 Coordinates } func (c *Circle) Area() float64 { return c.Radius * math.Pi * math.Pi } func (c *Circle) isShapeUnion() {} func (c *Circle) isShape() {} type Rectangle struct { Length, Width float64 Coordinates } func (r *Rectangle) Area() float64 { return r.Length * r.Width } func (r *Rectangle) isShapeUnion() {} func (r *Rectangle) isShape() {} type Node interface { Child() (Node, error) } type ConcreteNodeA struct { ID string Name string child Node } func (n *ConcreteNodeA) Child() (Node, error) { return n.child, nil } // Implements the Node interface with another interface type ConcreteNodeInterface interface { Node ID() string } type ConcreteNodeInterfaceImplementor struct{} func (c ConcreteNodeInterfaceImplementor) ID() string { return "CNII" } func (c ConcreteNodeInterfaceImplementor) Child() (Node, error) { return &ConcreteNodeA{ ID: "Child", Name: "child", }, nil } type BackedByInterface interface { ThisShouldBind() string ThisShouldBindWithError() (string, error) } type BackedByInterfaceImpl struct { Value string Error error } func (b *BackedByInterfaceImpl) ThisShouldBind() string { return b.Value } func (b *BackedByInterfaceImpl) ThisShouldBindWithError() (string, error) { return b.Value, b.Error } ================================================ FILE: codegen/testserver/followschema/interfaces.graphql ================================================ extend type Query { shapes: [Shape] noShape: Shape @makeNil node: Node! noShapeTypedNil: Shape @makeTypedNil animal: Animal @makeTypedNil notAnInterface: BackedByInterface dog: Dog } interface Animal { species: String! size: Size! } type Size { height: Int! weight: Int! } type BackedByInterface { id: String! thisShouldBind: String! thisShouldBindWithError: String! } type Dog implements Animal { species: String! size: Size! dogBreed: String! } type Cat implements Animal { species: String! size: Size! catBreed: String! } type Coordinates { x: Float! y: Float! } interface Shape { area: Float coordinates: Coordinates } type Circle implements Shape { radius: Float area: Float coordinates: Coordinates } type Rectangle implements Shape { length: Float width: Float area: Float coordinates: Coordinates } union ShapeUnion @goModel(model: "followschema.ShapeUnion") = Circle | Rectangle directive @makeNil on FIELD_DEFINITION directive @makeTypedNil on FIELD_DEFINITION interface Node { id: ID! child: Node! } type ConcreteNodeA implements Node { id: ID! child: Node! name: String! } " Implements the Node interface with another interface " type ConcreteNodeInterface implements Node { id: ID! child: Node! } interface Mammalian implements Animal { species: String! size: Size! } # Types with multiple interfaces are evaluated first in the case statement type Horse implements Mammalian & Animal { species: String! size: Size! horseBreed: String! } ================================================ FILE: codegen/testserver/followschema/interfaces_test.go ================================================ package followschema import ( "context" "errors" "reflect" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestInterfaces(t *testing.T) { t.Run("slices of interfaces are not pointers", func(t *testing.T) { field, ok := reflect.TypeFor[QueryResolver]().MethodByName("Shapes") require.True(t, ok) require.Equal(t, "[]followschema.Shape", field.Type.Out(0).String()) }) t.Run("models returning interfaces", func(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.Node = func(ctx context.Context) (node Node, err error) { return &ConcreteNodeA{ ID: "1234", Name: "asdf", child: &ConcreteNodeA{ ID: "5678", Name: "hjkl", child: nil, }, }, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) var resp struct { Node struct { ID string Child struct { ID string } } } c.MustPost(`{ node { id, child { id } } }`, &resp) require.Equal(t, "1234", resp.Node.ID) require.Equal(t, "5678", resp.Node.Child.ID) }) t.Run("interfaces can be nil", func(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.NoShape = func(ctx context.Context) (shapes Shape, e error) { return nil, nil } srv := handler.New( NewExecutableSchema(Config{ Resolvers: resolvers, Directives: DirectiveRoot{ MakeNil: func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) { return nil, nil }, }, }), ) srv.AddTransport(transport.POST{}) c := client.New(srv) var resp any c.MustPost(`{ noShape { area } }`, &resp) }) t.Run("interfaces can be typed nil", func(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.NoShapeTypedNil = func(ctx context.Context) (shapes Shape, e error) { t.Fatal("should not be called") return shapes, e } srv := handler.New( NewExecutableSchema(Config{ Resolvers: resolvers, Directives: DirectiveRoot{ MakeTypedNil: func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) { var circle *Circle return circle, nil }, }, }), ) srv.AddTransport(transport.POST{}) c := client.New(srv) var resp any c.MustPost(`{ noShapeTypedNil { area } }`, &resp) }) t.Run("interfaces can be nil (test with code-generated resolver)", func(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.Animal = func(ctx context.Context) (animal Animal, e error) { t.Fatal("should not be called") return animal, e } srv := handler.New( NewExecutableSchema(Config{ Resolvers: resolvers, Directives: DirectiveRoot{ MakeTypedNil: func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) { var dog *Dog // return a typed nil, not just nil return dog, nil }, }, }), ) srv.AddTransport(transport.POST{}) c := client.New(srv) var resp any c.MustPost(`{ animal { species } }`, &resp) }) t.Run("can bind to interfaces even when the graphql is not", func(t *testing.T) { resolvers := &Stub{} resolvers.BackedByInterfaceResolver.ID = func(ctx context.Context, obj BackedByInterface) (s string, err error) { return "ID:" + obj.ThisShouldBind(), nil } resolvers.QueryResolver.NotAnInterface = func(ctx context.Context) (byInterface BackedByInterface, err error) { return &BackedByInterfaceImpl{ Value: "A", Error: nil, }, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) var resp struct { NotAnInterface struct { ID string ThisShouldBind string ThisShouldBindWithError string } } c.MustPost(`{ notAnInterface { id, thisShouldBind, thisShouldBindWithError } }`, &resp) require.Equal(t, "ID:A", resp.NotAnInterface.ID) require.Equal(t, "A", resp.NotAnInterface.ThisShouldBind) require.Equal(t, "A", resp.NotAnInterface.ThisShouldBindWithError) }) t.Run("can return errors from interface funcs", func(t *testing.T) { resolvers := &Stub{} resolvers.BackedByInterfaceResolver.ID = func(ctx context.Context, obj BackedByInterface) (s string, err error) { return "ID:" + obj.ThisShouldBind(), nil } resolvers.QueryResolver.NotAnInterface = func(ctx context.Context) (byInterface BackedByInterface, err error) { return &BackedByInterfaceImpl{ Value: "A", Error: errors.New("boom"), }, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) var resp struct { NotAnInterface struct { ID string ThisShouldBind string ThisShouldBindWithError string } } err := c.Post(`{ notAnInterface { id, thisShouldBind, thisShouldBindWithError } }`, &resp) require.EqualError( t, err, `[{"message":"boom","path":["notAnInterface","thisShouldBindWithError"]}]`, ) }) t.Run("interfaces can implement other interfaces", func(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.Node = func(ctx context.Context) (node Node, err error) { return ConcreteNodeInterfaceImplementor{}, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) var resp struct { Node struct { ID string Child struct { ID string } } } c.MustPost(`{ node { id, child { id } } }`, &resp) require.Equal(t, "CNII", resp.Node.ID) require.Equal(t, "Child", resp.Node.Child.ID) }) t.Run("interface implementors should return merged base fields", func(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.Shapes = func(ctx context.Context) (shapes []Shape, err error) { return []Shape{ &Rectangle{ Coordinates: Coordinates{ X: -1, Y: -1, }, }, &Circle{ Coordinates: Coordinates{ X: 1, Y: 1, }, }, }, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) var resp struct { Shapes []struct { Coordinates struct { X float64 Y float64 } } } c.MustPost(` { shapes { coordinates { x } ... on Rectangle { coordinates { x } } ... on Circle { coordinates { y } } } } `, &resp) require.Len(t, resp.Shapes, 2) require.InDelta(t, float64(-1), resp.Shapes[0].Coordinates.X, 0.02) require.InDelta(t, float64(0), resp.Shapes[0].Coordinates.Y, 0.02) require.InDelta(t, float64(1), resp.Shapes[1].Coordinates.X, 0.02) require.InDelta(t, float64(1), resp.Shapes[1].Coordinates.Y, 0.02) }) t.Run("fragment on interface must return merged fields", func(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.Dog = func(ctx context.Context) (dog *Dog, err error) { return &Dog{ Size: &Size{ Height: 100, Weight: 35, }, }, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) var resp struct { Dog struct { Size struct { Height int Weight int } } } c.MustPost(` { dog { size { height } ...AnimalWeight } } fragment AnimalWeight on Animal { size { weight } } `, &resp) require.Equal(t, 100, resp.Dog.Size.Height) require.Equal(t, 35, resp.Dog.Size.Weight) }) } ================================================ FILE: codegen/testserver/followschema/introspection/it.go ================================================ package introspection type It struct { ID string } ================================================ FILE: codegen/testserver/followschema/introspection_test.go ================================================ package followschema import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "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/introspection" ) func TestIntrospection(t *testing.T) { t.Run("disabled when creating your own server", func(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) var resp any err := c.Post(introspection.Query, &resp) require.EqualError( t, err, "[{\"message\":\"introspection disabled\",\"path\":[\"__schema\"]}]", ) }) t.Run("enabled by adding extension", func(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) srv.Use(extension.Introspection{}) c := client.New(srv) var resp any err := c.Post(introspection.Query, &resp) require.NoError(t, err) t.Run("does not return empty deprecation strings", func(t *testing.T) { q := `{ __type(name:"InnerObject") { fields { name deprecationReason } } }` var resp struct { Type struct { Fields []struct { Name string DeprecationReason *string } } `json:"__type"` } err := c.Post(q, &resp) require.NoError(t, err) require.Equal(t, "id", resp.Type.Fields[0].Name) require.Nil(t, resp.Type.Fields[0].DeprecationReason) }) t.Run("chained interface possibleTypes", func(t *testing.T) { var resp struct { Type struct { PossibleTypes []struct { Name string } } `json:"__type"` } err := c.Post(`{ __type(name: "Animal") { possibleTypes { name } } }`, &resp) require.NoError(t, err) names := make([]string, len(resp.Type.PossibleTypes)) for i, pt := range resp.Type.PossibleTypes { names[i] = pt.Name } require.Contains(t, names, "Dog") require.Contains(t, names, "Cat") // Horse implements Animal transitively via Mammalian require.Contains(t, names, "Horse") }) t.Run("deprecated directive on field arguments", func(t *testing.T) { var resp struct { Type struct { Fields []struct { Name string Args []struct { Name string DeprecationReason *string } } } `json:"__type"` } err := c.Post( `{ __type(name:"Query") { fields { name args { name deprecationReason }}}}`, &resp, ) require.NoError(t, err) var args []struct { Name string DeprecationReason *string } for _, f := range resp.Type.Fields { if f.Name == "fieldWithDeprecatedArg" { args = f.Args break } } require.Len(t, args, 2) require.Equal(t, "oldArg", args[0].Name) require.NotNil(t, args[0].DeprecationReason) require.Equal(t, "old arg", *args[0].DeprecationReason) require.Equal(t, "newArg", args[1].Name) require.Nil(t, args[1].DeprecationReason) }) }) t.Run("disabled by middleware", func(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) srv.Use(extension.Introspection{}) srv.AroundOperations( func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler { graphql.GetOperationContext(ctx).DisableIntrospection = true return next(ctx) }, ) c := client.New(srv) var resp any err := c.Post(introspection.Query, &resp) require.EqualError( t, err, "[{\"message\":\"introspection disabled\",\"path\":[\"__schema\"]}]", ) }) } ================================================ FILE: codegen/testserver/followschema/invalid-packagename/invalid-identifier.go ================================================ package invalid_packagename type InvalidIdentifier struct { ID int } ================================================ FILE: codegen/testserver/followschema/issue4053.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "github.com/99designs/gqlgen/graphql" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** func (ec *executionContext) unmarshalInputIssue4053Input1(ctx context.Context, obj any) (Issue4053Input1, error) { var it Issue4053Input1 if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"input2"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "input2": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input2")) data, err := ec.unmarshalOIssue4053Input22githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐIssue4053Input2(ctx, v) if err != nil { return it, err } it.Input2 = data } } return it, nil } func (ec *executionContext) unmarshalInputIssue4053Input2(ctx context.Context, obj any) (Issue4053Input2, error) { var it Issue4053Input2 if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } if _, present := asMap["helloWithDefault"]; !present { asMap["helloWithDefault"] = "world" } fieldsInOrder := [...]string{"hello", "helloWithDefault"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "hello": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hello")) data, err := ec.unmarshalOString2string(ctx, v) if err != nil { return it, err } it.Hello = data case "helloWithDefault": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("helloWithDefault")) data, err := ec.unmarshalOString2string(ctx, v) if err != nil { return it, err } it.HelloWithDefault = data } } return it, nil } // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) unmarshalOIssue4053Input12ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐIssue4053Input1(ctx context.Context, v any) (*Issue4053Input1, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputIssue4053Input1(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalOIssue4053Input22githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐIssue4053Input2(ctx context.Context, v any) (Issue4053Input2, error) { res, err := ec.unmarshalInputIssue4053Input2(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/issue4053.go ================================================ package followschema type Issue4053Input1 struct { Input2 Issue4053Input2 } type Issue4053Input2 struct { Hello string HelloWithDefault string } ================================================ FILE: codegen/testserver/followschema/issue4053.graphql ================================================ # This is a reproduction of https://github.com/99designs/gqlgen/issues/4053 extend type Mutation { issue4053(input: Issue4053Input1): Boolean! } input Issue4053Input1 { input2: Issue4053Input2 } # Issue4053Input2 exists in issue4053.go input Issue4053Input2 { hello: String helloWithDefault: String = "world" } ================================================ FILE: codegen/testserver/followschema/issue896.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _CheckIssue896_id(ctx context.Context, field graphql.CollectedField, obj *CheckIssue896) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_CheckIssue896_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOInt2ᚖint, true, false, ) } func (ec *executionContext) fieldContext_CheckIssue896_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "CheckIssue896", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var checkIssue896Implementors = []string{"CheckIssue896"} func (ec *executionContext) _CheckIssue896(ctx context.Context, sel ast.SelectionSet, obj *CheckIssue896) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, checkIssue896Implementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("CheckIssue896") case "id": out.Values[i] = ec._CheckIssue896_id(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshalNCheckIssue8962ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCheckIssue896(ctx context.Context, sel ast.SelectionSet, v *CheckIssue896) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._CheckIssue896(ctx, sel, v) } func (ec *executionContext) marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCheckIssue896(ctx context.Context, sel ast.SelectionSet, v []*CheckIssue896) 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.marshalOCheckIssue8962ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCheckIssue896(ctx, sel, v[i]) }) return ret } func (ec *executionContext) marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCheckIssue896ᚄ(ctx context.Context, sel ast.SelectionSet, v []*CheckIssue896) graphql.Marshaler { if v == nil { return graphql.Null } ret := 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.marshalNCheckIssue8962ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCheckIssue896(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalOCheckIssue8962ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCheckIssue896(ctx context.Context, sel ast.SelectionSet, v *CheckIssue896) graphql.Marshaler { if v == nil { return graphql.Null } return ec._CheckIssue896(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/issue896.graphql ================================================ # This example should build stable output. If the file content starts # alternating nondeterministically between two outputs, then see # https://github.com/99designs/gqlgen/issues/896. extend schema { query: Query subscription: Subscription } type CheckIssue896 {id: Int} extend type Query { issue896a: [CheckIssue896!] # Note the "!" or lack thereof. } extend type Subscription { issue896b: [CheckIssue896] # Note the "!" or lack thereof. } ================================================ FILE: codegen/testserver/followschema/loops.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "fmt" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _LoopA_b(ctx context.Context, field graphql.CollectedField, obj *LoopA) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_LoopA_b, func(ctx context.Context) (any, error) { return obj.B, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNLoopB2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐLoopB, true, true, ) } func (ec *executionContext) fieldContext_LoopA_b(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "LoopA", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "a": return ec.fieldContext_LoopB_a(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type LoopB", field.Name) }, } return fc, nil } func (ec *executionContext) _LoopB_a(ctx context.Context, field graphql.CollectedField, obj *LoopB) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_LoopB_a, func(ctx context.Context) (any, error) { return obj.A, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNLoopA2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐLoopA, true, true, ) } func (ec *executionContext) fieldContext_LoopB_a(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "LoopB", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "b": return ec.fieldContext_LoopA_b(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type LoopA", field.Name) }, } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var loopAImplementors = []string{"LoopA"} func (ec *executionContext) _LoopA(ctx context.Context, sel ast.SelectionSet, obj *LoopA) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, loopAImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("LoopA") case "b": out.Values[i] = ec._LoopA_b(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var loopBImplementors = []string{"LoopB"} func (ec *executionContext) _LoopB(ctx context.Context, sel ast.SelectionSet, obj *LoopB) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, loopBImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("LoopB") case "a": out.Values[i] = ec._LoopB_a(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshalNLoopA2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐLoopA(ctx context.Context, sel ast.SelectionSet, v *LoopA) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._LoopA(ctx, sel, v) } func (ec *executionContext) marshalNLoopB2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐLoopB(ctx context.Context, sel ast.SelectionSet, v *LoopB) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._LoopB(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/loops.graphql ================================================ type LoopA { b: LoopB! } type LoopB { a: LoopA! } ================================================ FILE: codegen/testserver/followschema/map_nested_map_slice_test.go ================================================ package followschema import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestMapNestedMapSlice(t *testing.T) { resolver := &Stub{} resolver.QueryResolver.MapNestedMapSlice = func(ctx context.Context, input map[string]any) (*bool, error) { require.NotNil(t, input, "expected input") require.NotNil(t, input["recurse"], "expected recurse") require.IsType( t, []map[string]any{}, input["recurse"], "expected recurse as [][]map[string]any", ) recurse := input["recurse"].([]map[string]any) require.Len(t, recurse, 1, "expected 1 item in recurse") return nil, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolver})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("recursive input", func(t *testing.T) { var resp struct { MapNestedMapSlice bool } // recurse is [MapNestedMapSlice!] err := c.Post( `query { mapNestedMapSlice(input: { recurse: [{ name: "child" }] }) }`, &resp, ) require.NoError(t, err) }) } ================================================ FILE: codegen/testserver/followschema/maps.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "fmt" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _MapNested_value(ctx context.Context, field graphql.CollectedField, obj *MapNested) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_MapNested_value, func(ctx context.Context) (any, error) { return obj.Value, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNCustomScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCustomScalar, true, true, ) } func (ec *executionContext) fieldContext_MapNested_value(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MapNested", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type CustomScalar does not have child fields") }, } return fc, nil } func (ec *executionContext) _MapStringInterfaceType_a(ctx context.Context, field graphql.CollectedField, obj map[string]any) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_MapStringInterfaceType_a, func(ctx context.Context) (any, error) { switch v := obj["a"].(type) { case *string: return v, nil case string: return &v, nil case nil: return (*string)(nil), nil default: return nil, fmt.Errorf("unexpected type %T for field %s", v, "a") } }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_MapStringInterfaceType_a(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MapStringInterfaceType", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _MapStringInterfaceType_b(ctx context.Context, field graphql.CollectedField, obj map[string]any) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_MapStringInterfaceType_b, func(ctx context.Context) (any, error) { switch v := obj["b"].(type) { case *int: return v, nil case int: return &v, nil case nil: return (*int)(nil), nil default: return nil, fmt.Errorf("unexpected type %T for field %s", v, "b") } }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOInt2ᚖint, true, false, ) } func (ec *executionContext) fieldContext_MapStringInterfaceType_b(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MapStringInterfaceType", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _MapStringInterfaceType_c(ctx context.Context, field graphql.CollectedField, obj map[string]any) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_MapStringInterfaceType_c, func(ctx context.Context) (any, error) { switch v := obj["c"].(type) { case *CustomScalar: return v, nil case CustomScalar: return &v, nil case nil: return (*CustomScalar)(nil), nil default: return nil, fmt.Errorf("unexpected type %T for field %s", v, "c") } }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOCustomScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCustomScalar, true, false, ) } func (ec *executionContext) fieldContext_MapStringInterfaceType_c(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MapStringInterfaceType", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type CustomScalar does not have child fields") }, } return fc, nil } func (ec *executionContext) _MapStringInterfaceType_nested(ctx context.Context, field graphql.CollectedField, obj map[string]any) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_MapStringInterfaceType_nested, func(ctx context.Context) (any, error) { switch v := obj["nested"].(type) { case *MapNested: return v, nil case MapNested: return &v, nil case nil: return (*MapNested)(nil), nil default: return nil, fmt.Errorf("unexpected type %T for field %s", v, "nested") } }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOMapNested2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMapNested, true, false, ) } func (ec *executionContext) fieldContext_MapStringInterfaceType_nested(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MapStringInterfaceType", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "value": return ec.fieldContext_MapNested_value(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type MapNested", field.Name) }, } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** func (ec *executionContext) unmarshalInputMapNestedInput(ctx context.Context, obj any) (MapNested, error) { var it MapNested if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"value"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "value": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("value")) data, err := ec.unmarshalNCustomScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCustomScalar(ctx, v) if err != nil { return it, err } it.Value = data } } return it, nil } func (ec *executionContext) unmarshalInputMapNestedMapSliceInput(ctx context.Context, obj any) (map[string]any, error) { var it map[string]any if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"name", "recurse"} it = make(map[string]any, len(asMap)) for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "name": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it["name"] = data case "recurse": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("recurse")) data, err := ec.unmarshalOMapNestedMapSliceInput2ᚕmapᚄ(ctx, v) if err != nil { return it, err } it["recurse"] = data } } return it, nil } func (ec *executionContext) unmarshalInputMapStringInterfaceInput(ctx context.Context, obj any) (map[string]any, error) { var it map[string]any if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"a", "b", "c", "nested"} it = make(map[string]any, len(asMap)) for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "a": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("a")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it["a"] = data case "b": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("b")) data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } it["b"] = data case "c": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("c")) data, err := ec.unmarshalOCustomScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCustomScalar(ctx, v) if err != nil { return it, err } it["c"] = data case "nested": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nested")) data, err := ec.unmarshalOMapNestedInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMapNested(ctx, v) if err != nil { return it, err } it["nested"] = data } } return it, nil } func (ec *executionContext) unmarshalInputNestedMapInput(ctx context.Context, obj any) (NestedMapInput, error) { var it NestedMapInput if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"map"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "map": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("map")) data, err := ec.unmarshalOMapStringInterfaceInput2map(ctx, v) if err != nil { return it, err } it.Map = data } } return it, nil } // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var mapNestedImplementors = []string{"MapNested"} func (ec *executionContext) _MapNested(ctx context.Context, sel ast.SelectionSet, obj *MapNested) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, mapNestedImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("MapNested") case "value": out.Values[i] = ec._MapNested_value(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var mapStringInterfaceTypeImplementors = []string{"MapStringInterfaceType"} func (ec *executionContext) _MapStringInterfaceType(ctx context.Context, sel ast.SelectionSet, obj map[string]any) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, mapStringInterfaceTypeImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("MapStringInterfaceType") case "a": out.Values[i] = ec._MapStringInterfaceType_a(ctx, field, obj) case "b": out.Values[i] = ec._MapStringInterfaceType_b(ctx, field, obj) case "c": out.Values[i] = ec._MapStringInterfaceType_c(ctx, field, obj) case "nested": out.Values[i] = ec._MapStringInterfaceType_nested(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) unmarshalNCustomScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCustomScalar(ctx context.Context, v any) (CustomScalar, error) { var res CustomScalar err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNCustomScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCustomScalar(ctx context.Context, sel ast.SelectionSet, v CustomScalar) graphql.Marshaler { return v } func (ec *executionContext) unmarshalNMapNestedMapSliceInput2map(ctx context.Context, v any) (map[string]any, error) { res, err := ec.unmarshalInputMapNestedMapSliceInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalOCustomScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCustomScalar(ctx context.Context, v any) (*CustomScalar, error) { if v == nil { return nil, nil } var res = new(CustomScalar) err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOCustomScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCustomScalar(ctx context.Context, sel ast.SelectionSet, v *CustomScalar) graphql.Marshaler { if v == nil { return graphql.Null } return v } func (ec *executionContext) marshalOMapNested2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMapNested(ctx context.Context, sel ast.SelectionSet, v *MapNested) graphql.Marshaler { if v == nil { return graphql.Null } return ec._MapNested(ctx, sel, v) } func (ec *executionContext) unmarshalOMapNestedInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMapNested(ctx context.Context, v any) (*MapNested, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputMapNestedInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalOMapNestedMapSliceInput2map(ctx context.Context, v any) (map[string]any, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputMapNestedMapSliceInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalOMapNestedMapSliceInput2ᚕ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.unmarshalNMapNestedMapSliceInput2map(ctx, vSlice[i]) if err != nil { return nil, err } } return res, nil } func (ec *executionContext) unmarshalOMapStringInterfaceInput2map(ctx context.Context, v any) (map[string]any, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputMapStringInterfaceInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOMapStringInterfaceType2map(ctx context.Context, sel ast.SelectionSet, v map[string]any) graphql.Marshaler { if v == nil { return graphql.Null } return ec._MapStringInterfaceType(ctx, sel, v) } func (ec *executionContext) unmarshalONestedMapInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNestedMapInput(ctx context.Context, v any) (*NestedMapInput, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputNestedMapInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/maps.go ================================================ package followschema import ( "io" "strconv" ) type MapNested struct { Value CustomScalar } type CustomScalar struct { value int64 } func (s *CustomScalar) UnmarshalGQL(v any) (err error) { switch v := v.(type) { case string: s.value, err = strconv.ParseInt(v, 10, 64) case int64: s.value = v } return err } func (s CustomScalar) MarshalGQL(w io.Writer) { _, _ = w.Write([]byte(strconv.Quote(strconv.FormatInt(s.value, 10)))) } ================================================ FILE: codegen/testserver/followschema/maps.graphql ================================================ extend type Query { mapStringInterface(in: MapStringInterfaceInput): MapStringInterfaceType mapNestedStringInterface(in: NestedMapInput): MapStringInterfaceType } type MapStringInterfaceType @goModel(model: "map[string]interface{}") { a: String b: Int c: CustomScalar nested: MapNested } type MapNested @goModel(model: "followschema.MapNested") { value: CustomScalar! } input MapStringInterfaceInput @goModel(model: "map[string]interface{}") { a: String! b: Int c: CustomScalar nested: MapNestedInput } input MapNestedInput @goModel(model: "followschema.MapNested") { value: CustomScalar! } scalar CustomScalar @goModel(model: "followschema.CustomScalar") input NestedMapInput { map: MapStringInterfaceInput } input MapNestedMapSliceInput @goModel(model: "map[string]interface{}") { name: String recurse: [MapNestedMapSliceInput!] } extend type Query { mapNestedMapSlice(input: MapNestedMapSliceInput): Boolean } ================================================ FILE: codegen/testserver/followschema/maps_test.go ================================================ package followschema import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestMaps(t *testing.T) { resolver := &Stub{} resolver.QueryResolver.MapStringInterface = func(ctx context.Context, in map[string]any) (i map[string]any, e error) { validateMapItemsType(t, in) return in, nil } resolver.QueryResolver.MapNestedStringInterface = func(ctx context.Context, in *NestedMapInput) (i map[string]any, e error) { if in == nil { return nil, nil } validateMapItemsType(t, in.Map) return in.Map, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolver})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("unset", func(t *testing.T) { var resp struct { MapStringInterface map[string]any } err := c.Post(`query { mapStringInterface { a, b, c, nested { value } } }`, &resp) require.NoError(t, err) require.Nil(t, resp.MapStringInterface) }) t.Run("nil", func(t *testing.T) { var resp struct { MapStringInterface map[string]any } err := c.Post(`query { mapStringInterface(in: null) { a, b, c, nested { value } } }`, &resp) require.NoError(t, err) require.Nil(t, resp.MapStringInterface) }) t.Run("values", func(t *testing.T) { var resp struct { MapStringInterface map[string]any } err := c.Post( `query($value: CustomScalar!) { mapStringInterface(in: { a: "a", b: null, c: 42, nested: { value: $value } }) { a, b, c, nested { value } } }`, &resp, client.Var("value", "17"), ) require.NoError(t, err) require.Equal(t, "a", resp.MapStringInterface["a"]) require.Nil(t, resp.MapStringInterface["b"]) require.Equal(t, "42", resp.MapStringInterface["c"]) require.NotNil(t, resp.MapStringInterface["nested"]) require.IsType(t, map[string]any{}, resp.MapStringInterface["nested"]) require.Equal(t, "17", (resp.MapStringInterface["nested"].(map[string]any))["value"]) }) t.Run("nested", func(t *testing.T) { var resp struct { MapNestedStringInterface map[string]any } err := c.Post( `query { mapNestedStringInterface(in: { map: { a: "a", c: "42", nested: { value: 31 } } }) { a, b, c, nested { value } } }`, &resp, ) require.NoError(t, err) require.Equal(t, "a", resp.MapNestedStringInterface["a"]) require.Nil(t, resp.MapNestedStringInterface["b"]) require.Equal(t, "42", resp.MapNestedStringInterface["c"]) require.NotNil(t, resp.MapNestedStringInterface["nested"]) require.IsType(t, map[string]any{}, resp.MapNestedStringInterface["nested"]) require.Equal(t, "31", (resp.MapNestedStringInterface["nested"].(map[string]any))["value"]) }) t.Run("nested nil", func(t *testing.T) { var resp struct { MapNestedStringInterface map[string]any } err := c.Post( `query { mapNestedStringInterface(in: { map: null }) { a, b, c, nested { value } } }`, &resp, ) require.NoError(t, err) require.Nil(t, resp.MapNestedStringInterface) }) } func validateMapItemsType(t *testing.T, in map[string]any) { for k, v := range in { switch k { case "a": require.IsType(t, "", v) case "b": require.IsType(t, new(int), v) case "c": require.IsType(t, new(CustomScalar), v) case "nested": require.IsType(t, new(MapNested), v) default: require.Failf(t, "unexpected key in map", "key %q was not expected in map", k) } } } ================================================ FILE: codegen/testserver/followschema/middleware_test.go ================================================ package followschema import ( "context" "sync" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestMiddleware(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.ErrorBubble = func(ctx context.Context) (i *Error, e error) { return &Error{ID: "E1234"}, nil } resolvers.QueryResolver.User = func(ctx context.Context, id int) (user *User, e error) { return &User{ID: 1}, nil } resolvers.UserResolver.Friends = func(ctx context.Context, obj *User) (users []*User, e error) { return []*User{{ID: 1}}, nil } resolvers.QueryResolver.ModelMethods = func(ctx context.Context) (methods *ModelMethods, e error) { return &ModelMethods{}, nil } var mu sync.Mutex areMethods := map[string]bool{} areResolvers := map[string]bool{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res any, err error) { path, _ := ctx.Value(ckey("path")).([]int) return next(context.WithValue(ctx, ckey("path"), append(path, 1))) }) srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res any, err error) { path, _ := ctx.Value(ckey("path")).([]int) return next(context.WithValue(ctx, ckey("path"), append(path, 2))) }) srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res any, err error) { fc := graphql.GetFieldContext(ctx) mu.Lock() areMethods[fc.Field.Name] = fc.IsMethod areResolvers[fc.Field.Name] = fc.IsResolver mu.Unlock() return next(ctx) }) c := client.New(srv) var resp struct { User struct { ID int Friends []struct { ID int } } ModelMethods struct { NoContext bool } } called := false resolvers.UserResolver.Friends = func(ctx context.Context, obj *User) ([]*User, error) { assert.Equal(t, []int{1, 2, 1, 2}, ctx.Value(ckey("path"))) called = true return []*User{}, nil } err := c.Post(`query { user(id: 1) { id, friends { id } } modelMethods { noContext } }`, &resp) assert.Equal(t, map[string]bool{ "user": true, "id": false, "friends": true, "modelMethods": true, "noContext": true, }, areMethods) assert.Equal(t, map[string]bool{ "user": true, "id": false, "friends": true, "modelMethods": true, "noContext": false, }, areResolvers) require.NoError(t, err) require.True(t, called) } ================================================ FILE: codegen/testserver/followschema/modelmethod_test.go ================================================ package followschema import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestModelMethods(t *testing.T) { resolver := &Stub{} resolver.QueryResolver.ModelMethods = func(ctx context.Context) (methods *ModelMethods, e error) { return &ModelMethods{}, nil } resolver.ModelMethodsResolver.ResolverField = func(ctx context.Context, obj *ModelMethods) (b bool, e error) { return true, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolver})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("without context", func(t *testing.T) { var resp struct { ModelMethods struct { NoContext bool } } err := c.Post(`query { modelMethods{ noContext } }`, &resp) require.NoError(t, err) require.True(t, resp.ModelMethods.NoContext) }) t.Run("with context", func(t *testing.T) { var resp struct { ModelMethods struct { WithContext bool } } err := c.Post(`query { modelMethods{ withContext } }`, &resp) require.NoError(t, err) require.True(t, resp.ModelMethods.WithContext) }) } ================================================ FILE: codegen/testserver/followschema/models-gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "bytes" "fmt" "io" "strconv" "time" "github.com/99designs/gqlgen/graphql" ) type Animal interface { IsAnimal() GetSpecies() string GetSize() *Size } type ContentChild interface { IsContentChild() } type Mammalian interface { IsAnimal() IsMammalian() GetSpecies() string GetSize() *Size } type TestUnion interface { IsTestUnion() } type A struct { ID string `json:"id"` } func (A) IsTestUnion() {} type AIt struct { ID string `json:"id"` } type AbIt struct { ID string `json:"id"` } type B struct { ID string `json:"id"` } func (B) IsTestUnion() {} type Cat struct { Species string `json:"species"` Size *Size `json:"size"` CatBreed string `json:"catBreed"` } func (Cat) IsAnimal() {} func (this Cat) GetSpecies() string { return this.Species } func (this Cat) GetSize() *Size { return this.Size } type CheckIssue896 struct { ID *int `json:"id,omitempty"` } type ContentPost struct { Foo *string `json:"foo,omitempty"` } func (ContentPost) IsContentChild() {} type ContentUser struct { Foo *string `json:"foo,omitempty"` } func (ContentUser) IsContentChild() {} type Coordinates struct { X float64 `json:"x"` Y float64 `json:"y"` } type DefaultInput struct { FalsyBoolean *bool `json:"falsyBoolean,omitempty"` TruthyBoolean *bool `json:"truthyBoolean,omitempty"` } type DefaultParametersMirror struct { FalsyBoolean *bool `json:"falsyBoolean,omitempty"` TruthyBoolean *bool `json:"truthyBoolean,omitempty"` } type DeferModel struct { ID string `json:"id"` Name string `json:"name"` Values []string `json:"values"` } type Dog struct { Species string `json:"species"` Size *Size `json:"size"` DogBreed string `json:"dogBreed"` } func (Dog) IsAnimal() {} func (this Dog) GetSpecies() string { return this.Species } func (this Dog) GetSize() *Size { return this.Size } type EmbeddedDefaultScalar struct { Value *string `json:"value,omitempty"` } type FieldsOrderPayload struct { FirstFieldValue *string `json:"firstFieldValue,omitempty"` } type Horse struct { Species string `json:"species"` Size *Size `json:"size"` HorseBreed string `json:"horseBreed"` } func (Horse) IsMammalian() {} func (this Horse) GetSpecies() string { return this.Species } func (this Horse) GetSize() *Size { return this.Size } func (Horse) IsAnimal() {} type InnerDirectives struct { Message string `json:"message"` } type InnerInput struct { ID int `json:"id"` } type InnerObject struct { ID int `json:"id"` } type InputDirectives struct { Text string `json:"text"` NullableText *string `json:"nullableText,omitempty"` Inner *InnerDirectives `json:"inner"` InnerNullable *InnerDirectives `json:"innerNullable,omitempty"` ThirdParty *ThirdParty `json:"thirdParty,omitempty"` } type InputWithEnumValue struct { Enum EnumTest `json:"enum"` } type LoopA struct { B *LoopB `json:"b"` } type LoopB struct { A *LoopA `json:"a"` } // Since gqlgen defines default implementation for a Map scalar, this tests that the builtin is _not_ // added to the TypeMap type Map struct { ID string `json:"id"` } type Mutation struct { } type NestedInput struct { Field Email `json:"field"` } type NestedMapInput struct { Map map[string]any `json:"map,omitempty"` } type ObjectDirectives struct { Text string `json:"text"` NullableText *string `json:"nullableText,omitempty"` Order []string `json:"order"` } type OmittableInput struct { ID graphql.Omittable[*string] `json:"id,omitempty"` Bool graphql.Omittable[*bool] `json:"bool,omitempty"` Str graphql.Omittable[*string] `json:"str,omitempty"` Int graphql.Omittable[*int] `json:"int,omitempty"` Time graphql.Omittable[*time.Time] `json:"time,omitempty"` Enum graphql.Omittable[*Status] `json:"enum,omitempty"` Scalar graphql.Omittable[*ThirdParty] `json:"scalar,omitempty"` Object graphql.Omittable[*OuterInput] `json:"object,omitempty"` } type OuterInput struct { Inner *InnerInput `json:"inner"` } type OuterObject struct { Inner *InnerObject `json:"inner"` } type OuterWrapperInput struct { Inner *InputDirectives `json:"inner"` } type Pet struct { ID int `json:"id"` Friends []*Pet `json:"friends,omitempty"` } type Query struct { } type Size struct { Height int `json:"height"` Weight int `json:"weight"` } type SkipIncludeTestType struct { A *string `json:"a,omitempty"` B *string `json:"b,omitempty"` } type Slices struct { Test1 []*string `json:"test1,omitempty"` Test2 []string `json:"test2,omitempty"` Test3 []*string `json:"test3"` Test4 []string `json:"test4"` } type SpecialInput struct { Nesting *NestedInput `json:"nesting"` } type Subscription struct { } type User struct { ID int `json:"id"` Friends []*User `json:"friends"` Created time.Time `json:"created"` Updated *time.Time `json:"updated,omitempty"` Pets []*Pet `json:"pets,omitempty"` } type ValidInput struct { Break string `json:"break"` Default string `json:"default"` Func string `json:"func"` Interface string `json:"interface"` Select string `json:"select"` Case string `json:"case"` Defer string `json:"defer"` Go string `json:"go"` Map string `json:"map"` Struct string `json:"struct"` Chan string `json:"chan"` Else string `json:"else"` Goto string `json:"goto"` Package string `json:"package"` Switch string `json:"switch"` Const string `json:"const"` Fallthrough string `json:"fallthrough"` If string `json:"if"` Range string `json:"range"` Type string `json:"type"` Continue string `json:"continue"` For string `json:"for"` Import string `json:"import"` Return string `json:"return"` Var string `json:"var"` Underscore string `json:"_"` } // These things are all valid, but without care generate invalid go code type ValidType struct { DifferentCase string `json:"differentCase"` DifferentCaseOld string `json:"different_case"` ValidInputKeywords bool `json:"validInputKeywords"` ValidArgs bool `json:"validArgs"` } type XXIt struct { ID string `json:"id"` } type XxIt struct { ID string `json:"id"` } type AsdfIt struct { ID string `json:"id"` } type IIt struct { ID string `json:"id"` } type EnumTest string const ( EnumTestOk EnumTest = "OK" EnumTestNg EnumTest = "NG" ) var AllEnumTest = []EnumTest{ EnumTestOk, EnumTestNg, } func (e EnumTest) IsValid() bool { switch e { case EnumTestOk, EnumTestNg: return true } return false } func (e EnumTest) String() string { return string(e) } func (e *EnumTest) UnmarshalGQL(v any) error { str, ok := v.(string) if !ok { return fmt.Errorf("enums must be strings") } *e = EnumTest(str) if !e.IsValid() { return fmt.Errorf("%s is not a valid EnumTest", str) } return nil } func (e EnumTest) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } func (e *EnumTest) UnmarshalJSON(b []byte) error { s, err := strconv.Unquote(string(b)) if err != nil { return err } return e.UnmarshalGQL(s) } func (e EnumTest) MarshalJSON() ([]byte, error) { var buf bytes.Buffer e.MarshalGQL(&buf) return buf.Bytes(), nil } type Status string const ( StatusOk Status = "OK" StatusError Status = "ERROR" ) var AllStatus = []Status{ StatusOk, StatusError, } func (e Status) IsValid() bool { switch e { case StatusOk, StatusError: return true } return false } func (e Status) String() string { return string(e) } func (e *Status) UnmarshalGQL(v any) error { str, ok := v.(string) if !ok { return fmt.Errorf("enums must be strings") } *e = Status(str) if !e.IsValid() { return fmt.Errorf("%s is not a valid Status", str) } return nil } func (e Status) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } func (e *Status) UnmarshalJSON(b []byte) error { s, err := strconv.Unquote(string(b)) if err != nil { return err } return e.UnmarshalGQL(s) } func (e Status) MarshalJSON() ([]byte, error) { var buf bytes.Buffer e.MarshalGQL(&buf) return buf.Bytes(), nil } ================================================ FILE: codegen/testserver/followschema/models.go ================================================ package followschema import ( "context" "errors" "io" ) type ForcedResolver struct { Field Circle } type ModelMethods struct{} func (m ModelMethods) NoContext() bool { return true } func (m ModelMethods) WithContext(_ context.Context) bool { return true } type Errors struct{} type Error struct { ID string } func (Error) ErrorOnRequiredField() (string, error) { return "", errors.New("boom") } func (Error) ErrorOnNonRequiredField() (string, error) { return "", errors.New("boom") } func (Error) NilOnRequiredField() *string { return nil } type EmbeddedPointerModel struct { *EmbeddedPointer ID string } type EmbeddedPointer struct { Title string } type MarshalPanic string func (m *MarshalPanic) UnmarshalGQL(v any) error { panic("BOOM") } func (m MarshalPanic) MarshalGQL(w io.Writer) { panic("BOOM") } type Panics struct{} func (p *Panics) FieldFuncMarshal(ctx context.Context, u []MarshalPanic) []MarshalPanic { return []MarshalPanic{MarshalPanic("aa"), MarshalPanic("bb")} } type Autobind struct { Int int Int32 int32 Int64 int64 IdStr string IdInt int } type OverlappingFields struct { Foo int NewFoo int } type ObjectDirectivesWithCustomGoModel struct { NullableText string // not *string, but schema is `String @toNull` type. } type FallbackToStringEncoding string const ( FallbackToStringEncodingA FallbackToStringEncoding = "A" FallbackToStringEncodingB FallbackToStringEncoding = "B" FallbackToStringEncodingC FallbackToStringEncoding = "C" ) type Primitive int func (p Primitive) Squared() int { return int(p) * int(p) } type PrimitiveString string func (s PrimitiveString) Doubled() string { return string(s) + string(s) } type Bytes []byte ================================================ FILE: codegen/testserver/followschema/mutation_with_custom_scalar.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** func (ec *executionContext) unmarshalInputNestedInput(ctx context.Context, obj any) (NestedInput, error) { var it NestedInput if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"field"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "field": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) data, err := ec.unmarshalNEmail2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEmail(ctx, v) if err != nil { return it, err } it.Field = data } } return it, nil } func (ec *executionContext) unmarshalInputSpecialInput(ctx context.Context, obj any) (SpecialInput, error) { var it SpecialInput if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"nesting"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "nesting": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nesting")) data, err := ec.unmarshalNNestedInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNestedInput(ctx, v) if err != nil { return it, err } it.Nesting = data } } return it, nil } // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) unmarshalNEmail2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEmail(ctx context.Context, v any) (Email, error) { var res Email err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNEmail2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEmail(ctx context.Context, sel ast.SelectionSet, v Email) graphql.Marshaler { return v } func (ec *executionContext) unmarshalNNestedInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNestedInput(ctx context.Context, v any) (*NestedInput, error) { res, err := ec.unmarshalInputNestedInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalNSpecialInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSpecialInput(ctx context.Context, v any) (SpecialInput, error) { res, err := ec.unmarshalInputSpecialInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/mutation_with_custom_scalar.go ================================================ package followschema import ( "encoding/json" "errors" "io" "regexp" ) var re = regexp.MustCompile( "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$", ) type Email string func (value *Email) UnmarshalGQL(v any) error { input, ok := v.(string) if !ok { return errors.New("email expects a string value") } if !re.MatchString(input) { return errors.New("invalid email format") } *value = Email(input) return nil } func (value Email) MarshalGQL(w io.Writer) { output, _ := json.Marshal(string(value)) w.Write(output) } ================================================ FILE: codegen/testserver/followschema/mutation_with_custom_scalar.graphql ================================================ extend type Mutation { updateSomething(input: SpecialInput!): String! } scalar Email input SpecialInput { nesting: NestedInput! } input NestedInput { field: Email! } ================================================ FILE: codegen/testserver/followschema/mutation_with_custom_scalar_test.go ================================================ package followschema import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestErrorInsideMutationArgument(t *testing.T) { resolvers := &Stub{} resolvers.MutationResolver.UpdateSomething = func(_ context.Context, input SpecialInput) (s string, err error) { return "Hello world", nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("mutation with correct input doesn't return error", func(t *testing.T) { var resp map[string]any input := map[string]any{ "nesting": map[string]any{ "field": "email@example.com", }, } err := c.Post( `mutation TestMutation($input: SpecialInput!) { updateSomething(input: $input) }`, &resp, client.Var("input", input), ) require.Equal(t, "Hello world", resp["updateSomething"]) require.NoError(t, err) }) t.Run("mutation with incorrect input returns full path", func(t *testing.T) { var resp map[string]any input := map[string]any{ "nesting": map[string]any{ "field": "not-an-email", }, } err := c.Post( `mutation TestMutation($input: SpecialInput!) { updateSomething(input: $input) }`, &resp, client.Var("input", input), ) require.EqualError( t, err, `[{"message":"invalid email format","path":["updateSomething","input","nesting","field"]}]`, ) }) } ================================================ FILE: codegen/testserver/followschema/nulls.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "fmt" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** type ErrorsResolver interface { A(ctx context.Context, obj *Errors) (*Error, error) B(ctx context.Context, obj *Errors) (*Error, error) C(ctx context.Context, obj *Errors) (*Error, error) D(ctx context.Context, obj *Errors) (*Error, error) E(ctx context.Context, obj *Errors) (*Error, error) } // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _Error_id(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Error_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_Error_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Error", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _Error_errorOnNonRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Error_errorOnNonRequiredField, func(ctx context.Context) (any, error) { return obj.ErrorOnNonRequiredField() }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2string, true, false, ) } func (ec *executionContext) fieldContext_Error_errorOnNonRequiredField(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Error", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Error_errorOnRequiredField, func(ctx context.Context) (any, error) { return obj.ErrorOnRequiredField() }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Error_errorOnRequiredField(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Error", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Error_nilOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Error_nilOnRequiredField, func(ctx context.Context) (any, error) { return obj.NilOnRequiredField(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2ᚖstring, true, true, ) } func (ec *executionContext) fieldContext_Error_nilOnRequiredField(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Error", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Errors_a(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Errors_a, func(ctx context.Context) (any, error) { return ec.Resolvers.Errors().A(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError, true, true, ) } func (ec *executionContext) fieldContext_Errors_a(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Errors", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Error_id(ctx, field) case "errorOnNonRequiredField": return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) case "errorOnRequiredField": return ec.fieldContext_Error_errorOnRequiredField(ctx, field) case "nilOnRequiredField": return ec.fieldContext_Error_nilOnRequiredField(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) }, } return fc, nil } func (ec *executionContext) _Errors_b(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Errors_b, func(ctx context.Context) (any, error) { return ec.Resolvers.Errors().B(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError, true, true, ) } func (ec *executionContext) fieldContext_Errors_b(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Errors", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Error_id(ctx, field) case "errorOnNonRequiredField": return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) case "errorOnRequiredField": return ec.fieldContext_Error_errorOnRequiredField(ctx, field) case "nilOnRequiredField": return ec.fieldContext_Error_nilOnRequiredField(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) }, } return fc, nil } func (ec *executionContext) _Errors_c(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Errors_c, func(ctx context.Context) (any, error) { return ec.Resolvers.Errors().C(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError, true, true, ) } func (ec *executionContext) fieldContext_Errors_c(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Errors", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Error_id(ctx, field) case "errorOnNonRequiredField": return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) case "errorOnRequiredField": return ec.fieldContext_Error_errorOnRequiredField(ctx, field) case "nilOnRequiredField": return ec.fieldContext_Error_nilOnRequiredField(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) }, } return fc, nil } func (ec *executionContext) _Errors_d(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Errors_d, func(ctx context.Context) (any, error) { return ec.Resolvers.Errors().D(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError, true, true, ) } func (ec *executionContext) fieldContext_Errors_d(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Errors", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Error_id(ctx, field) case "errorOnNonRequiredField": return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) case "errorOnRequiredField": return ec.fieldContext_Error_errorOnRequiredField(ctx, field) case "nilOnRequiredField": return ec.fieldContext_Error_nilOnRequiredField(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) }, } return fc, nil } func (ec *executionContext) _Errors_e(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Errors_e, func(ctx context.Context) (any, error) { return ec.Resolvers.Errors().E(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError, true, true, ) } func (ec *executionContext) fieldContext_Errors_e(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Errors", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Error_id(ctx, field) case "errorOnNonRequiredField": return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) case "errorOnRequiredField": return ec.fieldContext_Error_errorOnRequiredField(ctx, field) case "nilOnRequiredField": return ec.fieldContext_Error_nilOnRequiredField(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) }, } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var errorImplementors = []string{"Error"} func (ec *executionContext) _Error(ctx context.Context, sel ast.SelectionSet, obj *Error) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, errorImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Error") case "id": out.Values[i] = ec._Error_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "errorOnNonRequiredField": out.Values[i] = ec._Error_errorOnNonRequiredField(ctx, field, obj) case "errorOnRequiredField": out.Values[i] = ec._Error_errorOnRequiredField(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "nilOnRequiredField": out.Values[i] = ec._Error_nilOnRequiredField(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var errorsImplementors = []string{"Errors"} func (ec *executionContext) _Errors(ctx context.Context, sel ast.SelectionSet, obj *Errors) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, errorsImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Errors") case "a": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Errors_a(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "b": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Errors_b(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "c": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Errors_c(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "d": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Errors_d(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "e": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Errors_e(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshalNError2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx context.Context, sel ast.SelectionSet, v Error) graphql.Marshaler { return ec._Error(ctx, sel, &v) } func (ec *executionContext) marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx context.Context, sel ast.SelectionSet, v *Error) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._Error(ctx, sel, v) } func (ec *executionContext) marshalOError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx context.Context, sel ast.SelectionSet, v []*Error) 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.marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, sel, v[i]) }) return ret } func (ec *executionContext) marshalOError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐErrorᚄ(ctx context.Context, sel ast.SelectionSet, v []*Error) graphql.Marshaler { if v == nil { return graphql.Null } ret := 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.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError(ctx context.Context, sel ast.SelectionSet, v *Error) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Error(ctx, sel, v) } func (ec *executionContext) marshalOErrors2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐErrors(ctx context.Context, sel ast.SelectionSet, v *Errors) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Errors(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/nulls.graphql ================================================ extend type Query { errorBubble: Error errorBubbleList: [Error!] errorList: [Error] errors: Errors valid: String! invalid: String! } extend type Subscription { errorRequired: Error! } type Errors { a: Error! b: Error! c: Error! d: Error! e: Error! } type Error { id: ID! errorOnNonRequiredField: String errorOnRequiredField: String! nilOnRequiredField: String! } ================================================ FILE: codegen/testserver/followschema/nulls_test.go ================================================ package followschema import ( "context" "errors" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestNullBubbling(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.Valid = func(ctx context.Context) (s string, e error) { return "Ok", nil } resolvers.QueryResolver.Invalid = func(ctx context.Context) (s string, e error) { return "Ok", errors.New("ERROR") } resolvers.QueryResolver.Errors = func(ctx context.Context) (errors *Errors, e error) { return &Errors{}, nil } resolvers.QueryResolver.ErrorBubble = func(ctx context.Context) (i *Error, e error) { return &Error{ID: "E1234"}, nil } resolvers.QueryResolver.ErrorBubbleList = func(ctx context.Context) (i []*Error, e error) { return []*Error{{ID: "1"}, nil, nil}, nil } resolvers.QueryResolver.ErrorList = func(ctx context.Context) (i []*Error, e error) { return []*Error{nil}, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("when function errors on non required field", func(t *testing.T) { var resp struct { Valid string ErrorBubble *struct { Id string ErrorOnNonRequiredField *string } } err := c.Post(`query { valid, errorBubble { id, errorOnNonRequiredField } }`, &resp) require.EqualError( t, err, `[{"message":"boom","path":["errorBubble","errorOnNonRequiredField"]}]`, ) require.Equal(t, "E1234", resp.ErrorBubble.Id) require.Nil(t, resp.ErrorBubble.ErrorOnNonRequiredField) require.Equal(t, "Ok", resp.Valid) }) t.Run("when function errors", func(t *testing.T) { var resp struct { Valid string ErrorBubble *struct { NilOnRequiredField string } } err := c.Post(`query { valid, errorBubble { id, errorOnRequiredField } }`, &resp) require.EqualError( t, err, `[{"message":"boom","path":["errorBubble","errorOnRequiredField"]}]`, ) require.Nil(t, resp.ErrorBubble) require.Equal(t, "Ok", resp.Valid) }) t.Run("when user returns null on required field", func(t *testing.T) { var resp struct { Valid string ErrorBubble *struct { NilOnRequiredField string } } err := c.Post(`query { valid, errorBubble { id, nilOnRequiredField } }`, &resp) require.EqualError( t, err, `[{"message":"the requested element is null which the schema does not allow","path":["errorBubble","nilOnRequiredField"]}]`, ) require.Nil(t, resp.ErrorBubble) require.Equal(t, "Ok", resp.Valid) }) t.Run("when list element is null", func(t *testing.T) { var resp struct { Valid string ErrorList []*struct{} } err := c.Post(`query { valid, errorList { id } }`, &resp) require.NoError(t, err) require.Len(t, resp.ErrorList, 1) require.Nil(t, resp.ErrorList[0]) require.Equal(t, "Ok", resp.Valid) }) t.Run("when non-null list element is null", func(t *testing.T) { var resp struct { Valid string ErrorBubbleList []*struct{} } err := c.Post(`query { valid, errorBubbleList { id } }`, &resp) require.Contains( t, err.Error(), `{"message":"the requested element is null which the schema does not allow","path":["errorBubbleList",2]}`, ) require.Contains( t, err.Error(), `{"message":"the requested element is null which the schema does not allow","path":["errorBubbleList",1]}`, ) require.Nil(t, resp.ErrorBubbleList) require.Equal(t, "Ok", resp.Valid) }) t.Run("null args", func(t *testing.T) { var resp struct { NullableArg *string } resolvers.QueryResolver.NullableArg = func(ctx context.Context, arg *int) (i *string, e error) { v := "Ok" return &v, nil } err := c.Post(`query { nullableArg(arg: null) }`, &resp) require.NoError(t, err) require.Equal(t, "Ok", *resp.NullableArg) }) t.Run("concurrent null detection", func(t *testing.T) { var resp any resolvers.ErrorsResolver.A = func(ctx context.Context, obj *Errors) (i *Error, e error) { return nil, nil } resolvers.ErrorsResolver.B = func(ctx context.Context, obj *Errors) (i *Error, e error) { return nil, nil } resolvers.ErrorsResolver.C = func(ctx context.Context, obj *Errors) (i *Error, e error) { return nil, nil } resolvers.ErrorsResolver.D = func(ctx context.Context, obj *Errors) (i *Error, e error) { return nil, nil } resolvers.ErrorsResolver.E = func(ctx context.Context, obj *Errors) (i *Error, e error) { return nil, nil } err := c.Post(`{ errors { a { id }, b { id }, c { id }, d { id }, e { id }, } }`, &resp) require.Error(t, err) require.Contains( t, err.Error(), "the requested element is null which the schema does not allow", ) }) t.Run("when non-nullable field returns content while error occurred", func(t *testing.T) { var resp any err := c.Post(`query { invalid }`, &resp) require.Nil(t, resp) require.Error(t, err) require.Contains(t, err.Error(), `{"message":"ERROR","path":["invalid"]}`) }) } ================================================ FILE: codegen/testserver/followschema/otherpkg/model.go ================================================ package otherpkg type ( Scalar string Map map[string]string Slice []string ) type Struct struct { Name Scalar Desc *Scalar } ================================================ FILE: codegen/testserver/followschema/panics.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** type PanicsResolver interface { FieldScalarMarshal(ctx context.Context, obj *Panics) ([]MarshalPanic, error) ArgUnmarshal(ctx context.Context, obj *Panics, u []MarshalPanic) (bool, error) } // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) field_Panics_argUnmarshal_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "u", ec.unmarshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanicᚄ) if err != nil { return nil, err } args["u"] = arg0 return args, nil } func (ec *executionContext) field_Panics_fieldFuncMarshal_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "u", ec.unmarshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanicᚄ) if err != nil { return nil, err } args["u"] = arg0 return args, nil } // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _Panics_fieldScalarMarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Panics_fieldScalarMarshal, func(ctx context.Context) (any, error) { return ec.Resolvers.Panics().FieldScalarMarshal(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanicᚄ, true, true, ) } func (ec *executionContext) fieldContext_Panics_fieldScalarMarshal(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Panics", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type MarshalPanic does not have child fields") }, } return fc, nil } func (ec *executionContext) _Panics_fieldFuncMarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Panics_fieldFuncMarshal, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return obj.FieldFuncMarshal(ctx, fc.Args["u"].([]MarshalPanic)), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanicᚄ, true, true, ) } func (ec *executionContext) fieldContext_Panics_fieldFuncMarshal(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Panics", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type MarshalPanic does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Panics_fieldFuncMarshal_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Panics_argUnmarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Panics_argUnmarshal, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Panics().ArgUnmarshal(ctx, obj, fc.Args["u"].([]MarshalPanic)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNBoolean2bool, true, true, ) } func (ec *executionContext) fieldContext_Panics_argUnmarshal(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Panics", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Panics_argUnmarshal_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var panicsImplementors = []string{"Panics"} func (ec *executionContext) _Panics(ctx context.Context, sel ast.SelectionSet, obj *Panics) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, panicsImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Panics") case "fieldScalarMarshal": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Panics_fieldScalarMarshal(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "fieldFuncMarshal": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Panics_fieldFuncMarshal(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "argUnmarshal": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Panics_argUnmarshal(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) unmarshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanic(ctx context.Context, v any) (MarshalPanic, error) { var res MarshalPanic err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanic(ctx context.Context, sel ast.SelectionSet, v MarshalPanic) graphql.Marshaler { return v } func (ec *executionContext) unmarshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanicᚄ(ctx context.Context, v any) ([]MarshalPanic, error) { var vSlice []any vSlice = graphql.CoerceList(v) var err error res := make([]MarshalPanic, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) res[i], err = ec.unmarshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanic(ctx, vSlice[i]) if err != nil { return nil, err } } return res, nil } func (ec *executionContext) marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanicᚄ(ctx context.Context, sel ast.SelectionSet, v []MarshalPanic) graphql.Marshaler { ret := make(graphql.Array, len(v)) for i := range v { ret[i] = ec.marshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐMarshalPanic(ctx, sel, v[i]) } for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalOPanics2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPanics(ctx context.Context, sel ast.SelectionSet, v *Panics) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Panics(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/panics.graphql ================================================ extend type Query { panics: Panics } type Panics { fieldScalarMarshal: [MarshalPanic!]! fieldFuncMarshal(u: [MarshalPanic!]!): [MarshalPanic!]! argUnmarshal(u: [MarshalPanic!]!): Boolean! } scalar MarshalPanic ================================================ FILE: codegen/testserver/followschema/panics_test.go ================================================ package followschema import ( "context" "fmt" "testing" "github.com/stretchr/testify/require" "github.com/vektah/gqlparser/v2/gqlerror" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestPanics(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.Panics = func(ctx context.Context) (panics *Panics, e error) { return &Panics{}, nil } resolvers.PanicsResolver.ArgUnmarshal = func(ctx context.Context, obj *Panics, u []MarshalPanic) (b bool, e error) { return true, nil } resolvers.PanicsResolver.FieldScalarMarshal = func(ctx context.Context, obj *Panics) (marshalPanic []MarshalPanic, e error) { return []MarshalPanic{MarshalPanic("aa"), MarshalPanic("bb")}, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) srv.SetRecoverFunc(func(ctx context.Context, err any) (userMessage error) { return fmt.Errorf("panic: %v", err) }) srv.SetErrorPresenter(func(ctx context.Context, err error) *gqlerror.Error { return &gqlerror.Error{ Message: "presented: " + err.Error(), Path: graphql.GetPath(ctx), } }) c := client.New(srv) t.Run("panics in marshallers will not kill server", func(t *testing.T) { var resp any err := c.Post(`query { panics { fieldScalarMarshal } }`, &resp) require.EqualError( t, err, "http 422: {\"errors\":[{\"message\":\"presented: panic: BOOM\"}],\"data\":null}", ) }) t.Run("panics in unmarshalers will not kill server", func(t *testing.T) { var resp any err := c.Post(`query { panics { argUnmarshal(u: ["aa", "bb"]) } }`, &resp) require.EqualError( t, err, "[{\"message\":\"presented: input: panics.argUnmarshal panic: BOOM\",\"path\":[\"panics\",\"argUnmarshal\"]}]", ) }) t.Run("panics in funcs unmarshal return errors", func(t *testing.T) { var resp any err := c.Post(`query { panics { fieldFuncMarshal(u: ["aa", "bb"]) } }`, &resp) require.EqualError( t, err, "[{\"message\":\"presented: input: panics.fieldFuncMarshal panic: BOOM\",\"path\":[\"panics\",\"fieldFuncMarshal\"]}]", ) }) t.Run("panics in funcs marshal return errors", func(t *testing.T) { var resp any err := c.Post(`query { panics { fieldFuncMarshal(u: []) } }`, &resp) require.EqualError( t, err, "http 422: {\"errors\":[{\"message\":\"presented: panic: BOOM\"}],\"data\":null}", ) }) } ================================================ FILE: codegen/testserver/followschema/prelude.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "fmt" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) field___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) ___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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 __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) 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) unmarshalNID2int(ctx context.Context, v any) (int, error) { res, err := graphql.UnmarshalIntID(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNID2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { _ = sel res := graphql.MarshalIntID(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) unmarshalNInt2int32(ctx context.Context, v any) (int32, error) { res, err := graphql.UnmarshalInt32(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNInt2int32(ctx context.Context, sel ast.SelectionSet, v int32) graphql.Marshaler { _ = sel res := graphql.MarshalInt32(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) unmarshalNInt2int64(ctx context.Context, v any) (int64, error) { res, err := graphql.UnmarshalInt64(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNInt2int64(ctx context.Context, sel ast.SelectionSet, v int64) graphql.Marshaler { _ = sel res := graphql.MarshalInt64(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) 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) 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.unmarshalOString2ᚖstring(ctx, vSlice[i]) if err != nil { return nil, err } } return res, nil } func (ec *executionContext) marshalNString2ᚕᚖstring(ctx context.Context, sel ast.SelectionSet, v []*string) graphql.Marshaler { ret := make(graphql.Array, len(v)) for i := range v { ret[i] = ec.marshalOString2ᚖstring(ctx, sel, v[i]) } return ret } func (ec *executionContext) unmarshalNString2ᚖstring(ctx context.Context, v any) (*string, error) { res, err := graphql.UnmarshalString(v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } _ = 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__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) unmarshalOFloat2float64(ctx context.Context, v any) (float64, error) { res, err := graphql.UnmarshalFloatContext(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { _ = sel res := graphql.MarshalFloatContext(v) return graphql.WrapContextMarshaler(ctx, res) } func (ec *executionContext) unmarshalOFloat2ᚖfloat64(ctx context.Context, v any) (*float64, error) { if v == nil { return nil, nil } res, err := graphql.UnmarshalFloatContext(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOFloat2ᚖfloat64(ctx context.Context, sel ast.SelectionSet, v *float64) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel res := graphql.MarshalFloatContext(*v) return graphql.WrapContextMarshaler(ctx, res) } func (ec *executionContext) unmarshalOID2ᚖstring(ctx context.Context, v any) (*string, error) { if v == nil { return nil, nil } res, err := graphql.UnmarshalID(v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOID2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel _ = ctx res := graphql.MarshalID(*v) return res } 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) 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 } 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) unmarshalOString2ᚖᚕstringᚄ(ctx context.Context, v any) (*[]string, error) { if v == nil { return nil, nil } res, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v *[]string) graphql.Marshaler { return ec.marshalOString2ᚕstringᚄ(ctx, sel, *v) } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { if v == nil { return graphql.Null } ret := 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: codegen/testserver/followschema/primitive_objects.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** type PrimitiveResolver interface { Value(ctx context.Context, obj *Primitive) (int, error) } type PrimitiveStringResolver interface { Value(ctx context.Context, obj *PrimitiveString) (string, error) Len(ctx context.Context, obj *PrimitiveString) (int, error) } // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _Primitive_value(ctx context.Context, field graphql.CollectedField, obj *Primitive) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Primitive_value, func(ctx context.Context) (any, error) { return ec.Resolvers.Primitive().Value(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_Primitive_value(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Primitive", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _Primitive_squared(ctx context.Context, field graphql.CollectedField, obj *Primitive) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Primitive_squared, func(ctx context.Context) (any, error) { return obj.Squared(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_Primitive_squared(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Primitive", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _PrimitiveString_value(ctx context.Context, field graphql.CollectedField, obj *PrimitiveString) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PrimitiveString_value, func(ctx context.Context) (any, error) { return ec.Resolvers.PrimitiveString().Value(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_PrimitiveString_value(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PrimitiveString", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _PrimitiveString_doubled(ctx context.Context, field graphql.CollectedField, obj *PrimitiveString) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PrimitiveString_doubled, func(ctx context.Context) (any, error) { return obj.Doubled(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_PrimitiveString_doubled(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PrimitiveString", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _PrimitiveString_len(ctx context.Context, field graphql.CollectedField, obj *PrimitiveString) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PrimitiveString_len, func(ctx context.Context) (any, error) { return ec.Resolvers.PrimitiveString().Len(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_PrimitiveString_len(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PrimitiveString", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var primitiveImplementors = []string{"Primitive"} func (ec *executionContext) _Primitive(ctx context.Context, sel ast.SelectionSet, obj *Primitive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, primitiveImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Primitive") case "value": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Primitive_value(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "squared": out.Values[i] = ec._Primitive_squared(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var primitiveStringImplementors = []string{"PrimitiveString"} func (ec *executionContext) _PrimitiveString(ctx context.Context, sel ast.SelectionSet, obj *PrimitiveString) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, primitiveStringImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("PrimitiveString") case "value": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._PrimitiveString_value(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "doubled": out.Values[i] = ec._PrimitiveString_doubled(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "len": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._PrimitiveString_len(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshalNPrimitive2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPrimitive(ctx context.Context, sel ast.SelectionSet, v Primitive) graphql.Marshaler { return ec._Primitive(ctx, sel, &v) } func (ec *executionContext) marshalNPrimitive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPrimitiveᚄ(ctx context.Context, sel ast.SelectionSet, v []Primitive) graphql.Marshaler { ret := 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.marshalNPrimitive2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPrimitive(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalNPrimitiveString2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPrimitiveString(ctx context.Context, sel ast.SelectionSet, v PrimitiveString) graphql.Marshaler { return ec._PrimitiveString(ctx, sel, &v) } func (ec *executionContext) marshalNPrimitiveString2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPrimitiveStringᚄ(ctx context.Context, sel ast.SelectionSet, v []PrimitiveString) graphql.Marshaler { ret := 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.marshalNPrimitiveString2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPrimitiveString(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/primitive_objects.graphql ================================================ extend type Query { primitiveObject: [Primitive!]! primitiveStringObject: [PrimitiveString!]! } type Primitive { value: Int! squared: Int! } type PrimitiveString { value: String! doubled: String! len: Int! } ================================================ FILE: codegen/testserver/followschema/primitive_objects_test.go ================================================ package followschema import ( "context" "testing" "github.com/stretchr/testify/assert" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestPrimitiveObjects(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.PrimitiveObject = func(ctx context.Context) (out []Primitive, e error) { return []Primitive{2, 4}, nil } resolvers.PrimitiveResolver.Value = func(ctx context.Context, obj *Primitive) (i int, e error) { return int(*obj), nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("can fetch value", func(t *testing.T) { var resp struct { PrimitiveObject []struct { Value int Squared int } } c.MustPost(`query { primitiveObject { value, squared } }`, &resp) assert.Equal(t, 2, resp.PrimitiveObject[0].Value) assert.Equal(t, 4, resp.PrimitiveObject[0].Squared) assert.Equal(t, 4, resp.PrimitiveObject[1].Value) assert.Equal(t, 16, resp.PrimitiveObject[1].Squared) }) } func TestPrimitiveStringObjects(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.PrimitiveStringObject = func(ctx context.Context) (out []PrimitiveString, e error) { return []PrimitiveString{"hello", "world"}, nil } resolvers.PrimitiveStringResolver.Value = func(ctx context.Context, obj *PrimitiveString) (i string, e error) { return string(*obj), nil } resolvers.PrimitiveStringResolver.Len = func(ctx context.Context, obj *PrimitiveString) (i int, e error) { return len(string(*obj)), nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("can fetch value", func(t *testing.T) { var resp struct { PrimitiveStringObject []struct { Value string Doubled string Len int } } c.MustPost(`query { primitiveStringObject { value, doubled, len } }`, &resp) assert.Equal(t, "hello", resp.PrimitiveStringObject[0].Value) assert.Equal(t, "hellohello", resp.PrimitiveStringObject[0].Doubled) assert.Equal(t, 5, resp.PrimitiveStringObject[0].Len) assert.Equal(t, "world", resp.PrimitiveStringObject[1].Value) assert.Equal(t, "worldworld", resp.PrimitiveStringObject[1].Doubled) assert.Equal(t, 5, resp.PrimitiveStringObject[1].Len) }) } ================================================ FILE: codegen/testserver/followschema/ptr_to_any.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _PtrToAnyContainer_ptrToAny(ctx context.Context, field graphql.CollectedField, obj *PtrToAnyContainer) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PtrToAnyContainer_ptrToAny, func(ctx context.Context) (any, error) { return obj.PtrToAny, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOAny2ᚖinterface, true, false, ) } func (ec *executionContext) fieldContext_PtrToAnyContainer_ptrToAny(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PtrToAnyContainer", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Any does not have child fields") }, } return fc, nil } func (ec *executionContext) _PtrToAnyContainer_binding(ctx context.Context, field graphql.CollectedField, obj *PtrToAnyContainer) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PtrToAnyContainer_binding, func(ctx context.Context) (any, error) { return obj.Binding(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOAny2ᚖinterface, true, false, ) } func (ec *executionContext) fieldContext_PtrToAnyContainer_binding(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PtrToAnyContainer", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Any does not have child fields") }, } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var ptrToAnyContainerImplementors = []string{"PtrToAnyContainer"} func (ec *executionContext) _PtrToAnyContainer(ctx context.Context, sel ast.SelectionSet, obj *PtrToAnyContainer) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, ptrToAnyContainerImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("PtrToAnyContainer") case "ptrToAny": out.Values[i] = ec._PtrToAnyContainer_ptrToAny(ctx, field, obj) case "binding": out.Values[i] = ec._PtrToAnyContainer_binding(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshalNPtrToAnyContainer2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToAnyContainer(ctx context.Context, sel ast.SelectionSet, v PtrToAnyContainer) graphql.Marshaler { return ec._PtrToAnyContainer(ctx, sel, &v) } func (ec *executionContext) marshalNPtrToAnyContainer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToAnyContainer(ctx context.Context, sel ast.SelectionSet, v *PtrToAnyContainer) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._PtrToAnyContainer(ctx, sel, v) } func (ec *executionContext) unmarshalOAny2interface(ctx context.Context, v any) (any, error) { if v == nil { return nil, nil } res, err := graphql.UnmarshalAny(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOAny2interface(ctx context.Context, sel ast.SelectionSet, v any) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel _ = ctx res := graphql.MarshalAny(v) return res } func (ec *executionContext) unmarshalOAny2ᚖinterface(ctx context.Context, v any) (*any, error) { if v == nil { return nil, nil } res, err := ec.unmarshalOAny2interface(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOAny2ᚖinterface(ctx context.Context, sel ast.SelectionSet, v *any) graphql.Marshaler { return ec.marshalOAny2interface(ctx, sel, *v) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/ptr_to_any.go ================================================ package followschema type PtrToAnyContainer struct { PtrToAny *any } func (c *PtrToAnyContainer) Binding() *any { return c.PtrToAny } ================================================ FILE: codegen/testserver/followschema/ptr_to_any.graphql ================================================ scalar Any type PtrToAnyContainer { ptrToAny: Any binding: Any } extend type Query { ptrToAnyContainer: PtrToAnyContainer! } ================================================ FILE: codegen/testserver/followschema/ptr_to_any_test.go ================================================ package followschema import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestPtrToAny(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) var a any = `{"some":"thing"}` resolvers.QueryResolver.PtrToAnyContainer = func(ctx context.Context) (wrappedStruct *PtrToAnyContainer, e error) { ptrToAnyContainer := PtrToAnyContainer{ PtrToAny: &a, } return &ptrToAnyContainer, nil } t.Run("binding to pointer to any", func(t *testing.T) { var resp struct { PtrToAnyContainer struct { Binding *any } } err := c.Post(`query { ptrToAnyContainer { binding }}`, &resp) require.NoError(t, err) require.Equal(t, &a, resp.PtrToAnyContainer.Binding) }) } ================================================ FILE: codegen/testserver/followschema/ptr_to_ptr_input.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "fmt" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _PtrToPtrInner_key(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrInner) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PtrToPtrInner_key, func(ctx context.Context) (any, error) { return obj.Key, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_PtrToPtrInner_key(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PtrToPtrInner", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _PtrToPtrInner_value(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrInner) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PtrToPtrInner_value, func(ctx context.Context) (any, error) { return obj.Value, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_PtrToPtrInner_value(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PtrToPtrInner", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _PtrToPtrOuter_name(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrOuter) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PtrToPtrOuter_name, func(ctx context.Context) (any, error) { return obj.Name, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_PtrToPtrOuter_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PtrToPtrOuter", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _PtrToPtrOuter_inner(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrOuter) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PtrToPtrOuter_inner, func(ctx context.Context) (any, error) { return obj.Inner, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOPtrToPtrInner2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner, true, false, ) } func (ec *executionContext) fieldContext_PtrToPtrOuter_inner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PtrToPtrOuter", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "key": return ec.fieldContext_PtrToPtrInner_key(ctx, field) case "value": return ec.fieldContext_PtrToPtrInner_value(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type PtrToPtrInner", field.Name) }, } return fc, nil } func (ec *executionContext) _PtrToPtrOuter_stupidInner(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrOuter) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PtrToPtrOuter_stupidInner, func(ctx context.Context) (any, error) { return obj.StupidInner, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner, true, false, ) } func (ec *executionContext) fieldContext_PtrToPtrOuter_stupidInner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PtrToPtrOuter", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "key": return ec.fieldContext_PtrToPtrInner_key(ctx, field) case "value": return ec.fieldContext_PtrToPtrInner_value(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type PtrToPtrInner", field.Name) }, } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** func (ec *executionContext) unmarshalInputUpdatePtrToPtrInner(ctx context.Context, obj any) (UpdatePtrToPtrInner, error) { var it UpdatePtrToPtrInner if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"key", "value"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "key": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("key")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it.Key = data case "value": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("value")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it.Value = data } } return it, nil } func (ec *executionContext) unmarshalInputUpdatePtrToPtrOuter(ctx context.Context, obj any) (UpdatePtrToPtrOuter, error) { var it UpdatePtrToPtrOuter if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"name", "inner", "stupidInner"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "name": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it.Name = data case "inner": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("inner")) data, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx, v) if err != nil { return it, err } it.Inner = data case "stupidInner": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("stupidInner")) data, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx, v) if err != nil { return it, err } it.StupidInner = data } } return it, nil } // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var ptrToPtrInnerImplementors = []string{"PtrToPtrInner"} func (ec *executionContext) _PtrToPtrInner(ctx context.Context, sel ast.SelectionSet, obj *PtrToPtrInner) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, ptrToPtrInnerImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("PtrToPtrInner") case "key": out.Values[i] = ec._PtrToPtrInner_key(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "value": out.Values[i] = ec._PtrToPtrInner_value(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var ptrToPtrOuterImplementors = []string{"PtrToPtrOuter"} func (ec *executionContext) _PtrToPtrOuter(ctx context.Context, sel ast.SelectionSet, obj *PtrToPtrOuter) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, ptrToPtrOuterImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("PtrToPtrOuter") case "name": out.Values[i] = ec._PtrToPtrOuter_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "inner": out.Values[i] = ec._PtrToPtrOuter_inner(ctx, field, obj) case "stupidInner": out.Values[i] = ec._PtrToPtrOuter_stupidInner(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshalNPtrToPtrOuter2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrOuter(ctx context.Context, sel ast.SelectionSet, v PtrToPtrOuter) graphql.Marshaler { return ec._PtrToPtrOuter(ctx, sel, &v) } func (ec *executionContext) marshalNPtrToPtrOuter2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrOuter(ctx context.Context, sel ast.SelectionSet, v *PtrToPtrOuter) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._PtrToPtrOuter(ctx, sel, v) } func (ec *executionContext) unmarshalNUpdatePtrToPtrOuter2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrOuter(ctx context.Context, v any) (UpdatePtrToPtrOuter, error) { res, err := ec.unmarshalInputUpdatePtrToPtrOuter(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOPtrToPtrInner2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v *PtrToPtrInner) graphql.Marshaler { if v == nil { return graphql.Null } return ec._PtrToPtrInner(ctx, sel, v) } func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v **PtrToPtrInner) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOPtrToPtrInner2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx, sel, *v) } func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v ***PtrToPtrInner) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOPtrToPtrInner2ᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx, sel, *v) } func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v ****PtrToPtrInner) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOPtrToPtrInner2ᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx, sel, *v) } func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v *****PtrToPtrInner) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOPtrToPtrInner2ᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx, sel, *v) } func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v ******PtrToPtrInner) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx, sel, *v) } func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v *******PtrToPtrInner) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToPtrInner(ctx, sel, *v) } func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx context.Context, v any) (*UpdatePtrToPtrInner, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputUpdatePtrToPtrInner(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx context.Context, v any) (**UpdatePtrToPtrInner, error) { var pres *UpdatePtrToPtrInner if v != nil { res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx, v) if err != nil { return nil, graphql.ErrorOnPath(ctx, err) } pres = res } return &pres, nil } func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx context.Context, v any) (***UpdatePtrToPtrInner, error) { var pres **UpdatePtrToPtrInner if v != nil { res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx, v) if err != nil { return nil, graphql.ErrorOnPath(ctx, err) } pres = res } return &pres, nil } func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx context.Context, v any) (****UpdatePtrToPtrInner, error) { var pres ***UpdatePtrToPtrInner if v != nil { res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx, v) if err != nil { return nil, graphql.ErrorOnPath(ctx, err) } pres = res } return &pres, nil } func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx context.Context, v any) (*****UpdatePtrToPtrInner, error) { var pres ****UpdatePtrToPtrInner if v != nil { res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx, v) if err != nil { return nil, graphql.ErrorOnPath(ctx, err) } pres = res } return &pres, nil } func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx context.Context, v any) (******UpdatePtrToPtrInner, error) { var pres *****UpdatePtrToPtrInner if v != nil { res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx, v) if err != nil { return nil, graphql.ErrorOnPath(ctx, err) } pres = res } return &pres, nil } func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx context.Context, v any) (*******UpdatePtrToPtrInner, error) { var pres ******UpdatePtrToPtrInner if v != nil { res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx, v) if err != nil { return nil, graphql.ErrorOnPath(ctx, err) } pres = res } return &pres, nil } func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx context.Context, v any) (********UpdatePtrToPtrInner, error) { var pres *******UpdatePtrToPtrInner if v != nil { res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUpdatePtrToPtrInner(ctx, v) if err != nil { return nil, graphql.ErrorOnPath(ctx, err) } pres = res } return &pres, nil } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/ptr_to_ptr_input.go ================================================ package followschema type PtrToPtrOuter struct { Name string Inner *PtrToPtrInner StupidInner *******PtrToPtrInner } type PtrToPtrInner struct { Key string Value string } type UpdatePtrToPtrOuter struct { Name *string Inner **UpdatePtrToPtrInner StupidInner ********UpdatePtrToPtrInner } type UpdatePtrToPtrInner struct { Key *string Value *string } ================================================ FILE: codegen/testserver/followschema/ptr_to_ptr_input.graphql ================================================ type PtrToPtrOuter { name: String! inner: PtrToPtrInner stupidInner: PtrToPtrInner } type PtrToPtrInner { key: String! value: String! } input UpdatePtrToPtrOuter { name: String inner: UpdatePtrToPtrInner stupidInner: UpdatePtrToPtrInner } input UpdatePtrToPtrInner { key: String value: String } extend type Mutation { updatePtrToPtr(input: UpdatePtrToPtrOuter!): PtrToPtrOuter! } ================================================ FILE: codegen/testserver/followschema/ptr_to_ptr_input_test.go ================================================ package followschema import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) type UpdatePtrToPtrResults struct { UpdatedPtrToPtr PtrToPtrOuter `json:"updatePtrToPtr"` } func TestPtrToPtr(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) resolvers.MutationResolver.UpdatePtrToPtr = func(ctx context.Context, in UpdatePtrToPtrOuter) (ret *PtrToPtrOuter, err error) { ret = &PtrToPtrOuter{ Name: "oldName", Inner: &PtrToPtrInner{ Key: "oldKey", Value: "oldValue", }, StupidInner: nest7(&PtrToPtrInner{ Key: "oldStupidKey", Value: "oldStupidValue", }), } if in.Name != nil { ret.Name = *in.Name } if in.Inner != nil { inner := *in.Inner if inner == nil { ret.Inner = nil } else { if in.Inner == nil { ret.Inner = &PtrToPtrInner{} } if inner.Key != nil { ret.Inner.Key = *inner.Key } if inner.Value != nil { ret.Inner.Value = *inner.Value } } } if in.StupidInner != nil { si := *in.StupidInner if si == nil { ret.StupidInner = nil } else { deepIn := ******si deepOut := ******ret.StupidInner if deepIn.Key != nil { deepOut.Key = *deepIn.Key } if deepIn.Value != nil { deepOut.Value = *deepIn.Value } } } return ret, err } t.Run("pointer to pointer input missing", func(t *testing.T) { var resp UpdatePtrToPtrResults err := c.Post( `mutation { updatePtrToPtr(input: { name: "newName" }) { name, inner { key, value }, stupidInner { key, value }}}`, &resp, ) require.NoError(t, err) require.Equal(t, "newName", resp.UpdatedPtrToPtr.Name) require.NotNil(t, resp.UpdatedPtrToPtr.Inner) require.Equal(t, "oldKey", resp.UpdatedPtrToPtr.Inner.Key) require.Equal(t, "oldValue", resp.UpdatedPtrToPtr.Inner.Value) require.NotNil(t, resp.UpdatedPtrToPtr.StupidInner) require.NotNil(t, ******resp.UpdatedPtrToPtr.StupidInner) require.Equal(t, "oldStupidKey", (******resp.UpdatedPtrToPtr.StupidInner).Key) require.Equal(t, "oldStupidValue", (******resp.UpdatedPtrToPtr.StupidInner).Value) }) t.Run("pointer to pointer input non-null", func(t *testing.T) { var resp UpdatePtrToPtrResults err := c.Post(`mutation { updatePtrToPtr(input: { inner: { key: "newKey" value: "newValue" } }) { name, inner { key, value }, stupidInner { key, value }} }`, &resp) require.NoError(t, err) require.Equal(t, "oldName", resp.UpdatedPtrToPtr.Name) require.NotNil(t, resp.UpdatedPtrToPtr.Inner) require.Equal(t, "newKey", resp.UpdatedPtrToPtr.Inner.Key) require.Equal(t, "newValue", resp.UpdatedPtrToPtr.Inner.Value) require.NotNil(t, resp.UpdatedPtrToPtr.StupidInner) require.NotNil(t, ******resp.UpdatedPtrToPtr.StupidInner) require.Equal(t, "oldStupidKey", (******resp.UpdatedPtrToPtr.StupidInner).Key) require.Equal(t, "oldStupidValue", (******resp.UpdatedPtrToPtr.StupidInner).Value) }) t.Run("pointer to pointer input null", func(t *testing.T) { var resp UpdatePtrToPtrResults err := c.Post( `mutation { updatePtrToPtr(input: { inner: null }) { name, inner { key, value }, stupidInner { key, value }}}`, &resp, ) require.NoError(t, err) require.Equal(t, "oldName", resp.UpdatedPtrToPtr.Name) require.Nil(t, resp.UpdatedPtrToPtr.Inner) require.NotNil(t, resp.UpdatedPtrToPtr.StupidInner) require.NotNil(t, ******resp.UpdatedPtrToPtr.StupidInner) require.Equal(t, "oldStupidKey", (******resp.UpdatedPtrToPtr.StupidInner).Key) require.Equal(t, "oldStupidValue", (******resp.UpdatedPtrToPtr.StupidInner).Value) }) t.Run("many pointers input non-null", func(t *testing.T) { var resp UpdatePtrToPtrResults err := c.Post(`mutation { updatePtrToPtr(input: { stupidInner: { key: "newKey" value: "newValue" } }) { name, inner { key, value }, stupidInner { key, value }} }`, &resp) require.NoError(t, err) require.Equal(t, "oldName", resp.UpdatedPtrToPtr.Name) require.NotNil(t, resp.UpdatedPtrToPtr.Inner) require.Equal(t, "oldKey", resp.UpdatedPtrToPtr.Inner.Key) require.Equal(t, "oldValue", resp.UpdatedPtrToPtr.Inner.Value) require.NotNil(t, resp.UpdatedPtrToPtr.StupidInner) require.NotNil(t, ******resp.UpdatedPtrToPtr.StupidInner) require.Equal(t, "newKey", (******resp.UpdatedPtrToPtr.StupidInner).Key) require.Equal(t, "newValue", (******resp.UpdatedPtrToPtr.StupidInner).Value) }) t.Run("many pointers input null", func(t *testing.T) { var resp UpdatePtrToPtrResults err := c.Post( `mutation { updatePtrToPtr(input: { stupidInner: null }) { name, inner { key, value }, stupidInner { key, value }}}`, &resp, ) require.NoError(t, err) require.Equal(t, "oldName", resp.UpdatedPtrToPtr.Name) require.NotNil(t, resp.UpdatedPtrToPtr.Inner) require.Equal(t, "oldKey", resp.UpdatedPtrToPtr.Inner.Key) require.Equal(t, "oldValue", resp.UpdatedPtrToPtr.Inner.Value) require.Nil(t, resp.UpdatedPtrToPtr.StupidInner) }) } func nest7(in *PtrToPtrInner) *******PtrToPtrInner { si2 := &in si3 := &si2 si4 := &si3 si5 := &si4 si6 := &si5 si7 := &si6 return si7 } ================================================ FILE: codegen/testserver/followschema/ptr_to_slice.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _PtrToSliceContainer_ptrToSlice(ctx context.Context, field graphql.CollectedField, obj *PtrToSliceContainer) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PtrToSliceContainer_ptrToSlice, func(ctx context.Context) (any, error) { return obj.PtrToSlice, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2ᚖᚕstringᚄ, true, false, ) } func (ec *executionContext) fieldContext_PtrToSliceContainer_ptrToSlice(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PtrToSliceContainer", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var ptrToSliceContainerImplementors = []string{"PtrToSliceContainer"} func (ec *executionContext) _PtrToSliceContainer(ctx context.Context, sel ast.SelectionSet, obj *PtrToSliceContainer) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, ptrToSliceContainerImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("PtrToSliceContainer") case "ptrToSlice": out.Values[i] = ec._PtrToSliceContainer_ptrToSlice(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshalNPtrToSliceContainer2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToSliceContainer(ctx context.Context, sel ast.SelectionSet, v PtrToSliceContainer) graphql.Marshaler { return ec._PtrToSliceContainer(ctx, sel, &v) } func (ec *executionContext) marshalNPtrToSliceContainer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToSliceContainer(ctx context.Context, sel ast.SelectionSet, v *PtrToSliceContainer) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._PtrToSliceContainer(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/ptr_to_slice.go ================================================ package followschema type PtrToSliceContainer struct { PtrToSlice *[]string } ================================================ FILE: codegen/testserver/followschema/ptr_to_slice.graphql ================================================ type PtrToSliceContainer { ptrToSlice: [String!] } extend type Query { ptrToSliceContainer: PtrToSliceContainer! } ================================================ FILE: codegen/testserver/followschema/ptr_to_slice_test.go ================================================ package followschema import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestPtrToSlice(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) resolvers.QueryResolver.PtrToSliceContainer = func(ctx context.Context) (wrappedStruct *PtrToSliceContainer, e error) { ptrToSliceContainer := PtrToSliceContainer{ PtrToSlice: &[]string{"hello"}, } return &ptrToSliceContainer, nil } t.Run("pointer to slice", func(t *testing.T) { var resp struct { PtrToSliceContainer struct { PtrToSlice []string } } err := c.Post(`query { ptrToSliceContainer { ptrToSlice }}`, &resp) require.NoError(t, err) require.Equal(t, []string{"hello"}, resp.PtrToSliceContainer.PtrToSlice) }) } ================================================ FILE: codegen/testserver/followschema/recursive.go ================================================ package followschema type RecursiveInputSlice struct { Self []RecursiveInputSlice } ================================================ FILE: codegen/testserver/followschema/resolver.go ================================================ package followschema // 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" introspection1 "github.com/99designs/gqlgen/codegen/testserver/followschema/introspection" invalid_packagename "github.com/99designs/gqlgen/codegen/testserver/followschema/invalid-packagename" "github.com/99designs/gqlgen/codegen/testserver/followschema/otherpkg" ) type Resolver struct{} // ID is the resolver for the id field. func (r *backedByInterfaceResolver) ID(ctx context.Context, obj BackedByInterface) (string, error) { panic("not implemented") } // Values is the resolver for the values field. func (r *deferModelResolver) Values(ctx context.Context, obj *DeferModel) ([]string, error) { panic("not implemented") } // A is the resolver for the a field. func (r *errorsResolver) A(ctx context.Context, obj *Errors) (*Error, error) { panic("not implemented") } // B is the resolver for the b field. func (r *errorsResolver) B(ctx context.Context, obj *Errors) (*Error, error) { panic("not implemented") } // C is the resolver for the c field. func (r *errorsResolver) C(ctx context.Context, obj *Errors) (*Error, error) { panic("not implemented") } // D is the resolver for the d field. func (r *errorsResolver) D(ctx context.Context, obj *Errors) (*Error, error) { panic("not implemented") } // E is the resolver for the e field. func (r *errorsResolver) E(ctx context.Context, obj *Errors) (*Error, error) { panic("not implemented") } // Field is the resolver for the field field. func (r *forcedResolverResolver) Field(ctx context.Context, obj *ForcedResolver) (*Circle, error) { panic("not implemented") } // ResolverField is the resolver for the resolverField field. func (r *modelMethodsResolver) ResolverField(ctx context.Context, obj *ModelMethods) (bool, error) { panic("not implemented") } // DefaultInput is the resolver for the defaultInput field. func (r *mutationResolver) DefaultInput(ctx context.Context, input DefaultInput) (*DefaultParametersMirror, error) { panic("not implemented") } // OverrideValueViaInput is the resolver for the overrideValueViaInput field. func (r *mutationResolver) OverrideValueViaInput(ctx context.Context, input FieldsOrderInput) (*FieldsOrderPayload, error) { panic("not implemented") } // UpdateProduct is the resolver for the updateProduct field. func (r *mutationResolver) UpdateProduct(ctx context.Context, input map[string]interface{}) (string, error) { panic("not implemented") } // Issue4053 is the resolver for the issue4053 field. func (r *mutationResolver) Issue4053(ctx context.Context, input *Issue4053Input1) (bool, error) { panic("not implemented") } // UpdateSomething is the resolver for the updateSomething field. func (r *mutationResolver) UpdateSomething(ctx context.Context, input SpecialInput) (string, error) { panic("not implemented") } // UpdatePtrToPtr is the resolver for the updatePtrToPtr field. func (r *mutationResolver) UpdatePtrToPtr(ctx context.Context, input UpdatePtrToPtrOuter) (*PtrToPtrOuter, error) { panic("not implemented") } // OldFoo is the resolver for the oldFoo field. func (r *overlappingFieldsResolver) OldFoo(ctx context.Context, obj *OverlappingFields) (int, error) { panic("not implemented") } // FieldScalarMarshal is the resolver for the fieldScalarMarshal field. func (r *panicsResolver) FieldScalarMarshal(ctx context.Context, obj *Panics) ([]MarshalPanic, error) { panic("not implemented") } // ArgUnmarshal is the resolver for the argUnmarshal field. func (r *panicsResolver) ArgUnmarshal(ctx context.Context, obj *Panics, u []MarshalPanic) (bool, error) { panic("not implemented") } // Friends is the resolver for the friends field. func (r *petResolver) Friends(ctx context.Context, obj *Pet, limit *int) ([]*Pet, error) { panic("not implemented") } // Value is the resolver for the value field. func (r *primitiveResolver) Value(ctx context.Context, obj *Primitive) (int, error) { panic("not implemented") } // Value is the resolver for the value field. func (r *primitiveStringResolver) Value(ctx context.Context, obj *PrimitiveString) (string, error) { panic("not implemented") } // Len is the resolver for the len field. func (r *primitiveStringResolver) Len(ctx context.Context, obj *PrimitiveString) (int, error) { panic("not implemented") } // InvalidIdentifier is the resolver for the invalidIdentifier field. func (r *queryResolver) InvalidIdentifier(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) { panic("not implemented") } // Collision is the resolver for the collision field. func (r *queryResolver) Collision(ctx context.Context) (*introspection1.It, error) { panic("not implemented") } // MapInput is the resolver for the mapInput field. func (r *queryResolver) MapInput(ctx context.Context, input map[string]any) (*bool, error) { panic("not implemented") } // Recursive is the resolver for the recursive field. func (r *queryResolver) Recursive(ctx context.Context, input *RecursiveInputSlice) (*bool, error) { panic("not implemented") } // NestedInputs is the resolver for the nestedInputs field. func (r *queryResolver) NestedInputs(ctx context.Context, input [][]*OuterInput) (*bool, error) { panic("not implemented") } // NestedOutputs is the resolver for the nestedOutputs field. func (r *queryResolver) NestedOutputs(ctx context.Context) ([][]*OuterObject, error) { panic("not implemented") } // ModelMethods is the resolver for the modelMethods field. func (r *queryResolver) ModelMethods(ctx context.Context) (*ModelMethods, error) { panic("not implemented") } // User is the resolver for the user field. func (r *queryResolver) User(ctx context.Context, id int) (*User, error) { panic("not implemented") } // NullableArg is the resolver for the nullableArg field. func (r *queryResolver) NullableArg(ctx context.Context, arg *int) (*string, error) { panic("not implemented") } // InputSlice is the resolver for the inputSlice field. func (r *queryResolver) InputSlice(ctx context.Context, arg []string) (bool, error) { panic("not implemented") } // InputNullableSlice is the resolver for the inputNullableSlice field. func (r *queryResolver) InputNullableSlice(ctx context.Context, arg []string) (bool, error) { panic("not implemented") } // InputOmittable is the resolver for the inputOmittable field. func (r *queryResolver) InputOmittable(ctx context.Context, arg OmittableInput) (string, error) { panic("not implemented") } // ShapeUnion is the resolver for the shapeUnion field. func (r *queryResolver) ShapeUnion(ctx context.Context) (ShapeUnion, error) { panic("not implemented") } // Autobind is the resolver for the autobind field. func (r *queryResolver) Autobind(ctx context.Context) (*Autobind, error) { panic("not implemented") } // DeprecatedField is the resolver for the deprecatedField field. func (r *queryResolver) DeprecatedField(ctx context.Context) (string, error) { panic("not implemented") } // FieldWithDeprecatedArg is the resolver for the fieldWithDeprecatedArg field. func (r *queryResolver) FieldWithDeprecatedArg(ctx context.Context, oldArg *int, newArg *int) (*string, error) { panic("not implemented") } // Overlapping is the resolver for the overlapping field. func (r *queryResolver) Overlapping(ctx context.Context) (*OverlappingFields, error) { panic("not implemented") } // DefaultParameters is the resolver for the defaultParameters field. func (r *queryResolver) DefaultParameters(ctx context.Context, falsyBoolean *bool, truthyBoolean *bool) (*DefaultParametersMirror, error) { panic("not implemented") } // DeferSingle is the resolver for the deferSingle field. func (r *queryResolver) DeferSingle(ctx context.Context) (*DeferModel, error) { panic("not implemented") } // DeferMultiple is the resolver for the deferMultiple field. func (r *queryResolver) DeferMultiple(ctx context.Context) ([]*DeferModel, error) { panic("not implemented") } // DirectiveArg is the resolver for the directiveArg field. func (r *queryResolver) DirectiveArg(ctx context.Context, arg string) (*string, error) { panic("not implemented") } // DirectiveNullableArg is the resolver for the directiveNullableArg field. func (r *queryResolver) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (*string, error) { panic("not implemented") } // DirectiveSingleNullableArg is the resolver for the directiveSingleNullableArg field. func (r *queryResolver) DirectiveSingleNullableArg(ctx context.Context, arg1 *string) (*string, error) { panic("not implemented") } // DirectiveInputNullable is the resolver for the directiveInputNullable field. func (r *queryResolver) DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) { panic("not implemented") } // DirectiveInput is the resolver for the directiveInput field. func (r *queryResolver) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) { panic("not implemented") } // DirectiveInputType is the resolver for the directiveInputType field. func (r *queryResolver) DirectiveInputType(ctx context.Context, arg InnerInput) (*string, error) { panic("not implemented") } // DirectiveInputOuter is the resolver for the directiveInputOuter field. func (r *queryResolver) DirectiveInputOuter(ctx context.Context, arg OuterWrapperInput) (*string, error) { panic("not implemented") } // DirectiveObject is the resolver for the directiveObject field. func (r *queryResolver) DirectiveObject(ctx context.Context) (*ObjectDirectives, error) { panic("not implemented") } // DirectiveObjectWithCustomGoModel is the resolver for the directiveObjectWithCustomGoModel field. func (r *queryResolver) DirectiveObjectWithCustomGoModel(ctx context.Context) (*ObjectDirectivesWithCustomGoModel, error) { panic("not implemented") } // DirectiveFieldDef is the resolver for the directiveFieldDef field. func (r *queryResolver) DirectiveFieldDef(ctx context.Context, ret string) (string, error) { panic("not implemented") } // DirectiveField is the resolver for the directiveField field. func (r *queryResolver) DirectiveField(ctx context.Context) (*string, error) { panic("not implemented") } // DirectiveDouble is the resolver for the directiveDouble field. func (r *queryResolver) DirectiveDouble(ctx context.Context) (*string, error) { panic("not implemented") } // DirectiveUnimplemented is the resolver for the directiveUnimplemented field. func (r *queryResolver) DirectiveUnimplemented(ctx context.Context) (*string, error) { panic("not implemented") } // EmbeddedCase1 is the resolver for the embeddedCase1 field. func (r *queryResolver) EmbeddedCase1(ctx context.Context) (*EmbeddedCase1, error) { panic("not implemented") } // EmbeddedCase2 is the resolver for the embeddedCase2 field. func (r *queryResolver) EmbeddedCase2(ctx context.Context) (*EmbeddedCase2, error) { panic("not implemented") } // EmbeddedCase3 is the resolver for the embeddedCase3 field. func (r *queryResolver) EmbeddedCase3(ctx context.Context) (*EmbeddedCase3, error) { panic("not implemented") } // EnumInInput is the resolver for the enumInInput field. func (r *queryResolver) EnumInInput(ctx context.Context, input *InputWithEnumValue) (EnumTest, error) { panic("not implemented") } // SearchProducts is the resolver for the searchProducts field. func (r *queryResolver) SearchProducts(ctx context.Context, filters map[string]interface{}) ([]string, error) { panic("not implemented") } // SearchRequired is the resolver for the searchRequired field. func (r *queryResolver) SearchRequired(ctx context.Context, filters map[string]interface{}) ([]string, error) { panic("not implemented") } // SearchProductsNormal is the resolver for the searchProductsNormal field. func (r *queryResolver) SearchProductsNormal(ctx context.Context, filters map[string]any) ([]string, error) { panic("not implemented") } // SearchWithDefaults is the resolver for the searchWithDefaults field. func (r *queryResolver) SearchWithDefaults(ctx context.Context, filters map[string]interface{}) ([]string, error) { panic("not implemented") } // SearchMixed is the resolver for the searchMixed field. func (r *queryResolver) SearchMixed(ctx context.Context, filters map[string]interface{}, limit *int, offset *int, sortBy *string) ([]string, error) { panic("not implemented") } // FilterProducts is the resolver for the filterProducts field. func (r *queryResolver) FilterProducts(ctx context.Context, filters map[string]interface{}) ([]string, error) { panic("not implemented") } // FindProducts is the resolver for the findProducts field. func (r *queryResolver) FindProducts(ctx context.Context, filters map[string]interface{}) ([]string, error) { panic("not implemented") } // SearchWithDirectives is the resolver for the searchWithDirectives field. func (r *queryResolver) SearchWithDirectives(ctx context.Context, input map[string]interface{}) ([]string, error) { panic("not implemented") } // Shapes is the resolver for the shapes field. func (r *queryResolver) Shapes(ctx context.Context) ([]Shape, error) { panic("not implemented") } // NoShape is the resolver for the noShape field. func (r *queryResolver) NoShape(ctx context.Context) (Shape, error) { panic("not implemented") } // Node is the resolver for the node field. func (r *queryResolver) Node(ctx context.Context) (Node, error) { panic("not implemented") } // NoShapeTypedNil is the resolver for the noShapeTypedNil field. func (r *queryResolver) NoShapeTypedNil(ctx context.Context) (Shape, error) { panic("not implemented") } // Animal is the resolver for the animal field. func (r *queryResolver) Animal(ctx context.Context) (Animal, error) { panic("not implemented") } // NotAnInterface is the resolver for the notAnInterface field. func (r *queryResolver) NotAnInterface(ctx context.Context) (BackedByInterface, error) { panic("not implemented") } // Dog is the resolver for the dog field. func (r *queryResolver) Dog(ctx context.Context) (*Dog, error) { panic("not implemented") } // Issue896a is the resolver for the issue896a field. func (r *queryResolver) Issue896a(ctx context.Context) ([]*CheckIssue896, error) { panic("not implemented") } // MapStringInterface is the resolver for the mapStringInterface field. func (r *queryResolver) MapStringInterface(ctx context.Context, in map[string]any) (map[string]any, error) { panic("not implemented") } // MapNestedStringInterface is the resolver for the mapNestedStringInterface field. func (r *queryResolver) MapNestedStringInterface(ctx context.Context, in *NestedMapInput) (map[string]any, error) { panic("not implemented") } // MapNestedMapSlice is the resolver for the mapNestedMapSlice field. func (r *queryResolver) MapNestedMapSlice(ctx context.Context, input map[string]any) (*bool, error) { panic("not implemented") } // ErrorBubble is the resolver for the errorBubble field. func (r *queryResolver) ErrorBubble(ctx context.Context) (*Error, error) { panic("not implemented") } // ErrorBubbleList is the resolver for the errorBubbleList field. func (r *queryResolver) ErrorBubbleList(ctx context.Context) ([]*Error, error) { panic("not implemented") } // ErrorList is the resolver for the errorList field. func (r *queryResolver) ErrorList(ctx context.Context) ([]*Error, error) { panic("not implemented") } // Errors is the resolver for the errors field. func (r *queryResolver) Errors(ctx context.Context) (*Errors, error) { panic("not implemented") } // Valid is the resolver for the valid field. func (r *queryResolver) Valid(ctx context.Context) (string, error) { panic("not implemented") } // Invalid is the resolver for the invalid field. func (r *queryResolver) Invalid(ctx context.Context) (string, error) { panic("not implemented") } // Panics is the resolver for the panics field. func (r *queryResolver) Panics(ctx context.Context) (*Panics, error) { panic("not implemented") } // PrimitiveObject is the resolver for the primitiveObject field. func (r *queryResolver) PrimitiveObject(ctx context.Context) ([]Primitive, error) { panic("not implemented") } // PrimitiveStringObject is the resolver for the primitiveStringObject field. func (r *queryResolver) PrimitiveStringObject(ctx context.Context) ([]PrimitiveString, error) { panic("not implemented") } // PtrToAnyContainer is the resolver for the ptrToAnyContainer field. func (r *queryResolver) PtrToAnyContainer(ctx context.Context) (*PtrToAnyContainer, error) { panic("not implemented") } // PtrToSliceContainer is the resolver for the ptrToSliceContainer field. func (r *queryResolver) PtrToSliceContainer(ctx context.Context) (*PtrToSliceContainer, error) { panic("not implemented") } // Infinity is the resolver for the infinity field. func (r *queryResolver) Infinity(ctx context.Context) (float64, error) { panic("not implemented") } // StringFromContextInterface is the resolver for the stringFromContextInterface field. func (r *queryResolver) StringFromContextInterface(ctx context.Context) (*StringFromContextInterface, error) { panic("not implemented") } // StringFromContextFunction is the resolver for the stringFromContextFunction field. func (r *queryResolver) StringFromContextFunction(ctx context.Context) (string, error) { panic("not implemented") } // DefaultScalar is the resolver for the defaultScalar field. func (r *queryResolver) DefaultScalar(ctx context.Context, arg string) (string, error) { panic("not implemented") } // SkipInclude is the resolver for the skipInclude field. func (r *queryResolver) SkipInclude(ctx context.Context) (*SkipIncludeTestType, error) { panic("not implemented") } // Slices is the resolver for the slices field. func (r *queryResolver) Slices(ctx context.Context) (*Slices, error) { panic("not implemented") } // ScalarSlice is the resolver for the scalarSlice field. func (r *queryResolver) ScalarSlice(ctx context.Context) ([]byte, error) { panic("not implemented") } // Fallback is the resolver for the fallback field. func (r *queryResolver) Fallback(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) { panic("not implemented") } // OptionalUnion is the resolver for the optionalUnion field. func (r *queryResolver) OptionalUnion(ctx context.Context) (TestUnion, error) { panic("not implemented") } // VOkCaseValue is the resolver for the vOkCaseValue field. func (r *queryResolver) VOkCaseValue(ctx context.Context) (*VOkCaseValue, error) { panic("not implemented") } // VOkCaseNil is the resolver for the vOkCaseNil field. func (r *queryResolver) VOkCaseNil(ctx context.Context) (*VOkCaseNil, error) { panic("not implemented") } // ValidType is the resolver for the validType field. func (r *queryResolver) ValidType(ctx context.Context) (*ValidType, error) { panic("not implemented") } // VariadicModel is the resolver for the variadicModel field. func (r *queryResolver) VariadicModel(ctx context.Context) (*VariadicModel, error) { panic("not implemented") } // WrappedStruct is the resolver for the wrappedStruct field. func (r *queryResolver) WrappedStruct(ctx context.Context) (*WrappedStruct, error) { panic("not implemented") } // WrappedScalar is the resolver for the wrappedScalar field. func (r *queryResolver) WrappedScalar(ctx context.Context) (otherpkg.Scalar, error) { panic("not implemented") } // WrappedMap is the resolver for the wrappedMap field. func (r *queryResolver) WrappedMap(ctx context.Context) (WrappedMap, error) { panic("not implemented") } // WrappedSlice is the resolver for the wrappedSlice field. func (r *queryResolver) WrappedSlice(ctx context.Context) (WrappedSlice, error) { panic("not implemented") } // Updated is the resolver for the updated field. func (r *subscriptionResolver) Updated(ctx context.Context) (<-chan string, error) { panic("not implemented") } // InitPayload is the resolver for the initPayload field. func (r *subscriptionResolver) InitPayload(ctx context.Context) (<-chan string, error) { panic("not implemented") } // DirectiveArg is the resolver for the directiveArg field. func (r *subscriptionResolver) DirectiveArg(ctx context.Context, arg string) (<-chan *string, error) { panic("not implemented") } // DirectiveNullableArg is the resolver for the directiveNullableArg field. func (r *subscriptionResolver) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (<-chan *string, error) { panic("not implemented") } // DirectiveDouble is the resolver for the directiveDouble field. func (r *subscriptionResolver) DirectiveDouble(ctx context.Context) (<-chan *string, error) { panic("not implemented") } // DirectiveUnimplemented is the resolver for the directiveUnimplemented field. func (r *subscriptionResolver) DirectiveUnimplemented(ctx context.Context) (<-chan *string, error) { panic("not implemented") } // Issue896b is the resolver for the issue896b field. func (r *subscriptionResolver) Issue896b(ctx context.Context) (<-chan []*CheckIssue896, error) { panic("not implemented") } // ErrorRequired is the resolver for the errorRequired field. func (r *subscriptionResolver) ErrorRequired(ctx context.Context) (<-chan *Error, error) { panic("not implemented") } // Friends is the resolver for the friends field. func (r *userResolver) Friends(ctx context.Context, obj *User) ([]*User, error) { panic("not implemented") } // Pets is the resolver for the pets field. func (r *userResolver) Pets(ctx context.Context, obj *User, limit *int) ([]*Pet, error) { panic("not implemented") } // Get is the resolver for the get field. func (r *wrappedMapResolver) Get(ctx context.Context, obj WrappedMap, key string) (string, error) { panic("not implemented") } // Get is the resolver for the get field. func (r *wrappedSliceResolver) Get(ctx context.Context, obj WrappedSlice, idx int) (string, error) { panic("not implemented") } // BackedByInterface returns BackedByInterfaceResolver implementation. func (r *Resolver) BackedByInterface() BackedByInterfaceResolver { return &backedByInterfaceResolver{r} } // DeferModel returns DeferModelResolver implementation. func (r *Resolver) DeferModel() DeferModelResolver { return &deferModelResolver{r} } // Errors returns ErrorsResolver implementation. func (r *Resolver) Errors() ErrorsResolver { return &errorsResolver{r} } // ForcedResolver returns ForcedResolverResolver implementation. func (r *Resolver) ForcedResolver() ForcedResolverResolver { return &forcedResolverResolver{r} } // ModelMethods returns ModelMethodsResolver implementation. func (r *Resolver) ModelMethods() ModelMethodsResolver { return &modelMethodsResolver{r} } // Mutation returns MutationResolver implementation. func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } // OverlappingFields returns OverlappingFieldsResolver implementation. func (r *Resolver) OverlappingFields() OverlappingFieldsResolver { return &overlappingFieldsResolver{r} } // Panics returns PanicsResolver implementation. func (r *Resolver) Panics() PanicsResolver { return &panicsResolver{r} } // Pet returns PetResolver implementation. func (r *Resolver) Pet() PetResolver { return &petResolver{r} } // Primitive returns PrimitiveResolver implementation. func (r *Resolver) Primitive() PrimitiveResolver { return &primitiveResolver{r} } // PrimitiveString returns PrimitiveStringResolver implementation. func (r *Resolver) PrimitiveString() PrimitiveStringResolver { return &primitiveStringResolver{r} } // Query returns QueryResolver implementation. func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } // Subscription returns SubscriptionResolver implementation. func (r *Resolver) Subscription() SubscriptionResolver { return &subscriptionResolver{r} } // User returns UserResolver implementation. func (r *Resolver) User() UserResolver { return &userResolver{r} } // WrappedMap returns WrappedMapResolver implementation. func (r *Resolver) WrappedMap() WrappedMapResolver { return &wrappedMapResolver{r} } // WrappedSlice returns WrappedSliceResolver implementation. func (r *Resolver) WrappedSlice() WrappedSliceResolver { return &wrappedSliceResolver{r} } type backedByInterfaceResolver struct{ *Resolver } type deferModelResolver struct{ *Resolver } type errorsResolver struct{ *Resolver } type forcedResolverResolver struct{ *Resolver } type modelMethodsResolver struct{ *Resolver } type mutationResolver struct{ *Resolver } type overlappingFieldsResolver struct{ *Resolver } type panicsResolver struct{ *Resolver } type petResolver struct{ *Resolver } type primitiveResolver struct{ *Resolver } type primitiveStringResolver struct{ *Resolver } type queryResolver struct{ *Resolver } type subscriptionResolver struct{ *Resolver } type userResolver struct{ *Resolver } type wrappedMapResolver struct{ *Resolver } type wrappedSliceResolver struct{ *Resolver } ================================================ FILE: codegen/testserver/followschema/response_extension_test.go ================================================ package followschema import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestResponseExtension(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.Valid = func(ctx context.Context) (s string, e error) { return "Ok", nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) srv.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { graphql.RegisterExtension(ctx, "example", "value") return next(ctx) }) c := client.New(srv) raw, _ := c.RawPost(`query { valid }`) require.Equal(t, "value", raw.Extensions["example"]) } ================================================ FILE: codegen/testserver/followschema/root_.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "bytes" "context" "sync/atomic" "github.com/99designs/gqlgen/graphql" gqlparser "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" ) // NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { return &executableSchema{SchemaData: cfg.Schema, Resolvers: cfg.Resolvers, Directives: cfg.Directives, ComplexityRoot: cfg.Complexity} } type Config = graphql.Config[ResolverRoot, DirectiveRoot, ComplexityRoot] type ResolverRoot interface { BackedByInterface() BackedByInterfaceResolver DeferModel() DeferModelResolver Errors() ErrorsResolver ForcedResolver() ForcedResolverResolver ModelMethods() ModelMethodsResolver Mutation() MutationResolver OverlappingFields() OverlappingFieldsResolver Panics() PanicsResolver Pet() PetResolver Primitive() PrimitiveResolver PrimitiveString() PrimitiveStringResolver Query() QueryResolver Subscription() SubscriptionResolver User() UserResolver WrappedMap() WrappedMapResolver WrappedSlice() WrappedSliceResolver FieldsOrderInput() FieldsOrderInputResolver } type DirectiveRoot struct { Custom func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) Defer func(ctx context.Context, obj any, next graphql.Resolver, ifArg *bool, label *string) (res any, err error) Directive1 func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) Directive2 func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) Directive3 func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) Length func(ctx context.Context, obj any, next graphql.Resolver, min int, max *int, message *string) (res any, err error) Logged func(ctx context.Context, obj any, next graphql.Resolver, id string) (res any, err error) MakeNil func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) MakeTypedNil func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) Noop func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) Order1 func(ctx context.Context, obj any, next graphql.Resolver, location string) (res any, err error) Order2 func(ctx context.Context, obj any, next graphql.Resolver, location string) (res any, err error) Populate func(ctx context.Context, obj any, next graphql.Resolver, value string) (res any, err error) Range func(ctx context.Context, obj any, next graphql.Resolver, min *int, max *int) (res any, err error) ToNull func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) Unimplemented func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) } type ComplexityRoot struct { A struct { ID func(childComplexity int) int } AIt struct { ID func(childComplexity int) int } AbIt struct { ID func(childComplexity int) int } Autobind struct { IdInt func(childComplexity int) int IdStr func(childComplexity int) int Int func(childComplexity int) int Int32 func(childComplexity int) int Int64 func(childComplexity int) int } B struct { ID func(childComplexity int) int } BackedByInterface struct { ID func(childComplexity int) int ThisShouldBind func(childComplexity int) int ThisShouldBindWithError func(childComplexity int) int } Cat struct { CatBreed func(childComplexity int) int Size func(childComplexity int) int Species func(childComplexity int) int } CheckIssue896 struct { ID func(childComplexity int) int } Circle struct { Area func(childComplexity int) int Coordinates func(childComplexity int) int Radius func(childComplexity int) int } ConcreteNodeA struct { Child func(childComplexity int) int ID func(childComplexity int) int Name func(childComplexity int) int } ConcreteNodeInterface struct { Child func(childComplexity int) int ID func(childComplexity int) int } Content_Post struct { Foo func(childComplexity int) int } Content_User struct { Foo func(childComplexity int) int } Coordinates struct { X func(childComplexity int) int Y func(childComplexity int) int } DefaultParametersMirror struct { FalsyBoolean func(childComplexity int) int TruthyBoolean func(childComplexity int) int } DeferModel struct { ID func(childComplexity int) int Name func(childComplexity int) int Values func(childComplexity int) int } Dog struct { DogBreed func(childComplexity int) int Size func(childComplexity int) int Species func(childComplexity int) int } EmbeddedCase1 struct { ExportedEmbeddedPointerExportedMethod func(childComplexity int) int } EmbeddedCase2 struct { UnexportedEmbeddedPointerExportedMethod func(childComplexity int) int } EmbeddedCase3 struct { UnexportedEmbeddedInterfaceExportedMethod func(childComplexity int) int } EmbeddedDefaultScalar struct { Value func(childComplexity int) int } EmbeddedPointer struct { ID func(childComplexity int) int Title func(childComplexity int) int } Error struct { ErrorOnNonRequiredField func(childComplexity int) int ErrorOnRequiredField func(childComplexity int) int ID func(childComplexity int) int NilOnRequiredField func(childComplexity int) int } Errors struct { A func(childComplexity int) int B func(childComplexity int) int C func(childComplexity int) int D func(childComplexity int) int E func(childComplexity int) int } FieldsOrderPayload struct { FirstFieldValue func(childComplexity int) int } ForcedResolver struct { Field func(childComplexity int) int } Horse struct { HorseBreed func(childComplexity int) int Size func(childComplexity int) int Species func(childComplexity int) int } InnerObject struct { ID func(childComplexity int) int } InvalidIdentifier struct { ID func(childComplexity int) int } It struct { ID func(childComplexity int) int } LoopA struct { B func(childComplexity int) int } LoopB struct { A func(childComplexity int) int } Map struct { ID func(childComplexity int) int } MapNested struct { Value func(childComplexity int) int } MapStringInterfaceType struct { A func(childComplexity int) int B func(childComplexity int) int C func(childComplexity int) int Nested func(childComplexity int) int } ModelMethods struct { NoContext func(childComplexity int) int ResolverField func(childComplexity int) int WithContext func(childComplexity int) int } Mutation struct { DefaultInput func(childComplexity int, input DefaultInput) int Issue4053 func(childComplexity int, input *Issue4053Input1) int OverrideValueViaInput func(childComplexity int, input FieldsOrderInput) int UpdateProduct func(childComplexity int, id string, name *string, price *float64) int UpdatePtrToPtr func(childComplexity int, input UpdatePtrToPtrOuter) int UpdateSomething func(childComplexity int, input SpecialInput) int } ObjectDirectives struct { NullableText func(childComplexity int) int Order func(childComplexity int) int Text func(childComplexity int) int } ObjectDirectivesWithCustomGoModel struct { NullableText func(childComplexity int) int } OuterObject struct { Inner func(childComplexity int) int } OverlappingFields struct { Foo func(childComplexity int) int NewFoo func(childComplexity int) int OldFoo func(childComplexity int) int } Panics struct { ArgUnmarshal func(childComplexity int, u []MarshalPanic) int FieldFuncMarshal func(childComplexity int, u []MarshalPanic) int FieldScalarMarshal func(childComplexity int) int } Pet struct { Friends func(childComplexity int, limit *int) int ID func(childComplexity int) int } Primitive struct { Squared func(childComplexity int) int Value func(childComplexity int) int } PrimitiveString struct { Doubled func(childComplexity int) int Len func(childComplexity int) int Value func(childComplexity int) int } PtrToAnyContainer struct { Binding func(childComplexity int) int PtrToAny func(childComplexity int) int } PtrToPtrInner struct { Key func(childComplexity int) int Value func(childComplexity int) int } PtrToPtrOuter struct { Inner func(childComplexity int) int Name func(childComplexity int) int StupidInner func(childComplexity int) int } PtrToSliceContainer struct { PtrToSlice func(childComplexity int) int } Query struct { Animal func(childComplexity int) int Autobind func(childComplexity int) int Collision func(childComplexity int) int DefaultParameters func(childComplexity int, falsyBoolean *bool, truthyBoolean *bool) int DefaultScalar func(childComplexity int, arg string) int DeferMultiple func(childComplexity int) int DeferSingle func(childComplexity int) int DeprecatedField func(childComplexity int) int DirectiveArg func(childComplexity int, arg string) int DirectiveDouble func(childComplexity int) int DirectiveField func(childComplexity int) int DirectiveFieldDef func(childComplexity int, ret string) int DirectiveInput func(childComplexity int, arg InputDirectives) int DirectiveInputNullable func(childComplexity int, arg *InputDirectives) int DirectiveInputOuter func(childComplexity int, arg OuterWrapperInput) int DirectiveInputType func(childComplexity int, arg InnerInput) int DirectiveNullableArg func(childComplexity int, arg *int, arg2 *int, arg3 *string) int DirectiveObject func(childComplexity int) int DirectiveObjectWithCustomGoModel func(childComplexity int) int DirectiveSingleNullableArg func(childComplexity int, arg1 *string) int DirectiveUnimplemented func(childComplexity int) int Dog func(childComplexity int) int EmbeddedCase1 func(childComplexity int) int EmbeddedCase2 func(childComplexity int) int EmbeddedCase3 func(childComplexity int) int EnumInInput func(childComplexity int, input *InputWithEnumValue) int ErrorBubble func(childComplexity int) int ErrorBubbleList func(childComplexity int) int ErrorList func(childComplexity int) int Errors func(childComplexity int) int Fallback func(childComplexity int, arg FallbackToStringEncoding) int FieldWithDeprecatedArg func(childComplexity int, oldArg *int, newArg *int) int FilterProducts func(childComplexity int, query *string, category *string, minPrice *int) int FindProducts func(childComplexity int, query *string, category *string, minPrice *int) int Infinity func(childComplexity int) int InputNullableSlice func(childComplexity int, arg []string) int InputOmittable func(childComplexity int, arg OmittableInput) int InputSlice func(childComplexity int, arg []string) int Invalid func(childComplexity int) int InvalidIdentifier func(childComplexity int) int Issue896a func(childComplexity int) int MapInput func(childComplexity int, input map[string]any) int MapNestedMapSlice func(childComplexity int, input map[string]any) int MapNestedStringInterface func(childComplexity int, in *NestedMapInput) int MapStringInterface func(childComplexity int, in map[string]any) int ModelMethods func(childComplexity int) int NestedInputs func(childComplexity int, input [][]*OuterInput) int NestedOutputs func(childComplexity int) int NoShape func(childComplexity int) int NoShapeTypedNil func(childComplexity int) int Node func(childComplexity int) int NotAnInterface func(childComplexity int) int NullableArg func(childComplexity int, arg *int) int OptionalUnion func(childComplexity int) int Overlapping func(childComplexity int) int Panics func(childComplexity int) int PrimitiveObject func(childComplexity int) int PrimitiveStringObject func(childComplexity int) int PtrToAnyContainer func(childComplexity int) int PtrToSliceContainer func(childComplexity int) int Recursive func(childComplexity int, input *RecursiveInputSlice) int ScalarSlice func(childComplexity int) int SearchMixed func(childComplexity int, query *string, category *string, minPrice *int, limit *int, offset *int, sortBy *string) int SearchProducts func(childComplexity int, query *string, category *string, minPrice *int) int SearchProductsNormal func(childComplexity int, filters map[string]any) int SearchRequired func(childComplexity int, name string, age int) int SearchWithDefaults func(childComplexity int, query *string, limit *int, includeArchived *bool) int SearchWithDirectives func(childComplexity int, oldField *string, newField *string) int ShapeUnion func(childComplexity int) int Shapes func(childComplexity int) int SkipInclude func(childComplexity int) int Slices func(childComplexity int) int StringFromContextFunction func(childComplexity int) int StringFromContextInterface func(childComplexity int) int User func(childComplexity int, id int) int VOkCaseNil func(childComplexity int) int VOkCaseValue func(childComplexity int) int Valid func(childComplexity int) int ValidType func(childComplexity int) int VariadicModel func(childComplexity int) int WrappedMap func(childComplexity int) int WrappedScalar func(childComplexity int) int WrappedSlice func(childComplexity int) int WrappedStruct func(childComplexity int) int } Rectangle struct { Area func(childComplexity int) int Coordinates func(childComplexity int) int Length func(childComplexity int) int Width func(childComplexity int) int } Size struct { Height func(childComplexity int) int Weight func(childComplexity int) int } SkipIncludeTestType struct { A func(childComplexity int) int B func(childComplexity int) int } Slices struct { Test1 func(childComplexity int) int Test2 func(childComplexity int) int Test3 func(childComplexity int) int Test4 func(childComplexity int) int } Subscription struct { DirectiveArg func(childComplexity int, arg string) int DirectiveDouble func(childComplexity int) int DirectiveNullableArg func(childComplexity int, arg *int, arg2 *int, arg3 *string) int DirectiveUnimplemented func(childComplexity int) int ErrorRequired func(childComplexity int) int InitPayload func(childComplexity int) int Issue896b func(childComplexity int) int Updated func(childComplexity int) int } User struct { Created func(childComplexity int) int Friends func(childComplexity int) int ID func(childComplexity int) int Pets func(childComplexity int, limit *int) int Updated func(childComplexity int) int } VOkCaseNil struct { Value func(childComplexity int) int } VOkCaseValue struct { Value func(childComplexity int) int } ValidType struct { DifferentCase func(childComplexity int) int DifferentCaseOld func(childComplexity int) int ValidArgs func(childComplexity int, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string, _ string) int ValidInputKeywords func(childComplexity int, input *ValidInput) int } VariadicModel struct { Value func(childComplexity int, rank int) int } WrappedMap struct { Get func(childComplexity int, key string) int } WrappedSlice struct { Get func(childComplexity int, idx int) int } WrappedStruct struct { Desc func(childComplexity int) int Name func(childComplexity int) int } XXIt struct { ID func(childComplexity int) int } XxIt struct { ID func(childComplexity int) int } AsdfIt struct { ID func(childComplexity int) int } IIt struct { ID func(childComplexity int) int } } type executableSchema 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 "A.id": if e.ComplexityRoot.A.ID == nil { break } return e.ComplexityRoot.A.ID(childComplexity), true case "AIt.id": if e.ComplexityRoot.AIt.ID == nil { break } return e.ComplexityRoot.AIt.ID(childComplexity), true case "AbIt.id": if e.ComplexityRoot.AbIt.ID == nil { break } return e.ComplexityRoot.AbIt.ID(childComplexity), true case "Autobind.idInt": if e.ComplexityRoot.Autobind.IdInt == nil { break } return e.ComplexityRoot.Autobind.IdInt(childComplexity), true case "Autobind.idStr": if e.ComplexityRoot.Autobind.IdStr == nil { break } return e.ComplexityRoot.Autobind.IdStr(childComplexity), true case "Autobind.int": if e.ComplexityRoot.Autobind.Int == nil { break } return e.ComplexityRoot.Autobind.Int(childComplexity), true case "Autobind.int32": if e.ComplexityRoot.Autobind.Int32 == nil { break } return e.ComplexityRoot.Autobind.Int32(childComplexity), true case "Autobind.int64": if e.ComplexityRoot.Autobind.Int64 == nil { break } return e.ComplexityRoot.Autobind.Int64(childComplexity), true case "B.id": if e.ComplexityRoot.B.ID == nil { break } return e.ComplexityRoot.B.ID(childComplexity), true case "BackedByInterface.id": if e.ComplexityRoot.BackedByInterface.ID == nil { break } return e.ComplexityRoot.BackedByInterface.ID(childComplexity), true case "BackedByInterface.thisShouldBind": if e.ComplexityRoot.BackedByInterface.ThisShouldBind == nil { break } return e.ComplexityRoot.BackedByInterface.ThisShouldBind(childComplexity), true case "BackedByInterface.thisShouldBindWithError": if e.ComplexityRoot.BackedByInterface.ThisShouldBindWithError == nil { break } return e.ComplexityRoot.BackedByInterface.ThisShouldBindWithError(childComplexity), true case "Cat.catBreed": if e.ComplexityRoot.Cat.CatBreed == nil { break } return e.ComplexityRoot.Cat.CatBreed(childComplexity), true case "Cat.size": if e.ComplexityRoot.Cat.Size == nil { break } return e.ComplexityRoot.Cat.Size(childComplexity), true case "Cat.species": if e.ComplexityRoot.Cat.Species == nil { break } return e.ComplexityRoot.Cat.Species(childComplexity), true case "CheckIssue896.id": if e.ComplexityRoot.CheckIssue896.ID == nil { break } return e.ComplexityRoot.CheckIssue896.ID(childComplexity), true case "Circle.area": if e.ComplexityRoot.Circle.Area == nil { break } return e.ComplexityRoot.Circle.Area(childComplexity), true case "Circle.coordinates": if e.ComplexityRoot.Circle.Coordinates == nil { break } return e.ComplexityRoot.Circle.Coordinates(childComplexity), true case "Circle.radius": if e.ComplexityRoot.Circle.Radius == nil { break } return e.ComplexityRoot.Circle.Radius(childComplexity), true case "ConcreteNodeA.child": if e.ComplexityRoot.ConcreteNodeA.Child == nil { break } return e.ComplexityRoot.ConcreteNodeA.Child(childComplexity), true case "ConcreteNodeA.id": if e.ComplexityRoot.ConcreteNodeA.ID == nil { break } return e.ComplexityRoot.ConcreteNodeA.ID(childComplexity), true case "ConcreteNodeA.name": if e.ComplexityRoot.ConcreteNodeA.Name == nil { break } return e.ComplexityRoot.ConcreteNodeA.Name(childComplexity), true case "ConcreteNodeInterface.child": if e.ComplexityRoot.ConcreteNodeInterface.Child == nil { break } return e.ComplexityRoot.ConcreteNodeInterface.Child(childComplexity), true case "ConcreteNodeInterface.id": if e.ComplexityRoot.ConcreteNodeInterface.ID == nil { break } return e.ComplexityRoot.ConcreteNodeInterface.ID(childComplexity), true case "Content_Post.foo": if e.ComplexityRoot.Content_Post.Foo == nil { break } return e.ComplexityRoot.Content_Post.Foo(childComplexity), true case "Content_User.foo": if e.ComplexityRoot.Content_User.Foo == nil { break } return e.ComplexityRoot.Content_User.Foo(childComplexity), true case "Coordinates.x": if e.ComplexityRoot.Coordinates.X == nil { break } return e.ComplexityRoot.Coordinates.X(childComplexity), true case "Coordinates.y": if e.ComplexityRoot.Coordinates.Y == nil { break } return e.ComplexityRoot.Coordinates.Y(childComplexity), true case "DefaultParametersMirror.falsyBoolean": if e.ComplexityRoot.DefaultParametersMirror.FalsyBoolean == nil { break } return e.ComplexityRoot.DefaultParametersMirror.FalsyBoolean(childComplexity), true case "DefaultParametersMirror.truthyBoolean": if e.ComplexityRoot.DefaultParametersMirror.TruthyBoolean == nil { break } return e.ComplexityRoot.DefaultParametersMirror.TruthyBoolean(childComplexity), true case "DeferModel.id": if e.ComplexityRoot.DeferModel.ID == nil { break } return e.ComplexityRoot.DeferModel.ID(childComplexity), true case "DeferModel.name": if e.ComplexityRoot.DeferModel.Name == nil { break } return e.ComplexityRoot.DeferModel.Name(childComplexity), true case "DeferModel.values": if e.ComplexityRoot.DeferModel.Values == nil { break } return e.ComplexityRoot.DeferModel.Values(childComplexity), true case "Dog.dogBreed": if e.ComplexityRoot.Dog.DogBreed == nil { break } return e.ComplexityRoot.Dog.DogBreed(childComplexity), true case "Dog.size": if e.ComplexityRoot.Dog.Size == nil { break } return e.ComplexityRoot.Dog.Size(childComplexity), true case "Dog.species": if e.ComplexityRoot.Dog.Species == nil { break } return e.ComplexityRoot.Dog.Species(childComplexity), true case "EmbeddedCase1.exportedEmbeddedPointerExportedMethod": if e.ComplexityRoot.EmbeddedCase1.ExportedEmbeddedPointerExportedMethod == nil { break } return e.ComplexityRoot.EmbeddedCase1.ExportedEmbeddedPointerExportedMethod(childComplexity), true case "EmbeddedCase2.unexportedEmbeddedPointerExportedMethod": if e.ComplexityRoot.EmbeddedCase2.UnexportedEmbeddedPointerExportedMethod == nil { break } return e.ComplexityRoot.EmbeddedCase2.UnexportedEmbeddedPointerExportedMethod(childComplexity), true case "EmbeddedCase3.unexportedEmbeddedInterfaceExportedMethod": if e.ComplexityRoot.EmbeddedCase3.UnexportedEmbeddedInterfaceExportedMethod == nil { break } return e.ComplexityRoot.EmbeddedCase3.UnexportedEmbeddedInterfaceExportedMethod(childComplexity), true case "EmbeddedDefaultScalar.value": if e.ComplexityRoot.EmbeddedDefaultScalar.Value == nil { break } return e.ComplexityRoot.EmbeddedDefaultScalar.Value(childComplexity), true case "EmbeddedPointer.ID": if e.ComplexityRoot.EmbeddedPointer.ID == nil { break } return e.ComplexityRoot.EmbeddedPointer.ID(childComplexity), true case "EmbeddedPointer.Title": if e.ComplexityRoot.EmbeddedPointer.Title == nil { break } return e.ComplexityRoot.EmbeddedPointer.Title(childComplexity), true case "Error.errorOnNonRequiredField": if e.ComplexityRoot.Error.ErrorOnNonRequiredField == nil { break } return e.ComplexityRoot.Error.ErrorOnNonRequiredField(childComplexity), true case "Error.errorOnRequiredField": if e.ComplexityRoot.Error.ErrorOnRequiredField == nil { break } return e.ComplexityRoot.Error.ErrorOnRequiredField(childComplexity), true case "Error.id": if e.ComplexityRoot.Error.ID == nil { break } return e.ComplexityRoot.Error.ID(childComplexity), true case "Error.nilOnRequiredField": if e.ComplexityRoot.Error.NilOnRequiredField == nil { break } return e.ComplexityRoot.Error.NilOnRequiredField(childComplexity), true case "Errors.a": if e.ComplexityRoot.Errors.A == nil { break } return e.ComplexityRoot.Errors.A(childComplexity), true case "Errors.b": if e.ComplexityRoot.Errors.B == nil { break } return e.ComplexityRoot.Errors.B(childComplexity), true case "Errors.c": if e.ComplexityRoot.Errors.C == nil { break } return e.ComplexityRoot.Errors.C(childComplexity), true case "Errors.d": if e.ComplexityRoot.Errors.D == nil { break } return e.ComplexityRoot.Errors.D(childComplexity), true case "Errors.e": if e.ComplexityRoot.Errors.E == nil { break } return e.ComplexityRoot.Errors.E(childComplexity), true case "FieldsOrderPayload.firstFieldValue": if e.ComplexityRoot.FieldsOrderPayload.FirstFieldValue == nil { break } return e.ComplexityRoot.FieldsOrderPayload.FirstFieldValue(childComplexity), true case "ForcedResolver.field": if e.ComplexityRoot.ForcedResolver.Field == nil { break } return e.ComplexityRoot.ForcedResolver.Field(childComplexity), true case "Horse.horseBreed": if e.ComplexityRoot.Horse.HorseBreed == nil { break } return e.ComplexityRoot.Horse.HorseBreed(childComplexity), true case "Horse.size": if e.ComplexityRoot.Horse.Size == nil { break } return e.ComplexityRoot.Horse.Size(childComplexity), true case "Horse.species": if e.ComplexityRoot.Horse.Species == nil { break } return e.ComplexityRoot.Horse.Species(childComplexity), true case "InnerObject.id": if e.ComplexityRoot.InnerObject.ID == nil { break } return e.ComplexityRoot.InnerObject.ID(childComplexity), true case "InvalidIdentifier.id": if e.ComplexityRoot.InvalidIdentifier.ID == nil { break } return e.ComplexityRoot.InvalidIdentifier.ID(childComplexity), true case "It.id": if e.ComplexityRoot.It.ID == nil { break } return e.ComplexityRoot.It.ID(childComplexity), true case "LoopA.b": if e.ComplexityRoot.LoopA.B == nil { break } return e.ComplexityRoot.LoopA.B(childComplexity), true case "LoopB.a": if e.ComplexityRoot.LoopB.A == nil { break } return e.ComplexityRoot.LoopB.A(childComplexity), true case "Map.id": if e.ComplexityRoot.Map.ID == nil { break } return e.ComplexityRoot.Map.ID(childComplexity), true case "MapNested.value": if e.ComplexityRoot.MapNested.Value == nil { break } return e.ComplexityRoot.MapNested.Value(childComplexity), true case "MapStringInterfaceType.a": if e.ComplexityRoot.MapStringInterfaceType.A == nil { break } return e.ComplexityRoot.MapStringInterfaceType.A(childComplexity), true case "MapStringInterfaceType.b": if e.ComplexityRoot.MapStringInterfaceType.B == nil { break } return e.ComplexityRoot.MapStringInterfaceType.B(childComplexity), true case "MapStringInterfaceType.c": if e.ComplexityRoot.MapStringInterfaceType.C == nil { break } return e.ComplexityRoot.MapStringInterfaceType.C(childComplexity), true case "MapStringInterfaceType.nested": if e.ComplexityRoot.MapStringInterfaceType.Nested == nil { break } return e.ComplexityRoot.MapStringInterfaceType.Nested(childComplexity), true case "ModelMethods.noContext": if e.ComplexityRoot.ModelMethods.NoContext == nil { break } return e.ComplexityRoot.ModelMethods.NoContext(childComplexity), true case "ModelMethods.resolverField": if e.ComplexityRoot.ModelMethods.ResolverField == nil { break } return e.ComplexityRoot.ModelMethods.ResolverField(childComplexity), true case "ModelMethods.withContext": if e.ComplexityRoot.ModelMethods.WithContext == nil { break } return e.ComplexityRoot.ModelMethods.WithContext(childComplexity), true case "Mutation.defaultInput": if e.ComplexityRoot.Mutation.DefaultInput == nil { break } args, err := ec.field_Mutation_defaultInput_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Mutation.DefaultInput(childComplexity, args["input"].(DefaultInput)), true case "Mutation.issue4053": if e.ComplexityRoot.Mutation.Issue4053 == nil { break } args, err := ec.field_Mutation_issue4053_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Mutation.Issue4053(childComplexity, args["input"].(*Issue4053Input1)), true case "Mutation.overrideValueViaInput": if e.ComplexityRoot.Mutation.OverrideValueViaInput == nil { break } args, err := ec.field_Mutation_overrideValueViaInput_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Mutation.OverrideValueViaInput(childComplexity, args["input"].(FieldsOrderInput)), true case "Mutation.updateProduct": if e.ComplexityRoot.Mutation.UpdateProduct == nil { break } args, err := ec.field_Mutation_updateProduct_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Mutation.UpdateProduct(childComplexity, args["id"].(string), args["name"].(*string), args["price"].(*float64)), true case "Mutation.updatePtrToPtr": if e.ComplexityRoot.Mutation.UpdatePtrToPtr == nil { break } args, err := ec.field_Mutation_updatePtrToPtr_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Mutation.UpdatePtrToPtr(childComplexity, args["input"].(UpdatePtrToPtrOuter)), true case "Mutation.updateSomething": if e.ComplexityRoot.Mutation.UpdateSomething == nil { break } args, err := ec.field_Mutation_updateSomething_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Mutation.UpdateSomething(childComplexity, args["input"].(SpecialInput)), true case "ObjectDirectives.nullableText": if e.ComplexityRoot.ObjectDirectives.NullableText == nil { break } return e.ComplexityRoot.ObjectDirectives.NullableText(childComplexity), true case "ObjectDirectives.order": if e.ComplexityRoot.ObjectDirectives.Order == nil { break } return e.ComplexityRoot.ObjectDirectives.Order(childComplexity), true case "ObjectDirectives.text": if e.ComplexityRoot.ObjectDirectives.Text == nil { break } return e.ComplexityRoot.ObjectDirectives.Text(childComplexity), true case "ObjectDirectivesWithCustomGoModel.nullableText": if e.ComplexityRoot.ObjectDirectivesWithCustomGoModel.NullableText == nil { break } return e.ComplexityRoot.ObjectDirectivesWithCustomGoModel.NullableText(childComplexity), true case "OuterObject.inner": if e.ComplexityRoot.OuterObject.Inner == nil { break } return e.ComplexityRoot.OuterObject.Inner(childComplexity), true case "OverlappingFields.oneFoo", "OverlappingFields.twoFoo": if e.ComplexityRoot.OverlappingFields.Foo == nil { break } return e.ComplexityRoot.OverlappingFields.Foo(childComplexity), true case "OverlappingFields.newFoo", "OverlappingFields.new_foo": if e.ComplexityRoot.OverlappingFields.NewFoo == nil { break } return e.ComplexityRoot.OverlappingFields.NewFoo(childComplexity), true case "OverlappingFields.oldFoo": if e.ComplexityRoot.OverlappingFields.OldFoo == nil { break } return e.ComplexityRoot.OverlappingFields.OldFoo(childComplexity), true case "Panics.argUnmarshal": if e.ComplexityRoot.Panics.ArgUnmarshal == nil { break } args, err := ec.field_Panics_argUnmarshal_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Panics.ArgUnmarshal(childComplexity, args["u"].([]MarshalPanic)), true case "Panics.fieldFuncMarshal": if e.ComplexityRoot.Panics.FieldFuncMarshal == nil { break } args, err := ec.field_Panics_fieldFuncMarshal_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Panics.FieldFuncMarshal(childComplexity, args["u"].([]MarshalPanic)), true case "Panics.fieldScalarMarshal": if e.ComplexityRoot.Panics.FieldScalarMarshal == nil { break } return e.ComplexityRoot.Panics.FieldScalarMarshal(childComplexity), true case "Pet.friends": if e.ComplexityRoot.Pet.Friends == nil { break } args, err := ec.field_Pet_friends_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Pet.Friends(childComplexity, args["limit"].(*int)), true case "Pet.id": if e.ComplexityRoot.Pet.ID == nil { break } return e.ComplexityRoot.Pet.ID(childComplexity), true case "Primitive.squared": if e.ComplexityRoot.Primitive.Squared == nil { break } return e.ComplexityRoot.Primitive.Squared(childComplexity), true case "Primitive.value": if e.ComplexityRoot.Primitive.Value == nil { break } return e.ComplexityRoot.Primitive.Value(childComplexity), true case "PrimitiveString.doubled": if e.ComplexityRoot.PrimitiveString.Doubled == nil { break } return e.ComplexityRoot.PrimitiveString.Doubled(childComplexity), true case "PrimitiveString.len": if e.ComplexityRoot.PrimitiveString.Len == nil { break } return e.ComplexityRoot.PrimitiveString.Len(childComplexity), true case "PrimitiveString.value": if e.ComplexityRoot.PrimitiveString.Value == nil { break } return e.ComplexityRoot.PrimitiveString.Value(childComplexity), true case "PtrToAnyContainer.binding": if e.ComplexityRoot.PtrToAnyContainer.Binding == nil { break } return e.ComplexityRoot.PtrToAnyContainer.Binding(childComplexity), true case "PtrToAnyContainer.ptrToAny": if e.ComplexityRoot.PtrToAnyContainer.PtrToAny == nil { break } return e.ComplexityRoot.PtrToAnyContainer.PtrToAny(childComplexity), true case "PtrToPtrInner.key": if e.ComplexityRoot.PtrToPtrInner.Key == nil { break } return e.ComplexityRoot.PtrToPtrInner.Key(childComplexity), true case "PtrToPtrInner.value": if e.ComplexityRoot.PtrToPtrInner.Value == nil { break } return e.ComplexityRoot.PtrToPtrInner.Value(childComplexity), true case "PtrToPtrOuter.inner": if e.ComplexityRoot.PtrToPtrOuter.Inner == nil { break } return e.ComplexityRoot.PtrToPtrOuter.Inner(childComplexity), true case "PtrToPtrOuter.name": if e.ComplexityRoot.PtrToPtrOuter.Name == nil { break } return e.ComplexityRoot.PtrToPtrOuter.Name(childComplexity), true case "PtrToPtrOuter.stupidInner": if e.ComplexityRoot.PtrToPtrOuter.StupidInner == nil { break } return e.ComplexityRoot.PtrToPtrOuter.StupidInner(childComplexity), true case "PtrToSliceContainer.ptrToSlice": if e.ComplexityRoot.PtrToSliceContainer.PtrToSlice == nil { break } return e.ComplexityRoot.PtrToSliceContainer.PtrToSlice(childComplexity), true case "Query.animal": if e.ComplexityRoot.Query.Animal == nil { break } return e.ComplexityRoot.Query.Animal(childComplexity), true case "Query.autobind": if e.ComplexityRoot.Query.Autobind == nil { break } return e.ComplexityRoot.Query.Autobind(childComplexity), true case "Query.collision": if e.ComplexityRoot.Query.Collision == nil { break } return e.ComplexityRoot.Query.Collision(childComplexity), true case "Query.defaultParameters": if e.ComplexityRoot.Query.DefaultParameters == nil { break } args, err := ec.field_Query_defaultParameters_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.DefaultParameters(childComplexity, args["falsyBoolean"].(*bool), args["truthyBoolean"].(*bool)), true case "Query.defaultScalar": if e.ComplexityRoot.Query.DefaultScalar == nil { break } args, err := ec.field_Query_defaultScalar_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.DefaultScalar(childComplexity, args["arg"].(string)), true case "Query.deferMultiple": if e.ComplexityRoot.Query.DeferMultiple == nil { break } return e.ComplexityRoot.Query.DeferMultiple(childComplexity), true case "Query.deferSingle": if e.ComplexityRoot.Query.DeferSingle == nil { break } return e.ComplexityRoot.Query.DeferSingle(childComplexity), true case "Query.deprecatedField": if e.ComplexityRoot.Query.DeprecatedField == nil { break } return e.ComplexityRoot.Query.DeprecatedField(childComplexity), true case "Query.directiveArg": if e.ComplexityRoot.Query.DirectiveArg == nil { break } args, err := ec.field_Query_directiveArg_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.DirectiveArg(childComplexity, args["arg"].(string)), true case "Query.directiveDouble": if e.ComplexityRoot.Query.DirectiveDouble == nil { break } return e.ComplexityRoot.Query.DirectiveDouble(childComplexity), true case "Query.directiveField": if e.ComplexityRoot.Query.DirectiveField == nil { break } return e.ComplexityRoot.Query.DirectiveField(childComplexity), true case "Query.directiveFieldDef": if e.ComplexityRoot.Query.DirectiveFieldDef == nil { break } args, err := ec.field_Query_directiveFieldDef_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.DirectiveFieldDef(childComplexity, args["ret"].(string)), true case "Query.directiveInput": if e.ComplexityRoot.Query.DirectiveInput == nil { break } args, err := ec.field_Query_directiveInput_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.DirectiveInput(childComplexity, args["arg"].(InputDirectives)), true case "Query.directiveInputNullable": if e.ComplexityRoot.Query.DirectiveInputNullable == nil { break } args, err := ec.field_Query_directiveInputNullable_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.DirectiveInputNullable(childComplexity, args["arg"].(*InputDirectives)), true case "Query.directiveInputOuter": if e.ComplexityRoot.Query.DirectiveInputOuter == nil { break } args, err := ec.field_Query_directiveInputOuter_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.DirectiveInputOuter(childComplexity, args["arg"].(OuterWrapperInput)), true case "Query.directiveInputType": if e.ComplexityRoot.Query.DirectiveInputType == nil { break } args, err := ec.field_Query_directiveInputType_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.DirectiveInputType(childComplexity, args["arg"].(InnerInput)), true case "Query.directiveNullableArg": if e.ComplexityRoot.Query.DirectiveNullableArg == nil { break } args, err := ec.field_Query_directiveNullableArg_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.DirectiveNullableArg(childComplexity, args["arg"].(*int), args["arg2"].(*int), args["arg3"].(*string)), true case "Query.directiveObject": if e.ComplexityRoot.Query.DirectiveObject == nil { break } return e.ComplexityRoot.Query.DirectiveObject(childComplexity), true case "Query.directiveObjectWithCustomGoModel": if e.ComplexityRoot.Query.DirectiveObjectWithCustomGoModel == nil { break } return e.ComplexityRoot.Query.DirectiveObjectWithCustomGoModel(childComplexity), true case "Query.directiveSingleNullableArg": if e.ComplexityRoot.Query.DirectiveSingleNullableArg == nil { break } args, err := ec.field_Query_directiveSingleNullableArg_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.DirectiveSingleNullableArg(childComplexity, args["arg1"].(*string)), true case "Query.directiveUnimplemented": if e.ComplexityRoot.Query.DirectiveUnimplemented == nil { break } return e.ComplexityRoot.Query.DirectiveUnimplemented(childComplexity), true case "Query.dog": if e.ComplexityRoot.Query.Dog == nil { break } return e.ComplexityRoot.Query.Dog(childComplexity), true case "Query.embeddedCase1": if e.ComplexityRoot.Query.EmbeddedCase1 == nil { break } return e.ComplexityRoot.Query.EmbeddedCase1(childComplexity), true case "Query.embeddedCase2": if e.ComplexityRoot.Query.EmbeddedCase2 == nil { break } return e.ComplexityRoot.Query.EmbeddedCase2(childComplexity), true case "Query.embeddedCase3": if e.ComplexityRoot.Query.EmbeddedCase3 == nil { break } return e.ComplexityRoot.Query.EmbeddedCase3(childComplexity), true case "Query.enumInInput": if e.ComplexityRoot.Query.EnumInInput == nil { break } args, err := ec.field_Query_enumInInput_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.EnumInInput(childComplexity, args["input"].(*InputWithEnumValue)), true case "Query.errorBubble": if e.ComplexityRoot.Query.ErrorBubble == nil { break } return e.ComplexityRoot.Query.ErrorBubble(childComplexity), true case "Query.errorBubbleList": if e.ComplexityRoot.Query.ErrorBubbleList == nil { break } return e.ComplexityRoot.Query.ErrorBubbleList(childComplexity), true case "Query.errorList": if e.ComplexityRoot.Query.ErrorList == nil { break } return e.ComplexityRoot.Query.ErrorList(childComplexity), true case "Query.errors": if e.ComplexityRoot.Query.Errors == nil { break } return e.ComplexityRoot.Query.Errors(childComplexity), true case "Query.fallback": if e.ComplexityRoot.Query.Fallback == nil { break } args, err := ec.field_Query_fallback_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.Fallback(childComplexity, args["arg"].(FallbackToStringEncoding)), true case "Query.fieldWithDeprecatedArg": if e.ComplexityRoot.Query.FieldWithDeprecatedArg == nil { break } args, err := ec.field_Query_fieldWithDeprecatedArg_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.FieldWithDeprecatedArg(childComplexity, args["oldArg"].(*int), args["newArg"].(*int)), true case "Query.filterProducts": if e.ComplexityRoot.Query.FilterProducts == nil { break } args, err := ec.field_Query_filterProducts_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.FilterProducts(childComplexity, args["query"].(*string), args["category"].(*string), args["minPrice"].(*int)), true case "Query.findProducts": if e.ComplexityRoot.Query.FindProducts == nil { break } args, err := ec.field_Query_findProducts_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.FindProducts(childComplexity, args["query"].(*string), args["category"].(*string), args["minPrice"].(*int)), true case "Query.infinity": if e.ComplexityRoot.Query.Infinity == nil { break } return e.ComplexityRoot.Query.Infinity(childComplexity), true case "Query.inputNullableSlice": if e.ComplexityRoot.Query.InputNullableSlice == nil { break } args, err := ec.field_Query_inputNullableSlice_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.InputNullableSlice(childComplexity, args["arg"].([]string)), true case "Query.inputOmittable": if e.ComplexityRoot.Query.InputOmittable == nil { break } args, err := ec.field_Query_inputOmittable_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.InputOmittable(childComplexity, args["arg"].(OmittableInput)), true case "Query.inputSlice": if e.ComplexityRoot.Query.InputSlice == nil { break } args, err := ec.field_Query_inputSlice_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.InputSlice(childComplexity, args["arg"].([]string)), true case "Query.invalid": if e.ComplexityRoot.Query.Invalid == nil { break } return e.ComplexityRoot.Query.Invalid(childComplexity), true case "Query.invalidIdentifier": if e.ComplexityRoot.Query.InvalidIdentifier == nil { break } return e.ComplexityRoot.Query.InvalidIdentifier(childComplexity), true case "Query.issue896a": if e.ComplexityRoot.Query.Issue896a == nil { break } return e.ComplexityRoot.Query.Issue896a(childComplexity), true case "Query.mapInput": if e.ComplexityRoot.Query.MapInput == nil { break } args, err := ec.field_Query_mapInput_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.MapInput(childComplexity, args["input"].(map[string]any)), true case "Query.mapNestedMapSlice": if e.ComplexityRoot.Query.MapNestedMapSlice == nil { break } args, err := ec.field_Query_mapNestedMapSlice_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.MapNestedMapSlice(childComplexity, args["input"].(map[string]any)), true case "Query.mapNestedStringInterface": if e.ComplexityRoot.Query.MapNestedStringInterface == nil { break } args, err := ec.field_Query_mapNestedStringInterface_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.MapNestedStringInterface(childComplexity, args["in"].(*NestedMapInput)), true case "Query.mapStringInterface": if e.ComplexityRoot.Query.MapStringInterface == nil { break } args, err := ec.field_Query_mapStringInterface_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.MapStringInterface(childComplexity, args["in"].(map[string]any)), true case "Query.modelMethods": if e.ComplexityRoot.Query.ModelMethods == nil { break } return e.ComplexityRoot.Query.ModelMethods(childComplexity), true case "Query.nestedInputs": if e.ComplexityRoot.Query.NestedInputs == nil { break } args, err := ec.field_Query_nestedInputs_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.NestedInputs(childComplexity, args["input"].([][]*OuterInput)), true case "Query.nestedOutputs": if e.ComplexityRoot.Query.NestedOutputs == nil { break } return e.ComplexityRoot.Query.NestedOutputs(childComplexity), true case "Query.noShape": if e.ComplexityRoot.Query.NoShape == nil { break } return e.ComplexityRoot.Query.NoShape(childComplexity), true case "Query.noShapeTypedNil": if e.ComplexityRoot.Query.NoShapeTypedNil == nil { break } return e.ComplexityRoot.Query.NoShapeTypedNil(childComplexity), true case "Query.node": if e.ComplexityRoot.Query.Node == nil { break } return e.ComplexityRoot.Query.Node(childComplexity), true case "Query.notAnInterface": if e.ComplexityRoot.Query.NotAnInterface == nil { break } return e.ComplexityRoot.Query.NotAnInterface(childComplexity), true case "Query.nullableArg": if e.ComplexityRoot.Query.NullableArg == nil { break } args, err := ec.field_Query_nullableArg_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.NullableArg(childComplexity, args["arg"].(*int)), true case "Query.optionalUnion": if e.ComplexityRoot.Query.OptionalUnion == nil { break } return e.ComplexityRoot.Query.OptionalUnion(childComplexity), true case "Query.overlapping": if e.ComplexityRoot.Query.Overlapping == nil { break } return e.ComplexityRoot.Query.Overlapping(childComplexity), true case "Query.panics": if e.ComplexityRoot.Query.Panics == nil { break } return e.ComplexityRoot.Query.Panics(childComplexity), true case "Query.primitiveObject": if e.ComplexityRoot.Query.PrimitiveObject == nil { break } return e.ComplexityRoot.Query.PrimitiveObject(childComplexity), true case "Query.primitiveStringObject": if e.ComplexityRoot.Query.PrimitiveStringObject == nil { break } return e.ComplexityRoot.Query.PrimitiveStringObject(childComplexity), true case "Query.ptrToAnyContainer": if e.ComplexityRoot.Query.PtrToAnyContainer == nil { break } return e.ComplexityRoot.Query.PtrToAnyContainer(childComplexity), true case "Query.ptrToSliceContainer": if e.ComplexityRoot.Query.PtrToSliceContainer == nil { break } return e.ComplexityRoot.Query.PtrToSliceContainer(childComplexity), true case "Query.recursive": if e.ComplexityRoot.Query.Recursive == nil { break } args, err := ec.field_Query_recursive_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.Recursive(childComplexity, args["input"].(*RecursiveInputSlice)), true case "Query.scalarSlice": if e.ComplexityRoot.Query.ScalarSlice == nil { break } return e.ComplexityRoot.Query.ScalarSlice(childComplexity), true case "Query.searchMixed": if e.ComplexityRoot.Query.SearchMixed == nil { break } args, err := ec.field_Query_searchMixed_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.SearchMixed(childComplexity, args["query"].(*string), args["category"].(*string), args["minPrice"].(*int), args["limit"].(*int), args["offset"].(*int), args["sortBy"].(*string)), true case "Query.searchProducts": if e.ComplexityRoot.Query.SearchProducts == nil { break } args, err := ec.field_Query_searchProducts_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.SearchProducts(childComplexity, args["query"].(*string), args["category"].(*string), args["minPrice"].(*int)), true case "Query.searchProductsNormal": if e.ComplexityRoot.Query.SearchProductsNormal == nil { break } args, err := ec.field_Query_searchProductsNormal_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.SearchProductsNormal(childComplexity, args["filters"].(map[string]any)), true case "Query.searchRequired": if e.ComplexityRoot.Query.SearchRequired == nil { break } args, err := ec.field_Query_searchRequired_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.SearchRequired(childComplexity, args["name"].(string), args["age"].(int)), true case "Query.searchWithDefaults": if e.ComplexityRoot.Query.SearchWithDefaults == nil { break } args, err := ec.field_Query_searchWithDefaults_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.SearchWithDefaults(childComplexity, args["query"].(*string), args["limit"].(*int), args["includeArchived"].(*bool)), true case "Query.searchWithDirectives": if e.ComplexityRoot.Query.SearchWithDirectives == nil { break } args, err := ec.field_Query_searchWithDirectives_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.SearchWithDirectives(childComplexity, args["oldField"].(*string), args["newField"].(*string)), true case "Query.shapeUnion": if e.ComplexityRoot.Query.ShapeUnion == nil { break } return e.ComplexityRoot.Query.ShapeUnion(childComplexity), true case "Query.shapes": if e.ComplexityRoot.Query.Shapes == nil { break } return e.ComplexityRoot.Query.Shapes(childComplexity), true case "Query.skipInclude": if e.ComplexityRoot.Query.SkipInclude == nil { break } return e.ComplexityRoot.Query.SkipInclude(childComplexity), true case "Query.slices": if e.ComplexityRoot.Query.Slices == nil { break } return e.ComplexityRoot.Query.Slices(childComplexity), true case "Query.stringFromContextFunction": if e.ComplexityRoot.Query.StringFromContextFunction == nil { break } return e.ComplexityRoot.Query.StringFromContextFunction(childComplexity), true case "Query.stringFromContextInterface": if e.ComplexityRoot.Query.StringFromContextInterface == nil { break } return e.ComplexityRoot.Query.StringFromContextInterface(childComplexity), true case "Query.user": if e.ComplexityRoot.Query.User == nil { break } args, err := ec.field_Query_user_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.User(childComplexity, args["id"].(int)), true case "Query.vOkCaseNil": if e.ComplexityRoot.Query.VOkCaseNil == nil { break } return e.ComplexityRoot.Query.VOkCaseNil(childComplexity), true case "Query.vOkCaseValue": if e.ComplexityRoot.Query.VOkCaseValue == nil { break } return e.ComplexityRoot.Query.VOkCaseValue(childComplexity), true case "Query.valid": if e.ComplexityRoot.Query.Valid == nil { break } return e.ComplexityRoot.Query.Valid(childComplexity), true case "Query.validType": if e.ComplexityRoot.Query.ValidType == nil { break } return e.ComplexityRoot.Query.ValidType(childComplexity), true case "Query.variadicModel": if e.ComplexityRoot.Query.VariadicModel == nil { break } return e.ComplexityRoot.Query.VariadicModel(childComplexity), true case "Query.wrappedMap": if e.ComplexityRoot.Query.WrappedMap == nil { break } return e.ComplexityRoot.Query.WrappedMap(childComplexity), true case "Query.wrappedScalar": if e.ComplexityRoot.Query.WrappedScalar == nil { break } return e.ComplexityRoot.Query.WrappedScalar(childComplexity), true case "Query.wrappedSlice": if e.ComplexityRoot.Query.WrappedSlice == nil { break } return e.ComplexityRoot.Query.WrappedSlice(childComplexity), true case "Query.wrappedStruct": if e.ComplexityRoot.Query.WrappedStruct == nil { break } return e.ComplexityRoot.Query.WrappedStruct(childComplexity), true case "Rectangle.area": if e.ComplexityRoot.Rectangle.Area == nil { break } return e.ComplexityRoot.Rectangle.Area(childComplexity), true case "Rectangle.coordinates": if e.ComplexityRoot.Rectangle.Coordinates == nil { break } return e.ComplexityRoot.Rectangle.Coordinates(childComplexity), true case "Rectangle.length": if e.ComplexityRoot.Rectangle.Length == nil { break } return e.ComplexityRoot.Rectangle.Length(childComplexity), true case "Rectangle.width": if e.ComplexityRoot.Rectangle.Width == nil { break } return e.ComplexityRoot.Rectangle.Width(childComplexity), true case "Size.height": if e.ComplexityRoot.Size.Height == nil { break } return e.ComplexityRoot.Size.Height(childComplexity), true case "Size.weight": if e.ComplexityRoot.Size.Weight == nil { break } return e.ComplexityRoot.Size.Weight(childComplexity), true case "SkipIncludeTestType.a": if e.ComplexityRoot.SkipIncludeTestType.A == nil { break } return e.ComplexityRoot.SkipIncludeTestType.A(childComplexity), true case "SkipIncludeTestType.b": if e.ComplexityRoot.SkipIncludeTestType.B == nil { break } return e.ComplexityRoot.SkipIncludeTestType.B(childComplexity), true case "Slices.test1": if e.ComplexityRoot.Slices.Test1 == nil { break } return e.ComplexityRoot.Slices.Test1(childComplexity), true case "Slices.test2": if e.ComplexityRoot.Slices.Test2 == nil { break } return e.ComplexityRoot.Slices.Test2(childComplexity), true case "Slices.test3": if e.ComplexityRoot.Slices.Test3 == nil { break } return e.ComplexityRoot.Slices.Test3(childComplexity), true case "Slices.test4": if e.ComplexityRoot.Slices.Test4 == nil { break } return e.ComplexityRoot.Slices.Test4(childComplexity), true case "Subscription.directiveArg": if e.ComplexityRoot.Subscription.DirectiveArg == nil { break } args, err := ec.field_Subscription_directiveArg_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Subscription.DirectiveArg(childComplexity, args["arg"].(string)), true case "Subscription.directiveDouble": if e.ComplexityRoot.Subscription.DirectiveDouble == nil { break } return e.ComplexityRoot.Subscription.DirectiveDouble(childComplexity), true case "Subscription.directiveNullableArg": if e.ComplexityRoot.Subscription.DirectiveNullableArg == nil { break } args, err := ec.field_Subscription_directiveNullableArg_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Subscription.DirectiveNullableArg(childComplexity, args["arg"].(*int), args["arg2"].(*int), args["arg3"].(*string)), true case "Subscription.directiveUnimplemented": if e.ComplexityRoot.Subscription.DirectiveUnimplemented == nil { break } return e.ComplexityRoot.Subscription.DirectiveUnimplemented(childComplexity), true case "Subscription.errorRequired": if e.ComplexityRoot.Subscription.ErrorRequired == nil { break } return e.ComplexityRoot.Subscription.ErrorRequired(childComplexity), true case "Subscription.initPayload": if e.ComplexityRoot.Subscription.InitPayload == nil { break } return e.ComplexityRoot.Subscription.InitPayload(childComplexity), true case "Subscription.issue896b": if e.ComplexityRoot.Subscription.Issue896b == nil { break } return e.ComplexityRoot.Subscription.Issue896b(childComplexity), true case "Subscription.updated": if e.ComplexityRoot.Subscription.Updated == nil { break } return e.ComplexityRoot.Subscription.Updated(childComplexity), true case "User.created": if e.ComplexityRoot.User.Created == nil { break } return e.ComplexityRoot.User.Created(childComplexity), true case "User.friends": if e.ComplexityRoot.User.Friends == nil { break } return e.ComplexityRoot.User.Friends(childComplexity), true case "User.id": if e.ComplexityRoot.User.ID == nil { break } return e.ComplexityRoot.User.ID(childComplexity), true case "User.pets": if e.ComplexityRoot.User.Pets == nil { break } args, err := ec.field_User_pets_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.User.Pets(childComplexity, args["limit"].(*int)), true case "User.updated": if e.ComplexityRoot.User.Updated == nil { break } return e.ComplexityRoot.User.Updated(childComplexity), true case "VOkCaseNil.value": if e.ComplexityRoot.VOkCaseNil.Value == nil { break } return e.ComplexityRoot.VOkCaseNil.Value(childComplexity), true case "VOkCaseValue.value": if e.ComplexityRoot.VOkCaseValue.Value == nil { break } return e.ComplexityRoot.VOkCaseValue.Value(childComplexity), true case "ValidType.differentCase": if e.ComplexityRoot.ValidType.DifferentCase == nil { break } return e.ComplexityRoot.ValidType.DifferentCase(childComplexity), true case "ValidType.different_case": if e.ComplexityRoot.ValidType.DifferentCaseOld == nil { break } return e.ComplexityRoot.ValidType.DifferentCaseOld(childComplexity), true case "ValidType.validArgs": if e.ComplexityRoot.ValidType.ValidArgs == nil { break } args, err := ec.field_ValidType_validArgs_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.ValidType.ValidArgs(childComplexity, args["break"].(string), args["default"].(string), args["func"].(string), args["interface"].(string), args["select"].(string), args["case"].(string), args["defer"].(string), args["go"].(string), args["map"].(string), args["struct"].(string), args["chan"].(string), args["else"].(string), args["goto"].(string), args["package"].(string), args["switch"].(string), args["const"].(string), args["fallthrough"].(string), args["if"].(string), args["range"].(string), args["type"].(string), args["continue"].(string), args["for"].(string), args["import"].(string), args["return"].(string), args["var"].(string), args["_"].(string)), true case "ValidType.validInputKeywords": if e.ComplexityRoot.ValidType.ValidInputKeywords == nil { break } args, err := ec.field_ValidType_validInputKeywords_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.ValidType.ValidInputKeywords(childComplexity, args["input"].(*ValidInput)), true case "VariadicModel.value": if e.ComplexityRoot.VariadicModel.Value == nil { break } args, err := ec.field_VariadicModel_value_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.VariadicModel.Value(childComplexity, args["rank"].(int)), true case "WrappedMap.get": if e.ComplexityRoot.WrappedMap.Get == nil { break } args, err := ec.field_WrappedMap_get_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.WrappedMap.Get(childComplexity, args["key"].(string)), true case "WrappedSlice.get": if e.ComplexityRoot.WrappedSlice.Get == nil { break } args, err := ec.field_WrappedSlice_get_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.WrappedSlice.Get(childComplexity, args["idx"].(int)), true case "WrappedStruct.desc": if e.ComplexityRoot.WrappedStruct.Desc == nil { break } return e.ComplexityRoot.WrappedStruct.Desc(childComplexity), true case "WrappedStruct.name": if e.ComplexityRoot.WrappedStruct.Name == nil { break } return e.ComplexityRoot.WrappedStruct.Name(childComplexity), true case "XXIt.id": if e.ComplexityRoot.XXIt.ID == nil { break } return e.ComplexityRoot.XXIt.ID(childComplexity), true case "XxIt.id": if e.ComplexityRoot.XxIt.ID == nil { break } return e.ComplexityRoot.XxIt.ID(childComplexity), true case "asdfIt.id": if e.ComplexityRoot.AsdfIt.ID == nil { break } return e.ComplexityRoot.AsdfIt.ID(childComplexity), true case "iIt.id": if e.ComplexityRoot.IIt.ID == nil { break } return e.ComplexityRoot.IIt.ID(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.unmarshalInputChanges, ec.unmarshalInputDefaultInput, ec.unmarshalInputDirectiveInput, ec.unmarshalInputFieldsOrderInput, ec.unmarshalInputInnerDirectives, ec.unmarshalInputInnerInput, ec.unmarshalInputInputDirectives, ec.unmarshalInputInputWithEnumValue, ec.unmarshalInputIssue4053Input1, ec.unmarshalInputIssue4053Input2, ec.unmarshalInputMapNestedInput, ec.unmarshalInputMapNestedMapSliceInput, ec.unmarshalInputMapStringInterfaceInput, ec.unmarshalInputNestedInput, ec.unmarshalInputNestedMapInput, ec.unmarshalInputOmittableInput, ec.unmarshalInputOuterInput, ec.unmarshalInputOuterWrapperInput, ec.unmarshalInputRecursiveInputSlice, ec.unmarshalInputRequiredFilters, ec.unmarshalInputSearchFilters, ec.unmarshalInputSearchWithDefaults, ec.unmarshalInputSpecialInput, ec.unmarshalInputUpdateProductInput, ec.unmarshalInputUpdatePtrToPtrInner, ec.unmarshalInputUpdatePtrToPtrOuter, ec.unmarshalInputValidInput, ) 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._Subscription(ctx, opCtx.Operation.SelectionSet) var buf bytes.Buffer return func(ctx context.Context) *graphql.Response { buf.Reset() data := next(ctx) if data == nil { return nil } data.MarshalGQL(&buf) return &graphql.Response{ Data: buf.Bytes(), } } default: return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) } } type executionContext struct { *graphql.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: "inline_arguments_transformed_schema.graphql", Input: `directive @custom on ARGUMENT_DEFINITION directive @defer(if: Boolean = true, label: String) on FRAGMENT_SPREAD | INLINE_FRAGMENT directive @directive1 on FIELD_DEFINITION directive @directive2 on FIELD_DEFINITION directive @directive3 on INPUT_OBJECT directive @goField(forceResolver: Boolean, name: String, omittable: Boolean, type: String) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION directive @inlineArguments on ARGUMENT_DEFINITION directive @length(min: Int!, max: Int, message: String) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | FIELD_DEFINITION directive @logged(id: UUID!) on FIELD directive @makeNil on FIELD_DEFINITION directive @makeTypedNil on FIELD_DEFINITION directive @noop on ARGUMENT_DEFINITION directive @order1(location: String!) repeatable on FIELD_DEFINITION | OBJECT directive @order2(location: String!) on OBJECT directive @populate(value: String!) on ARGUMENT_DEFINITION directive @range(min: Int = 0, max: Int) on ARGUMENT_DEFINITION directive @toNull on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | FIELD_DEFINITION directive @unimplemented on FIELD_DEFINITION type A { id: ID! } type AIt { id: ID! } type AbIt { id: ID! } interface Animal { species: String! size: Size! } scalar Any type Autobind { int: Int! int32: Int! int64: Int! idStr: ID! idInt: ID! } type B { id: ID! } type BackedByInterface { id: String! thisShouldBind: String! thisShouldBindWithError: String! } scalar Bytes type Cat implements Animal { species: String! size: Size! catBreed: String! } input Changes @goModel(model: "map[string]interface{}") { a: Int b: Int } type CheckIssue896 { id: Int } type Circle implements Shape { radius: Float area: Float coordinates: Coordinates } type ConcreteNodeA implements Node { id: ID! child: Node! name: String! } """ Implements the Node interface with another interface """ type ConcreteNodeInterface implements Node { id: ID! child: Node! } union Content_Child = Content_User | Content_Post type Content_Post { foo: String } type Content_User { foo: String } type Coordinates { x: Float! y: Float! } scalar CustomScalar @goModel(model: "followschema.CustomScalar") input DefaultInput { falsyBoolean: Boolean = false truthyBoolean: Boolean = true } type DefaultParametersMirror { falsyBoolean: Boolean truthyBoolean: Boolean } """ This doesnt have an implementation in the typemap, so it should act like a string """ scalar DefaultScalarImplementation type DeferModel { id: ID! name: String! values: [String!]! @goField(forceResolver: true) } input DirectiveInput @goModel(model: "map[string]interface{}") { oldField: String @deprecated(reason: "Use newField instead") newField: String } type Dog implements Animal { species: String! size: Size! dogBreed: String! } scalar Email type EmbeddedCase1 @goModel(model: "followschema.EmbeddedCase1") { exportedEmbeddedPointerExportedMethod: String! } type EmbeddedCase2 @goModel(model: "followschema.EmbeddedCase2") { unexportedEmbeddedPointerExportedMethod: String! } type EmbeddedCase3 @goModel(model: "followschema.EmbeddedCase3") { unexportedEmbeddedInterfaceExportedMethod: String! } type EmbeddedDefaultScalar { value: DefaultScalarImplementation } type EmbeddedPointer @goModel(model: "followschema.EmbeddedPointerModel") { ID: String Title: String } enum EnumTest { OK NG } type Error { id: ID! errorOnNonRequiredField: String errorOnRequiredField: String! nilOnRequiredField: String! } type Errors { a: Error! b: Error! c: Error! d: Error! e: Error! } enum FallbackToStringEncoding { A B C } input FieldsOrderInput { firstField: String overrideFirstField: String } type FieldsOrderPayload { firstFieldValue: String } type ForcedResolver { field: Circle @goField(forceResolver: true) } type Horse implements Mammalian & Animal { species: String! size: Size! horseBreed: String! } input InnerDirectives { message: String! @length(min: 1, message: "not valid") } input InnerInput { id: Int! } type InnerObject { id: Int! } input InputDirectives @directive3 { text: String! @length(min: 0, max: 7, message: "not valid") nullableText: String @toNull inner: InnerDirectives! innerNullable: InnerDirectives thirdParty: ThirdParty @length(min: 0, max: 7) } input InputWithEnumValue { enum: EnumTest! } type InvalidIdentifier { id: Int! } input Issue4053Input1 { input2: Issue4053Input2 } input Issue4053Input2 { hello: String helloWithDefault: String = "world" } type It { id: ID! } type LoopA { b: LoopB! } type LoopB { a: LoopA! } interface Mammalian implements Animal { species: String! size: Size! } """ Since gqlgen defines default implementation for a Map scalar, this tests that the builtin is _not_ added to the TypeMap """ type Map { id: ID! } type MapNested @goModel(model: "followschema.MapNested") { value: CustomScalar! } input MapNestedInput @goModel(model: "followschema.MapNested") { value: CustomScalar! } input MapNestedMapSliceInput @goModel(model: "map[string]interface{}") { name: String recurse: [MapNestedMapSliceInput!] } input MapStringInterfaceInput @goModel(model: "map[string]interface{}") { a: String! b: Int c: CustomScalar nested: MapNestedInput } type MapStringInterfaceType @goModel(model: "map[string]interface{}") { a: String b: Int c: CustomScalar nested: MapNested } scalar MarshalPanic type ModelMethods { resolverField: Boolean! noContext: Boolean! withContext: Boolean! } type Mutation { defaultInput(input: DefaultInput!): DefaultParametersMirror! overrideValueViaInput(input: FieldsOrderInput!): FieldsOrderPayload! updateProduct(id: ID!, name: String, price: Float): String! issue4053(input: Issue4053Input1): Boolean! updateSomething(input: SpecialInput!): String! updatePtrToPtr(input: UpdatePtrToPtrOuter!): PtrToPtrOuter! } input NestedInput { field: Email! } input NestedMapInput { map: MapStringInterfaceInput } interface Node { id: ID! child: Node! } type ObjectDirectives @order1(location: "order1_1") @order1(location: "order1_2") @order2(location: "order2_1") { text: String! @length(min: 0, max: 7, message: "not valid") nullableText: String @toNull order: [String!]! } type ObjectDirectivesWithCustomGoModel { nullableText: String @toNull } input OmittableInput { id: ID @goField(omittable: true) bool: Boolean @goField(omittable: true) str: String @goField(omittable: true) int: Int @goField(omittable: true) time: Time @goField(omittable: true) enum: Status @goField(omittable: true) scalar: ThirdParty @goField(omittable: true) object: OuterInput @goField(omittable: true) } input OuterInput { inner: InnerInput! } type OuterObject { inner: InnerObject! } input OuterWrapperInput { inner: InputDirectives! } type OverlappingFields { oneFoo: Int! @goField(name: "foo") twoFoo: Int! @goField(name: "foo") oldFoo: Int! @goField(name: "foo", forceResolver: true) newFoo: Int! new_foo: Int! } type Panics { fieldScalarMarshal: [MarshalPanic!]! fieldFuncMarshal(u: [MarshalPanic!]!): [MarshalPanic!]! argUnmarshal(u: [MarshalPanic!]!): Boolean! } type Pet { id: Int! friends(limit: Int): [Pet!] @goField(forceResolver: true) } type Primitive { value: Int! squared: Int! } type PrimitiveString { value: String! doubled: String! len: Int! } type PtrToAnyContainer { ptrToAny: Any binding: Any } type PtrToPtrInner { key: String! value: String! } type PtrToPtrOuter { name: String! inner: PtrToPtrInner stupidInner: PtrToPtrInner } type PtrToSliceContainer { ptrToSlice: [String!] } type Query { invalidIdentifier: InvalidIdentifier collision: It mapInput(input: Changes): Boolean recursive(input: RecursiveInputSlice): Boolean nestedInputs(input: [[OuterInput]] = [[{inner:{id:1}}]]): Boolean nestedOutputs: [[OuterObject]] modelMethods: ModelMethods user(id: Int!): User! nullableArg(arg: Int = 123): String inputSlice(arg: [String!]!): Boolean! inputNullableSlice(arg: [String!]): Boolean! inputOmittable(arg: OmittableInput!): String! shapeUnion: ShapeUnion! autobind: Autobind deprecatedField: String! @deprecated(reason: "test deprecated directive") fieldWithDeprecatedArg(oldArg: Int @deprecated(reason: "old arg"), newArg: Int): String overlapping: OverlappingFields defaultParameters(falsyBoolean: Boolean = false, truthyBoolean: Boolean = true): DefaultParametersMirror! deferSingle: DeferModel deferMultiple: [DeferModel!] directiveArg(arg: String! @length(min: 1, max: 255, message: "invalid length")): String directiveNullableArg(arg: Int @range(min: 0), arg2: Int @range, arg3: String @toNull): String directiveSingleNullableArg(arg1: String @populate(value: "test") @noop): String directiveInputNullable(arg: InputDirectives): String directiveInput(arg: InputDirectives!): String directiveInputType(arg: InnerInput! @custom): String directiveInputOuter(arg: OuterWrapperInput!): String directiveObject: ObjectDirectives @order1(location: "Query_field") directiveObjectWithCustomGoModel: ObjectDirectivesWithCustomGoModel directiveFieldDef(ret: String!): String! @length(min: 1, message: "not valid") directiveField: String directiveDouble: String @directive1 @directive2 directiveUnimplemented: String @unimplemented embeddedCase1: EmbeddedCase1 embeddedCase2: EmbeddedCase2 embeddedCase3: EmbeddedCase3 enumInInput(input: InputWithEnumValue): EnumTest! searchProducts(query: String, category: String, minPrice: Int): [String!]! searchRequired(name: String!, age: Int!): [String!]! searchProductsNormal(filters: SearchFilters): [String!]! searchWithDefaults(query: String = "default search", limit: Int = 20, includeArchived: Boolean = false): [String!]! searchMixed(query: String, category: String, minPrice: Int, limit: Int = 10, offset: Int = 0, sortBy: String): [String!]! filterProducts(query: String, category: String, minPrice: Int): [String!]! findProducts(query: String, category: String, minPrice: Int): [String!]! searchWithDirectives(oldField: String @deprecated(reason: "Use newField instead"), newField: String): [String!]! shapes: [Shape] noShape: Shape @makeNil node: Node! noShapeTypedNil: Shape @makeTypedNil animal: Animal @makeTypedNil notAnInterface: BackedByInterface dog: Dog issue896a: [CheckIssue896!] mapStringInterface(in: MapStringInterfaceInput): MapStringInterfaceType mapNestedStringInterface(in: NestedMapInput): MapStringInterfaceType mapNestedMapSlice(input: MapNestedMapSliceInput): Boolean errorBubble: Error errorBubbleList: [Error!] errorList: [Error] errors: Errors valid: String! invalid: String! panics: Panics primitiveObject: [Primitive!]! primitiveStringObject: [PrimitiveString!]! ptrToAnyContainer: PtrToAnyContainer! ptrToSliceContainer: PtrToSliceContainer! infinity: Float! stringFromContextInterface: StringFromContextInterface! stringFromContextFunction: StringFromContextFunction! defaultScalar(arg: DefaultScalarImplementation! = "default"): DefaultScalarImplementation! skipInclude: SkipIncludeTestType slices: Slices scalarSlice: Bytes! fallback(arg: FallbackToStringEncoding!): FallbackToStringEncoding! optionalUnion: TestUnion vOkCaseValue: VOkCaseValue vOkCaseNil: VOkCaseNil validType: ValidType variadicModel: VariadicModel wrappedStruct: WrappedStruct! wrappedScalar: WrappedScalar! wrappedMap: WrappedMap! wrappedSlice: WrappedSlice! } type Rectangle implements Shape { length: Float width: Float area: Float coordinates: Coordinates } input RecursiveInputSlice { self: [RecursiveInputSlice!] } input RequiredFilters @goModel(model: "map[string]interface{}") { name: String! age: Int! } input SearchFilters @goModel(model: "map[string]interface{}") { query: String category: String minPrice: Int } input SearchWithDefaults @goModel(model: "map[string]interface{}") { query: String = "default search" limit: Int = 20 includeArchived: Boolean = false } interface Shape { area: Float coordinates: Coordinates } union ShapeUnion @goModel(model: "followschema.ShapeUnion") = Circle | Rectangle type Size { height: Int! weight: Int! } type SkipIncludeTestType { a: String b: String } type Slices { test1: [String] test2: [String!] test3: [String]! test4: [String!]! } input SpecialInput { nesting: NestedInput! } enum Status { OK ERROR } scalar StringFromContextFunction scalar StringFromContextInterface type Subscription { updated: String! initPayload: String! directiveArg(arg: String! @length(min: 1, max: 255, message: "invalid length")): String directiveNullableArg(arg: Int @range(min: 0), arg2: Int @range, arg3: String @toNull): String directiveDouble: String @directive1 @directive2 directiveUnimplemented: String @unimplemented issue896b: [CheckIssue896] errorRequired: Error! } union TestUnion = A | B scalar ThirdParty @goModel(model: "followschema.ThirdParty") scalar Time scalar UUID input UpdateProductInput @goModel(model: "map[string]interface{}") { id: ID! name: String price: Float } input UpdatePtrToPtrInner { key: String value: String } input UpdatePtrToPtrOuter { name: String inner: UpdatePtrToPtrInner stupidInner: UpdatePtrToPtrInner } type User { id: Int! friends: [User!]! @goField(forceResolver: true) created: Time! updated: Time pets(limit: Int): [Pet!] @goField(forceResolver: true) } type VOkCaseNil @goModel(model: "followschema.VOkCaseNil") { value: String } type VOkCaseValue @goModel(model: "followschema.VOkCaseValue") { value: String } input ValidInput { break: String! default: String! func: String! interface: String! select: String! case: String! defer: String! go: String! map: String! struct: String! chan: String! else: String! goto: String! package: String! switch: String! const: String! fallthrough: String! if: String! range: String! type: String! continue: String! for: String! import: String! return: String! var: String! _: String! @goField(name: "Underscore") } """ These things are all valid, but without care generate invalid go code """ type ValidType { differentCase: String! different_case: String! @goField(name: "DifferentCaseOld") validInputKeywords(input: ValidInput): Boolean! validArgs(break: String!, default: String!, func: String!, interface: String!, select: String!, case: String!, defer: String!, go: String!, map: String!, struct: String!, chan: String!, else: String!, goto: String!, package: String!, switch: String!, const: String!, fallthrough: String!, if: String!, range: String!, type: String!, continue: String!, for: String!, import: String!, return: String!, var: String!, _: String!): Boolean! } type VariadicModel { value(rank: Int!): String } type WrappedMap { get(key: String!): String! } scalar WrappedScalar type WrappedSlice { get(idx: Int!): String! } type WrappedStruct { name: WrappedScalar! desc: WrappedScalar } type XXIt { id: ID! } type XxIt { id: ID! } type asdfIt { id: ID! } type iIt { id: ID! } `, BuiltIn: true}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) ================================================ FILE: codegen/testserver/followschema/scalar_context.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) unmarshalNStringFromContextFunction2string(ctx context.Context, v any) (string, error) { res, err := UnmarshalStringFromContextFunction(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNStringFromContextFunction2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { _ = sel res := MarshalStringFromContextFunction(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) unmarshalNStringFromContextInterface2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐStringFromContextInterface(ctx context.Context, v any) (StringFromContextInterface, error) { var res StringFromContextInterface err := res.UnmarshalGQLContext(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNStringFromContextInterface2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐStringFromContextInterface(ctx context.Context, sel ast.SelectionSet, v StringFromContextInterface) graphql.Marshaler { return graphql.WrapContextMarshaler(ctx, v) } func (ec *executionContext) unmarshalNStringFromContextInterface2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐStringFromContextInterface(ctx context.Context, v any) (*StringFromContextInterface, error) { var res = new(StringFromContextInterface) err := res.UnmarshalGQLContext(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNStringFromContextInterface2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐStringFromContextInterface(ctx context.Context, sel ast.SelectionSet, v *StringFromContextInterface) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return graphql.WrapContextMarshaler(ctx, v) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/scalar_context.go ================================================ package followschema import ( "context" "io" "strconv" "github.com/99designs/gqlgen/graphql" ) type StringFromContextInterface struct { OperationName string } var ( _ graphql.ContextMarshaler = StringFromContextInterface{} _ graphql.ContextUnmarshaler = (*StringFromContextInterface)(nil) ) func (StringFromContextInterface) MarshalGQLContext(ctx context.Context, w io.Writer) error { io.WriteString(w, strconv.Quote(graphql.GetFieldContext(ctx).Field.Name)) return nil } func (i *StringFromContextInterface) UnmarshalGQLContext(ctx context.Context, v any) error { i.OperationName = graphql.GetFieldContext(ctx).Field.Name return nil } func MarshalStringFromContextFunction(v string) graphql.ContextMarshaler { return graphql.ContextWriterFunc(func(ctx context.Context, w io.Writer) error { io.WriteString(w, strconv.Quote(graphql.GetFieldContext(ctx).Field.Name)) return nil }) } func UnmarshalStringFromContextFunction(ctx context.Context, v any) (string, error) { return graphql.GetFieldContext(ctx).Field.Name, nil } ================================================ FILE: codegen/testserver/followschema/scalar_context.graphql ================================================ extend type Query { infinity: Float! stringFromContextInterface: StringFromContextInterface! stringFromContextFunction: StringFromContextFunction! } scalar StringFromContextInterface scalar StringFromContextFunction ================================================ FILE: codegen/testserver/followschema/scalar_context_test.go ================================================ package followschema import ( "context" "math" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestFloatInfAndNaN(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) resolvers.QueryResolver.Infinity = func(ctx context.Context) (float64, error) { return math.Inf(-1), nil } t.Run("errors on marshaller with context", func(t *testing.T) { err := c.Post(`query { infinity }`, nil) require.Error(t, err) }) } func TestContextPassedToMarshal(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) resolvers.QueryResolver.StringFromContextInterface = func(ctx context.Context) (*StringFromContextInterface, error) { return &StringFromContextInterface{}, nil } resolvers.QueryResolver.StringFromContextFunction = func(ctx context.Context) (string, error) { return "", nil } var res struct { StringFromContextInterface string StringFromContextFunction string } err := c.Post(`query my_name { stringFromContextInterface stringFromContextFunction }`, &res) require.NoError(t, err) require.Equal(t, "stringFromContextInterface", res.StringFromContextInterface) require.Equal(t, "stringFromContextFunction", res.StringFromContextFunction) } ================================================ FILE: codegen/testserver/followschema/scalar_default.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _EmbeddedDefaultScalar_value(ctx context.Context, field graphql.CollectedField, obj *EmbeddedDefaultScalar) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_EmbeddedDefaultScalar_value, func(ctx context.Context) (any, error) { return obj.Value, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalODefaultScalarImplementation2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_EmbeddedDefaultScalar_value(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "EmbeddedDefaultScalar", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type DefaultScalarImplementation does not have child fields") }, } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var embeddedDefaultScalarImplementors = []string{"EmbeddedDefaultScalar"} func (ec *executionContext) _EmbeddedDefaultScalar(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedDefaultScalar) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, embeddedDefaultScalarImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("EmbeddedDefaultScalar") case "value": out.Values[i] = ec._EmbeddedDefaultScalar_value(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) unmarshalNDefaultScalarImplementation2string(ctx context.Context, v any) (string, error) { res, err := graphql.UnmarshalString(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNDefaultScalarImplementation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { _ = 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) unmarshalODefaultScalarImplementation2ᚖ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) marshalODefaultScalarImplementation2ᚖ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 } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/scalar_default.graphql ================================================ extend type Query { defaultScalar(arg: DefaultScalarImplementation! = "default"): DefaultScalarImplementation! } """ This doesnt have an implementation in the typemap, so it should act like a string """ scalar DefaultScalarImplementation type EmbeddedDefaultScalar { value: DefaultScalarImplementation } ================================================ FILE: codegen/testserver/followschema/scalar_default_test.go ================================================ package followschema import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestDefaultScalarImplementation(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) resolvers.QueryResolver.DefaultScalar = func(ctx context.Context, arg string) (i string, e error) { return arg, nil } t.Run("with arg value", func(t *testing.T) { var resp struct{ DefaultScalar string } c.MustPost(`query { defaultScalar(arg: "fff") }`, &resp) require.Equal(t, "fff", resp.DefaultScalar) }) t.Run("with default value", func(t *testing.T) { var resp struct{ DefaultScalar string } c.MustPost(`query { defaultScalar }`, &resp) require.Equal(t, "default", resp.DefaultScalar) }) } ================================================ FILE: codegen/testserver/followschema/schema.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "fmt" "strconv" "sync/atomic" "time" introspection1 "github.com/99designs/gqlgen/codegen/testserver/followschema/introspection" invalid_packagename "github.com/99designs/gqlgen/codegen/testserver/followschema/invalid-packagename" "github.com/99designs/gqlgen/codegen/testserver/followschema/otherpkg" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** type ForcedResolverResolver interface { Field(ctx context.Context, obj *ForcedResolver) (*Circle, error) } type ModelMethodsResolver interface { ResolverField(ctx context.Context, obj *ModelMethods) (bool, error) } type PetResolver interface { Friends(ctx context.Context, obj *Pet, limit *int) ([]*Pet, error) } type QueryResolver interface { InvalidIdentifier(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) Collision(ctx context.Context) (*introspection1.It, error) MapInput(ctx context.Context, input map[string]any) (*bool, error) Recursive(ctx context.Context, input *RecursiveInputSlice) (*bool, error) NestedInputs(ctx context.Context, input [][]*OuterInput) (*bool, error) NestedOutputs(ctx context.Context) ([][]*OuterObject, error) ModelMethods(ctx context.Context) (*ModelMethods, error) User(ctx context.Context, id int) (*User, error) NullableArg(ctx context.Context, arg *int) (*string, error) InputSlice(ctx context.Context, arg []string) (bool, error) InputNullableSlice(ctx context.Context, arg []string) (bool, error) InputOmittable(ctx context.Context, arg OmittableInput) (string, error) ShapeUnion(ctx context.Context) (ShapeUnion, error) Autobind(ctx context.Context) (*Autobind, error) DeprecatedField(ctx context.Context) (string, error) FieldWithDeprecatedArg(ctx context.Context, oldArg *int, newArg *int) (*string, error) Overlapping(ctx context.Context) (*OverlappingFields, error) DefaultParameters(ctx context.Context, falsyBoolean *bool, truthyBoolean *bool) (*DefaultParametersMirror, error) DeferSingle(ctx context.Context) (*DeferModel, error) DeferMultiple(ctx context.Context) ([]*DeferModel, error) DirectiveArg(ctx context.Context, arg string) (*string, error) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (*string, error) DirectiveSingleNullableArg(ctx context.Context, arg1 *string) (*string, error) DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) DirectiveInputType(ctx context.Context, arg InnerInput) (*string, error) DirectiveInputOuter(ctx context.Context, arg OuterWrapperInput) (*string, error) DirectiveObject(ctx context.Context) (*ObjectDirectives, error) DirectiveObjectWithCustomGoModel(ctx context.Context) (*ObjectDirectivesWithCustomGoModel, error) DirectiveFieldDef(ctx context.Context, ret string) (string, error) DirectiveField(ctx context.Context) (*string, error) DirectiveDouble(ctx context.Context) (*string, error) DirectiveUnimplemented(ctx context.Context) (*string, error) EmbeddedCase1(ctx context.Context) (*EmbeddedCase1, error) EmbeddedCase2(ctx context.Context) (*EmbeddedCase2, error) EmbeddedCase3(ctx context.Context) (*EmbeddedCase3, error) EnumInInput(ctx context.Context, input *InputWithEnumValue) (EnumTest, error) SearchProducts(ctx context.Context, filters map[string]interface{}) ([]string, error) SearchRequired(ctx context.Context, filters map[string]interface{}) ([]string, error) SearchProductsNormal(ctx context.Context, filters map[string]any) ([]string, error) SearchWithDefaults(ctx context.Context, filters map[string]interface{}) ([]string, error) SearchMixed(ctx context.Context, filters map[string]interface{}, limit *int, offset *int, sortBy *string) ([]string, error) FilterProducts(ctx context.Context, filters map[string]interface{}) ([]string, error) FindProducts(ctx context.Context, filters map[string]interface{}) ([]string, error) SearchWithDirectives(ctx context.Context, input map[string]interface{}) ([]string, error) Shapes(ctx context.Context) ([]Shape, error) NoShape(ctx context.Context) (Shape, error) Node(ctx context.Context) (Node, error) NoShapeTypedNil(ctx context.Context) (Shape, error) Animal(ctx context.Context) (Animal, error) NotAnInterface(ctx context.Context) (BackedByInterface, error) Dog(ctx context.Context) (*Dog, error) Issue896a(ctx context.Context) ([]*CheckIssue896, error) MapStringInterface(ctx context.Context, in map[string]any) (map[string]any, error) MapNestedStringInterface(ctx context.Context, in *NestedMapInput) (map[string]any, error) MapNestedMapSlice(ctx context.Context, input map[string]any) (*bool, error) ErrorBubble(ctx context.Context) (*Error, error) ErrorBubbleList(ctx context.Context) ([]*Error, error) ErrorList(ctx context.Context) ([]*Error, error) Errors(ctx context.Context) (*Errors, error) Valid(ctx context.Context) (string, error) Invalid(ctx context.Context) (string, error) Panics(ctx context.Context) (*Panics, error) PrimitiveObject(ctx context.Context) ([]Primitive, error) PrimitiveStringObject(ctx context.Context) ([]PrimitiveString, error) PtrToAnyContainer(ctx context.Context) (*PtrToAnyContainer, error) PtrToSliceContainer(ctx context.Context) (*PtrToSliceContainer, error) Infinity(ctx context.Context) (float64, error) StringFromContextInterface(ctx context.Context) (*StringFromContextInterface, error) StringFromContextFunction(ctx context.Context) (string, error) DefaultScalar(ctx context.Context, arg string) (string, error) SkipInclude(ctx context.Context) (*SkipIncludeTestType, error) Slices(ctx context.Context) (*Slices, error) ScalarSlice(ctx context.Context) ([]byte, error) Fallback(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) OptionalUnion(ctx context.Context) (TestUnion, error) VOkCaseValue(ctx context.Context) (*VOkCaseValue, error) VOkCaseNil(ctx context.Context) (*VOkCaseNil, error) ValidType(ctx context.Context) (*ValidType, error) VariadicModel(ctx context.Context) (*VariadicModel, error) WrappedStruct(ctx context.Context) (*WrappedStruct, error) WrappedScalar(ctx context.Context) (otherpkg.Scalar, error) WrappedMap(ctx context.Context) (WrappedMap, error) WrappedSlice(ctx context.Context) (WrappedSlice, error) } type SubscriptionResolver interface { Updated(ctx context.Context) (<-chan string, error) InitPayload(ctx context.Context) (<-chan string, error) DirectiveArg(ctx context.Context, arg string) (<-chan *string, error) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (<-chan *string, error) DirectiveDouble(ctx context.Context) (<-chan *string, error) DirectiveUnimplemented(ctx context.Context) (<-chan *string, error) Issue896b(ctx context.Context) (<-chan []*CheckIssue896, error) ErrorRequired(ctx context.Context) (<-chan *Error, error) } type UserResolver interface { Friends(ctx context.Context, obj *User) ([]*User, error) Pets(ctx context.Context, obj *User, limit *int) ([]*Pet, error) } // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) dir_defer_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "if", ec.unmarshalOBoolean2ᚖbool) if err != nil { return nil, err } args["if"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "label", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["label"] = arg1 return args, nil } func (ec *executionContext) field_Pet_friends_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "limit", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["limit"] = arg0 return args, nil } func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]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_defaultParameters_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, "falsyBoolean", ec.unmarshalOBoolean2ᚖbool) if err != nil { return nil, err } args["falsyBoolean"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "truthyBoolean", ec.unmarshalOBoolean2ᚖbool) if err != nil { return nil, err } args["truthyBoolean"] = arg1 return args, nil } func (ec *executionContext) field_Query_defaultScalar_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "arg", ec.unmarshalNDefaultScalarImplementation2string) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_directiveArg_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Query_directiveArg_argsArg(ctx, rawArgs) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_directiveArg_argsArg( ctx context.Context, rawArgs map[string]any, ) (string, error) { if _, ok := rawArgs["arg"]; !ok { var zeroVal string return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("arg")) directive0 := func(ctx context.Context) (any, error) { tmp, ok := rawArgs["arg"] if !ok { var zeroVal string return zeroVal, nil } return ec.unmarshalNString2string(ctx, tmp) } directive1 := func(ctx context.Context) (any, error) { min, err := ec.unmarshalNInt2int(ctx, 1) if err != nil { var zeroVal string return zeroVal, err } max, err := ec.unmarshalOInt2ᚖint(ctx, 255) if err != nil { var zeroVal string return zeroVal, err } message, err := ec.unmarshalOString2ᚖstring(ctx, "invalid length") if err != nil { var zeroVal string return zeroVal, err } if ec.Directives.Length == nil { var zeroVal string return zeroVal, errors.New("directive length is not implemented") } return ec.Directives.Length(ctx, rawArgs, directive0, min, max, message) } tmp, err := directive1(ctx) if err != nil { var zeroVal string return zeroVal, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(string); ok { return data, nil } else { var zeroVal string return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp)) } } func (ec *executionContext) field_Query_directiveFieldDef_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, "ret", ec.unmarshalNString2string) if err != nil { return nil, err } args["ret"] = arg0 return args, nil } func (ec *executionContext) field_Query_directiveInputNullable_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "arg", ec.unmarshalOInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInputDirectives) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_directiveInputOuter_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, "arg", ec.unmarshalNOuterWrapperInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterWrapperInput) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_directiveInputType_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Query_directiveInputType_argsArg(ctx, rawArgs) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_directiveInputType_argsArg( ctx context.Context, rawArgs map[string]any, ) (InnerInput, error) { if _, ok := rawArgs["arg"]; !ok { var zeroVal InnerInput return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("arg")) directive0 := func(ctx context.Context) (any, error) { tmp, ok := rawArgs["arg"] if !ok { var zeroVal InnerInput return zeroVal, nil } return ec.unmarshalNInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInnerInput(ctx, tmp) } directive1 := func(ctx context.Context) (any, error) { if ec.Directives.Custom == nil { var zeroVal InnerInput return zeroVal, errors.New("directive custom is not implemented") } return ec.Directives.Custom(ctx, rawArgs, directive0) } tmp, err := directive1(ctx) if err != nil { var zeroVal InnerInput return zeroVal, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(InnerInput); ok { return data, nil } else { var zeroVal InnerInput return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be github.com/99designs/gqlgen/codegen/testserver/followschema.InnerInput`, tmp)) } } func (ec *executionContext) field_Query_directiveInput_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, "arg", ec.unmarshalNInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInputDirectives) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_directiveNullableArg_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Query_directiveNullableArg_argsArg(ctx, rawArgs) if err != nil { return nil, err } args["arg"] = arg0 arg1, err := ec.field_Query_directiveNullableArg_argsArg2(ctx, rawArgs) if err != nil { return nil, err } args["arg2"] = arg1 arg2, err := ec.field_Query_directiveNullableArg_argsArg3(ctx, rawArgs) if err != nil { return nil, err } args["arg3"] = arg2 return args, nil } func (ec *executionContext) field_Query_directiveNullableArg_argsArg( ctx context.Context, rawArgs map[string]any, ) (*int, error) { if _, ok := rawArgs["arg"]; !ok { var zeroVal *int return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("arg")) directive0 := func(ctx context.Context) (any, error) { tmp, ok := rawArgs["arg"] if !ok { var zeroVal *int return zeroVal, nil } return ec.unmarshalOInt2ᚖint(ctx, tmp) } directive1 := func(ctx context.Context) (any, error) { min, err := ec.unmarshalOInt2ᚖint(ctx, 0) if err != nil { var zeroVal *int return zeroVal, err } if ec.Directives.Range == nil { var zeroVal *int return zeroVal, errors.New("directive range is not implemented") } return ec.Directives.Range(ctx, rawArgs, directive0, min, nil) } tmp, err := directive1(ctx) if err != nil { var zeroVal *int return zeroVal, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(*int); ok { return data, nil } else if tmp == nil { var zeroVal *int return zeroVal, nil } else { var zeroVal *int return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be *int`, tmp)) } } func (ec *executionContext) field_Query_directiveNullableArg_argsArg2( ctx context.Context, rawArgs map[string]any, ) (*int, error) { if _, ok := rawArgs["arg2"]; !ok { var zeroVal *int return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("arg2")) directive0 := func(ctx context.Context) (any, error) { tmp, ok := rawArgs["arg2"] if !ok { var zeroVal *int return zeroVal, nil } return ec.unmarshalOInt2ᚖint(ctx, tmp) } directive1 := func(ctx context.Context) (any, error) { min, err := ec.unmarshalOInt2ᚖint(ctx, 0) if err != nil { var zeroVal *int return zeroVal, err } if ec.Directives.Range == nil { var zeroVal *int return zeroVal, errors.New("directive range is not implemented") } return ec.Directives.Range(ctx, rawArgs, directive0, min, nil) } tmp, err := directive1(ctx) if err != nil { var zeroVal *int return zeroVal, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(*int); ok { return data, nil } else if tmp == nil { var zeroVal *int return zeroVal, nil } else { var zeroVal *int return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be *int`, tmp)) } } func (ec *executionContext) field_Query_directiveNullableArg_argsArg3( ctx context.Context, rawArgs map[string]any, ) (*string, error) { if _, ok := rawArgs["arg3"]; !ok { var zeroVal *string return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("arg3")) directive0 := func(ctx context.Context) (any, error) { tmp, ok := rawArgs["arg3"] if !ok { var zeroVal *string return zeroVal, nil } return ec.unmarshalOString2ᚖstring(ctx, tmp) } directive1 := func(ctx context.Context) (any, error) { if ec.Directives.ToNull == nil { var zeroVal *string return zeroVal, errors.New("directive toNull is not implemented") } return ec.Directives.ToNull(ctx, rawArgs, directive0) } tmp, err := directive1(ctx) if err != nil { var zeroVal *string return zeroVal, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(*string); ok { return data, nil } else if tmp == nil { var zeroVal *string return zeroVal, nil } else { var zeroVal *string return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp)) } } func (ec *executionContext) field_Query_directiveSingleNullableArg_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Query_directiveSingleNullableArg_argsArg1(ctx, rawArgs) if err != nil { return nil, err } args["arg1"] = arg0 return args, nil } func (ec *executionContext) field_Query_directiveSingleNullableArg_argsArg1( ctx context.Context, rawArgs map[string]any, ) (*string, error) { if _, ok := rawArgs["arg1"]; !ok { var zeroVal *string return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("arg1")) directive0 := func(ctx context.Context) (any, error) { tmp, ok := rawArgs["arg1"] if !ok { var zeroVal *string return zeroVal, nil } return ec.unmarshalOString2ᚖstring(ctx, tmp) } directive1 := func(ctx context.Context) (any, error) { value, err := ec.unmarshalNString2string(ctx, "test") if err != nil { var zeroVal *string return zeroVal, err } if ec.Directives.Populate == nil { var zeroVal *string return zeroVal, errors.New("directive populate is not implemented") } return ec.Directives.Populate(ctx, rawArgs, directive0, value) } directive2 := func(ctx context.Context) (any, error) { if ec.Directives.Noop == nil { var zeroVal *string return zeroVal, errors.New("directive noop is not implemented") } return ec.Directives.Noop(ctx, rawArgs, directive1) } tmp, err := directive2(ctx) if err != nil { var zeroVal *string return zeroVal, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(*string); ok { return data, nil } else if tmp == nil { var zeroVal *string return zeroVal, nil } else { var zeroVal *string return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp)) } } func (ec *executionContext) field_Query_enumInInput_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, "input", ec.unmarshalOInputWithEnumValue2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInputWithEnumValue) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Query_fallback_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "arg", ec.unmarshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFallbackToStringEncoding) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_fieldWithDeprecatedArg_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, "oldArg", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["oldArg"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "newArg", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["newArg"] = arg1 return args, nil } func (ec *executionContext) field_Query_filterProducts_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, "query", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["query"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "category", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["category"] = arg1 arg2, err := graphql.ProcessArgField(ctx, rawArgs, "minPrice", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["minPrice"] = arg2 return args, nil } func (ec *executionContext) field_Query_findProducts_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, "query", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["query"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "category", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["category"] = arg1 arg2, err := graphql.ProcessArgField(ctx, rawArgs, "minPrice", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["minPrice"] = arg2 return args, nil } func (ec *executionContext) field_Query_inputNullableSlice_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, "arg", ec.unmarshalOString2ᚕstringᚄ) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_inputOmittable_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "arg", ec.unmarshalNOmittableInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOmittableInput) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_inputSlice_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "arg", ec.unmarshalNString2ᚕstringᚄ) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_mapInput_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalOChanges2map) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Query_mapNestedMapSlice_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, "input", ec.unmarshalOMapNestedMapSliceInput2map) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Query_mapNestedStringInterface_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "in", ec.unmarshalONestedMapInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNestedMapInput) if err != nil { return nil, err } args["in"] = arg0 return args, nil } func (ec *executionContext) field_Query_mapStringInterface_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "in", ec.unmarshalOMapStringInterfaceInput2map) if err != nil { return nil, err } args["in"] = arg0 return args, nil } func (ec *executionContext) field_Query_nestedInputs_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalOOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterInput) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Query_nullableArg_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "arg", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_recursive_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalORecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐRecursiveInputSlice) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Query_searchMixed_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, "query", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["query"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "category", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["category"] = arg1 arg2, err := graphql.ProcessArgField(ctx, rawArgs, "minPrice", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["minPrice"] = arg2 arg3, err := graphql.ProcessArgField(ctx, rawArgs, "limit", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["limit"] = arg3 arg4, err := graphql.ProcessArgField(ctx, rawArgs, "offset", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["offset"] = arg4 arg5, err := graphql.ProcessArgField(ctx, rawArgs, "sortBy", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["sortBy"] = arg5 return args, nil } func (ec *executionContext) field_Query_searchProductsNormal_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, "filters", ec.unmarshalOSearchFilters2map) if err != nil { return nil, err } args["filters"] = arg0 return args, nil } func (ec *executionContext) field_Query_searchProducts_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, "query", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["query"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "category", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["category"] = arg1 arg2, err := graphql.ProcessArgField(ctx, rawArgs, "minPrice", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["minPrice"] = arg2 return args, nil } func (ec *executionContext) field_Query_searchRequired_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 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "age", ec.unmarshalNInt2int) if err != nil { return nil, err } args["age"] = arg1 return args, nil } func (ec *executionContext) field_Query_searchWithDefaults_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, "query", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["query"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "limit", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["limit"] = arg1 arg2, err := graphql.ProcessArgField(ctx, rawArgs, "includeArchived", ec.unmarshalOBoolean2ᚖbool) if err != nil { return nil, err } args["includeArchived"] = arg2 return args, nil } func (ec *executionContext) field_Query_searchWithDirectives_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, "oldField", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["oldField"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "newField", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["newField"] = arg1 return args, nil } func (ec *executionContext) field_Query_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, "id", ec.unmarshalNInt2int) if err != nil { return nil, err } args["id"] = arg0 return args, nil } func (ec *executionContext) field_Subscription_directiveArg_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Subscription_directiveArg_argsArg(ctx, rawArgs) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Subscription_directiveArg_argsArg( ctx context.Context, rawArgs map[string]any, ) (string, error) { if _, ok := rawArgs["arg"]; !ok { var zeroVal string return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("arg")) directive0 := func(ctx context.Context) (any, error) { tmp, ok := rawArgs["arg"] if !ok { var zeroVal string return zeroVal, nil } return ec.unmarshalNString2string(ctx, tmp) } directive1 := func(ctx context.Context) (any, error) { min, err := ec.unmarshalNInt2int(ctx, 1) if err != nil { var zeroVal string return zeroVal, err } max, err := ec.unmarshalOInt2ᚖint(ctx, 255) if err != nil { var zeroVal string return zeroVal, err } message, err := ec.unmarshalOString2ᚖstring(ctx, "invalid length") if err != nil { var zeroVal string return zeroVal, err } if ec.Directives.Length == nil { var zeroVal string return zeroVal, errors.New("directive length is not implemented") } return ec.Directives.Length(ctx, rawArgs, directive0, min, max, message) } tmp, err := directive1(ctx) if err != nil { var zeroVal string return zeroVal, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(string); ok { return data, nil } else { var zeroVal string return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp)) } } func (ec *executionContext) field_Subscription_directiveNullableArg_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Subscription_directiveNullableArg_argsArg(ctx, rawArgs) if err != nil { return nil, err } args["arg"] = arg0 arg1, err := ec.field_Subscription_directiveNullableArg_argsArg2(ctx, rawArgs) if err != nil { return nil, err } args["arg2"] = arg1 arg2, err := ec.field_Subscription_directiveNullableArg_argsArg3(ctx, rawArgs) if err != nil { return nil, err } args["arg3"] = arg2 return args, nil } func (ec *executionContext) field_Subscription_directiveNullableArg_argsArg( ctx context.Context, rawArgs map[string]any, ) (*int, error) { if _, ok := rawArgs["arg"]; !ok { var zeroVal *int return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("arg")) directive0 := func(ctx context.Context) (any, error) { tmp, ok := rawArgs["arg"] if !ok { var zeroVal *int return zeroVal, nil } return ec.unmarshalOInt2ᚖint(ctx, tmp) } directive1 := func(ctx context.Context) (any, error) { min, err := ec.unmarshalOInt2ᚖint(ctx, 0) if err != nil { var zeroVal *int return zeroVal, err } if ec.Directives.Range == nil { var zeroVal *int return zeroVal, errors.New("directive range is not implemented") } return ec.Directives.Range(ctx, rawArgs, directive0, min, nil) } tmp, err := directive1(ctx) if err != nil { var zeroVal *int return zeroVal, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(*int); ok { return data, nil } else if tmp == nil { var zeroVal *int return zeroVal, nil } else { var zeroVal *int return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be *int`, tmp)) } } func (ec *executionContext) field_Subscription_directiveNullableArg_argsArg2( ctx context.Context, rawArgs map[string]any, ) (*int, error) { if _, ok := rawArgs["arg2"]; !ok { var zeroVal *int return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("arg2")) directive0 := func(ctx context.Context) (any, error) { tmp, ok := rawArgs["arg2"] if !ok { var zeroVal *int return zeroVal, nil } return ec.unmarshalOInt2ᚖint(ctx, tmp) } directive1 := func(ctx context.Context) (any, error) { min, err := ec.unmarshalOInt2ᚖint(ctx, 0) if err != nil { var zeroVal *int return zeroVal, err } if ec.Directives.Range == nil { var zeroVal *int return zeroVal, errors.New("directive range is not implemented") } return ec.Directives.Range(ctx, rawArgs, directive0, min, nil) } tmp, err := directive1(ctx) if err != nil { var zeroVal *int return zeroVal, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(*int); ok { return data, nil } else if tmp == nil { var zeroVal *int return zeroVal, nil } else { var zeroVal *int return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be *int`, tmp)) } } func (ec *executionContext) field_Subscription_directiveNullableArg_argsArg3( ctx context.Context, rawArgs map[string]any, ) (*string, error) { if _, ok := rawArgs["arg3"]; !ok { var zeroVal *string return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("arg3")) directive0 := func(ctx context.Context) (any, error) { tmp, ok := rawArgs["arg3"] if !ok { var zeroVal *string return zeroVal, nil } return ec.unmarshalOString2ᚖstring(ctx, tmp) } directive1 := func(ctx context.Context) (any, error) { if ec.Directives.ToNull == nil { var zeroVal *string return zeroVal, errors.New("directive toNull is not implemented") } return ec.Directives.ToNull(ctx, rawArgs, directive0) } tmp, err := directive1(ctx) if err != nil { var zeroVal *string return zeroVal, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(*string); ok { return data, nil } else if tmp == nil { var zeroVal *string return zeroVal, nil } else { var zeroVal *string return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp)) } } func (ec *executionContext) field_User_pets_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, "limit", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["limit"] = arg0 return args, nil } // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _Autobind_int(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Autobind_int, func(ctx context.Context) (any, error) { return obj.Int, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_Autobind_int(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Autobind", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _Autobind_int32(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Autobind_int32, func(ctx context.Context) (any, error) { return obj.Int32, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int32, true, true, ) } func (ec *executionContext) fieldContext_Autobind_int32(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Autobind", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _Autobind_int64(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Autobind_int64, func(ctx context.Context) (any, error) { return obj.Int64, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int64, true, true, ) } func (ec *executionContext) fieldContext_Autobind_int64(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Autobind", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _Autobind_idStr(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Autobind_idStr, func(ctx context.Context) (any, error) { return obj.IdStr, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_Autobind_idStr(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Autobind", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _Autobind_idInt(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Autobind_idInt, func(ctx context.Context) (any, error) { return obj.IdInt, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2int, true, true, ) } func (ec *executionContext) fieldContext_Autobind_idInt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Autobind", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _EmbeddedPointer_ID(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_EmbeddedPointer_ID, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2string, true, false, ) } func (ec *executionContext) fieldContext_EmbeddedPointer_ID(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "EmbeddedPointer", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _EmbeddedPointer_Title(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_EmbeddedPointer_Title, func(ctx context.Context) (any, error) { return obj.Title, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2string, true, false, ) } func (ec *executionContext) fieldContext_EmbeddedPointer_Title(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "EmbeddedPointer", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field graphql.CollectedField, obj *ForcedResolver) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ForcedResolver_field, func(ctx context.Context) (any, error) { return ec.Resolvers.ForcedResolver().Field(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOCircle2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCircle, true, false, ) } func (ec *executionContext) fieldContext_ForcedResolver_field(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ForcedResolver", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "radius": return ec.fieldContext_Circle_radius(ctx, field) case "area": return ec.fieldContext_Circle_area(ctx, field) case "coordinates": return ec.fieldContext_Circle_coordinates(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Circle", field.Name) }, } return fc, nil } func (ec *executionContext) _InnerObject_id(ctx context.Context, field graphql.CollectedField, obj *InnerObject) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_InnerObject_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_InnerObject_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "InnerObject", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _InvalidIdentifier_id(ctx context.Context, field graphql.CollectedField, obj *invalid_packagename.InvalidIdentifier) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_InvalidIdentifier_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_InvalidIdentifier_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "InvalidIdentifier", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedField, obj *introspection1.It) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_It_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_It_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "It", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _ModelMethods_resolverField(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ModelMethods_resolverField, func(ctx context.Context) (any, error) { return ec.Resolvers.ModelMethods().ResolverField(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNBoolean2bool, true, true, ) } func (ec *executionContext) fieldContext_ModelMethods_resolverField(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ModelMethods", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } func (ec *executionContext) _ModelMethods_noContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ModelMethods_noContext, func(ctx context.Context) (any, error) { return obj.NoContext(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNBoolean2bool, true, true, ) } func (ec *executionContext) fieldContext_ModelMethods_noContext(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ModelMethods", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } func (ec *executionContext) _ModelMethods_withContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ModelMethods_withContext, func(ctx context.Context) (any, error) { return obj.WithContext(ctx), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNBoolean2bool, true, true, ) } func (ec *executionContext) fieldContext_ModelMethods_withContext(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ModelMethods", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphql.CollectedField, obj *OuterObject) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_OuterObject_inner, func(ctx context.Context) (any, error) { return obj.Inner, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInnerObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInnerObject, true, true, ) } func (ec *executionContext) fieldContext_OuterObject_inner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "OuterObject", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_InnerObject_id(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type InnerObject", field.Name) }, } return fc, nil } func (ec *executionContext) _Pet_id(ctx context.Context, field graphql.CollectedField, obj *Pet) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Pet_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_Pet_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Pet", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _Pet_friends(ctx context.Context, field graphql.CollectedField, obj *Pet) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Pet_friends, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Pet().Friends(ctx, obj, fc.Args["limit"].(*int)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOPet2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPetᚄ, true, false, ) } func (ec *executionContext) fieldContext_Pet_friends(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Pet", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Pet_id(ctx, field) case "friends": return ec.fieldContext_Pet_friends(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Pet", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Pet_friends_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_invalidIdentifier, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().InvalidIdentifier(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOInvalidIdentifier2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋinvalidᚑpackagenameᚐInvalidIdentifier, true, false, ) } func (ec *executionContext) fieldContext_Query_invalidIdentifier(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_InvalidIdentifier_id(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type InvalidIdentifier", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_collision(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_collision, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Collision(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOIt2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋintrospectionᚐIt, true, false, ) } func (ec *executionContext) fieldContext_Query_collision(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_It_id(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type It", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_mapInput, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().MapInput(ctx, fc.Args["input"].(map[string]any)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOBoolean2ᚖbool, true, false, ) } func (ec *executionContext) fieldContext_Query_mapInput(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_mapInput_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_recursive, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().Recursive(ctx, fc.Args["input"].(*RecursiveInputSlice)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOBoolean2ᚖbool, true, false, ) } func (ec *executionContext) fieldContext_Query_recursive(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_recursive_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_nestedInputs, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().NestedInputs(ctx, fc.Args["input"].([][]*OuterInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOBoolean2ᚖbool, true, false, ) } func (ec *executionContext) fieldContext_Query_nestedInputs(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_nestedInputs_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_nestedOutputs, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().NestedOutputs(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOOuterObject2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterObject, true, false, ) } func (ec *executionContext) fieldContext_Query_nestedOutputs(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "inner": return ec.fieldContext_OuterObject_inner(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type OuterObject", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_modelMethods(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_modelMethods, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().ModelMethods(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOModelMethods2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐModelMethods, true, false, ) } func (ec *executionContext) fieldContext_Query_modelMethods(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "resolverField": return ec.fieldContext_ModelMethods_resolverField(ctx, field) case "noContext": return ec.fieldContext_ModelMethods_noContext(ctx, field) case "withContext": return ec.fieldContext_ModelMethods_withContext(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type ModelMethods", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_user, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().User(ctx, fc.Args["id"].(int)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUser, true, true, ) } func (ec *executionContext) fieldContext_Query_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_User_id(ctx, field) case "friends": return ec.fieldContext_User_friends(ctx, field) case "created": return ec.fieldContext_User_created(ctx, field) case "updated": return ec.fieldContext_User_updated(ctx, field) case "pets": return ec.fieldContext_User_pets(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_user_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_nullableArg(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_nullableArg, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().NullableArg(ctx, fc.Args["arg"].(*int)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_nullableArg(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_nullableArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_inputSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_inputSlice, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().InputSlice(ctx, fc.Args["arg"].([]string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNBoolean2bool, true, true, ) } func (ec *executionContext) fieldContext_Query_inputSlice(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_inputSlice_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_inputNullableSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_inputNullableSlice, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().InputNullableSlice(ctx, fc.Args["arg"].([]string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNBoolean2bool, true, true, ) } func (ec *executionContext) fieldContext_Query_inputNullableSlice(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_inputNullableSlice_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_inputOmittable(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_inputOmittable, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().InputOmittable(ctx, fc.Args["arg"].(OmittableInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Query_inputOmittable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_inputOmittable_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_shapeUnion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_shapeUnion, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().ShapeUnion(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNShapeUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShapeUnion, true, true, ) } func (ec *executionContext) fieldContext_Query_shapeUnion(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ShapeUnion does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_autobind(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_autobind, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Autobind(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOAutobind2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐAutobind, true, false, ) } func (ec *executionContext) fieldContext_Query_autobind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "int": return ec.fieldContext_Autobind_int(ctx, field) case "int32": return ec.fieldContext_Autobind_int32(ctx, field) case "int64": return ec.fieldContext_Autobind_int64(ctx, field) case "idStr": return ec.fieldContext_Autobind_idStr(ctx, field) case "idInt": return ec.fieldContext_Autobind_idInt(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Autobind", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_deprecatedField(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_deprecatedField, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().DeprecatedField(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Query_deprecatedField(_ 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_fieldWithDeprecatedArg(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_fieldWithDeprecatedArg, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().FieldWithDeprecatedArg(ctx, fc.Args["oldArg"].(*int), fc.Args["newArg"].(*int)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_fieldWithDeprecatedArg(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_fieldWithDeprecatedArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_overlapping(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_overlapping, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Overlapping(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOOverlappingFields2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOverlappingFields, true, false, ) } func (ec *executionContext) fieldContext_Query_overlapping(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "oneFoo": return ec.fieldContext_OverlappingFields_oneFoo(ctx, field) case "twoFoo": return ec.fieldContext_OverlappingFields_twoFoo(ctx, field) case "oldFoo": return ec.fieldContext_OverlappingFields_oldFoo(ctx, field) case "newFoo": return ec.fieldContext_OverlappingFields_newFoo(ctx, field) case "new_foo": return ec.fieldContext_OverlappingFields_new_foo(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type OverlappingFields", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_defaultParameters(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_defaultParameters, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().DefaultParameters(ctx, fc.Args["falsyBoolean"].(*bool), fc.Args["truthyBoolean"].(*bool)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNDefaultParametersMirror2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDefaultParametersMirror, true, true, ) } func (ec *executionContext) fieldContext_Query_defaultParameters(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "falsyBoolean": return ec.fieldContext_DefaultParametersMirror_falsyBoolean(ctx, field) case "truthyBoolean": return ec.fieldContext_DefaultParametersMirror_truthyBoolean(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type DefaultParametersMirror", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_defaultParameters_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_deferSingle(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_deferSingle, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().DeferSingle(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalODeferModel2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDeferModel, true, false, ) } func (ec *executionContext) fieldContext_Query_deferSingle(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_DeferModel_id(ctx, field) case "name": return ec.fieldContext_DeferModel_name(ctx, field) case "values": return ec.fieldContext_DeferModel_values(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type DeferModel", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_deferMultiple(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_deferMultiple, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().DeferMultiple(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalODeferModel2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDeferModelᚄ, true, false, ) } func (ec *executionContext) fieldContext_Query_deferMultiple(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_DeferModel_id(ctx, field) case "name": return ec.fieldContext_DeferModel_name(ctx, field) case "values": return ec.fieldContext_DeferModel_values(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type DeferModel", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_directiveArg(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveArg, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().DirectiveArg(ctx, fc.Args["arg"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_directiveArg(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_directiveArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_directiveNullableArg(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveNullableArg, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().DirectiveNullableArg(ctx, fc.Args["arg"].(*int), fc.Args["arg2"].(*int), fc.Args["arg3"].(*string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_directiveNullableArg(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_directiveNullableArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_directiveSingleNullableArg(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveSingleNullableArg, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().DirectiveSingleNullableArg(ctx, fc.Args["arg1"].(*string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_directiveSingleNullableArg(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_directiveSingleNullableArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_directiveInputNullable(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveInputNullable, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().DirectiveInputNullable(ctx, fc.Args["arg"].(*InputDirectives)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_directiveInputNullable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_directiveInputNullable_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_directiveInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveInput, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().DirectiveInput(ctx, fc.Args["arg"].(InputDirectives)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_directiveInput(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_directiveInput_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_directiveInputType(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveInputType, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().DirectiveInputType(ctx, fc.Args["arg"].(InnerInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_directiveInputType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_directiveInputType_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_directiveInputOuter(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveInputOuter, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().DirectiveInputOuter(ctx, fc.Args["arg"].(OuterWrapperInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_directiveInputOuter(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_directiveInputOuter_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_directiveObject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveObject, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().DirectiveObject(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { location, err := ec.unmarshalNString2string(ctx, "order1_1") if err != nil { var zeroVal *ObjectDirectives return zeroVal, err } if ec.Directives.Order1 == nil { var zeroVal *ObjectDirectives return zeroVal, errors.New("directive order1 is not implemented") } return ec.Directives.Order1(ctx, nil, directive0, location) } directive2 := func(ctx context.Context) (any, error) { location, err := ec.unmarshalNString2string(ctx, "order1_2") if err != nil { var zeroVal *ObjectDirectives return zeroVal, err } if ec.Directives.Order1 == nil { var zeroVal *ObjectDirectives return zeroVal, errors.New("directive order1 is not implemented") } return ec.Directives.Order1(ctx, nil, directive1, location) } directive3 := func(ctx context.Context) (any, error) { location, err := ec.unmarshalNString2string(ctx, "order2_1") if err != nil { var zeroVal *ObjectDirectives return zeroVal, err } if ec.Directives.Order2 == nil { var zeroVal *ObjectDirectives return zeroVal, errors.New("directive order2 is not implemented") } return ec.Directives.Order2(ctx, nil, directive2, location) } directive4 := func(ctx context.Context) (any, error) { location, err := ec.unmarshalNString2string(ctx, "Query_field") if err != nil { var zeroVal *ObjectDirectives return zeroVal, err } if ec.Directives.Order1 == nil { var zeroVal *ObjectDirectives return zeroVal, errors.New("directive order1 is not implemented") } return ec.Directives.Order1(ctx, nil, directive3, location) } next = directive4 return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOObjectDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐObjectDirectives, true, false, ) } func (ec *executionContext) fieldContext_Query_directiveObject(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "text": return ec.fieldContext_ObjectDirectives_text(ctx, field) case "nullableText": return ec.fieldContext_ObjectDirectives_nullableText(ctx, field) case "order": return ec.fieldContext_ObjectDirectives_order(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type ObjectDirectives", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_directiveObjectWithCustomGoModel(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveObjectWithCustomGoModel, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().DirectiveObjectWithCustomGoModel(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOObjectDirectivesWithCustomGoModel2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐObjectDirectivesWithCustomGoModel, true, false, ) } func (ec *executionContext) fieldContext_Query_directiveObjectWithCustomGoModel(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "nullableText": return ec.fieldContext_ObjectDirectivesWithCustomGoModel_nullableText(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type ObjectDirectivesWithCustomGoModel", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_directiveFieldDef(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveFieldDef, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().DirectiveFieldDef(ctx, fc.Args["ret"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { min, err := ec.unmarshalNInt2int(ctx, 1) if err != nil { var zeroVal string return zeroVal, err } message, err := ec.unmarshalOString2ᚖstring(ctx, "not valid") if err != nil { var zeroVal string return zeroVal, err } if ec.Directives.Length == nil { var zeroVal string return zeroVal, errors.New("directive length is not implemented") } return ec.Directives.Length(ctx, nil, directive0, min, nil, message) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Query_directiveFieldDef(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_directiveFieldDef_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_directiveField(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveField, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().DirectiveField(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_directiveField(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_directiveDouble(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveDouble, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().DirectiveDouble(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { if ec.Directives.Directive1 == nil { var zeroVal *string return zeroVal, errors.New("directive directive1 is not implemented") } return ec.Directives.Directive1(ctx, nil, directive0) } directive2 := func(ctx context.Context) (any, error) { if ec.Directives.Directive2 == nil { var zeroVal *string return zeroVal, errors.New("directive directive2 is not implemented") } return ec.Directives.Directive2(ctx, nil, directive1) } next = directive2 return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_directiveDouble(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_directiveUnimplemented(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveUnimplemented, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().DirectiveUnimplemented(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { if ec.Directives.Unimplemented == nil { var zeroVal *string return zeroVal, errors.New("directive unimplemented is not implemented") } return ec.Directives.Unimplemented(ctx, nil, directive0) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_directiveUnimplemented(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_embeddedCase1(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_embeddedCase1, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().EmbeddedCase1(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOEmbeddedCase12ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEmbeddedCase1, true, false, ) } func (ec *executionContext) fieldContext_Query_embeddedCase1(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "exportedEmbeddedPointerExportedMethod": return ec.fieldContext_EmbeddedCase1_exportedEmbeddedPointerExportedMethod(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type EmbeddedCase1", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_embeddedCase2(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_embeddedCase2, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().EmbeddedCase2(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOEmbeddedCase22ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEmbeddedCase2, true, false, ) } func (ec *executionContext) fieldContext_Query_embeddedCase2(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "unexportedEmbeddedPointerExportedMethod": return ec.fieldContext_EmbeddedCase2_unexportedEmbeddedPointerExportedMethod(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type EmbeddedCase2", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_embeddedCase3(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_embeddedCase3, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().EmbeddedCase3(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOEmbeddedCase32ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEmbeddedCase3, true, false, ) } func (ec *executionContext) fieldContext_Query_embeddedCase3(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "unexportedEmbeddedInterfaceExportedMethod": return ec.fieldContext_EmbeddedCase3_unexportedEmbeddedInterfaceExportedMethod(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type EmbeddedCase3", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_enumInInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_enumInInput, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().EnumInInput(ctx, fc.Args["input"].(*InputWithEnumValue)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNEnumTest2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐEnumTest, true, true, ) } func (ec *executionContext) fieldContext_Query_enumInInput(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type EnumTest does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_enumInInput_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_searchProducts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_searchProducts, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().SearchProducts(ctx, map[string]interface{}{ "query": fc.Args["query"].(*string), "category": fc.Args["category"].(*string), "minPrice": fc.Args["minPrice"].(*int), }) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2ᚕstringᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_searchProducts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_searchProducts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_searchRequired(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_searchRequired, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().SearchRequired(ctx, map[string]interface{}{ "name": fc.Args["name"].(string), "age": fc.Args["age"].(int), }) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2ᚕstringᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_searchRequired(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_searchRequired_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_searchProductsNormal(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_searchProductsNormal, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().SearchProductsNormal(ctx, fc.Args["filters"].(map[string]any)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2ᚕstringᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_searchProductsNormal(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_searchProductsNormal_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_searchWithDefaults(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_searchWithDefaults, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().SearchWithDefaults(ctx, map[string]interface{}{ "query": fc.Args["query"].(*string), "limit": fc.Args["limit"].(*int), "includeArchived": fc.Args["includeArchived"].(*bool), }) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2ᚕstringᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_searchWithDefaults(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_searchWithDefaults_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_searchMixed(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_searchMixed, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().SearchMixed(ctx, map[string]interface{}{ "query": fc.Args["query"].(*string), "category": fc.Args["category"].(*string), "minPrice": fc.Args["minPrice"].(*int), }, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["sortBy"].(*string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2ᚕstringᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_searchMixed(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_searchMixed_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_filterProducts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_filterProducts, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().FilterProducts(ctx, map[string]interface{}{ "query": fc.Args["query"].(*string), "category": fc.Args["category"].(*string), "minPrice": fc.Args["minPrice"].(*int), }) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2ᚕstringᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_filterProducts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_filterProducts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_findProducts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_findProducts, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().FindProducts(ctx, map[string]interface{}{ "query": fc.Args["query"].(*string), "category": fc.Args["category"].(*string), "minPrice": fc.Args["minPrice"].(*int), }) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2ᚕstringᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_findProducts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_findProducts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_searchWithDirectives(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_searchWithDirectives, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().SearchWithDirectives(ctx, map[string]interface{}{ "oldField": fc.Args["oldField"].(*string), "newField": fc.Args["newField"].(*string), }) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2ᚕstringᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_searchWithDirectives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_searchWithDirectives_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_shapes, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Shapes(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShape, true, false, ) } func (ec *executionContext) fieldContext_Query_shapes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } return fc, nil } func (ec *executionContext) _Query_noShape(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_noShape, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().NoShape(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { if ec.Directives.MakeNil == nil { var zeroVal Shape return zeroVal, errors.New("directive makeNil is not implemented") } return ec.Directives.MakeNil(ctx, nil, directive0) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShape, true, false, ) } func (ec *executionContext) fieldContext_Query_noShape(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } return fc, nil } func (ec *executionContext) _Query_node(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_node, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Node(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐNode, true, true, ) } func (ec *executionContext) fieldContext_Query_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } return fc, nil } func (ec *executionContext) _Query_noShapeTypedNil(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_noShapeTypedNil, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().NoShapeTypedNil(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { if ec.Directives.MakeTypedNil == nil { var zeroVal Shape return zeroVal, errors.New("directive makeTypedNil is not implemented") } return ec.Directives.MakeTypedNil(ctx, nil, directive0) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐShape, true, false, ) } func (ec *executionContext) fieldContext_Query_noShapeTypedNil(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } return fc, nil } func (ec *executionContext) _Query_animal(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_animal, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Animal(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { if ec.Directives.MakeTypedNil == nil { var zeroVal Animal return zeroVal, errors.New("directive makeTypedNil is not implemented") } return ec.Directives.MakeTypedNil(ctx, nil, directive0) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOAnimal2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐAnimal, true, false, ) } func (ec *executionContext) fieldContext_Query_animal(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } return fc, nil } func (ec *executionContext) _Query_notAnInterface(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_notAnInterface, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().NotAnInterface(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOBackedByInterface2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐBackedByInterface, true, false, ) } func (ec *executionContext) fieldContext_Query_notAnInterface(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_BackedByInterface_id(ctx, field) case "thisShouldBind": return ec.fieldContext_BackedByInterface_thisShouldBind(ctx, field) case "thisShouldBindWithError": return ec.fieldContext_BackedByInterface_thisShouldBindWithError(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type BackedByInterface", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_dog(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_dog, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Dog(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalODog2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐDog, true, false, ) } func (ec *executionContext) fieldContext_Query_dog(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "species": return ec.fieldContext_Dog_species(ctx, field) case "size": return ec.fieldContext_Dog_size(ctx, field) case "dogBreed": return ec.fieldContext_Dog_dogBreed(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Dog", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_issue896a(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_issue896a, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Issue896a(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCheckIssue896ᚄ, true, false, ) } func (ec *executionContext) fieldContext_Query_issue896a(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_CheckIssue896_id(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type CheckIssue896", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_mapStringInterface(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_mapStringInterface, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().MapStringInterface(ctx, fc.Args["in"].(map[string]any)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOMapStringInterfaceType2map, true, false, ) } func (ec *executionContext) fieldContext_Query_mapStringInterface(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "a": return ec.fieldContext_MapStringInterfaceType_a(ctx, field) case "b": return ec.fieldContext_MapStringInterfaceType_b(ctx, field) case "c": return ec.fieldContext_MapStringInterfaceType_c(ctx, field) case "nested": return ec.fieldContext_MapStringInterfaceType_nested(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type MapStringInterfaceType", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_mapStringInterface_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_mapNestedStringInterface(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_mapNestedStringInterface, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().MapNestedStringInterface(ctx, fc.Args["in"].(*NestedMapInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOMapStringInterfaceType2map, true, false, ) } func (ec *executionContext) fieldContext_Query_mapNestedStringInterface(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "a": return ec.fieldContext_MapStringInterfaceType_a(ctx, field) case "b": return ec.fieldContext_MapStringInterfaceType_b(ctx, field) case "c": return ec.fieldContext_MapStringInterfaceType_c(ctx, field) case "nested": return ec.fieldContext_MapStringInterfaceType_nested(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type MapStringInterfaceType", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_mapNestedStringInterface_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_mapNestedMapSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_mapNestedMapSlice, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().MapNestedMapSlice(ctx, fc.Args["input"].(map[string]any)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOBoolean2ᚖbool, true, false, ) } func (ec *executionContext) fieldContext_Query_mapNestedMapSlice(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_mapNestedMapSlice_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_errorBubble(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_errorBubble, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().ErrorBubble(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError, true, false, ) } func (ec *executionContext) fieldContext_Query_errorBubble(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Error_id(ctx, field) case "errorOnNonRequiredField": return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) case "errorOnRequiredField": return ec.fieldContext_Error_errorOnRequiredField(ctx, field) case "nilOnRequiredField": return ec.fieldContext_Error_nilOnRequiredField(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_errorBubbleList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_errorBubbleList, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().ErrorBubbleList(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐErrorᚄ, true, false, ) } func (ec *executionContext) fieldContext_Query_errorBubbleList(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Error_id(ctx, field) case "errorOnNonRequiredField": return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) case "errorOnRequiredField": return ec.fieldContext_Error_errorOnRequiredField(ctx, field) case "nilOnRequiredField": return ec.fieldContext_Error_nilOnRequiredField(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_errorList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_errorList, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().ErrorList(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError, true, false, ) } func (ec *executionContext) fieldContext_Query_errorList(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Error_id(ctx, field) case "errorOnNonRequiredField": return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) case "errorOnRequiredField": return ec.fieldContext_Error_errorOnRequiredField(ctx, field) case "nilOnRequiredField": return ec.fieldContext_Error_nilOnRequiredField(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_errors(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_errors, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Errors(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOErrors2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐErrors, true, false, ) } func (ec *executionContext) fieldContext_Query_errors(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "a": return ec.fieldContext_Errors_a(ctx, field) case "b": return ec.fieldContext_Errors_b(ctx, field) case "c": return ec.fieldContext_Errors_c(ctx, field) case "d": return ec.fieldContext_Errors_d(ctx, field) case "e": return ec.fieldContext_Errors_e(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Errors", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_valid, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Valid(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Query_valid(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_invalid(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_invalid, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Invalid(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Query_invalid(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_panics(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_panics, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Panics(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOPanics2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPanics, true, false, ) } func (ec *executionContext) fieldContext_Query_panics(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "fieldScalarMarshal": return ec.fieldContext_Panics_fieldScalarMarshal(ctx, field) case "fieldFuncMarshal": return ec.fieldContext_Panics_fieldFuncMarshal(ctx, field) case "argUnmarshal": return ec.fieldContext_Panics_argUnmarshal(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Panics", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_primitiveObject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_primitiveObject, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().PrimitiveObject(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNPrimitive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPrimitiveᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_primitiveObject(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "value": return ec.fieldContext_Primitive_value(ctx, field) case "squared": return ec.fieldContext_Primitive_squared(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Primitive", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_primitiveStringObject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_primitiveStringObject, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().PrimitiveStringObject(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNPrimitiveString2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPrimitiveStringᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_primitiveStringObject(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "value": return ec.fieldContext_PrimitiveString_value(ctx, field) case "doubled": return ec.fieldContext_PrimitiveString_doubled(ctx, field) case "len": return ec.fieldContext_PrimitiveString_len(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type PrimitiveString", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_ptrToAnyContainer(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_ptrToAnyContainer, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().PtrToAnyContainer(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNPtrToAnyContainer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToAnyContainer, true, true, ) } func (ec *executionContext) fieldContext_Query_ptrToAnyContainer(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "ptrToAny": return ec.fieldContext_PtrToAnyContainer_ptrToAny(ctx, field) case "binding": return ec.fieldContext_PtrToAnyContainer_binding(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type PtrToAnyContainer", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_ptrToSliceContainer(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_ptrToSliceContainer, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().PtrToSliceContainer(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNPtrToSliceContainer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPtrToSliceContainer, true, true, ) } func (ec *executionContext) fieldContext_Query_ptrToSliceContainer(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "ptrToSlice": return ec.fieldContext_PtrToSliceContainer_ptrToSlice(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type PtrToSliceContainer", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_infinity(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_infinity, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Infinity(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNFloat2float64, true, true, ) } func (ec *executionContext) fieldContext_Query_infinity(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Float does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_stringFromContextInterface(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_stringFromContextInterface, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().StringFromContextInterface(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNStringFromContextInterface2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐStringFromContextInterface, true, true, ) } func (ec *executionContext) fieldContext_Query_stringFromContextInterface(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type StringFromContextInterface does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_stringFromContextFunction(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_stringFromContextFunction, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().StringFromContextFunction(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNStringFromContextFunction2string, true, true, ) } func (ec *executionContext) fieldContext_Query_stringFromContextFunction(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type StringFromContextFunction does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_defaultScalar(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_defaultScalar, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().DefaultScalar(ctx, fc.Args["arg"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNDefaultScalarImplementation2string, true, true, ) } func (ec *executionContext) fieldContext_Query_defaultScalar(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type DefaultScalarImplementation does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_defaultScalar_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_skipInclude(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_skipInclude, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().SkipInclude(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOSkipIncludeTestType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSkipIncludeTestType, true, false, ) } func (ec *executionContext) fieldContext_Query_skipInclude(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "a": return ec.fieldContext_SkipIncludeTestType_a(ctx, field) case "b": return ec.fieldContext_SkipIncludeTestType_b(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type SkipIncludeTestType", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_slices(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_slices, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Slices(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOSlices2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSlices, true, false, ) } func (ec *executionContext) fieldContext_Query_slices(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "test1": return ec.fieldContext_Slices_test1(ctx, field) case "test2": return ec.fieldContext_Slices_test2(ctx, field) case "test3": return ec.fieldContext_Slices_test3(ctx, field) case "test4": return ec.fieldContext_Slices_test4(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Slices", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_scalarSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_scalarSlice, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().ScalarSlice(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNBytes2ᚕbyte, true, true, ) } func (ec *executionContext) fieldContext_Query_scalarSlice(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Bytes does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_fallback(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_fallback, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().Fallback(ctx, fc.Args["arg"].(FallbackToStringEncoding)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFallbackToStringEncoding, true, true, ) } func (ec *executionContext) fieldContext_Query_fallback(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type FallbackToStringEncoding does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_fallback_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_optionalUnion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_optionalUnion, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().OptionalUnion(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOTestUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐTestUnion, true, false, ) } func (ec *executionContext) fieldContext_Query_optionalUnion(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type TestUnion does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_vOkCaseValue(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_vOkCaseValue, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().VOkCaseValue(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOVOkCaseValue2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐVOkCaseValue, true, false, ) } func (ec *executionContext) fieldContext_Query_vOkCaseValue(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "value": return ec.fieldContext_VOkCaseValue_value(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type VOkCaseValue", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_vOkCaseNil(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_vOkCaseNil, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().VOkCaseNil(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOVOkCaseNil2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐVOkCaseNil, true, false, ) } func (ec *executionContext) fieldContext_Query_vOkCaseNil(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "value": return ec.fieldContext_VOkCaseNil_value(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type VOkCaseNil", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_validType(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_validType, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().ValidType(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOValidType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐValidType, true, false, ) } func (ec *executionContext) fieldContext_Query_validType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "differentCase": return ec.fieldContext_ValidType_differentCase(ctx, field) case "different_case": return ec.fieldContext_ValidType_different_case(ctx, field) case "validInputKeywords": return ec.fieldContext_ValidType_validInputKeywords(ctx, field) case "validArgs": return ec.fieldContext_ValidType_validArgs(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type ValidType", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_variadicModel(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_variadicModel, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().VariadicModel(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOVariadicModel2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐVariadicModel, true, false, ) } func (ec *executionContext) fieldContext_Query_variadicModel(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "value": return ec.fieldContext_VariadicModel_value(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type VariadicModel", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_wrappedStruct(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_wrappedStruct, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().WrappedStruct(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNWrappedStruct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐWrappedStruct, true, true, ) } func (ec *executionContext) fieldContext_Query_wrappedStruct(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "name": return ec.fieldContext_WrappedStruct_name(ctx, field) case "desc": return ec.fieldContext_WrappedStruct_desc(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type WrappedStruct", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_wrappedScalar(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_wrappedScalar, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().WrappedScalar(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋotherpkgᚐScalar, true, true, ) } func (ec *executionContext) fieldContext_Query_wrappedScalar(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type WrappedScalar does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_wrappedMap(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_wrappedMap, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().WrappedMap(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNWrappedMap2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐWrappedMap, true, true, ) } func (ec *executionContext) fieldContext_Query_wrappedMap(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "get": return ec.fieldContext_WrappedMap_get(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type WrappedMap", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_wrappedSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_wrappedSlice, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().WrappedSlice(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNWrappedSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐWrappedSlice, true, true, ) } func (ec *executionContext) fieldContext_Query_wrappedSlice(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "get": return ec.fieldContext_WrappedSlice_get(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type WrappedSlice", field.Name) }, } return fc, nil } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 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)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, 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() }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, 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_updated(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { return graphql.ResolveFieldStream( ctx, ec.OperationContext, field, ec.fieldContext_Subscription_updated, func(ctx context.Context) (any, error) { return ec.Resolvers.Subscription().Updated(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Subscription_updated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Subscription", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Subscription_initPayload(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { return graphql.ResolveFieldStream( ctx, ec.OperationContext, field, ec.fieldContext_Subscription_initPayload, func(ctx context.Context) (any, error) { return ec.Resolvers.Subscription().InitPayload(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Subscription_initPayload(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Subscription", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Subscription_directiveArg(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { return graphql.ResolveFieldStream( ctx, ec.OperationContext, field, ec.fieldContext_Subscription_directiveArg, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Subscription().DirectiveArg(ctx, fc.Args["arg"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Subscription_directiveArg(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Subscription", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Subscription_directiveArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Subscription_directiveNullableArg(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { return graphql.ResolveFieldStream( ctx, ec.OperationContext, field, ec.fieldContext_Subscription_directiveNullableArg, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Subscription().DirectiveNullableArg(ctx, fc.Args["arg"].(*int), fc.Args["arg2"].(*int), fc.Args["arg3"].(*string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Subscription_directiveNullableArg(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Subscription", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Subscription_directiveNullableArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Subscription_directiveDouble(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { return graphql.ResolveFieldStream( ctx, ec.OperationContext, field, ec.fieldContext_Subscription_directiveDouble, func(ctx context.Context) (any, error) { return ec.Resolvers.Subscription().DirectiveDouble(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { if ec.Directives.Directive1 == nil { var zeroVal *string return zeroVal, errors.New("directive directive1 is not implemented") } return ec.Directives.Directive1(ctx, nil, directive0) } directive2 := func(ctx context.Context) (any, error) { if ec.Directives.Directive2 == nil { var zeroVal *string return zeroVal, errors.New("directive directive2 is not implemented") } return ec.Directives.Directive2(ctx, nil, directive1) } next = directive2 return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Subscription_directiveDouble(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Subscription", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Subscription_directiveUnimplemented(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { return graphql.ResolveFieldStream( ctx, ec.OperationContext, field, ec.fieldContext_Subscription_directiveUnimplemented, func(ctx context.Context) (any, error) { return ec.Resolvers.Subscription().DirectiveUnimplemented(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { if ec.Directives.Unimplemented == nil { var zeroVal *string return zeroVal, errors.New("directive unimplemented is not implemented") } return ec.Directives.Unimplemented(ctx, nil, directive0) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Subscription_directiveUnimplemented(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Subscription", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Subscription_issue896b(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { return graphql.ResolveFieldStream( ctx, ec.OperationContext, field, ec.fieldContext_Subscription_issue896b, func(ctx context.Context) (any, error) { return ec.Resolvers.Subscription().Issue896b(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐCheckIssue896, true, false, ) } func (ec *executionContext) fieldContext_Subscription_issue896b(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Subscription", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_CheckIssue896_id(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type CheckIssue896", field.Name) }, } return fc, nil } func (ec *executionContext) _Subscription_errorRequired(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { return graphql.ResolveFieldStream( ctx, ec.OperationContext, field, ec.fieldContext_Subscription_errorRequired, func(ctx context.Context) (any, error) { return ec.Resolvers.Subscription().ErrorRequired(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐError, true, true, ) } func (ec *executionContext) fieldContext_Subscription_errorRequired(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Subscription", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Error_id(ctx, field) case "errorOnNonRequiredField": return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) case "errorOnRequiredField": return ec.fieldContext_Error_errorOnRequiredField(ctx, field) case "nilOnRequiredField": return ec.fieldContext_Error_nilOnRequiredField(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) }, } return fc, nil } func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_User_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _User_friends(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_friends, func(ctx context.Context) (any, error) { return ec.Resolvers.User().Friends(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUserᚄ, true, true, ) } func (ec *executionContext) fieldContext_User_friends(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_User_id(ctx, field) case "friends": return ec.fieldContext_User_friends(ctx, field) case "created": return ec.fieldContext_User_created(ctx, field) case "updated": return ec.fieldContext_User_updated(ctx, field) case "pets": return ec.fieldContext_User_pets(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } func (ec *executionContext) _User_created(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_created, func(ctx context.Context) (any, error) { return obj.Created, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNTime2timeᚐTime, true, true, ) } func (ec *executionContext) fieldContext_User_created(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } func (ec *executionContext) _User_updated(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_updated, func(ctx context.Context) (any, error) { return obj.Updated, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOTime2ᚖtimeᚐTime, true, false, ) } func (ec *executionContext) fieldContext_User_updated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } func (ec *executionContext) _User_pets(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_pets, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.User().Pets(ctx, obj, fc.Args["limit"].(*int)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOPet2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPetᚄ, true, false, ) } func (ec *executionContext) fieldContext_User_pets(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Pet_id(ctx, field) case "friends": return ec.fieldContext_Pet_friends(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Pet", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_User_pets_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** func (ec *executionContext) unmarshalInputChanges(ctx context.Context, obj any) (map[string]any, error) { var it map[string]any if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"a", "b"} it = make(map[string]any, len(asMap)) for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "a": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("a")) data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } it["a"] = data case "b": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("b")) data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } it["b"] = data } } return it, nil } func (ec *executionContext) unmarshalInputInnerInput(ctx context.Context, obj any) (InnerInput, error) { var it InnerInput if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"id"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "id": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) data, err := ec.unmarshalNInt2int(ctx, v) if err != nil { return it, err } it.ID = data } } return it, nil } func (ec *executionContext) unmarshalInputOmittableInput(ctx context.Context, obj any) (OmittableInput, error) { var it OmittableInput if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"id", "bool", "str", "int", "time", "enum", "scalar", "object"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "id": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } it.ID = graphql.OmittableOf(data) case "bool": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("bool")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } it.Bool = graphql.OmittableOf(data) case "str": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("str")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it.Str = graphql.OmittableOf(data) case "int": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("int")) data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } it.Int = graphql.OmittableOf(data) case "time": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("time")) data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } it.Time = graphql.OmittableOf(data) case "enum": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("enum")) data, err := ec.unmarshalOStatus2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐStatus(ctx, v) if err != nil { return it, err } it.Enum = graphql.OmittableOf(data) case "scalar": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("scalar")) data, err := ec.unmarshalOThirdParty2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐThirdParty(ctx, v) if err != nil { return it, err } it.Scalar = graphql.OmittableOf(data) case "object": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("object")) data, err := ec.unmarshalOOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterInput(ctx, v) if err != nil { return it, err } it.Object = graphql.OmittableOf(data) } } return it, nil } func (ec *executionContext) unmarshalInputOuterInput(ctx context.Context, obj any) (OuterInput, error) { var it OuterInput if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"inner"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "inner": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("inner")) data, err := ec.unmarshalNInnerInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInnerInput(ctx, v) if err != nil { return it, err } it.Inner = data } } return it, nil } func (ec *executionContext) unmarshalInputRecursiveInputSlice(ctx context.Context, obj any) (RecursiveInputSlice, error) { var it RecursiveInputSlice if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"self"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "self": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("self")) data, err := ec.unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐRecursiveInputSliceᚄ(ctx, v) if err != nil { return it, err } it.Self = data } } return it, nil } // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var autobindImplementors = []string{"Autobind"} func (ec *executionContext) _Autobind(ctx context.Context, sel ast.SelectionSet, obj *Autobind) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, autobindImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Autobind") case "int": out.Values[i] = ec._Autobind_int(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "int32": out.Values[i] = ec._Autobind_int32(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "int64": out.Values[i] = ec._Autobind_int64(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "idStr": out.Values[i] = ec._Autobind_idStr(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "idInt": out.Values[i] = ec._Autobind_idInt(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var embeddedPointerImplementors = []string{"EmbeddedPointer"} func (ec *executionContext) _EmbeddedPointer(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedPointerModel) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, embeddedPointerImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("EmbeddedPointer") case "ID": out.Values[i] = ec._EmbeddedPointer_ID(ctx, field, obj) case "Title": out.Values[i] = ec._EmbeddedPointer_Title(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var forcedResolverImplementors = []string{"ForcedResolver"} func (ec *executionContext) _ForcedResolver(ctx context.Context, sel ast.SelectionSet, obj *ForcedResolver) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, forcedResolverImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("ForcedResolver") case "field": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._ForcedResolver_field(ctx, field, obj) return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var innerObjectImplementors = []string{"InnerObject"} func (ec *executionContext) _InnerObject(ctx context.Context, sel ast.SelectionSet, obj *InnerObject) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, innerObjectImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("InnerObject") case "id": out.Values[i] = ec._InnerObject_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var invalidIdentifierImplementors = []string{"InvalidIdentifier"} func (ec *executionContext) _InvalidIdentifier(ctx context.Context, sel ast.SelectionSet, obj *invalid_packagename.InvalidIdentifier) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, invalidIdentifierImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("InvalidIdentifier") case "id": out.Values[i] = ec._InvalidIdentifier_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var itImplementors = []string{"It"} func (ec *executionContext) _It(ctx context.Context, sel ast.SelectionSet, obj *introspection1.It) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, itImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("It") case "id": out.Values[i] = ec._It_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var modelMethodsImplementors = []string{"ModelMethods"} func (ec *executionContext) _ModelMethods(ctx context.Context, sel ast.SelectionSet, obj *ModelMethods) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, modelMethodsImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("ModelMethods") case "resolverField": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._ModelMethods_resolverField(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "noContext": out.Values[i] = ec._ModelMethods_noContext(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "withContext": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._ModelMethods_withContext(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var outerObjectImplementors = []string{"OuterObject"} func (ec *executionContext) _OuterObject(ctx context.Context, sel ast.SelectionSet, obj *OuterObject) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, outerObjectImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("OuterObject") case "inner": out.Values[i] = ec._OuterObject_inner(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var petImplementors = []string{"Pet"} func (ec *executionContext) _Pet(ctx context.Context, sel ast.SelectionSet, obj *Pet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, petImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Pet") case "id": out.Values[i] = ec._Pet_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "friends": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Pet_friends(ctx, field, obj) return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "invalidIdentifier": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_invalidIdentifier(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "collision": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_collision(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "mapInput": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_mapInput(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "recursive": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_recursive(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "nestedInputs": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_nestedInputs(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "nestedOutputs": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_nestedOutputs(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "modelMethods": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_modelMethods(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "user": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_user(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "nullableArg": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_nullableArg(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "inputSlice": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_inputSlice(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "inputNullableSlice": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_inputNullableSlice(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "inputOmittable": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_inputOmittable(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "shapeUnion": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_shapeUnion(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "autobind": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_autobind(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "deprecatedField": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_deprecatedField(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "fieldWithDeprecatedArg": 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_fieldWithDeprecatedArg(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 "overlapping": 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_overlapping(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "defaultParameters": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_defaultParameters(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "deferSingle": 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_deferSingle(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 "deferMultiple": 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_deferMultiple(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveArg": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_directiveArg(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveNullableArg": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_directiveNullableArg(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveSingleNullableArg": 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_directiveSingleNullableArg(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveInputNullable": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_directiveInputNullable(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveInput": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_directiveInput(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveInputType": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_directiveInputType(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveInputOuter": 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_directiveInputOuter(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveObject": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_directiveObject(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveObjectWithCustomGoModel": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_directiveObjectWithCustomGoModel(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveFieldDef": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_directiveFieldDef(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveField": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_directiveField(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveDouble": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_directiveDouble(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveUnimplemented": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_directiveUnimplemented(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "embeddedCase1": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_embeddedCase1(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "embeddedCase2": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_embeddedCase2(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "embeddedCase3": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_embeddedCase3(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "enumInInput": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_enumInInput(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "searchProducts": field := field innerFunc := func(ctx 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_searchProducts(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 "searchRequired": field := field innerFunc := func(ctx 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_searchRequired(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 "searchProductsNormal": field := field innerFunc := func(ctx 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_searchProductsNormal(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 "searchWithDefaults": field := field innerFunc := func(ctx 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_searchWithDefaults(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 "searchMixed": field := field innerFunc := func(ctx 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_searchMixed(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 "filterProducts": field := field innerFunc := func(ctx 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_filterProducts(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 "findProducts": field := field innerFunc := func(ctx 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_findProducts(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 "searchWithDirectives": field := field innerFunc := func(ctx 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_searchWithDirectives(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "shapes": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_shapes(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "noShape": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_noShape(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "node": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_node(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "noShapeTypedNil": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_noShapeTypedNil(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "animal": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_animal(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "notAnInterface": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_notAnInterface(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "dog": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_dog(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "issue896a": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_issue896a(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "mapStringInterface": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_mapStringInterface(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "mapNestedStringInterface": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_mapNestedStringInterface(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "mapNestedMapSlice": 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_mapNestedMapSlice(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "errorBubble": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_errorBubble(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "errorBubbleList": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_errorBubbleList(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "errorList": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_errorList(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "errors": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_errors(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "valid": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_valid(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "invalid": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_invalid(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "panics": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_panics(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "primitiveObject": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_primitiveObject(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "primitiveStringObject": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_primitiveStringObject(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "ptrToAnyContainer": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_ptrToAnyContainer(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "ptrToSliceContainer": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_ptrToSliceContainer(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "infinity": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_infinity(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "stringFromContextInterface": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_stringFromContextInterface(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "stringFromContextFunction": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_stringFromContextFunction(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "defaultScalar": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_defaultScalar(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "skipInclude": 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_skipInclude(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 "slices": 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_slices(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "scalarSlice": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_scalarSlice(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "fallback": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_fallback(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "optionalUnion": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_optionalUnion(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "vOkCaseValue": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_vOkCaseValue(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "vOkCaseNil": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_vOkCaseNil(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "validType": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_validType(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "variadicModel": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_variadicModel(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "wrappedStruct": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_wrappedStruct(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "wrappedScalar": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_wrappedScalar(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "wrappedMap": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_wrappedMap(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "wrappedSlice": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_wrappedSlice(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) case "__schema": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var subscriptionImplementors = []string{"Subscription"} func (ec *executionContext) _Subscription(ctx context.Context, sel ast.SelectionSet) func(ctx context.Context) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, subscriptionImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Subscription", }) if len(fields) != 1 { graphql.AddErrorf(ctx, "must subscribe to exactly one stream") return nil } switch fields[0].Name { case "updated": return ec._Subscription_updated(ctx, fields[0]) case "initPayload": return ec._Subscription_initPayload(ctx, fields[0]) case "directiveArg": return ec._Subscription_directiveArg(ctx, fields[0]) case "directiveNullableArg": return ec._Subscription_directiveNullableArg(ctx, fields[0]) case "directiveDouble": return ec._Subscription_directiveDouble(ctx, fields[0]) case "directiveUnimplemented": return ec._Subscription_directiveUnimplemented(ctx, fields[0]) case "issue896b": return ec._Subscription_issue896b(ctx, fields[0]) case "errorRequired": return ec._Subscription_errorRequired(ctx, fields[0]) default: panic("unknown field " + strconv.Quote(fields[0].Name)) } } var userImplementors = []string{"User"} func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *User) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("User") case "id": out.Values[i] = ec._User_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "friends": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._User_friends(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "created": out.Values[i] = ec._User_created(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "updated": out.Values[i] = ec._User_updated(ctx, field, obj) case "pets": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._User_pets(ctx, field, obj) return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) unmarshalNInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInnerInput(ctx context.Context, v any) (InnerInput, error) { res, err := ec.unmarshalInputInnerInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalNInnerInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInnerInput(ctx context.Context, v any) (*InnerInput, error) { res, err := ec.unmarshalInputInnerInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNInnerObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐInnerObject(ctx context.Context, sel ast.SelectionSet, v *InnerObject) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._InnerObject(ctx, sel, v) } func (ec *executionContext) unmarshalNOmittableInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOmittableInput(ctx context.Context, v any) (OmittableInput, error) { res, err := ec.unmarshalInputOmittableInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNPet2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPet(ctx context.Context, sel ast.SelectionSet, v *Pet) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._Pet(ctx, sel, v) } func (ec *executionContext) unmarshalNRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐRecursiveInputSlice(ctx context.Context, v any) (RecursiveInputSlice, error) { res, err := ec.unmarshalInputRecursiveInputSlice(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } 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) unmarshalNUUID2string(ctx context.Context, v any) (string, error) { res, err := graphql.UnmarshalString(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNUUID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { _ = 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) marshalNUser2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler { return ec._User(ctx, sel, &v) } func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐUserᚄ(ctx context.Context, sel ast.SelectionSet, v []*User) graphql.Marshaler { ret := 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ᚋcodegenᚋtestserverᚋfollowschemaᚐ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ᚋcodegenᚋtestserverᚋfollowschemaᚐ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) marshalOAutobind2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐAutobind(ctx context.Context, sel ast.SelectionSet, v *Autobind) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Autobind(ctx, sel, v) } func (ec *executionContext) unmarshalOChanges2map(ctx context.Context, v any) (map[string]any, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputChanges(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOInvalidIdentifier2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx context.Context, sel ast.SelectionSet, v *invalid_packagename.InvalidIdentifier) graphql.Marshaler { if v == nil { return graphql.Null } return ec._InvalidIdentifier(ctx, sel, v) } func (ec *executionContext) marshalOIt2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋintrospectionᚐIt(ctx context.Context, sel ast.SelectionSet, v *introspection1.It) graphql.Marshaler { if v == nil { return graphql.Null } return ec._It(ctx, sel, v) } func (ec *executionContext) marshalOModelMethods2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐModelMethods(ctx context.Context, sel ast.SelectionSet, v *ModelMethods) graphql.Marshaler { if v == nil { return graphql.Null } return ec._ModelMethods(ctx, sel, v) } func (ec *executionContext) unmarshalOOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterInput(ctx context.Context, v any) ([][]*OuterInput, error) { if v == nil { return nil, nil } var vSlice []any vSlice = graphql.CoerceList(v) var err error res := make([][]*OuterInput, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) res[i], err = ec.unmarshalOOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterInput(ctx, vSlice[i]) if err != nil { return nil, err } } return res, nil } func (ec *executionContext) unmarshalOOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterInput(ctx context.Context, v any) ([]*OuterInput, error) { if v == nil { return nil, nil } var vSlice []any vSlice = graphql.CoerceList(v) var err error res := make([]*OuterInput, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) res[i], err = ec.unmarshalOOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterInput(ctx, vSlice[i]) if err != nil { return nil, err } } return res, nil } func (ec *executionContext) unmarshalOOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterInput(ctx context.Context, v any) (*OuterInput, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputOuterInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOOuterObject2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v [][]*OuterObject) graphql.Marshaler { if v == nil { return graphql.Null } ret := 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.marshalOOuterObject2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterObject(ctx, sel, v[i]) }) return ret } func (ec *executionContext) marshalOOuterObject2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v []*OuterObject) graphql.Marshaler { if v == nil { return graphql.Null } ret := 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.marshalOOuterObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterObject(ctx, sel, v[i]) }) return ret } func (ec *executionContext) marshalOOuterObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v *OuterObject) graphql.Marshaler { if v == nil { return graphql.Null } return ec._OuterObject(ctx, sel, v) } func (ec *executionContext) marshalOPet2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPetᚄ(ctx context.Context, sel ast.SelectionSet, v []*Pet) 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.marshalNPet2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐPet(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐRecursiveInputSliceᚄ(ctx context.Context, v any) ([]RecursiveInputSlice, error) { if v == nil { return nil, nil } var vSlice []any vSlice = graphql.CoerceList(v) var err error res := make([]RecursiveInputSlice, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) res[i], err = ec.unmarshalNRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐRecursiveInputSlice(ctx, vSlice[i]) if err != nil { return nil, err } } return res, nil } func (ec *executionContext) unmarshalORecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐRecursiveInputSlice(ctx context.Context, v any) (*RecursiveInputSlice, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputRecursiveInputSlice(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalOStatus2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐStatus(ctx context.Context, v any) (*Status, error) { if v == nil { return nil, nil } var res = new(Status) err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOStatus2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐStatus(ctx context.Context, sel ast.SelectionSet, v *Status) graphql.Marshaler { if v == nil { return graphql.Null } return v } func (ec *executionContext) unmarshalOThirdParty2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐThirdParty(ctx context.Context, v any) (*ThirdParty, error) { if v == nil { return nil, nil } res, err := UnmarshalThirdParty(v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOThirdParty2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐThirdParty(ctx context.Context, sel ast.SelectionSet, v *ThirdParty) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel _ = ctx res := MarshalThirdParty(*v) return res } func (ec *executionContext) unmarshalOTime2ᚖtimeᚐTime(ctx context.Context, v any) (*time.Time, error) { if v == nil { return nil, nil } res, err := graphql.UnmarshalTime(v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOTime2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel _ = ctx res := graphql.MarshalTime(*v) return res } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/schema.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 ) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION directive @defer( if: Boolean = true label: String ) on FRAGMENT_SPREAD | INLINE_FRAGMENT type Query { invalidIdentifier: InvalidIdentifier collision: It mapInput(input: Changes): Boolean recursive(input: RecursiveInputSlice): Boolean nestedInputs(input: [[OuterInput]] = [[{ inner: { id: 1 } }]]): Boolean nestedOutputs: [[OuterObject]] modelMethods: ModelMethods user(id: Int!): User! nullableArg(arg: Int = 123): String inputSlice(arg: [String!]!): Boolean! inputNullableSlice(arg: [String!]): Boolean! inputOmittable(arg: OmittableInput!): String! shapeUnion: ShapeUnion! autobind: Autobind deprecatedField: String! @deprecated(reason: "test deprecated directive") fieldWithDeprecatedArg(oldArg: Int @deprecated(reason: "old arg"), newArg: Int): String } type Subscription { updated: String! initPayload: String! } type Pet { id: Int! friends(limit: Int): [Pet!] @goField(forceResolver: true) } type User { id: Int! friends: [User!]! @goField(forceResolver: true) created: Time! updated: Time pets(limit: Int): [Pet!] @goField(forceResolver: true) } type Autobind { int: Int! int32: Int! int64: Int! idStr: ID! idInt: ID! } type ModelMethods { resolverField: Boolean! noContext: Boolean! withContext: Boolean! } type InvalidIdentifier { id: Int! } type It { id: ID! } input Changes @goModel(model: "map[string]interface{}") { a: Int b: Int } input RecursiveInputSlice { self: [RecursiveInputSlice!] } input InnerInput { id: Int! } input OuterInput { inner: InnerInput! } input OmittableInput { id: ID @goField(omittable: true) bool: Boolean @goField(omittable: true) str: String @goField(omittable: true) int: Int @goField(omittable: true) time: Time @goField(omittable: true) enum: Status @goField(omittable: true) scalar: ThirdParty @goField(omittable: true) object: OuterInput @goField(omittable: true) } scalar ThirdParty @goModel(model: "followschema.ThirdParty") type OuterObject { inner: InnerObject! } type InnerObject { id: Int! } type ForcedResolver { field: Circle @goField(forceResolver: true) } type EmbeddedPointer @goModel(model: "followschema.EmbeddedPointerModel") { ID: String Title: String } scalar UUID enum Status { OK ERROR } scalar Time ================================================ FILE: codegen/testserver/followschema/skip-include.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _SkipIncludeTestType_a(ctx context.Context, field graphql.CollectedField, obj *SkipIncludeTestType) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_SkipIncludeTestType_a, func(ctx context.Context) (any, error) { return obj.A, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_SkipIncludeTestType_a(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "SkipIncludeTestType", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _SkipIncludeTestType_b(ctx context.Context, field graphql.CollectedField, obj *SkipIncludeTestType) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_SkipIncludeTestType_b, func(ctx context.Context) (any, error) { return obj.B, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_SkipIncludeTestType_b(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "SkipIncludeTestType", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx 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 skipIncludeTestTypeImplementors = []string{"SkipIncludeTestType"} func (ec *executionContext) _SkipIncludeTestType(ctx context.Context, sel ast.SelectionSet, obj *SkipIncludeTestType) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, skipIncludeTestTypeImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("SkipIncludeTestType") case "a": out.Values[i] = ec._SkipIncludeTestType_a(ctx, field, obj) case "b": out.Values[i] = ec._SkipIncludeTestType_b(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) marshalOSkipIncludeTestType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSkipIncludeTestType(ctx context.Context, sel ast.SelectionSet, v *SkipIncludeTestType) graphql.Marshaler { if v == nil { return graphql.Null } return ec._SkipIncludeTestType(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/skip-include.graphql ================================================ extend type Query { skipInclude: SkipIncludeTestType } type SkipIncludeTestType { a: String b: String } ================================================ FILE: codegen/testserver/followschema/slices.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _Slices_test1(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Slices_test1, func(ctx context.Context) (any, error) { return obj.Test1, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2ᚕᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Slices_test1(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Slices", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Slices_test2(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Slices_test2, func(ctx context.Context) (any, error) { return obj.Test2, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2ᚕstringᚄ, true, false, ) } func (ec *executionContext) fieldContext_Slices_test2(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Slices", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Slices_test3(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Slices_test3, func(ctx context.Context) (any, error) { return obj.Test3, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2ᚕᚖstring, true, true, ) } func (ec *executionContext) fieldContext_Slices_test3(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Slices", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Slices_test4(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Slices_test4, func(ctx context.Context) (any, error) { return obj.Test4, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2ᚕstringᚄ, true, true, ) } func (ec *executionContext) fieldContext_Slices_test4(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Slices", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var slicesImplementors = []string{"Slices"} func (ec *executionContext) _Slices(ctx context.Context, sel ast.SelectionSet, obj *Slices) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, slicesImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Slices") case "test1": out.Values[i] = ec._Slices_test1(ctx, field, obj) case "test2": out.Values[i] = ec._Slices_test2(ctx, field, obj) case "test3": out.Values[i] = ec._Slices_test3(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "test4": out.Values[i] = ec._Slices_test4(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) unmarshalNBytes2ᚕbyte(ctx context.Context, v any) ([]byte, error) { res, err := UnmarshalBytes(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNBytes2ᚕbyte(ctx context.Context, sel ast.SelectionSet, v []byte) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } _ = sel res := MarshalBytes(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) marshalOSlices2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐSlices(ctx context.Context, sel ast.SelectionSet, v *Slices) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Slices(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/slices.graphql ================================================ extend type Query { slices: Slices scalarSlice: Bytes! } type Slices { test1: [String] test2: [String!] test3: [String]! test4: [String!]! } scalar Bytes ================================================ FILE: codegen/testserver/followschema/slices_test.go ================================================ package followschema import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestSlices(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("nulls vs empty slices", func(t *testing.T) { resolvers.QueryResolver.Slices = func(ctx context.Context) (slices *Slices, e error) { return &Slices{}, nil } var resp struct { Slices Slices } c.MustPost(`query { slices { test1, test2, test3, test4 }}`, &resp) require.Nil(t, resp.Slices.Test1) require.Nil(t, resp.Slices.Test2) require.NotNil(t, resp.Slices.Test3) require.NotNil(t, resp.Slices.Test4) }) t.Run("custom scalars to slices work", func(t *testing.T) { resolvers.QueryResolver.ScalarSlice = func(ctx context.Context) ([]byte, error) { return []byte("testing"), nil } var resp struct { ScalarSlice string } c.MustPost(`query { scalarSlice }`, &resp) require.Equal(t, "testing", resp.ScalarSlice) }) } ================================================ FILE: codegen/testserver/followschema/stub.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" introspection1 "github.com/99designs/gqlgen/codegen/testserver/followschema/introspection" invalid_packagename "github.com/99designs/gqlgen/codegen/testserver/followschema/invalid-packagename" "github.com/99designs/gqlgen/codegen/testserver/followschema/otherpkg" ) type Stub struct { BackedByInterfaceResolver struct { ID func(ctx context.Context, obj BackedByInterface) (string, error) } DeferModelResolver struct { Values func(ctx context.Context, obj *DeferModel) ([]string, error) } ErrorsResolver struct { A func(ctx context.Context, obj *Errors) (*Error, error) B func(ctx context.Context, obj *Errors) (*Error, error) C func(ctx context.Context, obj *Errors) (*Error, error) D func(ctx context.Context, obj *Errors) (*Error, error) E func(ctx context.Context, obj *Errors) (*Error, error) } ForcedResolverResolver struct { Field func(ctx context.Context, obj *ForcedResolver) (*Circle, error) } ModelMethodsResolver struct { ResolverField func(ctx context.Context, obj *ModelMethods) (bool, error) } MutationResolver struct { DefaultInput func(ctx context.Context, input DefaultInput) (*DefaultParametersMirror, error) OverrideValueViaInput func(ctx context.Context, input FieldsOrderInput) (*FieldsOrderPayload, error) UpdateProduct func(ctx context.Context, input map[string]interface{}) (string, error) Issue4053 func(ctx context.Context, input *Issue4053Input1) (bool, error) UpdateSomething func(ctx context.Context, input SpecialInput) (string, error) UpdatePtrToPtr func(ctx context.Context, input UpdatePtrToPtrOuter) (*PtrToPtrOuter, error) } OverlappingFieldsResolver struct { OldFoo func(ctx context.Context, obj *OverlappingFields) (int, error) } PanicsResolver struct { FieldScalarMarshal func(ctx context.Context, obj *Panics) ([]MarshalPanic, error) ArgUnmarshal func(ctx context.Context, obj *Panics, u []MarshalPanic) (bool, error) } PetResolver struct { Friends func(ctx context.Context, obj *Pet, limit *int) ([]*Pet, error) } PrimitiveResolver struct { Value func(ctx context.Context, obj *Primitive) (int, error) } PrimitiveStringResolver struct { Value func(ctx context.Context, obj *PrimitiveString) (string, error) Len func(ctx context.Context, obj *PrimitiveString) (int, error) } QueryResolver struct { InvalidIdentifier func(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) Collision func(ctx context.Context) (*introspection1.It, error) MapInput func(ctx context.Context, input map[string]any) (*bool, error) Recursive func(ctx context.Context, input *RecursiveInputSlice) (*bool, error) NestedInputs func(ctx context.Context, input [][]*OuterInput) (*bool, error) NestedOutputs func(ctx context.Context) ([][]*OuterObject, error) ModelMethods func(ctx context.Context) (*ModelMethods, error) User func(ctx context.Context, id int) (*User, error) NullableArg func(ctx context.Context, arg *int) (*string, error) InputSlice func(ctx context.Context, arg []string) (bool, error) InputNullableSlice func(ctx context.Context, arg []string) (bool, error) InputOmittable func(ctx context.Context, arg OmittableInput) (string, error) ShapeUnion func(ctx context.Context) (ShapeUnion, error) Autobind func(ctx context.Context) (*Autobind, error) DeprecatedField func(ctx context.Context) (string, error) FieldWithDeprecatedArg func(ctx context.Context, oldArg *int, newArg *int) (*string, error) Overlapping func(ctx context.Context) (*OverlappingFields, error) DefaultParameters func(ctx context.Context, falsyBoolean *bool, truthyBoolean *bool) (*DefaultParametersMirror, error) DeferSingle func(ctx context.Context) (*DeferModel, error) DeferMultiple func(ctx context.Context) ([]*DeferModel, error) DirectiveArg func(ctx context.Context, arg string) (*string, error) DirectiveNullableArg func(ctx context.Context, arg *int, arg2 *int, arg3 *string) (*string, error) DirectiveSingleNullableArg func(ctx context.Context, arg1 *string) (*string, error) DirectiveInputNullable func(ctx context.Context, arg *InputDirectives) (*string, error) DirectiveInput func(ctx context.Context, arg InputDirectives) (*string, error) DirectiveInputType func(ctx context.Context, arg InnerInput) (*string, error) DirectiveInputOuter func(ctx context.Context, arg OuterWrapperInput) (*string, error) DirectiveObject func(ctx context.Context) (*ObjectDirectives, error) DirectiveObjectWithCustomGoModel func(ctx context.Context) (*ObjectDirectivesWithCustomGoModel, error) DirectiveFieldDef func(ctx context.Context, ret string) (string, error) DirectiveField func(ctx context.Context) (*string, error) DirectiveDouble func(ctx context.Context) (*string, error) DirectiveUnimplemented func(ctx context.Context) (*string, error) EmbeddedCase1 func(ctx context.Context) (*EmbeddedCase1, error) EmbeddedCase2 func(ctx context.Context) (*EmbeddedCase2, error) EmbeddedCase3 func(ctx context.Context) (*EmbeddedCase3, error) EnumInInput func(ctx context.Context, input *InputWithEnumValue) (EnumTest, error) SearchProducts func(ctx context.Context, filters map[string]interface{}) ([]string, error) SearchRequired func(ctx context.Context, filters map[string]interface{}) ([]string, error) SearchProductsNormal func(ctx context.Context, filters map[string]any) ([]string, error) SearchWithDefaults func(ctx context.Context, filters map[string]interface{}) ([]string, error) SearchMixed func(ctx context.Context, filters map[string]interface{}, limit *int, offset *int, sortBy *string) ([]string, error) FilterProducts func(ctx context.Context, filters map[string]interface{}) ([]string, error) FindProducts func(ctx context.Context, filters map[string]interface{}) ([]string, error) SearchWithDirectives func(ctx context.Context, input map[string]interface{}) ([]string, error) Shapes func(ctx context.Context) ([]Shape, error) NoShape func(ctx context.Context) (Shape, error) Node func(ctx context.Context) (Node, error) NoShapeTypedNil func(ctx context.Context) (Shape, error) Animal func(ctx context.Context) (Animal, error) NotAnInterface func(ctx context.Context) (BackedByInterface, error) Dog func(ctx context.Context) (*Dog, error) Issue896a func(ctx context.Context) ([]*CheckIssue896, error) MapStringInterface func(ctx context.Context, in map[string]any) (map[string]any, error) MapNestedStringInterface func(ctx context.Context, in *NestedMapInput) (map[string]any, error) MapNestedMapSlice func(ctx context.Context, input map[string]any) (*bool, error) ErrorBubble func(ctx context.Context) (*Error, error) ErrorBubbleList func(ctx context.Context) ([]*Error, error) ErrorList func(ctx context.Context) ([]*Error, error) Errors func(ctx context.Context) (*Errors, error) Valid func(ctx context.Context) (string, error) Invalid func(ctx context.Context) (string, error) Panics func(ctx context.Context) (*Panics, error) PrimitiveObject func(ctx context.Context) ([]Primitive, error) PrimitiveStringObject func(ctx context.Context) ([]PrimitiveString, error) PtrToAnyContainer func(ctx context.Context) (*PtrToAnyContainer, error) PtrToSliceContainer func(ctx context.Context) (*PtrToSliceContainer, error) Infinity func(ctx context.Context) (float64, error) StringFromContextInterface func(ctx context.Context) (*StringFromContextInterface, error) StringFromContextFunction func(ctx context.Context) (string, error) DefaultScalar func(ctx context.Context, arg string) (string, error) SkipInclude func(ctx context.Context) (*SkipIncludeTestType, error) Slices func(ctx context.Context) (*Slices, error) ScalarSlice func(ctx context.Context) ([]byte, error) Fallback func(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) OptionalUnion func(ctx context.Context) (TestUnion, error) VOkCaseValue func(ctx context.Context) (*VOkCaseValue, error) VOkCaseNil func(ctx context.Context) (*VOkCaseNil, error) ValidType func(ctx context.Context) (*ValidType, error) VariadicModel func(ctx context.Context) (*VariadicModel, error) WrappedStruct func(ctx context.Context) (*WrappedStruct, error) WrappedScalar func(ctx context.Context) (otherpkg.Scalar, error) WrappedMap func(ctx context.Context) (WrappedMap, error) WrappedSlice func(ctx context.Context) (WrappedSlice, error) } SubscriptionResolver struct { Updated func(ctx context.Context) (<-chan string, error) InitPayload func(ctx context.Context) (<-chan string, error) DirectiveArg func(ctx context.Context, arg string) (<-chan *string, error) DirectiveNullableArg func(ctx context.Context, arg *int, arg2 *int, arg3 *string) (<-chan *string, error) DirectiveDouble func(ctx context.Context) (<-chan *string, error) DirectiveUnimplemented func(ctx context.Context) (<-chan *string, error) Issue896b func(ctx context.Context) (<-chan []*CheckIssue896, error) ErrorRequired func(ctx context.Context) (<-chan *Error, error) } UserResolver struct { Friends func(ctx context.Context, obj *User) ([]*User, error) Pets func(ctx context.Context, obj *User, limit *int) ([]*Pet, error) } WrappedMapResolver struct { Get func(ctx context.Context, obj WrappedMap, key string) (string, error) } WrappedSliceResolver struct { Get func(ctx context.Context, obj WrappedSlice, idx int) (string, error) } FieldsOrderInputResolver struct { OverrideFirstField func(ctx context.Context, obj *FieldsOrderInput, data *string) error } } func (r *Stub) BackedByInterface() BackedByInterfaceResolver { return &stubBackedByInterface{r} } func (r *Stub) DeferModel() DeferModelResolver { return &stubDeferModel{r} } func (r *Stub) Errors() ErrorsResolver { return &stubErrors{r} } func (r *Stub) ForcedResolver() ForcedResolverResolver { return &stubForcedResolver{r} } func (r *Stub) ModelMethods() ModelMethodsResolver { return &stubModelMethods{r} } func (r *Stub) Mutation() MutationResolver { return &stubMutation{r} } func (r *Stub) OverlappingFields() OverlappingFieldsResolver { return &stubOverlappingFields{r} } func (r *Stub) Panics() PanicsResolver { return &stubPanics{r} } func (r *Stub) Pet() PetResolver { return &stubPet{r} } func (r *Stub) Primitive() PrimitiveResolver { return &stubPrimitive{r} } func (r *Stub) PrimitiveString() PrimitiveStringResolver { return &stubPrimitiveString{r} } func (r *Stub) Query() QueryResolver { return &stubQuery{r} } func (r *Stub) Subscription() SubscriptionResolver { return &stubSubscription{r} } func (r *Stub) User() UserResolver { return &stubUser{r} } func (r *Stub) WrappedMap() WrappedMapResolver { return &stubWrappedMap{r} } func (r *Stub) WrappedSlice() WrappedSliceResolver { return &stubWrappedSlice{r} } func (r *Stub) FieldsOrderInput() FieldsOrderInputResolver { return &stubFieldsOrderInput{r} } type stubBackedByInterface struct{ *Stub } func (r *stubBackedByInterface) ID(ctx context.Context, obj BackedByInterface) (string, error) { return r.BackedByInterfaceResolver.ID(ctx, obj) } type stubDeferModel struct{ *Stub } func (r *stubDeferModel) Values(ctx context.Context, obj *DeferModel) ([]string, error) { return r.DeferModelResolver.Values(ctx, obj) } type stubErrors struct{ *Stub } func (r *stubErrors) A(ctx context.Context, obj *Errors) (*Error, error) { return r.ErrorsResolver.A(ctx, obj) } func (r *stubErrors) B(ctx context.Context, obj *Errors) (*Error, error) { return r.ErrorsResolver.B(ctx, obj) } func (r *stubErrors) C(ctx context.Context, obj *Errors) (*Error, error) { return r.ErrorsResolver.C(ctx, obj) } func (r *stubErrors) D(ctx context.Context, obj *Errors) (*Error, error) { return r.ErrorsResolver.D(ctx, obj) } func (r *stubErrors) E(ctx context.Context, obj *Errors) (*Error, error) { return r.ErrorsResolver.E(ctx, obj) } type stubForcedResolver struct{ *Stub } func (r *stubForcedResolver) Field(ctx context.Context, obj *ForcedResolver) (*Circle, error) { return r.ForcedResolverResolver.Field(ctx, obj) } type stubModelMethods struct{ *Stub } func (r *stubModelMethods) ResolverField(ctx context.Context, obj *ModelMethods) (bool, error) { return r.ModelMethodsResolver.ResolverField(ctx, obj) } type stubMutation struct{ *Stub } func (r *stubMutation) DefaultInput(ctx context.Context, input DefaultInput) (*DefaultParametersMirror, error) { return r.MutationResolver.DefaultInput(ctx, input) } func (r *stubMutation) OverrideValueViaInput(ctx context.Context, input FieldsOrderInput) (*FieldsOrderPayload, error) { return r.MutationResolver.OverrideValueViaInput(ctx, input) } func (r *stubMutation) UpdateProduct(ctx context.Context, input map[string]interface{}) (string, error) { return r.MutationResolver.UpdateProduct(ctx, input) } func (r *stubMutation) Issue4053(ctx context.Context, input *Issue4053Input1) (bool, error) { return r.MutationResolver.Issue4053(ctx, input) } func (r *stubMutation) UpdateSomething(ctx context.Context, input SpecialInput) (string, error) { return r.MutationResolver.UpdateSomething(ctx, input) } func (r *stubMutation) UpdatePtrToPtr(ctx context.Context, input UpdatePtrToPtrOuter) (*PtrToPtrOuter, error) { return r.MutationResolver.UpdatePtrToPtr(ctx, input) } type stubOverlappingFields struct{ *Stub } func (r *stubOverlappingFields) OldFoo(ctx context.Context, obj *OverlappingFields) (int, error) { return r.OverlappingFieldsResolver.OldFoo(ctx, obj) } type stubPanics struct{ *Stub } func (r *stubPanics) FieldScalarMarshal(ctx context.Context, obj *Panics) ([]MarshalPanic, error) { return r.PanicsResolver.FieldScalarMarshal(ctx, obj) } func (r *stubPanics) ArgUnmarshal(ctx context.Context, obj *Panics, u []MarshalPanic) (bool, error) { return r.PanicsResolver.ArgUnmarshal(ctx, obj, u) } type stubPet struct{ *Stub } func (r *stubPet) Friends(ctx context.Context, obj *Pet, limit *int) ([]*Pet, error) { return r.PetResolver.Friends(ctx, obj, limit) } type stubPrimitive struct{ *Stub } func (r *stubPrimitive) Value(ctx context.Context, obj *Primitive) (int, error) { return r.PrimitiveResolver.Value(ctx, obj) } type stubPrimitiveString struct{ *Stub } func (r *stubPrimitiveString) Value(ctx context.Context, obj *PrimitiveString) (string, error) { return r.PrimitiveStringResolver.Value(ctx, obj) } func (r *stubPrimitiveString) Len(ctx context.Context, obj *PrimitiveString) (int, error) { return r.PrimitiveStringResolver.Len(ctx, obj) } type stubQuery struct{ *Stub } func (r *stubQuery) InvalidIdentifier(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) { return r.QueryResolver.InvalidIdentifier(ctx) } func (r *stubQuery) Collision(ctx context.Context) (*introspection1.It, error) { return r.QueryResolver.Collision(ctx) } func (r *stubQuery) MapInput(ctx context.Context, input map[string]any) (*bool, error) { return r.QueryResolver.MapInput(ctx, input) } func (r *stubQuery) Recursive(ctx context.Context, input *RecursiveInputSlice) (*bool, error) { return r.QueryResolver.Recursive(ctx, input) } func (r *stubQuery) NestedInputs(ctx context.Context, input [][]*OuterInput) (*bool, error) { return r.QueryResolver.NestedInputs(ctx, input) } func (r *stubQuery) NestedOutputs(ctx context.Context) ([][]*OuterObject, error) { return r.QueryResolver.NestedOutputs(ctx) } func (r *stubQuery) ModelMethods(ctx context.Context) (*ModelMethods, error) { return r.QueryResolver.ModelMethods(ctx) } func (r *stubQuery) User(ctx context.Context, id int) (*User, error) { return r.QueryResolver.User(ctx, id) } func (r *stubQuery) NullableArg(ctx context.Context, arg *int) (*string, error) { return r.QueryResolver.NullableArg(ctx, arg) } func (r *stubQuery) InputSlice(ctx context.Context, arg []string) (bool, error) { return r.QueryResolver.InputSlice(ctx, arg) } func (r *stubQuery) InputNullableSlice(ctx context.Context, arg []string) (bool, error) { return r.QueryResolver.InputNullableSlice(ctx, arg) } func (r *stubQuery) InputOmittable(ctx context.Context, arg OmittableInput) (string, error) { return r.QueryResolver.InputOmittable(ctx, arg) } func (r *stubQuery) ShapeUnion(ctx context.Context) (ShapeUnion, error) { return r.QueryResolver.ShapeUnion(ctx) } func (r *stubQuery) Autobind(ctx context.Context) (*Autobind, error) { return r.QueryResolver.Autobind(ctx) } func (r *stubQuery) DeprecatedField(ctx context.Context) (string, error) { return r.QueryResolver.DeprecatedField(ctx) } func (r *stubQuery) FieldWithDeprecatedArg(ctx context.Context, oldArg *int, newArg *int) (*string, error) { return r.QueryResolver.FieldWithDeprecatedArg(ctx, oldArg, newArg) } func (r *stubQuery) Overlapping(ctx context.Context) (*OverlappingFields, error) { return r.QueryResolver.Overlapping(ctx) } func (r *stubQuery) DefaultParameters(ctx context.Context, falsyBoolean *bool, truthyBoolean *bool) (*DefaultParametersMirror, error) { return r.QueryResolver.DefaultParameters(ctx, falsyBoolean, truthyBoolean) } func (r *stubQuery) DeferSingle(ctx context.Context) (*DeferModel, error) { return r.QueryResolver.DeferSingle(ctx) } func (r *stubQuery) DeferMultiple(ctx context.Context) ([]*DeferModel, error) { return r.QueryResolver.DeferMultiple(ctx) } func (r *stubQuery) DirectiveArg(ctx context.Context, arg string) (*string, error) { return r.QueryResolver.DirectiveArg(ctx, arg) } func (r *stubQuery) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (*string, error) { return r.QueryResolver.DirectiveNullableArg(ctx, arg, arg2, arg3) } func (r *stubQuery) DirectiveSingleNullableArg(ctx context.Context, arg1 *string) (*string, error) { return r.QueryResolver.DirectiveSingleNullableArg(ctx, arg1) } func (r *stubQuery) DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) { return r.QueryResolver.DirectiveInputNullable(ctx, arg) } func (r *stubQuery) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) { return r.QueryResolver.DirectiveInput(ctx, arg) } func (r *stubQuery) DirectiveInputType(ctx context.Context, arg InnerInput) (*string, error) { return r.QueryResolver.DirectiveInputType(ctx, arg) } func (r *stubQuery) DirectiveInputOuter(ctx context.Context, arg OuterWrapperInput) (*string, error) { return r.QueryResolver.DirectiveInputOuter(ctx, arg) } func (r *stubQuery) DirectiveObject(ctx context.Context) (*ObjectDirectives, error) { return r.QueryResolver.DirectiveObject(ctx) } func (r *stubQuery) DirectiveObjectWithCustomGoModel(ctx context.Context) (*ObjectDirectivesWithCustomGoModel, error) { return r.QueryResolver.DirectiveObjectWithCustomGoModel(ctx) } func (r *stubQuery) DirectiveFieldDef(ctx context.Context, ret string) (string, error) { return r.QueryResolver.DirectiveFieldDef(ctx, ret) } func (r *stubQuery) DirectiveField(ctx context.Context) (*string, error) { return r.QueryResolver.DirectiveField(ctx) } func (r *stubQuery) DirectiveDouble(ctx context.Context) (*string, error) { return r.QueryResolver.DirectiveDouble(ctx) } func (r *stubQuery) DirectiveUnimplemented(ctx context.Context) (*string, error) { return r.QueryResolver.DirectiveUnimplemented(ctx) } func (r *stubQuery) EmbeddedCase1(ctx context.Context) (*EmbeddedCase1, error) { return r.QueryResolver.EmbeddedCase1(ctx) } func (r *stubQuery) EmbeddedCase2(ctx context.Context) (*EmbeddedCase2, error) { return r.QueryResolver.EmbeddedCase2(ctx) } func (r *stubQuery) EmbeddedCase3(ctx context.Context) (*EmbeddedCase3, error) { return r.QueryResolver.EmbeddedCase3(ctx) } func (r *stubQuery) EnumInInput(ctx context.Context, input *InputWithEnumValue) (EnumTest, error) { return r.QueryResolver.EnumInInput(ctx, input) } func (r *stubQuery) SearchProducts(ctx context.Context, filters map[string]interface{}) ([]string, error) { return r.QueryResolver.SearchProducts(ctx, filters) } func (r *stubQuery) SearchRequired(ctx context.Context, filters map[string]interface{}) ([]string, error) { return r.QueryResolver.SearchRequired(ctx, filters) } func (r *stubQuery) SearchProductsNormal(ctx context.Context, filters map[string]any) ([]string, error) { return r.QueryResolver.SearchProductsNormal(ctx, filters) } func (r *stubQuery) SearchWithDefaults(ctx context.Context, filters map[string]interface{}) ([]string, error) { return r.QueryResolver.SearchWithDefaults(ctx, filters) } func (r *stubQuery) SearchMixed(ctx context.Context, filters map[string]interface{}, limit *int, offset *int, sortBy *string) ([]string, error) { return r.QueryResolver.SearchMixed(ctx, filters, limit, offset, sortBy) } func (r *stubQuery) FilterProducts(ctx context.Context, filters map[string]interface{}) ([]string, error) { return r.QueryResolver.FilterProducts(ctx, filters) } func (r *stubQuery) FindProducts(ctx context.Context, filters map[string]interface{}) ([]string, error) { return r.QueryResolver.FindProducts(ctx, filters) } func (r *stubQuery) SearchWithDirectives(ctx context.Context, input map[string]interface{}) ([]string, error) { return r.QueryResolver.SearchWithDirectives(ctx, input) } func (r *stubQuery) Shapes(ctx context.Context) ([]Shape, error) { return r.QueryResolver.Shapes(ctx) } func (r *stubQuery) NoShape(ctx context.Context) (Shape, error) { return r.QueryResolver.NoShape(ctx) } func (r *stubQuery) Node(ctx context.Context) (Node, error) { return r.QueryResolver.Node(ctx) } func (r *stubQuery) NoShapeTypedNil(ctx context.Context) (Shape, error) { return r.QueryResolver.NoShapeTypedNil(ctx) } func (r *stubQuery) Animal(ctx context.Context) (Animal, error) { return r.QueryResolver.Animal(ctx) } func (r *stubQuery) NotAnInterface(ctx context.Context) (BackedByInterface, error) { return r.QueryResolver.NotAnInterface(ctx) } func (r *stubQuery) Dog(ctx context.Context) (*Dog, error) { return r.QueryResolver.Dog(ctx) } func (r *stubQuery) Issue896a(ctx context.Context) ([]*CheckIssue896, error) { return r.QueryResolver.Issue896a(ctx) } func (r *stubQuery) MapStringInterface(ctx context.Context, in map[string]any) (map[string]any, error) { return r.QueryResolver.MapStringInterface(ctx, in) } func (r *stubQuery) MapNestedStringInterface(ctx context.Context, in *NestedMapInput) (map[string]any, error) { return r.QueryResolver.MapNestedStringInterface(ctx, in) } func (r *stubQuery) MapNestedMapSlice(ctx context.Context, input map[string]any) (*bool, error) { return r.QueryResolver.MapNestedMapSlice(ctx, input) } func (r *stubQuery) ErrorBubble(ctx context.Context) (*Error, error) { return r.QueryResolver.ErrorBubble(ctx) } func (r *stubQuery) ErrorBubbleList(ctx context.Context) ([]*Error, error) { return r.QueryResolver.ErrorBubbleList(ctx) } func (r *stubQuery) ErrorList(ctx context.Context) ([]*Error, error) { return r.QueryResolver.ErrorList(ctx) } func (r *stubQuery) Errors(ctx context.Context) (*Errors, error) { return r.QueryResolver.Errors(ctx) } func (r *stubQuery) Valid(ctx context.Context) (string, error) { return r.QueryResolver.Valid(ctx) } func (r *stubQuery) Invalid(ctx context.Context) (string, error) { return r.QueryResolver.Invalid(ctx) } func (r *stubQuery) Panics(ctx context.Context) (*Panics, error) { return r.QueryResolver.Panics(ctx) } func (r *stubQuery) PrimitiveObject(ctx context.Context) ([]Primitive, error) { return r.QueryResolver.PrimitiveObject(ctx) } func (r *stubQuery) PrimitiveStringObject(ctx context.Context) ([]PrimitiveString, error) { return r.QueryResolver.PrimitiveStringObject(ctx) } func (r *stubQuery) PtrToAnyContainer(ctx context.Context) (*PtrToAnyContainer, error) { return r.QueryResolver.PtrToAnyContainer(ctx) } func (r *stubQuery) PtrToSliceContainer(ctx context.Context) (*PtrToSliceContainer, error) { return r.QueryResolver.PtrToSliceContainer(ctx) } func (r *stubQuery) Infinity(ctx context.Context) (float64, error) { return r.QueryResolver.Infinity(ctx) } func (r *stubQuery) StringFromContextInterface(ctx context.Context) (*StringFromContextInterface, error) { return r.QueryResolver.StringFromContextInterface(ctx) } func (r *stubQuery) StringFromContextFunction(ctx context.Context) (string, error) { return r.QueryResolver.StringFromContextFunction(ctx) } func (r *stubQuery) DefaultScalar(ctx context.Context, arg string) (string, error) { return r.QueryResolver.DefaultScalar(ctx, arg) } func (r *stubQuery) SkipInclude(ctx context.Context) (*SkipIncludeTestType, error) { return r.QueryResolver.SkipInclude(ctx) } func (r *stubQuery) Slices(ctx context.Context) (*Slices, error) { return r.QueryResolver.Slices(ctx) } func (r *stubQuery) ScalarSlice(ctx context.Context) ([]byte, error) { return r.QueryResolver.ScalarSlice(ctx) } func (r *stubQuery) Fallback(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) { return r.QueryResolver.Fallback(ctx, arg) } func (r *stubQuery) OptionalUnion(ctx context.Context) (TestUnion, error) { return r.QueryResolver.OptionalUnion(ctx) } func (r *stubQuery) VOkCaseValue(ctx context.Context) (*VOkCaseValue, error) { return r.QueryResolver.VOkCaseValue(ctx) } func (r *stubQuery) VOkCaseNil(ctx context.Context) (*VOkCaseNil, error) { return r.QueryResolver.VOkCaseNil(ctx) } func (r *stubQuery) ValidType(ctx context.Context) (*ValidType, error) { return r.QueryResolver.ValidType(ctx) } func (r *stubQuery) VariadicModel(ctx context.Context) (*VariadicModel, error) { return r.QueryResolver.VariadicModel(ctx) } func (r *stubQuery) WrappedStruct(ctx context.Context) (*WrappedStruct, error) { return r.QueryResolver.WrappedStruct(ctx) } func (r *stubQuery) WrappedScalar(ctx context.Context) (otherpkg.Scalar, error) { return r.QueryResolver.WrappedScalar(ctx) } func (r *stubQuery) WrappedMap(ctx context.Context) (WrappedMap, error) { return r.QueryResolver.WrappedMap(ctx) } func (r *stubQuery) WrappedSlice(ctx context.Context) (WrappedSlice, error) { return r.QueryResolver.WrappedSlice(ctx) } type stubSubscription struct{ *Stub } func (r *stubSubscription) Updated(ctx context.Context) (<-chan string, error) { return r.SubscriptionResolver.Updated(ctx) } func (r *stubSubscription) InitPayload(ctx context.Context) (<-chan string, error) { return r.SubscriptionResolver.InitPayload(ctx) } func (r *stubSubscription) DirectiveArg(ctx context.Context, arg string) (<-chan *string, error) { return r.SubscriptionResolver.DirectiveArg(ctx, arg) } func (r *stubSubscription) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (<-chan *string, error) { return r.SubscriptionResolver.DirectiveNullableArg(ctx, arg, arg2, arg3) } func (r *stubSubscription) DirectiveDouble(ctx context.Context) (<-chan *string, error) { return r.SubscriptionResolver.DirectiveDouble(ctx) } func (r *stubSubscription) DirectiveUnimplemented(ctx context.Context) (<-chan *string, error) { return r.SubscriptionResolver.DirectiveUnimplemented(ctx) } func (r *stubSubscription) Issue896b(ctx context.Context) (<-chan []*CheckIssue896, error) { return r.SubscriptionResolver.Issue896b(ctx) } func (r *stubSubscription) ErrorRequired(ctx context.Context) (<-chan *Error, error) { return r.SubscriptionResolver.ErrorRequired(ctx) } type stubUser struct{ *Stub } func (r *stubUser) Friends(ctx context.Context, obj *User) ([]*User, error) { return r.UserResolver.Friends(ctx, obj) } func (r *stubUser) Pets(ctx context.Context, obj *User, limit *int) ([]*Pet, error) { return r.UserResolver.Pets(ctx, obj, limit) } type stubWrappedMap struct{ *Stub } func (r *stubWrappedMap) Get(ctx context.Context, obj WrappedMap, key string) (string, error) { return r.WrappedMapResolver.Get(ctx, obj, key) } type stubWrappedSlice struct{ *Stub } func (r *stubWrappedSlice) Get(ctx context.Context, obj WrappedSlice, idx int) (string, error) { return r.WrappedSliceResolver.Get(ctx, obj, idx) } type stubFieldsOrderInput struct{ *Stub } func (r *stubFieldsOrderInput) OverrideFirstField(ctx context.Context, obj *FieldsOrderInput, data *string) error { return r.FieldsOrderInputResolver.OverrideFirstField(ctx, obj, data) } ================================================ FILE: codegen/testserver/followschema/subscription_test.go ================================================ package followschema import ( "context" "fmt" "runtime" "sort" "testing" "time" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestSubscriptions(t *testing.T) { tick := make(chan string, 1) resolvers := &Stub{} resolvers.SubscriptionResolver.InitPayload = func(ctx context.Context) (strings <-chan string, e error) { payload := transport.GetInitPayload(ctx) channel := make(chan string, len(payload)+1) go func() { <-ctx.Done() close(channel) }() // Test the helper function separately auth := payload.Authorization() if auth != "" { channel <- "AUTH:" + auth } else { channel <- "AUTH:NONE" } // Send them over the channel in alphabetic order keys := make([]string, 0, len(payload)) for key := range payload { keys = append(keys, key) } sort.Strings(keys) for _, key := range keys { channel <- fmt.Sprintf("%s = %#+v", key, payload[key]) } return channel, nil } errorTick := make(chan *Error, 1) resolvers.SubscriptionResolver.ErrorRequired = func(ctx context.Context) (<-chan *Error, error) { res := make(chan *Error, 1) go func() { for { select { case t := <-errorTick: res <- t case <-ctx.Done(): close(res) return } } }() return res, nil } resolvers.SubscriptionResolver.Updated = func(ctx context.Context) (<-chan string, error) { res := make(chan string, 1) go func() { for { select { case t := <-tick: res <- t case <-ctx.Done(): close(res) return } } }() return res, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.Websocket{ KeepAlivePingInterval: time.Second, }) srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res any, err error) { path, _ := ctx.Value(ckey("path")).([]int) return next(context.WithValue(ctx, ckey("path"), append(path, 1))) }) srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res any, err error) { path, _ := ctx.Value(ckey("path")).([]int) return next(context.WithValue(ctx, ckey("path"), append(path, 2))) }) c := client.New(srv) t.Run("wont leak goroutines", func(t *testing.T) { runtime.GC() // ensure no go-routines left from preceding tests initialGoroutineCount := runtime.NumGoroutine() sub := c.Websocket(`subscription { updated }`) tick <- "message" var msg struct { resp struct { Updated string } } err := sub.Next(&msg.resp) require.NoError(t, err) require.Equal(t, "message", msg.resp.Updated) sub.Close() // need a little bit of time for goroutines to settle start := time.Now() for time.Since(start).Seconds() < 2 && initialGoroutineCount != runtime.NumGoroutine() { time.Sleep(5 * time.Millisecond) } require.Equal(t, initialGoroutineCount, runtime.NumGoroutine()) }) t.Run("will parse init payload", func(t *testing.T) { runtime.GC() // ensure no go-routines left from preceding tests initialGoroutineCount := runtime.NumGoroutine() sub := c.WebsocketWithPayload(`subscription { initPayload }`, map[string]any{ "Authorization": "Bearer of the curse", "number": 32, "strings": []string{"hello", "world"}, }) var msg struct { resp struct { InitPayload string } } err := sub.Next(&msg.resp) require.NoError(t, err) require.Equal(t, "AUTH:Bearer of the curse", msg.resp.InitPayload) err = sub.Next(&msg.resp) require.NoError(t, err) require.Equal(t, "Authorization = \"Bearer of the curse\"", msg.resp.InitPayload) err = sub.Next(&msg.resp) require.NoError(t, err) require.Equal(t, "number = 32", msg.resp.InitPayload) err = sub.Next(&msg.resp) require.NoError(t, err) require.Equal(t, "strings = []interface {}{\"hello\", \"world\"}", msg.resp.InitPayload) sub.Close() // need a little bit of time for goroutines to settle start := time.Now() for time.Since(start).Seconds() < 2 && initialGoroutineCount != runtime.NumGoroutine() { time.Sleep(5 * time.Millisecond) } require.Equal(t, initialGoroutineCount, runtime.NumGoroutine()) }) t.Run("websocket gets errors", func(t *testing.T) { runtime.GC() // ensure no go-routines left from preceding tests initialGoroutineCount := runtime.NumGoroutine() sub := c.Websocket(`subscription { errorRequired { id } }`) errorTick <- &Error{ID: "ID1234"} var msg struct { resp struct { ErrorRequired *struct { Id string } } } err := sub.Next(&msg.resp) require.NoError(t, err) require.Equal(t, "ID1234", msg.resp.ErrorRequired.Id) errorTick <- nil err = sub.Next(&msg.resp) require.Error(t, err) sub.Close() // need a little bit of time for goroutines to settle start := time.Now() for time.Since(start).Seconds() < 2 && initialGoroutineCount != runtime.NumGoroutine() { time.Sleep(5 * time.Millisecond) } require.Equal(t, initialGoroutineCount, runtime.NumGoroutine()) }) } ================================================ FILE: codegen/testserver/followschema/thirdparty.go ================================================ package followschema import ( "fmt" "io" "strconv" "github.com/99designs/gqlgen/graphql" ) type ThirdParty struct { str string } func MarshalThirdParty(tp ThirdParty) graphql.Marshaler { return graphql.WriterFunc(func(w io.Writer) { _, err := io.WriteString(w, strconv.Quote(tp.str)) if err != nil { panic(err) } }) } func UnmarshalThirdParty(input any) (ThirdParty, error) { switch input := input.(type) { case string: return ThirdParty{str: input}, nil default: return ThirdParty{}, fmt.Errorf("unknown type for input: %s", input) } } ================================================ FILE: codegen/testserver/followschema/time_test.go ================================================ package followschema import ( "context" "testing" "time" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestTime(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) resolvers.QueryResolver.User = func(ctx context.Context, id int) (user *User, e error) { return &User{}, nil } t.Run("zero value in nullable field", func(t *testing.T) { var resp struct { User struct { Updated *string } } err := c.Post(`query { user(id: 1) { updated } }`, &resp) require.NoError(t, err) require.Nil(t, resp.User.Updated) }) t.Run("zero value in non nullable field", func(t *testing.T) { var resp struct { User struct { Created *string } } err := c.Post(`query { user(id: 1) { created } }`, &resp) require.EqualError( t, err, `[{"message":"the requested element is null which the schema does not allow","path":["user","created"]}]`, ) }) t.Run("with values", func(t *testing.T) { resolvers.QueryResolver.User = func(ctx context.Context, id int) (user *User, e error) { updated := time.Date(2010, 1, 1, 0, 0, 20, 1, time.UTC) return &User{ Created: time.Date(2010, 1, 1, 0, 0, 10, 1, time.UTC), Updated: &updated, }, nil } var resp struct { User struct { Created string Updated string } } err := c.Post(`query { user(id: 1) { created, updated } }`, &resp) require.NoError(t, err) require.Equal(t, "2010-01-01T00:00:10.000000001Z", resp.User.Created) require.Equal(t, "2010-01-01T00:00:20.000000001Z", resp.User.Updated) }) } ================================================ FILE: codegen/testserver/followschema/typefallback.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) unmarshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFallbackToStringEncoding(ctx context.Context, v any) (FallbackToStringEncoding, error) { tmp, err := graphql.UnmarshalString(v) res := FallbackToStringEncoding(tmp) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐFallbackToStringEncoding(ctx context.Context, sel ast.SelectionSet, v FallbackToStringEncoding) graphql.Marshaler { _ = sel res := graphql.MarshalString(string(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 } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/typefallback.graphql ================================================ extend type Query { fallback(arg: FallbackToStringEncoding!): FallbackToStringEncoding! } enum FallbackToStringEncoding { A B C } ================================================ FILE: codegen/testserver/followschema/typefallback_test.go ================================================ package followschema import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestTypeFallback(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) resolvers.QueryResolver.Fallback = func(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) { return arg, nil } t.Run("fallback to string passthrough", func(t *testing.T) { var resp struct { Fallback string } c.MustPost(`query { fallback(arg: A) }`, &resp) require.Equal(t, "A", resp.Fallback) }) } ================================================ FILE: codegen/testserver/followschema/useptr.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "fmt" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _A_id(ctx context.Context, field graphql.CollectedField, obj *A) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_A_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_A_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "A", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _B_id(ctx context.Context, field graphql.CollectedField, obj *B) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_B_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_B_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "B", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** func (ec *executionContext) _TestUnion(ctx context.Context, sel ast.SelectionSet, obj TestUnion) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null case B: return ec._B(ctx, sel, &obj) case *B: if obj == nil { return graphql.Null } return ec._B(ctx, sel, obj) case A: return ec._A(ctx, sel, &obj) case *A: if obj == nil { return graphql.Null } return ec._A(ctx, sel, obj) default: if typedObj, ok := obj.(graphql.Marshaler); ok { return typedObj } else { panic(fmt.Errorf("unexpected type %T; non-generated variants of TestUnion must implement graphql.Marshaler", obj)) } } } // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var aImplementors = []string{"A", "TestUnion"} func (ec *executionContext) _A(ctx context.Context, sel ast.SelectionSet, obj *A) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, aImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("A") case "id": out.Values[i] = ec._A_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var bImplementors = []string{"B", "TestUnion"} func (ec *executionContext) _B(ctx context.Context, sel ast.SelectionSet, obj *B) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, bImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("B") case "id": out.Values[i] = ec._B_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshalOTestUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐTestUnion(ctx context.Context, sel ast.SelectionSet, v TestUnion) graphql.Marshaler { if v == nil { return graphql.Null } return ec._TestUnion(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/useptr.graphql ================================================ type A { id: ID! } type B { id: ID! } union TestUnion = A | B extend type Query { optionalUnion: TestUnion } ================================================ FILE: codegen/testserver/followschema/useptr_test.go ================================================ package followschema import ( "reflect" "testing" "github.com/stretchr/testify/require" ) func TestUserPtr(t *testing.T) { s := &Stub{} r := reflect.TypeOf(s.QueryResolver.OptionalUnion) require.Equal(t, reflect.Interface, r.Out(0).Kind()) } ================================================ FILE: codegen/testserver/followschema/v-ok.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _VOkCaseNil_value(ctx context.Context, field graphql.CollectedField, obj *VOkCaseNil) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_VOkCaseNil_value, func(ctx context.Context) (any, error) { v, ok := obj.Value() if !ok { return nil, nil } return v, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2string, true, false, ) } func (ec *executionContext) fieldContext_VOkCaseNil_value(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "VOkCaseNil", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _VOkCaseValue_value(ctx context.Context, field graphql.CollectedField, obj *VOkCaseValue) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_VOkCaseValue_value, func(ctx context.Context) (any, error) { v, ok := obj.Value() if !ok { return nil, nil } return v, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2string, true, false, ) } func (ec *executionContext) fieldContext_VOkCaseValue_value(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "VOkCaseValue", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var vOkCaseNilImplementors = []string{"VOkCaseNil"} func (ec *executionContext) _VOkCaseNil(ctx context.Context, sel ast.SelectionSet, obj *VOkCaseNil) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, vOkCaseNilImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("VOkCaseNil") case "value": out.Values[i] = ec._VOkCaseNil_value(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var vOkCaseValueImplementors = []string{"VOkCaseValue"} func (ec *executionContext) _VOkCaseValue(ctx context.Context, sel ast.SelectionSet, obj *VOkCaseValue) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, vOkCaseValueImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("VOkCaseValue") case "value": out.Values[i] = ec._VOkCaseValue_value(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshalOVOkCaseNil2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐVOkCaseNil(ctx context.Context, sel ast.SelectionSet, v *VOkCaseNil) graphql.Marshaler { if v == nil { return graphql.Null } return ec._VOkCaseNil(ctx, sel, v) } func (ec *executionContext) marshalOVOkCaseValue2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐVOkCaseValue(ctx context.Context, sel ast.SelectionSet, v *VOkCaseValue) graphql.Marshaler { if v == nil { return graphql.Null } return ec._VOkCaseValue(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/v-ok.go ================================================ package followschema // VOkCaseValue model type VOkCaseValue struct{} func (v VOkCaseValue) Value() (string, bool) { return "hi", true } // VOkCaseNil model type VOkCaseNil struct{} func (v VOkCaseNil) Value() (string, bool) { return "", false } ================================================ FILE: codegen/testserver/followschema/v-ok.graphql ================================================ extend type Query { vOkCaseValue: VOkCaseValue vOkCaseNil: VOkCaseNil } type VOkCaseValue @goModel(model:"followschema.VOkCaseValue") { value: String } type VOkCaseNil @goModel(model:"followschema.VOkCaseNil") { value: String } ================================================ FILE: codegen/testserver/followschema/v-ok_test.go ================================================ package followschema import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestOk(t *testing.T) { resolver := &Stub{} resolver.QueryResolver.VOkCaseValue = func(ctx context.Context) (*VOkCaseValue, error) { return &VOkCaseValue{}, nil } resolver.QueryResolver.VOkCaseNil = func(ctx context.Context) (*VOkCaseNil, error) { return &VOkCaseNil{}, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolver})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("v ok case value", func(t *testing.T) { var resp struct { VOkCaseValue struct { Value string } } err := c.Post(`query { vOkCaseValue { value } }`, &resp) require.NoError(t, err) require.Equal(t, "hi", resp.VOkCaseValue.Value) }) t.Run("v ok case nil", func(t *testing.T) { var resp struct { VOkCaseNil struct { Value *string } } err := c.Post(`query { vOkCaseNil { value } }`, &resp) require.NoError(t, err) require.Nil(t, resp.VOkCaseNil.Value) }) } ================================================ FILE: codegen/testserver/followschema/validtypes.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "fmt" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) field_ValidType_validArgs_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "break", ec.unmarshalNString2string) if err != nil { return nil, err } args["break"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "default", ec.unmarshalNString2string) if err != nil { return nil, err } args["default"] = arg1 arg2, err := graphql.ProcessArgField(ctx, rawArgs, "func", ec.unmarshalNString2string) if err != nil { return nil, err } args["func"] = arg2 arg3, err := graphql.ProcessArgField(ctx, rawArgs, "interface", ec.unmarshalNString2string) if err != nil { return nil, err } args["interface"] = arg3 arg4, err := graphql.ProcessArgField(ctx, rawArgs, "select", ec.unmarshalNString2string) if err != nil { return nil, err } args["select"] = arg4 arg5, err := graphql.ProcessArgField(ctx, rawArgs, "case", ec.unmarshalNString2string) if err != nil { return nil, err } args["case"] = arg5 arg6, err := graphql.ProcessArgField(ctx, rawArgs, "defer", ec.unmarshalNString2string) if err != nil { return nil, err } args["defer"] = arg6 arg7, err := graphql.ProcessArgField(ctx, rawArgs, "go", ec.unmarshalNString2string) if err != nil { return nil, err } args["go"] = arg7 arg8, err := graphql.ProcessArgField(ctx, rawArgs, "map", ec.unmarshalNString2string) if err != nil { return nil, err } args["map"] = arg8 arg9, err := graphql.ProcessArgField(ctx, rawArgs, "struct", ec.unmarshalNString2string) if err != nil { return nil, err } args["struct"] = arg9 arg10, err := graphql.ProcessArgField(ctx, rawArgs, "chan", ec.unmarshalNString2string) if err != nil { return nil, err } args["chan"] = arg10 arg11, err := graphql.ProcessArgField(ctx, rawArgs, "else", ec.unmarshalNString2string) if err != nil { return nil, err } args["else"] = arg11 arg12, err := graphql.ProcessArgField(ctx, rawArgs, "goto", ec.unmarshalNString2string) if err != nil { return nil, err } args["goto"] = arg12 arg13, err := graphql.ProcessArgField(ctx, rawArgs, "package", ec.unmarshalNString2string) if err != nil { return nil, err } args["package"] = arg13 arg14, err := graphql.ProcessArgField(ctx, rawArgs, "switch", ec.unmarshalNString2string) if err != nil { return nil, err } args["switch"] = arg14 arg15, err := graphql.ProcessArgField(ctx, rawArgs, "const", ec.unmarshalNString2string) if err != nil { return nil, err } args["const"] = arg15 arg16, err := graphql.ProcessArgField(ctx, rawArgs, "fallthrough", ec.unmarshalNString2string) if err != nil { return nil, err } args["fallthrough"] = arg16 arg17, err := graphql.ProcessArgField(ctx, rawArgs, "if", ec.unmarshalNString2string) if err != nil { return nil, err } args["if"] = arg17 arg18, err := graphql.ProcessArgField(ctx, rawArgs, "range", ec.unmarshalNString2string) if err != nil { return nil, err } args["range"] = arg18 arg19, err := graphql.ProcessArgField(ctx, rawArgs, "type", ec.unmarshalNString2string) if err != nil { return nil, err } args["type"] = arg19 arg20, err := graphql.ProcessArgField(ctx, rawArgs, "continue", ec.unmarshalNString2string) if err != nil { return nil, err } args["continue"] = arg20 arg21, err := graphql.ProcessArgField(ctx, rawArgs, "for", ec.unmarshalNString2string) if err != nil { return nil, err } args["for"] = arg21 arg22, err := graphql.ProcessArgField(ctx, rawArgs, "import", ec.unmarshalNString2string) if err != nil { return nil, err } args["import"] = arg22 arg23, err := graphql.ProcessArgField(ctx, rawArgs, "return", ec.unmarshalNString2string) if err != nil { return nil, err } args["return"] = arg23 arg24, err := graphql.ProcessArgField(ctx, rawArgs, "var", ec.unmarshalNString2string) if err != nil { return nil, err } args["var"] = arg24 arg25, err := graphql.ProcessArgField(ctx, rawArgs, "_", ec.unmarshalNString2string) if err != nil { return nil, err } args["_"] = arg25 return args, nil } func (ec *executionContext) field_ValidType_validInputKeywords_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, "input", ec.unmarshalOValidInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐValidInput) if err != nil { return nil, err } args["input"] = arg0 return args, nil } // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _Content_Post_foo(ctx context.Context, field graphql.CollectedField, obj *ContentPost) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Content_Post_foo, func(ctx context.Context) (any, error) { return obj.Foo, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Content_Post_foo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Content_Post", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Content_User_foo(ctx context.Context, field graphql.CollectedField, obj *ContentUser) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Content_User_foo, func(ctx context.Context) (any, error) { return obj.Foo, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Content_User_foo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Content_User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _ValidType_differentCase(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ValidType_differentCase, func(ctx context.Context) (any, error) { return obj.DifferentCase, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_ValidType_differentCase(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ValidType", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _ValidType_different_case(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ValidType_different_case, func(ctx context.Context) (any, error) { return obj.DifferentCaseOld, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_ValidType_different_case(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ValidType", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _ValidType_validInputKeywords(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ValidType_validInputKeywords, func(ctx context.Context) (any, error) { return obj.ValidInputKeywords, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNBoolean2bool, true, true, ) } func (ec *executionContext) fieldContext_ValidType_validInputKeywords(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ValidType", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_ValidType_validInputKeywords_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _ValidType_validArgs(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ValidType_validArgs, func(ctx context.Context) (any, error) { return obj.ValidArgs, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNBoolean2bool, true, true, ) } func (ec *executionContext) fieldContext_ValidType_validArgs(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ValidType", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_ValidType_validArgs_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** func (ec *executionContext) unmarshalInputValidInput(ctx context.Context, obj any) (ValidInput, error) { var it ValidInput if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"break", "default", "func", "interface", "select", "case", "defer", "go", "map", "struct", "chan", "else", "goto", "package", "switch", "const", "fallthrough", "if", "range", "type", "continue", "for", "import", "return", "var", "_"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "break": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("break")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Break = data case "default": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("default")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Default = data case "func": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("func")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Func = data case "interface": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("interface")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Interface = data case "select": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("select")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Select = data case "case": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("case")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Case = data case "defer": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("defer")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Defer = data case "go": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("go")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Go = data case "map": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("map")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Map = data case "struct": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("struct")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Struct = data case "chan": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chan")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Chan = data case "else": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("else")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Else = data case "goto": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("goto")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Goto = data case "package": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("package")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Package = data case "switch": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("switch")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Switch = data case "const": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("const")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Const = data case "fallthrough": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fallthrough")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Fallthrough = data case "if": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("if")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.If = data case "range": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("range")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Range = data case "type": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("type")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Type = data case "continue": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("continue")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Continue = data case "for": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("for")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.For = data case "import": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("import")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Import = data case "return": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("return")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Return = data case "var": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("var")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Var = data case "_": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("_")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Underscore = data } } return it, nil } // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** func (ec *executionContext) _Content_Child(ctx context.Context, sel ast.SelectionSet, obj ContentChild) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null case ContentUser: return ec._Content_User(ctx, sel, &obj) case *ContentUser: if obj == nil { return graphql.Null } return ec._Content_User(ctx, sel, obj) case ContentPost: return ec._Content_Post(ctx, sel, &obj) case *ContentPost: if obj == nil { return graphql.Null } return ec._Content_Post(ctx, sel, obj) default: if typedObj, ok := obj.(graphql.Marshaler); ok { return typedObj } else { panic(fmt.Errorf("unexpected type %T; non-generated variants of Content_Child must implement graphql.Marshaler", obj)) } } } // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var content_PostImplementors = []string{"Content_Post", "Content_Child"} func (ec *executionContext) _Content_Post(ctx context.Context, sel ast.SelectionSet, obj *ContentPost) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, content_PostImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Content_Post") case "foo": out.Values[i] = ec._Content_Post_foo(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var content_UserImplementors = []string{"Content_User", "Content_Child"} func (ec *executionContext) _Content_User(ctx context.Context, sel ast.SelectionSet, obj *ContentUser) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, content_UserImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Content_User") case "foo": out.Values[i] = ec._Content_User_foo(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var validTypeImplementors = []string{"ValidType"} func (ec *executionContext) _ValidType(ctx context.Context, sel ast.SelectionSet, obj *ValidType) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, validTypeImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("ValidType") case "differentCase": out.Values[i] = ec._ValidType_differentCase(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "different_case": out.Values[i] = ec._ValidType_different_case(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "validInputKeywords": out.Values[i] = ec._ValidType_validInputKeywords(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "validArgs": out.Values[i] = ec._ValidType_validArgs(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) unmarshalOValidInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐValidInput(ctx context.Context, v any) (*ValidInput, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputValidInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOValidType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐValidType(ctx context.Context, sel ast.SelectionSet, v *ValidType) graphql.Marshaler { if v == nil { return graphql.Null } return ec._ValidType(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/validtypes.graphql ================================================ extend type Query { validType: ValidType } """ These things are all valid, but without care generate invalid go code """ type ValidType { differentCase: String! different_case: String! @goField(name:"DifferentCaseOld") validInputKeywords(input: ValidInput): Boolean! validArgs( break: String!, default: String!, func: String!, interface: String!, select: String!, case: String!, defer: String!, go: String!, map: String!, struct: String!, chan: String!, else: String!, goto: String!, package: String!, switch: String!, const: String!, fallthrough: String!, if: String!, range: String!, type: String!, continue: String!, for: String!, import: String!, return: String!, var: String!, _: String!, ): Boolean! } input ValidInput { break: String! default: String! func: String! interface: String! select: String! case: String! defer: String! go: String! map: String! struct: String! chan: String! else: String! goto: String! package: String! switch: String! const: String! fallthrough: String! if: String! range: String! type: String! continue: String! for: String! import: String! return: String! var: String! _: String! @goField(name: "Underscore") } # see https://github.com/99designs/gqlgen/issues/694 type Content_User { foo: String } type Content_Post { foo: String } union Content_Child = Content_User | Content_Post ================================================ FILE: codegen/testserver/followschema/validtypes_test.go ================================================ package followschema import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestValidType(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.ValidType = func(ctx context.Context) (validType *ValidType, e error) { return &ValidType{ DifferentCase: "new", DifferentCaseOld: "old", }, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("fields with differing cases can be distinguished", func(t *testing.T) { var resp struct { ValidType struct { New string `json:"differentCase"` Old string `json:"different_case"` } } err := c.Post(`query { validType { differentCase, different_case } }`, &resp) require.NoError(t, err) require.Equal(t, "new", resp.ValidType.New) require.Equal(t, "old", resp.ValidType.Old) }) } ================================================ FILE: codegen/testserver/followschema/variadic.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) field_VariadicModel_value_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "rank", ec.unmarshalNInt2int) if err != nil { return nil, err } args["rank"] = arg0 return args, nil } // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _VariadicModel_value(ctx context.Context, field graphql.CollectedField, obj *VariadicModel) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_VariadicModel_value, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return obj.Value(ctx, fc.Args["rank"].(int)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2string, true, false, ) } func (ec *executionContext) fieldContext_VariadicModel_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "VariadicModel", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_VariadicModel_value_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var variadicModelImplementors = []string{"VariadicModel"} func (ec *executionContext) _VariadicModel(ctx context.Context, sel ast.SelectionSet, obj *VariadicModel) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, variadicModelImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("VariadicModel") case "value": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._VariadicModel_value(ctx, field, obj) return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshalOVariadicModel2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐVariadicModel(ctx context.Context, sel ast.SelectionSet, v *VariadicModel) graphql.Marshaler { if v == nil { return graphql.Null } return ec._VariadicModel(ctx, sel, v) } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/variadic.go ================================================ package followschema import ( "context" "strconv" ) type VariadicModel struct{} type VariadicModelOption func(*VariadicModel) func (v VariadicModel) Value( ctx context.Context, rank int, opts ...VariadicModelOption, ) (string, error) { return strconv.Itoa(rank), nil } ================================================ FILE: codegen/testserver/followschema/variadic.graphql ================================================ extend type Query { variadicModel: VariadicModel } type VariadicModel { value(rank: Int!): String } ================================================ FILE: codegen/testserver/followschema/weird_type_cases.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _AIt_id(ctx context.Context, field graphql.CollectedField, obj *AIt) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_AIt_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_AIt_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AIt", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _AbIt_id(ctx context.Context, field graphql.CollectedField, obj *AbIt) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_AbIt_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_AbIt_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AbIt", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _XXIt_id(ctx context.Context, field graphql.CollectedField, obj *XXIt) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_XXIt_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_XXIt_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "XXIt", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _XxIt_id(ctx context.Context, field graphql.CollectedField, obj *XxIt) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_XxIt_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_XxIt_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "XxIt", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _asdfIt_id(ctx context.Context, field graphql.CollectedField, obj *AsdfIt) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_asdfIt_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_asdfIt_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "asdfIt", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _iIt_id(ctx context.Context, field graphql.CollectedField, obj *IIt) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_iIt_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_iIt_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "iIt", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var aItImplementors = []string{"AIt"} func (ec *executionContext) _AIt(ctx context.Context, sel ast.SelectionSet, obj *AIt) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, aItImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("AIt") case "id": out.Values[i] = ec._AIt_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var abItImplementors = []string{"AbIt"} func (ec *executionContext) _AbIt(ctx context.Context, sel ast.SelectionSet, obj *AbIt) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, abItImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("AbIt") case "id": out.Values[i] = ec._AbIt_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var xXItImplementors = []string{"XXIt"} func (ec *executionContext) _XXIt(ctx context.Context, sel ast.SelectionSet, obj *XXIt) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, xXItImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("XXIt") case "id": out.Values[i] = ec._XXIt_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var xxItImplementors = []string{"XxIt"} func (ec *executionContext) _XxIt(ctx context.Context, sel ast.SelectionSet, obj *XxIt) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, xxItImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("XxIt") case "id": out.Values[i] = ec._XxIt_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var asdfItImplementors = []string{"asdfIt"} func (ec *executionContext) _asdfIt(ctx context.Context, sel ast.SelectionSet, obj *AsdfIt) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, asdfItImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("asdfIt") case "id": out.Values[i] = ec._asdfIt_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var iItImplementors = []string{"iIt"} func (ec *executionContext) _iIt(ctx context.Context, sel ast.SelectionSet, obj *IIt) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, iItImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("iIt") case "id": out.Values[i] = ec._iIt_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/weird_type_cases.graphql ================================================ # regression test for https://github.com/99designs/gqlgen/issues/583 type asdfIt { id: ID! } type iIt { id: ID! } type AIt { id: ID! } type XXIt { id: ID! } type AbIt { id: ID! } type XxIt { id: ID! } ================================================ FILE: codegen/testserver/followschema/wrapped_type.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "errors" "strconv" "sync/atomic" "github.com/99designs/gqlgen/codegen/testserver/followschema/otherpkg" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** type WrappedMapResolver interface { Get(ctx context.Context, obj WrappedMap, key string) (string, error) } type WrappedSliceResolver interface { Get(ctx context.Context, obj WrappedSlice, idx int) (string, error) } // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) field_WrappedMap_get_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "key", ec.unmarshalNString2string) if err != nil { return nil, err } args["key"] = arg0 return args, nil } func (ec *executionContext) field_WrappedSlice_get_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "idx", ec.unmarshalNInt2int) if err != nil { return nil, err } args["idx"] = arg0 return args, nil } // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _WrappedMap_get(ctx context.Context, field graphql.CollectedField, obj WrappedMap) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_WrappedMap_get, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.WrappedMap().Get(ctx, obj, fc.Args["key"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_WrappedMap_get(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "WrappedMap", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_WrappedMap_get_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _WrappedSlice_get(ctx context.Context, field graphql.CollectedField, obj WrappedSlice) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_WrappedSlice_get, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.WrappedSlice().Get(ctx, obj, fc.Args["idx"].(int)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_WrappedSlice_get(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "WrappedSlice", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_WrappedSlice_get_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _WrappedStruct_name(ctx context.Context, field graphql.CollectedField, obj *WrappedStruct) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_WrappedStruct_name, func(ctx context.Context) (any, error) { return obj.Name, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋotherpkgᚐScalar, true, true, ) } func (ec *executionContext) fieldContext_WrappedStruct_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "WrappedStruct", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type WrappedScalar does not have child fields") }, } return fc, nil } func (ec *executionContext) _WrappedStruct_desc(ctx context.Context, field graphql.CollectedField, obj *WrappedStruct) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_WrappedStruct_desc, func(ctx context.Context) (any, error) { return obj.Desc, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOWrappedScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋotherpkgᚐScalar, true, false, ) } func (ec *executionContext) fieldContext_WrappedStruct_desc(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "WrappedStruct", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type WrappedScalar does not have child fields") }, } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var wrappedMapImplementors = []string{"WrappedMap"} func (ec *executionContext) _WrappedMap(ctx context.Context, sel ast.SelectionSet, obj WrappedMap) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, wrappedMapImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("WrappedMap") case "get": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._WrappedMap_get(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var wrappedSliceImplementors = []string{"WrappedSlice"} func (ec *executionContext) _WrappedSlice(ctx context.Context, sel ast.SelectionSet, obj WrappedSlice) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, wrappedSliceImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("WrappedSlice") case "get": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._WrappedSlice_get(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var wrappedStructImplementors = []string{"WrappedStruct"} func (ec *executionContext) _WrappedStruct(ctx context.Context, sel ast.SelectionSet, obj *WrappedStruct) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, wrappedStructImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("WrappedStruct") case "name": out.Values[i] = ec._WrappedStruct_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "desc": out.Values[i] = ec._WrappedStruct_desc(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) marshalNWrappedMap2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐWrappedMap(ctx context.Context, sel ast.SelectionSet, v WrappedMap) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._WrappedMap(ctx, sel, v) } func (ec *executionContext) unmarshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋotherpkgᚐScalar(ctx context.Context, v any) (otherpkg.Scalar, error) { tmp, err := graphql.UnmarshalString(v) res := otherpkg.Scalar(tmp) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋotherpkgᚐScalar(ctx context.Context, sel ast.SelectionSet, v otherpkg.Scalar) graphql.Marshaler { _ = sel res := graphql.MarshalString(string(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) marshalNWrappedSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐWrappedSlice(ctx context.Context, sel ast.SelectionSet, v WrappedSlice) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._WrappedSlice(ctx, sel, v) } func (ec *executionContext) marshalNWrappedStruct2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐWrappedStruct(ctx context.Context, sel ast.SelectionSet, v WrappedStruct) graphql.Marshaler { return ec._WrappedStruct(ctx, sel, &v) } func (ec *executionContext) marshalNWrappedStruct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚐWrappedStruct(ctx context.Context, sel ast.SelectionSet, v *WrappedStruct) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._WrappedStruct(ctx, sel, v) } func (ec *executionContext) unmarshalOWrappedScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋotherpkgᚐScalar(ctx context.Context, v any) (*otherpkg.Scalar, error) { if v == nil { return nil, nil } tmp, err := graphql.UnmarshalString(v) res := otherpkg.Scalar(tmp) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOWrappedScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋfollowschemaᚋotherpkgᚐScalar(ctx context.Context, sel ast.SelectionSet, v *otherpkg.Scalar) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel _ = ctx res := graphql.MarshalString(string(*v)) return res } // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/followschema/wrapped_type.go ================================================ package followschema import "github.com/99designs/gqlgen/codegen/testserver/followschema/otherpkg" type ( WrappedScalar = otherpkg.Scalar WrappedStruct otherpkg.Struct WrappedMap otherpkg.Map WrappedSlice otherpkg.Slice ) ================================================ FILE: codegen/testserver/followschema/wrapped_type.graphql ================================================ # regression test for https://github.com/99designs/gqlgen/issues/721 extend type Query { wrappedStruct: WrappedStruct! wrappedScalar: WrappedScalar! wrappedMap: WrappedMap! wrappedSlice: WrappedSlice! } type WrappedStruct { name: WrappedScalar!, desc: WrappedScalar } scalar WrappedScalar type WrappedMap { get(key: String!): String! } type WrappedSlice { get(idx: Int!): String! } ================================================ FILE: codegen/testserver/followschema/wrapped_type_test.go ================================================ package followschema import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/codegen/testserver/followschema/otherpkg" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestWrappedTypes(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) resolvers.QueryResolver.WrappedScalar = func(ctx context.Context) (scalar WrappedScalar, e error) { return "hello", nil } resolvers.QueryResolver.WrappedStruct = func(ctx context.Context) (wrappedStruct *WrappedStruct, e error) { wrapped := WrappedStruct(otherpkg.Struct{ Name: "hello", }) return &wrapped, nil } resolvers.QueryResolver.WrappedMap = func(ctx context.Context) (wrappedMap WrappedMap, e error) { wrapped := WrappedMap(map[string]string{ "name": "hello", }) return wrapped, nil } resolvers.QueryResolver.WrappedSlice = func(ctx context.Context) (slice WrappedSlice, err error) { wrapped := WrappedSlice([]string{"hello"}) return wrapped, nil } resolvers.WrappedMapResolver.Get = func(ctx context.Context, obj WrappedMap, key string) (s string, err error) { return obj[key], nil } resolvers.WrappedSliceResolver.Get = func(ctx context.Context, obj WrappedSlice, idx int) (s string, err error) { return obj[idx], nil } t.Run("wrapped struct", func(t *testing.T) { var resp struct { WrappedStruct struct { Name string } } err := c.Post(`query { wrappedStruct { name } }`, &resp) require.NoError(t, err) require.Equal(t, "hello", resp.WrappedStruct.Name) }) t.Run("wrapped scalar", func(t *testing.T) { var resp struct { WrappedScalar string } err := c.Post(`query { wrappedScalar }`, &resp) require.NoError(t, err) require.Equal(t, "hello", resp.WrappedScalar) }) t.Run("wrapped map", func(t *testing.T) { var resp struct { WrappedMap struct { Name string } } err := c.Post(`query { wrappedMap { name: get(key: "name") } }`, &resp) require.NoError(t, err) require.Equal(t, "hello", resp.WrappedMap.Name) }) t.Run("wrapped slice", func(t *testing.T) { var resp struct { WrappedSlice struct { First string } } err := c.Post(`query { wrappedSlice { first: get(idx: 0) } }`, &resp) require.NoError(t, err) require.Equal(t, "hello", resp.WrappedSlice.First) }) } ================================================ FILE: codegen/testserver/generated_test.go ================================================ package testserver import ( "bytes" "go/ast" "go/parser" "go/printer" "go/token" "os" "path/filepath" "sort" "strings" "testing" "github.com/stretchr/testify/require" ) func TestLayouts(t *testing.T) { singlefileFSet := token.NewFileSet() singlefilePkg := loadPackage(t, "singlefile", singlefileFSet) followschemaFSet := token.NewFileSet() followschemaPkg := loadPackage(t, "followschema", followschemaFSet) singlefileDecls := collectDeclStrings(singlefilePkg.Files) followschemaDecls := collectDeclStrings(followschemaPkg.Files) // Normalize package names so that both sides can be compared. for i, s := range followschemaDecls { followschemaDecls[i] = strings.ReplaceAll(s, "followschema", "singlefile") } require.Equal(t, singlefileDecls, followschemaDecls) } func loadPackage(t *testing.T, name string, fset *token.FileSet) *ast.Package { path, err := filepath.Abs(name) require.NoError(t, err) files, err := os.ReadDir(path) require.NoError(t, err) pkg := ast.Package{ Name: name, Files: make(map[string]*ast.File), } for _, f := range files { // Only compare generated files. if strings.HasSuffix(f.Name(), ".generated.go") || f.Name() == "generated.go" || f.Name() == "resolver.go" || f.Name() == "stub.go" || f.Name() == "models-gen.go" { filename := filepath.Join(path, f.Name()) src, err := parser.ParseFile(fset, filename, nil, parser.AllErrors) require.NoError(t, err) pkg.Files[filename] = src } } return &pkg } func collectDeclStrings(files map[string]*ast.File) []string { printFSet := token.NewFileSet() var strs []string var buf bytes.Buffer for _, f := range files { for _, decl := range f.Decls { if gd, ok := decl.(*ast.GenDecl); ok && gd.Tok == token.IMPORT { continue } buf.Reset() if err := printer.Fprint(&buf, printFSet, decl); err != nil { continue } strs = append(strs, buf.String()) } } sort.Strings(strs) return strs } ================================================ FILE: codegen/testserver/nullabledirectives/directive.graphql ================================================ directive @populate(value: String!) on ARGUMENT_DEFINITION directive @noop on ARGUMENT_DEFINITION type Query { directiveSingleNullableArg( arg1: String @populate(value: "test") @noop, ): String } ================================================ FILE: codegen/testserver/nullabledirectives/directive_test.go ================================================ //go:generate go run ../../../testdata/gqlgen.go -config gqlgen.yml -stub stub.go package followschema import ( "context" "reflect" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/codegen/testserver/nullabledirectives/generated" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) // isNil checks if the given value is nil func isNil(input any) bool { if input == nil { return true } // Using reflect to check if the value is nil. This is necessary for // any types that are not nil types but have a nil value (e.g. *string). value := reflect.ValueOf(input) return value.IsNil() } func TestDirectives(t *testing.T) { resolvers := &Stub{} ok := "Ok" resolvers.QueryResolver.DirectiveSingleNullableArg = func(ctx context.Context, arg1 *string) (*string, error) { if arg1 != nil { return arg1, nil } return &ok, nil } srv := handler.New(generated.NewExecutableSchema(generated.Config{ Resolvers: resolvers, Directives: generated.DirectiveRoot{ Populate: func(ctx context.Context, obj any, next graphql.Resolver, value string) (any, error) { res, err := next(ctx) if err != nil { return nil, err } if !isNil(res) { return res, err } return &value, nil }, Noop: func(ctx context.Context, obj any, next graphql.Resolver) (any, error) { return next(ctx) }, }, })) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("arg directives", func(t *testing.T) { t.Run("directive is called with null arguments", func(t *testing.T) { var resp struct { DirectiveSingleNullableArg *string } err := c.Post(`query { directiveSingleNullableArg }`, &resp) require.NoError(t, err) require.Equal(t, "test", *resp.DirectiveSingleNullableArg) }) }) } ================================================ FILE: codegen/testserver/nullabledirectives/generated/directive.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package generated import ( "context" "errors" "fmt" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** type QueryResolver interface { DirectiveSingleNullableArg(ctx context.Context, arg1 *string) (*string, error) } // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) dir_populate_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.unmarshalNString2string) if err != nil { return nil, err } args["value"] = 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_directiveSingleNullableArg_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Query_directiveSingleNullableArg_argsArg1(ctx, rawArgs) if err != nil { return nil, err } args["arg1"] = arg0 return args, nil } func (ec *executionContext) field_Query_directiveSingleNullableArg_argsArg1( ctx context.Context, rawArgs map[string]any, ) (*string, error) { ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("arg1")) directive0 := func(ctx context.Context) (any, error) { tmp, ok := rawArgs["arg1"] if !ok { var zeroVal *string return zeroVal, nil } return ec.unmarshalOString2ᚖstring(ctx, tmp) } directive1 := func(ctx context.Context) (any, error) { value, err := ec.unmarshalNString2string(ctx, "test") if err != nil { var zeroVal *string return zeroVal, err } if ec.Directives.Populate == nil { var zeroVal *string return zeroVal, errors.New("directive populate is not implemented") } return ec.Directives.Populate(ctx, rawArgs, directive0, value) } directive2 := func(ctx context.Context) (any, error) { if ec.Directives.Noop == nil { var zeroVal *string return zeroVal, errors.New("directive noop is not implemented") } return ec.Directives.Noop(ctx, rawArgs, directive1) } tmp, err := directive2(ctx) if err != nil { var zeroVal *string return zeroVal, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(*string); ok { return data, nil } else if tmp == nil { var zeroVal *string return zeroVal, nil } else { var zeroVal *string return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp)) } } // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _Query_directiveSingleNullableArg(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveSingleNullableArg, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().DirectiveSingleNullableArg(ctx, fc.Args["arg1"].(*string)) }, nil, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_directiveSingleNullableArg(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_directiveSingleNullableArg_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 } // 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 "directiveSingleNullableArg": 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_directiveSingleNullableArg(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 } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** // endregion ***************************** type.gotpl ***************************** ================================================ FILE: codegen/testserver/nullabledirectives/generated/models/models-gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package models type Query struct { } ================================================ FILE: codegen/testserver/nullabledirectives/generated/prelude.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package generated import ( "context" "errors" "fmt" "strconv" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" "github.com/vektah/gqlparser/v2/ast" ) // region ************************** generated!.gotpl ************************** // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) dir_defer_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, "if", ec.unmarshalOBoolean2ᚖbool) if err != nil { return nil, err } args["if"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "label", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["label"] = arg1 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) ___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 __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) 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) 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: codegen/testserver/nullabledirectives/generated/resolvers/resolver.go ================================================ package resolver // 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" nullabledirectives "github.com/99designs/gqlgen/codegen/testserver/nullabledirectives/generated" ) type Resolver struct{} // DirectiveSingleNullableArg is the resolver for the directiveSingleNullableArg field. func (r *queryResolver) DirectiveSingleNullableArg(ctx context.Context, arg1 *string) (*string, error) { panic("not implemented") } // Query returns nullabledirectives.QueryResolver implementation. func (r *Resolver) Query() nullabledirectives.QueryResolver { return &queryResolver{r} } type queryResolver struct{ *Resolver } // !!! 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. /* type Resolver struct{} */ ================================================ FILE: codegen/testserver/nullabledirectives/generated/root_.generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package generated import ( "bytes" "context" "sync/atomic" "github.com/99designs/gqlgen/graphql" gqlparser "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" ) // NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { return &executableSchema{SchemaData: cfg.Schema, Resolvers: cfg.Resolvers, Directives: cfg.Directives, ComplexityRoot: cfg.Complexity} } type Config = graphql.Config[ResolverRoot, DirectiveRoot, ComplexityRoot] type ResolverRoot interface { Query() QueryResolver } type DirectiveRoot struct { Noop func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) Populate func(ctx context.Context, obj any, next graphql.Resolver, value string) (res any, err error) } type ComplexityRoot struct { Query struct { DirectiveSingleNullableArg func(childComplexity int, arg1 *string) int } } 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 "Query.directiveSingleNullableArg": if e.ComplexityRoot.Query.DirectiveSingleNullableArg == nil { break } args, err := ec.field_Query_directiveSingleNullableArg_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.DirectiveSingleNullableArg(childComplexity, args["arg1"].(*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 } 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: "../directive.graphql", Input: `directive @populate(value: String!) on ARGUMENT_DEFINITION directive @noop on ARGUMENT_DEFINITION type Query { directiveSingleNullableArg( arg1: String @populate(value: "test") @noop, ): String } `, BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) ================================================ FILE: codegen/testserver/nullabledirectives/gqlgen.yml ================================================ schema: - "*.graphql" skip_validation: true exec: layout: follow-schema dir: generated package: generated model: filename: generated/models/models-gen.go package: models resolver: filename: generated/resolvers/resolver.go package: resolver type: Resolver call_argument_directives_with_null: true ================================================ FILE: codegen/testserver/nullabledirectives/stub.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package followschema import ( "context" "github.com/99designs/gqlgen/codegen/testserver/nullabledirectives/generated" ) type Stub struct { QueryResolver struct { DirectiveSingleNullableArg func(ctx context.Context, arg1 *string) (*string, error) } } func (r *Stub) Query() generated.QueryResolver { return &stubQuery{r} } type stubQuery struct{ *Stub } func (r *stubQuery) DirectiveSingleNullableArg(ctx context.Context, arg1 *string) (*string, error) { return r.QueryResolver.DirectiveSingleNullableArg(ctx, arg1) } ================================================ FILE: codegen/testserver/protogetters/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package protogetters import ( "bytes" "context" "embed" "errors" "fmt" "strconv" "sync/atomic" "github.com/99designs/gqlgen/codegen/testserver/protogetters/models" "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 { Query() QueryResolver } type DirectiveRoot struct { } type ComplexityRoot struct { Query struct { User func(childComplexity int, id string) int } User struct { GetAge func(childComplexity int) int GetEmail func(childComplexity int) int GetId func(childComplexity int) int GetName func(childComplexity int) int } } type QueryResolver interface { User(ctx context.Context, id string) (*models.User, 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 "Query.user": if e.ComplexityRoot.Query.User == nil { break } args, err := ec.field_Query_user_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.User(childComplexity, args["id"].(string)), true case "User.age": if e.ComplexityRoot.User.GetAge == nil { break } return e.ComplexityRoot.User.GetAge(childComplexity), true case "User.email": if e.ComplexityRoot.User.GetEmail == nil { break } return e.ComplexityRoot.User.GetEmail(childComplexity), true case "User.id": if e.ComplexityRoot.User.GetId == nil { break } return e.ComplexityRoot.User.GetId(childComplexity), true case "User.name": if e.ComplexityRoot.User.GetName == nil { break } return e.ComplexityRoot.User.GetName(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_Query_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, "id", ec.unmarshalNID2string) if err != nil { return nil, err } args["id"] = 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_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_user, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().User(ctx, fc.Args["id"].(string)) }, nil, ec.marshalOUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋprotogettersᚋmodelsᚐUser, true, false, ) } func (ec *executionContext) fieldContext_Query_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_User_id(ctx, field) case "name": return ec.fieldContext_User_name(ctx, field) case "email": return ec.fieldContext_User_email(ctx, field) case "age": return ec.fieldContext_User_age(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_user_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query___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_id(ctx context.Context, field graphql.CollectedField, obj *models.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_id, func(ctx context.Context) (any, error) { return obj.GetId(), nil }, nil, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_User_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *models.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_name, func(ctx context.Context) (any, error) { if !obj.HasName() { return nil, nil } return obj.GetName(), nil }, nil, ec.marshalOString2string, true, false, ) } func (ec *executionContext) fieldContext_User_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _User_email(ctx context.Context, field graphql.CollectedField, obj *models.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_email, func(ctx context.Context) (any, error) { if !obj.HasEmail() { return nil, nil } return obj.GetEmail(), nil }, nil, ec.marshalOString2string, true, false, ) } func (ec *executionContext) fieldContext_User_email(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _User_age(ctx context.Context, field graphql.CollectedField, obj *models.User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_age, func(ctx context.Context) (any, error) { return obj.GetAge(), nil }, nil, ec.marshalNInt2int32, true, true, ) } func (ec *executionContext) fieldContext_User_age(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { 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 "user": 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_user(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__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 *models.User) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("User") case "id": out.Values[i] = ec._User_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "name": out.Values[i] = ec._User_name(ctx, field, obj) case "email": out.Values[i] = ec._User_email(ctx, field, obj) case "age": out.Values[i] = ec._User_age(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": out.Values[i] = ec.___Directive_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "description": out.Values[i] = ec.___Directive_description(ctx, field, obj) case "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) unmarshalNInt2int32(ctx context.Context, v any) (int32, error) { res, err := graphql.UnmarshalInt32(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNInt2int32(ctx context.Context, sel ast.SelectionSet, v int32) graphql.Marshaler { _ = sel res := graphql.MarshalInt32(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) 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) 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) marshalOUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋprotogettersᚋmodelsᚐUser(ctx context.Context, sel ast.SelectionSet, v *models.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 := 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: codegen/testserver/protogetters/gqlgen.yml ================================================ schema: - "*.graphql" exec: filename: generated.go package: protogetters model: filename: models_gen.go package: protogetters resolver: layout: follow-schema dir: . package: protogetters filename_template: "{name}.resolvers.go" autobind: - github.com/99designs/gqlgen/codegen/testserver/protogetters/models autobind_getter_haser: true models: Query: fields: user: resolver: true ================================================ FILE: codegen/testserver/protogetters/models/user.go ================================================ package models // User simulates a protobuf editions message with getter and haser methods type User struct { id string name *string email *string age int32 } // NewUser creates a new User func NewUser(id string, name, email *string, age int32) *User { return &User{ id: id, name: name, email: email, age: age, } } // GetId is a protobuf-style getter func (u *User) GetId() string { return u.id } // GetName is a protobuf-style getter func (u *User) GetName() string { if u.name == nil { return "" } return *u.name } // HasName is a protobuf-style haser func (u *User) HasName() bool { return u.name != nil } // GetEmail is a protobuf-style getter func (u *User) GetEmail() string { if u.email == nil { return "" } return *u.email } // HasEmail is a protobuf-style haser func (u *User) HasEmail() bool { return u.email != nil } // GetAge is a protobuf-style getter for non-nullable field func (u *User) GetAge() int32 { return u.age } ================================================ FILE: codegen/testserver/protogetters/models_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package protogetters type Query struct { } ================================================ FILE: codegen/testserver/protogetters/protogetters_test.go ================================================ //go:generate go run ../../../testdata/gqlgen.go -config gqlgen.yml -stub stub.go package protogetters import ( "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/codegen/testserver/protogetters/models" "github.com/99designs/gqlgen/graphql/handler" ) func TestProtoGetters(t *testing.T) { resolver := &Resolver{} c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolver}))) t.Run("user with all fields set", func(t *testing.T) { name := "Alice" email := "alice@example.com" resolver.users = map[string]*models.User{ "1": models.NewUser("1", &name, &email, 30), } var resp struct { User struct { ID string Name *string Email *string Age int } } c.MustPost(`{user(id:"1"){id name email age}}`, &resp) require.Equal(t, "1", resp.User.ID) require.NotNil(t, resp.User.Name) require.Equal(t, "Alice", *resp.User.Name) require.NotNil(t, resp.User.Email) require.Equal(t, "alice@example.com", *resp.User.Email) require.Equal(t, 30, resp.User.Age) }) t.Run("user with nullable fields unset", func(t *testing.T) { resolver.users = map[string]*models.User{ "2": models.NewUser("2", nil, nil, 25), } var resp struct { User struct { ID string Name *string Email *string Age int } } c.MustPost(`{user(id:"2"){id name email age}}`, &resp) require.Equal(t, "2", resp.User.ID) require.Nil(t, resp.User.Name) require.Nil(t, resp.User.Email) require.Equal(t, 25, resp.User.Age) }) t.Run("user with only name set", func(t *testing.T) { name := "Bob" resolver.users = map[string]*models.User{ "3": models.NewUser("3", &name, nil, 40), } var resp struct { User struct { ID string Name *string Email *string Age int } } c.MustPost(`{user(id:"3"){id name email age}}`, &resp) require.Equal(t, "3", resp.User.ID) require.NotNil(t, resp.User.Name) require.Equal(t, "Bob", *resp.User.Name) require.Nil(t, resp.User.Email) require.Equal(t, 40, resp.User.Age) }) } ================================================ FILE: codegen/testserver/protogetters/resolver.go ================================================ package protogetters import "github.com/99designs/gqlgen/codegen/testserver/protogetters/models" // This file will not be regenerated automatically. // // It serves as dependency injection for your app, add any dependencies you require // here. type Resolver struct { users map[string]*models.User } ================================================ FILE: codegen/testserver/protogetters/schema.graphql ================================================ type Query { user(id: ID!): User } type User { id: ID! name: String email: String age: Int! } ================================================ FILE: codegen/testserver/protogetters/schema.resolvers.go ================================================ package protogetters // 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" "github.com/99designs/gqlgen/codegen/testserver/protogetters/models" ) // User is the resolver for the user field. func (r *queryResolver) User(ctx context.Context, id string) (*models.User, error) { return r.users[id], nil } // Query returns QueryResolver implementation. func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } type queryResolver struct{ *Resolver } ================================================ FILE: codegen/testserver/protogetters/stub.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package protogetters import ( "context" "github.com/99designs/gqlgen/codegen/testserver/protogetters/models" ) type Stub struct { QueryResolver struct { User func(ctx context.Context, id string) (*models.User, error) } } func (r *Stub) Query() QueryResolver { return &stubQuery{r} } type stubQuery struct{ *Stub } func (r *stubQuery) User(ctx context.Context, id string) (*models.User, error) { return r.QueryResolver.User(ctx, id) } ================================================ FILE: codegen/testserver/singlefile/builtinscalar.graphql ================================================ """ Since gqlgen defines default implementation for a Map scalar, this tests that the builtin is _not_ added to the TypeMap """ type Map { id: ID! } ================================================ FILE: codegen/testserver/singlefile/bytes.go ================================================ package singlefile import ( "fmt" "io" "github.com/99designs/gqlgen/graphql" ) func MarshalBytes(b []byte) graphql.Marshaler { return graphql.WriterFunc(func(w io.Writer) { _, _ = fmt.Fprintf(w, "%q", string(b)) }) } func UnmarshalBytes(v any) ([]byte, error) { switch v := v.(type) { case string: return []byte(v), nil case *string: return []byte(*v), nil case []byte: return v, nil default: return nil, fmt.Errorf("%T is not []byte", v) } } ================================================ FILE: codegen/testserver/singlefile/complexity.graphql ================================================ extend type Query { overlapping: OverlappingFields } type OverlappingFields { oneFoo: Int! @goField(name: "foo") twoFoo: Int! @goField(name: "foo") oldFoo: Int! @goField(name: "foo", forceResolver: true) newFoo: Int! new_foo: Int! } ================================================ FILE: codegen/testserver/singlefile/complexity_test.go ================================================ package singlefile import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/extension" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestComplexityCollisions(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) resolvers.QueryResolver.Overlapping = func(ctx context.Context) (fields *OverlappingFields, e error) { return &OverlappingFields{ Foo: 2, NewFoo: 3, }, nil } resolvers.OverlappingFieldsResolver.OldFoo = func(ctx context.Context, obj *OverlappingFields) (i int, e error) { return obj.Foo, nil } var resp struct { Overlapping struct { OneFoo int `json:"oneFoo"` TwoFoo int `json:"twoFoo"` OldFoo int `json:"oldFoo"` NewFoo int `json:"newFoo"` New_foo int `json:"new_foo"` } } c.MustPost(`query { overlapping { oneFoo, twoFoo, oldFoo, newFoo, new_foo } }`, &resp) require.Equal(t, 2, resp.Overlapping.OneFoo) require.Equal(t, 2, resp.Overlapping.TwoFoo) require.Equal(t, 2, resp.Overlapping.OldFoo) require.Equal(t, 3, resp.Overlapping.NewFoo) require.Equal(t, 3, resp.Overlapping.New_foo) } func TestComplexityFuncs(t *testing.T) { resolvers := &Stub{} cfg := Config{Resolvers: resolvers} cfg.Complexity.OverlappingFields.Foo = func(childComplexity int) int { return 1000 } cfg.Complexity.OverlappingFields.NewFoo = func(childComplexity int) int { return 5 } srv := handler.New(NewExecutableSchema(cfg)) srv.AddTransport(transport.POST{}) srv.Use(extension.FixedComplexityLimit(10)) c := client.New(srv) resolvers.QueryResolver.Overlapping = func(ctx context.Context) (fields *OverlappingFields, e error) { return &OverlappingFields{ Foo: 2, NewFoo: 3, }, nil } t.Run("with high complexity limit will not run", func(t *testing.T) { ran := false resolvers.OverlappingFieldsResolver.OldFoo = func(ctx context.Context, obj *OverlappingFields) (i int, e error) { ran = true return obj.Foo, nil } var resp struct { Overlapping any } err := c.Post(`query { overlapping { oneFoo, twoFoo, oldFoo, newFoo, new_foo } }`, &resp) require.EqualError( t, err, `[{"message":"operation has complexity 2012, which exceeds the limit of 10","extensions":{"code":"COMPLEXITY_LIMIT_EXCEEDED"}}]`, ) require.False(t, ran) }) t.Run("with low complexity will run", func(t *testing.T) { ran := false resolvers.QueryResolver.Overlapping = func(ctx context.Context) (fields *OverlappingFields, e error) { ran = true return &OverlappingFields{ Foo: 2, NewFoo: 3, }, nil } var resp struct { Overlapping any } c.MustPost(`query { overlapping { newFoo } }`, &resp) require.True(t, ran) }) t.Run("with multiple low complexity will not run", func(t *testing.T) { ran := false resolvers.QueryResolver.Overlapping = func(ctx context.Context) (fields *OverlappingFields, e error) { ran = true return &OverlappingFields{ Foo: 2, NewFoo: 3, }, nil } var resp any err := c.Post(`query { a: overlapping { newFoo }, b: overlapping { newFoo }, c: overlapping { newFoo }, }`, &resp) require.EqualError( t, err, `[{"message":"operation has complexity 18, which exceeds the limit of 10","extensions":{"code":"COMPLEXITY_LIMIT_EXCEEDED"}}]`, ) require.False(t, ran) }) } ================================================ FILE: codegen/testserver/singlefile/defaults.graphql ================================================ extend type Query { defaultParameters( falsyBoolean: Boolean = false truthyBoolean: Boolean = true ): DefaultParametersMirror! } extend type Mutation { defaultInput(input: DefaultInput!): DefaultParametersMirror! } input DefaultInput { falsyBoolean: Boolean = false truthyBoolean: Boolean = true } type DefaultParametersMirror { falsyBoolean: Boolean truthyBoolean: Boolean } ================================================ FILE: codegen/testserver/singlefile/defaults_test.go ================================================ package singlefile import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func assertDefaults(t *testing.T, ret *DefaultParametersMirror) { require.NotNil(t, ret) require.NotNil(t, ret.FalsyBoolean) require.False(t, *ret.FalsyBoolean) require.NotNil(t, ret.TruthyBoolean) require.True(t, *ret.TruthyBoolean) } func TestDefaults(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("default field parameters", func(t *testing.T) { resolvers.QueryResolver.DefaultParameters = func( ctx context.Context, falsyBoolean, truthyBoolean *bool, ) (*DefaultParametersMirror, error) { return &DefaultParametersMirror{ FalsyBoolean: falsyBoolean, TruthyBoolean: truthyBoolean, }, nil } var resp struct{ DefaultParameters *DefaultParametersMirror } err := c.Post(`query { defaultParameters { falsyBoolean truthyBoolean } }`, &resp) require.NoError(t, err) assertDefaults(t, resp.DefaultParameters) }) t.Run("default input fields", func(t *testing.T) { resolvers.MutationResolver.DefaultInput = func( ctx context.Context, input DefaultInput, ) (*DefaultParametersMirror, error) { return &DefaultParametersMirror{ FalsyBoolean: input.FalsyBoolean, TruthyBoolean: input.TruthyBoolean, }, nil } var resp struct{ DefaultInput *DefaultParametersMirror } err := c.Post(`mutation { defaultInput(input: {}) { falsyBoolean truthyBoolean } }`, &resp) require.NoError(t, err) assertDefaults(t, resp.DefaultInput) }) } ================================================ FILE: codegen/testserver/singlefile/defer.graphql ================================================ extend type Query { deferSingle: DeferModel deferMultiple: [DeferModel!] } type DeferModel { id: ID! name: String! values: [String!]! @goField(forceResolver: true) } ================================================ FILE: codegen/testserver/singlefile/defer_test.go ================================================ package singlefile import ( "cmp" "context" "encoding/json" "math/rand" "reflect" "slices" "strconv" "strings" "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 TestDefer(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.SSE{}) srv.AddTransport(transport.MultipartMixed{}) c := client.New(srv) resolvers.QueryResolver.DeferSingle = func(ctx context.Context) (*DeferModel, error) { return &DeferModel{ ID: "1", Name: "Defer test 1", }, nil } resolvers.QueryResolver.DeferMultiple = func(ctx context.Context) ([]*DeferModel, error) { return []*DeferModel{ { ID: "1", Name: "Defer test 1", }, { ID: "2", Name: "Defer test 2", }, { ID: "3", Name: "Defer test 3", }, }, nil } resolvers.DeferModelResolver.Values = func(ctx context.Context, obj *DeferModel) ([]string, error) { time.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond) return []string{ "test defer 1", "test defer 2", "test defer 3", }, nil } type deferModel struct { Id string Name string Values []string } type response[T any] struct { Data T Label string `json:"label"` Path []any `json:"path"` HasNext bool `json:"hasNext"` Errors json.RawMessage `json:"errors"` Extensions map[string]any `json:"extensions"` } type deferredData response[struct { Values []string `json:"values"` }] type incrementalDeferredResponse struct { Incremental []deferredData `json:"incremental"` HasNext bool `json:"hasNext"` Errors json.RawMessage `json:"errors"` Extensions map[string]any `json:"extensions"` } pathStringer := func(path []any) string { var kb strings.Builder for i, part := range path { if i != 0 { kb.WriteRune('.') } switch pathValue := part.(type) { case string: kb.WriteString(pathValue) case float64: kb.WriteString(strconv.FormatFloat(pathValue, 'f', -1, 64)) default: t.Fatalf("unexpected path type: %T", pathValue) } } return kb.String() } cases := []struct { name string query string expectedInitialResponse any expectedDeferredResponses []deferredData }{ { name: "defer single", query: `query testDefer { deferSingle { id name ... @defer { values } } }`, expectedInitialResponse: response[struct { DeferSingle deferModel }]{ Data: struct { DeferSingle deferModel }{ DeferSingle: deferModel{ Id: "1", Name: "Defer test 1", Values: nil, }, }, HasNext: true, }, expectedDeferredResponses: []deferredData{ { Data: struct { Values []string `json:"values"` }{ Values: []string{"test defer 1", "test defer 2", "test defer 3"}, }, Path: []any{"deferSingle"}, }, }, }, { name: "defer single using inline fragment with type", query: `query testDefer { deferSingle { id name ... on DeferModel @defer { values } } }`, expectedInitialResponse: response[struct { DeferSingle deferModel }]{ Data: struct { DeferSingle deferModel }{ DeferSingle: deferModel{ Id: "1", Name: "Defer test 1", Values: nil, }, }, HasNext: true, }, expectedDeferredResponses: []deferredData{ { Data: struct { Values []string `json:"values"` }{ Values: []string{"test defer 1", "test defer 2", "test defer 3"}, }, Path: []any{"deferSingle"}, }, }, }, { name: "defer single using spread fragment", query: `query testDefer { deferSingle { id name ... DeferFragment @defer } } fragment DeferFragment on DeferModel { values } `, expectedInitialResponse: response[struct { DeferSingle deferModel }]{ Data: struct { DeferSingle deferModel }{ DeferSingle: deferModel{ Id: "1", Name: "Defer test 1", Values: nil, }, }, HasNext: true, }, expectedDeferredResponses: []deferredData{ { Data: struct { Values []string `json:"values"` }{ Values: []string{"test defer 1", "test defer 2", "test defer 3"}, }, Path: []any{"deferSingle"}, }, }, }, { name: "defer single with label", query: `query testDefer { deferSingle { id name ... @defer(label: "test label") { values } } }`, expectedInitialResponse: response[struct { DeferSingle deferModel }]{ Data: struct { DeferSingle deferModel }{ DeferSingle: deferModel{ Id: "1", Name: "Defer test 1", Values: nil, }, }, HasNext: true, }, expectedDeferredResponses: []deferredData{ { Data: struct { Values []string `json:"values"` }{ Values: []string{"test defer 1", "test defer 2", "test defer 3"}, }, Label: "test label", Path: []any{"deferSingle"}, }, }, }, { name: "defer single using spread fragment with label", query: `query testDefer { deferSingle { id name ... DeferFragment @defer(label: "test label") } } fragment DeferFragment on DeferModel { values } `, expectedInitialResponse: response[struct { DeferSingle deferModel }]{ Data: struct { DeferSingle deferModel }{ DeferSingle: deferModel{ Id: "1", Name: "Defer test 1", Values: nil, }, }, HasNext: true, }, expectedDeferredResponses: []deferredData{ { Data: struct { Values []string `json:"values"` }{ Values: []string{"test defer 1", "test defer 2", "test defer 3"}, }, Label: "test label", Path: []any{"deferSingle"}, }, }, }, { name: "defer single when if arg is true", query: `query testDefer { deferSingle { id name ... @defer(if: true, label: "test label") { values } } }`, expectedInitialResponse: response[struct { DeferSingle deferModel }]{ Data: struct { DeferSingle deferModel }{ DeferSingle: deferModel{ Id: "1", Name: "Defer test 1", Values: nil, }, }, HasNext: true, }, expectedDeferredResponses: []deferredData{ { Data: struct { Values []string `json:"values"` }{ Values: []string{"test defer 1", "test defer 2", "test defer 3"}, }, Label: "test label", Path: []any{"deferSingle"}, }, }, }, { name: "defer single when if arg is false", query: `query testDefer { deferSingle { id name ... @defer(if: false) { values } } }`, expectedInitialResponse: response[struct { DeferSingle deferModel }]{ Data: struct { DeferSingle deferModel }{ DeferSingle: deferModel{ Id: "1", Name: "Defer test 1", Values: []string{"test defer 1", "test defer 2", "test defer 3"}, }, }, }, }, { name: "defer multiple", query: `query testDefer { deferMultiple { id name ... @defer (label: "test label") { values } } }`, expectedInitialResponse: response[struct { DeferMultiple []deferModel }]{ Data: struct { DeferMultiple []deferModel }{ DeferMultiple: []deferModel{ { Id: "1", Name: "Defer test 1", Values: nil, }, { Id: "2", Name: "Defer test 2", Values: nil, }, { Id: "3", Name: "Defer test 3", Values: nil, }, }, }, HasNext: true, }, expectedDeferredResponses: []deferredData{ { Data: struct { Values []string `json:"values"` }{ Values: []string{"test defer 1", "test defer 2", "test defer 3"}, }, Label: "test label", Path: []any{"deferMultiple", float64(0)}, }, { Data: struct { Values []string `json:"values"` }{ Values: []string{"test defer 1", "test defer 2", "test defer 3"}, }, Label: "test label", Path: []any{"deferMultiple", float64(1)}, }, { Data: struct { Values []string `json:"values"` }{ Values: []string{"test defer 1", "test defer 2", "test defer 3"}, }, Label: "test label", Path: []any{"deferMultiple", float64(2)}, }, }, }, { name: "defer multiple when if arg is false", query: `query testDefer { deferMultiple { id name ... @defer(label: "test label", if: false) { values } } }`, expectedInitialResponse: response[struct { DeferMultiple []deferModel }]{ Data: struct { DeferMultiple []deferModel }{ DeferMultiple: []deferModel{ { Id: "1", Name: "Defer test 1", Values: []string{"test defer 1", "test defer 2", "test defer 3"}, }, { Id: "2", Name: "Defer test 2", Values: []string{"test defer 1", "test defer 2", "test defer 3"}, }, { Id: "3", Name: "Defer test 3", Values: []string{"test defer 1", "test defer 2", "test defer 3"}, }, }, }, }, }, } for _, tc := range cases { t.Run(tc.name+"/over SSE", func(t *testing.T) { resT := reflect.TypeOf(tc.expectedInitialResponse) resE := reflect.New(resT).Elem() resp := resE.Interface() read := c.SSE(context.Background(), tc.query) require.NoError(t, read.Next(&resp)) assert.Equal(t, tc.expectedInitialResponse, resp) // If there are no deferred responses, we can stop here. if !resE.FieldByName("HasNext").Bool() && len(tc.expectedDeferredResponses) == 0 { return } deferredResponses := make([]deferredData, 0) for { var valueResp deferredData require.NoError(t, read.Next(&valueResp)) if !valueResp.HasNext { deferredResponses = append(deferredResponses, valueResp) break } // Remove HasNext from comparison: we don't know the order they will be // delivered in, and so this can't be known in the setup. But if HasNext // does not work right we will either error out or get too few // responses, so it's still checked. valueResp.HasNext = false deferredResponses = append(deferredResponses, valueResp) } require.NoError(t, read.Close()) slices.SortFunc(deferredResponses, func(a, b deferredData) int { return cmp.Compare(pathStringer(a.Path), pathStringer(b.Path)) }) assert.Equal(t, tc.expectedDeferredResponses, deferredResponses) }) t.Run(tc.name+"/over multipart HTTP", func(t *testing.T) { resT := reflect.TypeOf(tc.expectedInitialResponse) resE := reflect.New(resT).Elem() resp := resE.Interface() read := c.IncrementalHTTP(context.Background(), tc.query) require.NoError(t, read.Next(&resp)) assert.Equal(t, tc.expectedInitialResponse, resp) // If there are no deferred responses, we can stop here. if !reflect.ValueOf(resp).FieldByName("HasNext").Bool() && len(tc.expectedDeferredResponses) == 0 { return } deferredIncrementalData := make([]deferredData, 0) for { var valueResp incrementalDeferredResponse require.NoError(t, read.Next(&valueResp)) assert.Empty(t, valueResp.Errors) assert.Empty(t, valueResp.Extensions) // Extract the incremental data from the response. // // FIXME: currently the HasNext field does not describe the state of the // delivery as bounded by the associated path, but rather the state of // the operation as a whole. This makes it impossible to determine it // from the response, so we can not define it ahead of time. // // It is also questionable that the incremental data objects should // include hasNext, so for now we remove them from assertion. Once we // align on the spec we must update this test, as the status of the // path-bounded delivery should be determinative and can be asserted. for _, incr := range valueResp.Incremental { incr.HasNext = false deferredIncrementalData = append(deferredIncrementalData, incr) } if !valueResp.HasNext { break } } require.NoError(t, read.Close()) slices.SortFunc(deferredIncrementalData, func(a, b deferredData) int { return cmp.Compare(pathStringer(a.Path), pathStringer(b.Path)) }) assert.Equal(t, tc.expectedDeferredResponses, deferredIncrementalData) }) } } ================================================ FILE: codegen/testserver/singlefile/directive.graphql ================================================ directive @length(min: Int!, max: Int, message: String) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | FIELD_DEFINITION directive @range(min: Int = 0, max: Int) on ARGUMENT_DEFINITION directive @custom on ARGUMENT_DEFINITION directive @logged(id: UUID!) on FIELD directive @toNull on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | FIELD_DEFINITION directive @populate(value: String!) on ARGUMENT_DEFINITION directive @directive1 on FIELD_DEFINITION directive @directive2 on FIELD_DEFINITION directive @directive3 on INPUT_OBJECT directive @unimplemented on FIELD_DEFINITION directive @order1(location: String!) repeatable on FIELD_DEFINITION | OBJECT directive @order2(location: String!) on OBJECT directive @noop on ARGUMENT_DEFINITION extend type Query { directiveArg(arg: String! @length(min:1, max: 255, message: "invalid length")): String directiveNullableArg(arg: Int @range(min:0), arg2: Int @range, arg3: String @toNull): String directiveSingleNullableArg( arg1: String @populate(value: "test") @noop, ): String directiveInputNullable(arg: InputDirectives): String directiveInput(arg: InputDirectives!): String directiveInputType(arg: InnerInput! @custom): String directiveInputOuter(arg: OuterWrapperInput!): String directiveObject: ObjectDirectives @order1(location: "Query_field") directiveObjectWithCustomGoModel: ObjectDirectivesWithCustomGoModel directiveFieldDef(ret: String!): String! @length(min: 1, message: "not valid") directiveField: String directiveDouble: String @directive1 @directive2 directiveUnimplemented: String @unimplemented } extend type Subscription { directiveArg(arg: String! @length(min:1, max: 255, message: "invalid length")): String directiveNullableArg(arg: Int @range(min:0), arg2: Int @range, arg3: String @toNull): String directiveDouble: String @directive1 @directive2 directiveUnimplemented: String @unimplemented } input OuterWrapperInput { inner: InputDirectives! } input InputDirectives @directive3 { text: String! @length(min: 0, max: 7, message: "not valid") nullableText: String @toNull inner: InnerDirectives! innerNullable: InnerDirectives thirdParty: ThirdParty @length(min: 0, max: 7) } input InnerDirectives { message: String! @length(min: 1, message: "not valid") } type ObjectDirectives @order1(location: "order1_1") @order1(location: "order1_2") @order2(location: "order2_1") { text: String! @length(min: 0, max: 7, message: "not valid") nullableText: String @toNull order: [String!]! } type ObjectDirectivesWithCustomGoModel { nullableText: String @toNull } ================================================ FILE: codegen/testserver/singlefile/directive_test.go ================================================ package singlefile import ( "context" "errors" "fmt" "reflect" "testing" "time" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) // isNil checks if the given value is nil func isNil(input any) bool { if input == nil { return true } // Using reflect to check if the value is nil. This is necessary for // any types that are not nil types but have a nil value (e.g. *string). value := reflect.ValueOf(input) return value.IsNil() } type ckey string func TestDirectives(t *testing.T) { resolvers := &Stub{} ok := "Ok" resolvers.QueryResolver.DirectiveArg = func(ctx context.Context, arg string) (i *string, e error) { return &ok, nil } resolvers.QueryResolver.DirectiveInput = func(ctx context.Context, arg InputDirectives) (i *string, e error) { return &ok, nil } resolvers.QueryResolver.DirectiveInputNullable = func(ctx context.Context, arg *InputDirectives) (i *string, e error) { return &ok, nil } resolvers.QueryResolver.DirectiveNullableArg = func(ctx context.Context, arg *int, arg2 *int, arg3 *string) (*string, error) { return &ok, nil } resolvers.QueryResolver.DirectiveSingleNullableArg = func(ctx context.Context, arg1 *string) (*string, error) { if arg1 != nil { return arg1, nil } return &ok, nil } resolvers.QueryResolver.DirectiveInputType = func(ctx context.Context, arg InnerInput) (i *string, e error) { return &ok, nil } resolvers.QueryResolver.DirectiveObject = func(ctx context.Context) (*ObjectDirectives, error) { return &ObjectDirectives{ Text: ok, NullableText: &ok, }, nil } resolvers.QueryResolver.DirectiveObjectWithCustomGoModel = func(ctx context.Context) (*ObjectDirectivesWithCustomGoModel, error) { return &ObjectDirectivesWithCustomGoModel{ NullableText: ok, }, nil } resolvers.QueryResolver.DirectiveField = func(ctx context.Context) (*string, error) { if s, ok := ctx.Value(ckey("request_id")).(*string); ok { return s, nil } return nil, nil } resolvers.QueryResolver.DirectiveDouble = func(ctx context.Context) (*string, error) { return &ok, nil } resolvers.QueryResolver.DirectiveUnimplemented = func(ctx context.Context) (*string, error) { return &ok, nil } okchan := func() (<-chan *string, error) { //nolint:unparam // interface purposes res := make(chan *string, 1) res <- &ok close(res) return res, nil } resolvers.SubscriptionResolver.DirectiveArg = func(ctx context.Context, arg string) (strings <-chan *string, e error) { return okchan() } resolvers.SubscriptionResolver.DirectiveNullableArg = func(ctx context.Context, arg *int, arg2 *int, arg3 *string) (strings <-chan *string, e error) { return okchan() } resolvers.SubscriptionResolver.DirectiveDouble = func(ctx context.Context) (strings <-chan *string, e error) { return okchan() } resolvers.SubscriptionResolver.DirectiveUnimplemented = func(ctx context.Context) (<-chan *string, error) { return okchan() } srv := handler.New(NewExecutableSchema(Config{ Resolvers: resolvers, Directives: DirectiveRoot{ //nolint:revive // can't rename min, max because it's generated code Length: func(ctx context.Context, obj any, next graphql.Resolver, min int, max *int, message *string) (any, error) { e := func(msg string) error { if message == nil { return errors.New(msg) } return errors.New(*message) } res, err := next(ctx) if err != nil { return nil, err } s := res.(string) if len(s) < min { return nil, e("too short") } if max != nil && len(s) > *max { return nil, e("too long") } return res, nil }, //nolint:revive // can't rename min, max because it's generated code Range: func(ctx context.Context, obj any, next graphql.Resolver, min *int, max *int) (any, error) { res, err := next(ctx) if err != nil { return nil, err } switch res := res.(type) { case int: if min != nil && res < *min { return nil, errors.New("too small") } if max != nil && res > *max { return nil, errors.New("too large") } return next(ctx) case int64: if min != nil && int(res) < *min { return nil, errors.New("too small") } if max != nil && int(res) > *max { return nil, errors.New("too large") } return next(ctx) case *int: if min != nil && *res < *min { return nil, errors.New("too small") } if max != nil && *res > *max { return nil, errors.New("too large") } return next(ctx) } return nil, fmt.Errorf("unsupported type %T", res) }, Custom: func(ctx context.Context, obj any, next graphql.Resolver) (any, error) { return next(ctx) }, Logged: func(ctx context.Context, obj any, next graphql.Resolver, id string) (any, error) { return next(context.WithValue(ctx, ckey("request_id"), &id)) }, ToNull: func(ctx context.Context, obj any, next graphql.Resolver) (any, error) { return nil, nil }, Populate: func(ctx context.Context, obj any, next graphql.Resolver, value string) (any, error) { res, err := next(ctx) if err != nil { return nil, err } if !isNil(res) { return res, err } return &value, nil }, Noop: func(ctx context.Context, obj any, next graphql.Resolver) (any, error) { return next(ctx) }, Directive1: func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) { return next(ctx) }, Directive2: func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) { return next(ctx) }, Directive3: func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) { return next(ctx) }, Order1: func(ctx context.Context, obj any, next graphql.Resolver, location string) (res any, err error) { order := []string{location} res, err = next(ctx) od := res.(*ObjectDirectives) od.Order = append(order, od.Order...) return od, err }, Order2: func(ctx context.Context, obj any, next graphql.Resolver, location string) (res any, err error) { order := []string{location} res, err = next(ctx) od := res.(*ObjectDirectives) od.Order = append(order, od.Order...) return od, err }, Unimplemented: nil, }, })) srv.AddTransport(transport.Websocket{KeepAlivePingInterval: time.Second}) srv.AddTransport(transport.POST{}) srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res any, err error) { path, _ := ctx.Value(ckey("path")).([]int) return next(context.WithValue(ctx, ckey("path"), append(path, 1))) }) srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res any, err error) { path, _ := ctx.Value(ckey("path")).([]int) return next(context.WithValue(ctx, ckey("path"), append(path, 2))) }) c := client.New(srv) t.Run("arg directives", func(t *testing.T) { t.Run("when function errors on directives", func(t *testing.T) { var resp struct { DirectiveArg *string } err := c.Post(`query { directiveArg(arg: "") }`, &resp) require.EqualError( t, err, `[{"message":"invalid length","path":["directiveArg","arg"]}]`, ) require.Nil(t, resp.DirectiveArg) }) t.Run("when function errors on nullable arg directives", func(t *testing.T) { var resp struct { DirectiveNullableArg *string } err := c.Post(`query { directiveNullableArg(arg: -100) }`, &resp) require.EqualError( t, err, `[{"message":"too small","path":["directiveNullableArg","arg"]}]`, ) require.Nil(t, resp.DirectiveNullableArg) }) t.Run("when function success on nullable arg directives", func(t *testing.T) { var resp struct { DirectiveNullableArg *string } err := c.Post(`query { directiveNullableArg }`, &resp) require.NoError(t, err) require.Equal(t, "Ok", *resp.DirectiveNullableArg) }) t.Run("when function success on valid nullable arg directives", func(t *testing.T) { var resp struct { DirectiveNullableArg *string } err := c.Post(`query { directiveNullableArg(arg: 1) }`, &resp) require.NoError(t, err) require.Equal(t, "Ok", *resp.DirectiveNullableArg) }) t.Run("when function success", func(t *testing.T) { var resp struct { DirectiveArg *string } err := c.Post(`query { directiveArg(arg: "test") }`, &resp) require.NoError(t, err) require.Equal(t, "Ok", *resp.DirectiveArg) }) t.Run("directive is not called with null arguments", func(t *testing.T) { var resp struct { DirectiveSingleNullableArg *string } err := c.Post(`query { directiveSingleNullableArg }`, &resp) require.NoError(t, err) require.Equal(t, "Ok", *resp.DirectiveSingleNullableArg) }) }) t.Run("field definition directives", func(t *testing.T) { resolvers.QueryResolver.DirectiveFieldDef = func(ctx context.Context, ret string) (i string, e error) { return ret, nil } t.Run("too short", func(t *testing.T) { var resp struct { DirectiveFieldDef string } err := c.Post(`query { directiveFieldDef(ret: "") }`, &resp) require.EqualError(t, err, `[{"message":"not valid","path":["directiveFieldDef"]}]`) }) t.Run("has 2 directives", func(t *testing.T) { var resp struct { DirectiveDouble string } c.MustPost(`query { directiveDouble }`, &resp) require.Equal(t, "Ok", resp.DirectiveDouble) }) t.Run("directive is not implemented", func(t *testing.T) { var resp struct { DirectiveUnimplemented string } err := c.Post(`query { directiveUnimplemented }`, &resp) require.EqualError( t, err, `[{"message":"directive unimplemented is not implemented","path":["directiveUnimplemented"]}]`, ) }) t.Run("ok", func(t *testing.T) { var resp struct { DirectiveFieldDef string } c.MustPost(`query { directiveFieldDef(ret: "aaa") }`, &resp) require.Equal(t, "aaa", resp.DirectiveFieldDef) }) }) t.Run("field directives", func(t *testing.T) { t.Run("add field directive", func(t *testing.T) { var resp struct { DirectiveField string } c.MustPost(`query { directiveField@logged(id:"testes_id") }`, &resp) require.Equal(t, `testes_id`, resp.DirectiveField) }) t.Run("without field directive", func(t *testing.T) { var resp struct { DirectiveField *string } c.MustPost(`query { directiveField }`, &resp) require.Nil(t, resp.DirectiveField) }) }) t.Run("input field directives", func(t *testing.T) { t.Run("when function errors on directives", func(t *testing.T) { var resp struct { DirectiveInputNullable *string } err := c.Post( `query { directiveInputNullable(arg: {text:"invalid text",inner:{message:"123"}}) }`, &resp, ) require.EqualError( t, err, `[{"message":"not valid","path":["directiveInputNullable","arg","text"]}]`, ) require.Nil(t, resp.DirectiveInputNullable) }) t.Run("when function errors on inner directives", func(t *testing.T) { var resp struct { DirectiveInputNullable *string } err := c.Post( `query { directiveInputNullable(arg: {text:"2",inner:{message:""}}) }`, &resp, ) require.EqualError( t, err, `[{"message":"not valid","path":["directiveInputNullable","arg","inner","message"]}]`, ) require.Nil(t, resp.DirectiveInputNullable) }) t.Run("when function errors on nullable inner directives", func(t *testing.T) { var resp struct { DirectiveInputNullable *string } err := c.Post( `query { directiveInputNullable(arg: {text:"success",inner:{message:"1"},innerNullable:{message:""}}) }`, &resp, ) require.EqualError( t, err, `[{"message":"not valid","path":["directiveInputNullable","arg","innerNullable","message"]}]`, ) require.Nil(t, resp.DirectiveInputNullable) }) t.Run("when function success", func(t *testing.T) { var resp struct { DirectiveInputNullable *string } err := c.Post( `query { directiveInputNullable(arg: {text:"23",inner:{message:"1"}}) }`, &resp, ) require.NoError(t, err) require.Equal(t, "Ok", *resp.DirectiveInputNullable) }) t.Run("when function inner nullable success", func(t *testing.T) { var resp struct { DirectiveInputNullable *string } err := c.Post( `query { directiveInputNullable(arg: {text:"23",nullableText:"23",inner:{message:"1"},innerNullable:{message:"success"}}) }`, &resp, ) require.NoError(t, err) require.Equal(t, "Ok", *resp.DirectiveInputNullable) }) t.Run("when arg has directive", func(t *testing.T) { var resp struct { DirectiveInputType *string } err := c.Post(`query { directiveInputType(arg: {id: 1}) }`, &resp) require.NoError(t, err) require.Equal(t, "Ok", *resp.DirectiveInputType) }) }) t.Run("object field directives", func(t *testing.T) { t.Run("when function success", func(t *testing.T) { var resp struct { DirectiveObject *struct { Text string NullableText *string Order []string } } err := c.Post(`query { directiveObject{ text nullableText order} }`, &resp) require.NoError(t, err) require.Equal(t, "Ok", resp.DirectiveObject.Text) require.Nil(t, resp.DirectiveObject.NullableText) require.Equal(t, "Query_field", resp.DirectiveObject.Order[0]) require.Equal(t, "order2_1", resp.DirectiveObject.Order[1]) require.Equal(t, "order1_2", resp.DirectiveObject.Order[2]) require.Equal(t, "order1_1", resp.DirectiveObject.Order[3]) }) t.Run("when directive returns nil & custom go field is not nilable", func(t *testing.T) { var resp struct { DirectiveObjectWithCustomGoModel *struct { NullableText *string } } err := c.Post(`query { directiveObjectWithCustomGoModel{ nullableText } }`, &resp) require.NoError(t, err) require.Nil(t, resp.DirectiveObjectWithCustomGoModel.NullableText) }) }) t.Run("Subscription directives", func(t *testing.T) { t.Run("arg directives", func(t *testing.T) { t.Run("when function errors on directives", func(t *testing.T) { var resp struct { DirectiveArg *string } err := c.WebsocketOnce(`subscription { directiveArg(arg: "") }`, &resp) require.EqualError( t, err, `[{"message":"invalid length","path":["directiveArg","arg"]}]`, ) require.Nil(t, resp.DirectiveArg) }) t.Run("when function errors on nullable arg directives", func(t *testing.T) { var resp struct { DirectiveNullableArg *string } err := c.WebsocketOnce(`subscription { directiveNullableArg(arg: -100) }`, &resp) require.EqualError( t, err, `[{"message":"too small","path":["directiveNullableArg","arg"]}]`, ) require.Nil(t, resp.DirectiveNullableArg) }) t.Run("when function success on nullable arg directives", func(t *testing.T) { var resp struct { DirectiveNullableArg *string } err := c.WebsocketOnce(`subscription { directiveNullableArg }`, &resp) require.NoError(t, err) require.NotNil(t, resp.DirectiveNullableArg) require.Equal(t, "Ok", *resp.DirectiveNullableArg) }) t.Run("when function success on valid nullable arg directives", func(t *testing.T) { var resp struct { DirectiveNullableArg *string } err := c.WebsocketOnce(`subscription { directiveNullableArg(arg: 1) }`, &resp) require.NoError(t, err) require.NotNil(t, resp.DirectiveNullableArg) require.Equal(t, "Ok", *resp.DirectiveNullableArg) }) t.Run("when function success", func(t *testing.T) { var resp struct { DirectiveArg *string } err := c.WebsocketOnce(`subscription { directiveArg(arg: "test") }`, &resp) require.NoError(t, err) require.NotNil(t, resp.DirectiveArg) require.Equal(t, "Ok", *resp.DirectiveArg) }) }) }) } ================================================ FILE: codegen/testserver/singlefile/embedded.go ================================================ package singlefile // EmbeddedCase1 model type EmbeddedCase1 struct { Empty *ExportedEmbeddedPointerAfterInterface } // Empty interface type Empty any // ExportedEmbeddedPointerAfterInterface model type ExportedEmbeddedPointerAfterInterface struct{} // ExportedEmbeddedPointerExportedMethod method func (*ExportedEmbeddedPointerAfterInterface) ExportedEmbeddedPointerExportedMethod() string { return "ExportedEmbeddedPointerExportedMethodResponse" } // EmbeddedCase2 model type EmbeddedCase2 struct { *unexportedEmbeddedPointer } type unexportedEmbeddedPointer struct{} // UnexportedEmbeddedPointerExportedMethod method func (*unexportedEmbeddedPointer) UnexportedEmbeddedPointerExportedMethod() string { return "UnexportedEmbeddedPointerExportedMethodResponse" } // EmbeddedCase3 model type EmbeddedCase3 struct { unexportedEmbeddedInterface } type unexportedEmbeddedInterface interface { nestedInterface } type nestedInterface interface { UnexportedEmbeddedInterfaceExportedMethod() string } ================================================ FILE: codegen/testserver/singlefile/embedded.graphql ================================================ extend type Query { embeddedCase1: EmbeddedCase1 embeddedCase2: EmbeddedCase2 embeddedCase3: EmbeddedCase3 } type EmbeddedCase1 @goModel(model:"singlefile.EmbeddedCase1") { exportedEmbeddedPointerExportedMethod: String! } type EmbeddedCase2 @goModel(model:"singlefile.EmbeddedCase2") { unexportedEmbeddedPointerExportedMethod: String! } type EmbeddedCase3 @goModel(model:"singlefile.EmbeddedCase3") { unexportedEmbeddedInterfaceExportedMethod: String! } ================================================ FILE: codegen/testserver/singlefile/embedded_test.go ================================================ package singlefile import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) type fakeUnexportedEmbeddedInterface struct{} func (*fakeUnexportedEmbeddedInterface) UnexportedEmbeddedInterfaceExportedMethod() string { return "UnexportedEmbeddedInterfaceExportedMethod" } func TestEmbedded(t *testing.T) { resolver := &Stub{} resolver.QueryResolver.EmbeddedCase1 = func(ctx context.Context) (*EmbeddedCase1, error) { return &EmbeddedCase1{}, nil } resolver.QueryResolver.EmbeddedCase2 = func(ctx context.Context) (*EmbeddedCase2, error) { return &EmbeddedCase2{&unexportedEmbeddedPointer{}}, nil } resolver.QueryResolver.EmbeddedCase3 = func(ctx context.Context) (*EmbeddedCase3, error) { return &EmbeddedCase3{&fakeUnexportedEmbeddedInterface{}}, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolver})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("embedded case 1", func(t *testing.T) { var resp struct { EmbeddedCase1 struct { ExportedEmbeddedPointerExportedMethod string } } err := c.Post(`query { embeddedCase1 { exportedEmbeddedPointerExportedMethod } }`, &resp) require.NoError(t, err) require.Equal( t, "ExportedEmbeddedPointerExportedMethodResponse", resp.EmbeddedCase1.ExportedEmbeddedPointerExportedMethod, ) }) t.Run("embedded case 2", func(t *testing.T) { var resp struct { EmbeddedCase2 struct { UnexportedEmbeddedPointerExportedMethod string } } err := c.Post(`query { embeddedCase2 { unexportedEmbeddedPointerExportedMethod } }`, &resp) require.NoError(t, err) require.Equal( t, "UnexportedEmbeddedPointerExportedMethodResponse", resp.EmbeddedCase2.UnexportedEmbeddedPointerExportedMethod, ) }) t.Run("embedded case 3", func(t *testing.T) { var resp struct { EmbeddedCase3 struct { UnexportedEmbeddedInterfaceExportedMethod string } } err := c.Post( `query { embeddedCase3 { unexportedEmbeddedInterfaceExportedMethod } }`, &resp, ) require.NoError(t, err) require.Equal( t, "UnexportedEmbeddedInterfaceExportedMethod", resp.EmbeddedCase3.UnexportedEmbeddedInterfaceExportedMethod, ) }) } ================================================ FILE: codegen/testserver/singlefile/enum.graphql ================================================ enum EnumTest { OK NG } input InputWithEnumValue { enum: EnumTest! } extend type Query { enumInInput(input: InputWithEnumValue): EnumTest! } ================================================ FILE: codegen/testserver/singlefile/enums_test.go ================================================ package singlefile import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestEnumsResolver(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.EnumInInput = func(ctx context.Context, input *InputWithEnumValue) (EnumTest, error) { return input.Enum, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("input with valid enum value", func(t *testing.T) { var resp struct { EnumInInput EnumTest } c.MustPost(`query { enumInInput(input: {enum: OK}) } `, &resp) require.Equal(t, EnumTestOk, resp.EnumInInput) }) t.Run("input with invalid enum value", func(t *testing.T) { var resp struct { EnumInInput EnumTest } err := c.Post(`query { enumInInput(input: {enum: INVALID}) } `, &resp) require.EqualError( t, err, `http 422: {"errors":[{"message":"Value \"INVALID\" does not exist in \"EnumTest!\" enum.","locations":[{"line":2,"column":30}],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}],"data":null}`, ) }) t.Run("input with invalid enum value via vars", func(t *testing.T) { var resp struct { EnumInInput EnumTest } err := c.Post(`query ($input: InputWithEnumValue) { enumInInput(input: $input) } `, &resp, client.Var("input", map[string]any{"enum": "INVALID"})) require.EqualError( t, err, `http 422: {"errors":[{"message":"INVALID is not a valid EnumTest","path":["variable","input","enum"],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}],"data":null}`, ) }) } ================================================ FILE: codegen/testserver/singlefile/fields_order.go ================================================ package singlefile type FieldsOrderInput struct { FirstField *string `json:"firstField"` } ================================================ FILE: codegen/testserver/singlefile/fields_order.graphql ================================================ type FieldsOrderPayload { firstFieldValue: String } input FieldsOrderInput { firstField: String overrideFirstField: String } extend type Mutation { overrideValueViaInput(input: FieldsOrderInput!): FieldsOrderPayload! } ================================================ FILE: codegen/testserver/singlefile/fields_order_test.go ================================================ package singlefile import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) type FieldsOrderPayloadResults struct { OverrideValueViaInput struct { FirstFieldValue *string `json:"firstFieldValue"` } `json:"overrideValueViaInput"` } func TestFieldsOrder(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) resolvers.FieldsOrderInputResolver.OverrideFirstField = func(ctx context.Context, in *FieldsOrderInput, data *string) error { if data != nil { in.FirstField = data } return nil } resolvers.MutationResolver.OverrideValueViaInput = func(ctx context.Context, in FieldsOrderInput) (ret *FieldsOrderPayload, err error) { ret = &FieldsOrderPayload{ FirstFieldValue: in.FirstField, } return ret, err } t.Run("firstField", func(t *testing.T) { var resp FieldsOrderPayloadResults err := c.Post(`mutation { overrideValueViaInput(input: { firstField:"newName" }) { firstFieldValue } }`, &resp) require.NoError(t, err) require.NotNil(t, resp.OverrideValueViaInput.FirstFieldValue) require.Equal(t, "newName", *resp.OverrideValueViaInput.FirstFieldValue) }) t.Run("firstField/override", func(t *testing.T) { var resp FieldsOrderPayloadResults err := c.Post(`mutation { overrideValueViaInput(input: { firstField:"newName", overrideFirstField: "override" }) { firstFieldValue } }`, &resp) require.NoError(t, err) require.NotNil(t, resp.OverrideValueViaInput.FirstFieldValue) require.NotEqual(t, "newName", *resp.OverrideValueViaInput.FirstFieldValue) require.Equal(t, "override", *resp.OverrideValueViaInput.FirstFieldValue) }) } ================================================ FILE: codegen/testserver/singlefile/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package singlefile import ( "bytes" "context" "errors" "fmt" "strconv" "sync/atomic" "time" introspection1 "github.com/99designs/gqlgen/codegen/testserver/singlefile/introspection" invalid_packagename "github.com/99designs/gqlgen/codegen/testserver/singlefile/invalid-packagename" "github.com/99designs/gqlgen/codegen/testserver/singlefile/otherpkg" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" gqlparser "github.com/vektah/gqlparser/v2" "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 { BackedByInterface() BackedByInterfaceResolver DeferModel() DeferModelResolver Errors() ErrorsResolver ForcedResolver() ForcedResolverResolver ModelMethods() ModelMethodsResolver Mutation() MutationResolver OverlappingFields() OverlappingFieldsResolver Panics() PanicsResolver Pet() PetResolver Primitive() PrimitiveResolver PrimitiveString() PrimitiveStringResolver Query() QueryResolver Subscription() SubscriptionResolver User() UserResolver WrappedMap() WrappedMapResolver WrappedSlice() WrappedSliceResolver FieldsOrderInput() FieldsOrderInputResolver } type DirectiveRoot struct { Custom func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) Defer func(ctx context.Context, obj any, next graphql.Resolver, ifArg *bool, label *string) (res any, err error) Directive1 func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) Directive2 func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) Directive3 func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) Length func(ctx context.Context, obj any, next graphql.Resolver, min int, max *int, message *string) (res any, err error) Logged func(ctx context.Context, obj any, next graphql.Resolver, id string) (res any, err error) MakeNil func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) MakeTypedNil func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) Noop func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) Order1 func(ctx context.Context, obj any, next graphql.Resolver, location string) (res any, err error) Order2 func(ctx context.Context, obj any, next graphql.Resolver, location string) (res any, err error) Populate func(ctx context.Context, obj any, next graphql.Resolver, value string) (res any, err error) Range func(ctx context.Context, obj any, next graphql.Resolver, min *int, max *int) (res any, err error) ToNull func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) Unimplemented func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) } type ComplexityRoot struct { A struct { ID func(childComplexity int) int } AIt struct { ID func(childComplexity int) int } AbIt struct { ID func(childComplexity int) int } Autobind struct { IdInt func(childComplexity int) int IdStr func(childComplexity int) int Int func(childComplexity int) int Int32 func(childComplexity int) int Int64 func(childComplexity int) int } B struct { ID func(childComplexity int) int } BackedByInterface struct { ID func(childComplexity int) int ThisShouldBind func(childComplexity int) int ThisShouldBindWithError func(childComplexity int) int } Cat struct { CatBreed func(childComplexity int) int Size func(childComplexity int) int Species func(childComplexity int) int } CheckIssue896 struct { ID func(childComplexity int) int } Circle struct { Area func(childComplexity int) int Coordinates func(childComplexity int) int Radius func(childComplexity int) int } ConcreteNodeA struct { Child func(childComplexity int) int ID func(childComplexity int) int Name func(childComplexity int) int } ConcreteNodeInterface struct { Child func(childComplexity int) int ID func(childComplexity int) int } Content_Post struct { Foo func(childComplexity int) int } Content_User struct { Foo func(childComplexity int) int } Coordinates struct { X func(childComplexity int) int Y func(childComplexity int) int } DefaultParametersMirror struct { FalsyBoolean func(childComplexity int) int TruthyBoolean func(childComplexity int) int } DeferModel struct { ID func(childComplexity int) int Name func(childComplexity int) int Values func(childComplexity int) int } Dog struct { DogBreed func(childComplexity int) int Size func(childComplexity int) int Species func(childComplexity int) int } EmbeddedCase1 struct { ExportedEmbeddedPointerExportedMethod func(childComplexity int) int } EmbeddedCase2 struct { UnexportedEmbeddedPointerExportedMethod func(childComplexity int) int } EmbeddedCase3 struct { UnexportedEmbeddedInterfaceExportedMethod func(childComplexity int) int } EmbeddedDefaultScalar struct { Value func(childComplexity int) int } EmbeddedPointer struct { ID func(childComplexity int) int Title func(childComplexity int) int } Error struct { ErrorOnNonRequiredField func(childComplexity int) int ErrorOnRequiredField func(childComplexity int) int ID func(childComplexity int) int NilOnRequiredField func(childComplexity int) int } Errors struct { A func(childComplexity int) int B func(childComplexity int) int C func(childComplexity int) int D func(childComplexity int) int E func(childComplexity int) int } FieldsOrderPayload struct { FirstFieldValue func(childComplexity int) int } ForcedResolver struct { Field func(childComplexity int) int } Horse struct { HorseBreed func(childComplexity int) int Size func(childComplexity int) int Species func(childComplexity int) int } InnerObject struct { ID func(childComplexity int) int } InvalidIdentifier struct { ID func(childComplexity int) int } It struct { ID func(childComplexity int) int } LoopA struct { B func(childComplexity int) int } LoopB struct { A func(childComplexity int) int } Map struct { ID func(childComplexity int) int } MapNested struct { Value func(childComplexity int) int } MapStringInterfaceType struct { A func(childComplexity int) int B func(childComplexity int) int C func(childComplexity int) int Nested func(childComplexity int) int } ModelMethods struct { NoContext func(childComplexity int) int ResolverField func(childComplexity int) int WithContext func(childComplexity int) int } Mutation struct { DefaultInput func(childComplexity int, input DefaultInput) int Issue4053 func(childComplexity int, input *Issue4053Input1) int OverrideValueViaInput func(childComplexity int, input FieldsOrderInput) int UpdateProduct func(childComplexity int, id string, name *string, price *float64) int UpdatePtrToPtr func(childComplexity int, input UpdatePtrToPtrOuter) int UpdateSomething func(childComplexity int, input SpecialInput) int } ObjectDirectives struct { NullableText func(childComplexity int) int Order func(childComplexity int) int Text func(childComplexity int) int } ObjectDirectivesWithCustomGoModel struct { NullableText func(childComplexity int) int } OuterObject struct { Inner func(childComplexity int) int } OverlappingFields struct { Foo func(childComplexity int) int NewFoo func(childComplexity int) int OldFoo func(childComplexity int) int } Panics struct { ArgUnmarshal func(childComplexity int, u []MarshalPanic) int FieldFuncMarshal func(childComplexity int, u []MarshalPanic) int FieldScalarMarshal func(childComplexity int) int } Pet struct { Friends func(childComplexity int, limit *int) int ID func(childComplexity int) int } Primitive struct { Squared func(childComplexity int) int Value func(childComplexity int) int } PrimitiveString struct { Doubled func(childComplexity int) int Len func(childComplexity int) int Value func(childComplexity int) int } PtrToAnyContainer struct { Binding func(childComplexity int) int PtrToAny func(childComplexity int) int } PtrToPtrInner struct { Key func(childComplexity int) int Value func(childComplexity int) int } PtrToPtrOuter struct { Inner func(childComplexity int) int Name func(childComplexity int) int StupidInner func(childComplexity int) int } PtrToSliceContainer struct { PtrToSlice func(childComplexity int) int } Query struct { Animal func(childComplexity int) int Autobind func(childComplexity int) int Collision func(childComplexity int) int DefaultParameters func(childComplexity int, falsyBoolean *bool, truthyBoolean *bool) int DefaultScalar func(childComplexity int, arg string) int DeferMultiple func(childComplexity int) int DeferSingle func(childComplexity int) int DeprecatedField func(childComplexity int) int DirectiveArg func(childComplexity int, arg string) int DirectiveDouble func(childComplexity int) int DirectiveField func(childComplexity int) int DirectiveFieldDef func(childComplexity int, ret string) int DirectiveInput func(childComplexity int, arg InputDirectives) int DirectiveInputNullable func(childComplexity int, arg *InputDirectives) int DirectiveInputOuter func(childComplexity int, arg OuterWrapperInput) int DirectiveInputType func(childComplexity int, arg InnerInput) int DirectiveNullableArg func(childComplexity int, arg *int, arg2 *int, arg3 *string) int DirectiveObject func(childComplexity int) int DirectiveObjectWithCustomGoModel func(childComplexity int) int DirectiveSingleNullableArg func(childComplexity int, arg1 *string) int DirectiveUnimplemented func(childComplexity int) int Dog func(childComplexity int) int EmbeddedCase1 func(childComplexity int) int EmbeddedCase2 func(childComplexity int) int EmbeddedCase3 func(childComplexity int) int EnumInInput func(childComplexity int, input *InputWithEnumValue) int ErrorBubble func(childComplexity int) int ErrorBubbleList func(childComplexity int) int ErrorList func(childComplexity int) int Errors func(childComplexity int) int Fallback func(childComplexity int, arg FallbackToStringEncoding) int FieldWithDeprecatedArg func(childComplexity int, oldArg *int, newArg *int) int FilterProducts func(childComplexity int, query *string, category *string, minPrice *int) int FindProducts func(childComplexity int, query *string, category *string, minPrice *int) int Infinity func(childComplexity int) int InputNullableSlice func(childComplexity int, arg []string) int InputOmittable func(childComplexity int, arg OmittableInput) int InputSlice func(childComplexity int, arg []string) int Invalid func(childComplexity int) int InvalidIdentifier func(childComplexity int) int Issue896a func(childComplexity int) int MapInput func(childComplexity int, input map[string]any) int MapNestedMapSlice func(childComplexity int, input map[string]any) int MapNestedStringInterface func(childComplexity int, in *NestedMapInput) int MapStringInterface func(childComplexity int, in map[string]any) int ModelMethods func(childComplexity int) int NestedInputs func(childComplexity int, input [][]*OuterInput) int NestedOutputs func(childComplexity int) int NoShape func(childComplexity int) int NoShapeTypedNil func(childComplexity int) int Node func(childComplexity int) int NotAnInterface func(childComplexity int) int NullableArg func(childComplexity int, arg *int) int OptionalUnion func(childComplexity int) int Overlapping func(childComplexity int) int Panics func(childComplexity int) int PrimitiveObject func(childComplexity int) int PrimitiveStringObject func(childComplexity int) int PtrToAnyContainer func(childComplexity int) int PtrToSliceContainer func(childComplexity int) int Recursive func(childComplexity int, input *RecursiveInputSlice) int ScalarSlice func(childComplexity int) int SearchMixed func(childComplexity int, query *string, category *string, minPrice *int, limit *int, offset *int, sortBy *string) int SearchProducts func(childComplexity int, query *string, category *string, minPrice *int) int SearchProductsNormal func(childComplexity int, filters map[string]any) int SearchRequired func(childComplexity int, name string, age int) int SearchWithDefaults func(childComplexity int, query *string, limit *int, includeArchived *bool) int SearchWithDirectives func(childComplexity int, oldField *string, newField *string) int ShapeUnion func(childComplexity int) int Shapes func(childComplexity int) int SkipInclude func(childComplexity int) int Slices func(childComplexity int) int StringFromContextFunction func(childComplexity int) int StringFromContextInterface func(childComplexity int) int User func(childComplexity int, id int) int VOkCaseNil func(childComplexity int) int VOkCaseValue func(childComplexity int) int Valid func(childComplexity int) int ValidType func(childComplexity int) int VariadicModel func(childComplexity int) int WrappedMap func(childComplexity int) int WrappedScalar func(childComplexity int) int WrappedSlice func(childComplexity int) int WrappedStruct func(childComplexity int) int } Rectangle struct { Area func(childComplexity int) int Coordinates func(childComplexity int) int Length func(childComplexity int) int Width func(childComplexity int) int } Size struct { Height func(childComplexity int) int Weight func(childComplexity int) int } SkipIncludeTestType struct { A func(childComplexity int) int B func(childComplexity int) int } Slices struct { Test1 func(childComplexity int) int Test2 func(childComplexity int) int Test3 func(childComplexity int) int Test4 func(childComplexity int) int } Subscription struct { DirectiveArg func(childComplexity int, arg string) int DirectiveDouble func(childComplexity int) int DirectiveNullableArg func(childComplexity int, arg *int, arg2 *int, arg3 *string) int DirectiveUnimplemented func(childComplexity int) int ErrorRequired func(childComplexity int) int InitPayload func(childComplexity int) int Issue896b func(childComplexity int) int Updated func(childComplexity int) int } User struct { Created func(childComplexity int) int Friends func(childComplexity int) int ID func(childComplexity int) int Pets func(childComplexity int, limit *int) int Updated func(childComplexity int) int } VOkCaseNil struct { Value func(childComplexity int) int } VOkCaseValue struct { Value func(childComplexity int) int } ValidType struct { DifferentCase func(childComplexity int) int DifferentCaseOld func(childComplexity int) int ValidArgs func(childComplexity int, breakArg string, defaultArg string, funcArg string, interfaceArg string, selectArg string, caseArg string, deferArg string, goArg string, mapArg string, structArg string, chanArg string, elseArg string, gotoArg string, packageArg string, switchArg string, constArg string, fallthroughArg string, ifArg string, rangeArg string, typeArg string, continueArg string, forArg string, importArg string, returnArg string, varArg string, _ string) int ValidInputKeywords func(childComplexity int, input *ValidInput) int } VariadicModel struct { Value func(childComplexity int, rank int) int } WrappedMap struct { Get func(childComplexity int, key string) int } WrappedSlice struct { Get func(childComplexity int, idx int) int } WrappedStruct struct { Desc func(childComplexity int) int Name func(childComplexity int) int } XXIt struct { ID func(childComplexity int) int } XxIt struct { ID func(childComplexity int) int } AsdfIt struct { ID func(childComplexity int) int } IIt struct { ID func(childComplexity int) int } } type BackedByInterfaceResolver interface { ID(ctx context.Context, obj BackedByInterface) (string, error) } type DeferModelResolver interface { Values(ctx context.Context, obj *DeferModel) ([]string, error) } type ErrorsResolver interface { A(ctx context.Context, obj *Errors) (*Error, error) B(ctx context.Context, obj *Errors) (*Error, error) C(ctx context.Context, obj *Errors) (*Error, error) D(ctx context.Context, obj *Errors) (*Error, error) E(ctx context.Context, obj *Errors) (*Error, error) } type ForcedResolverResolver interface { Field(ctx context.Context, obj *ForcedResolver) (*Circle, error) } type ModelMethodsResolver interface { ResolverField(ctx context.Context, obj *ModelMethods) (bool, error) } type MutationResolver interface { DefaultInput(ctx context.Context, input DefaultInput) (*DefaultParametersMirror, error) OverrideValueViaInput(ctx context.Context, input FieldsOrderInput) (*FieldsOrderPayload, error) UpdateProduct(ctx context.Context, input map[string]interface{}) (string, error) Issue4053(ctx context.Context, input *Issue4053Input1) (bool, error) UpdateSomething(ctx context.Context, input SpecialInput) (string, error) UpdatePtrToPtr(ctx context.Context, input UpdatePtrToPtrOuter) (*PtrToPtrOuter, error) } type OverlappingFieldsResolver interface { OldFoo(ctx context.Context, obj *OverlappingFields) (int, error) } type PanicsResolver interface { FieldScalarMarshal(ctx context.Context, obj *Panics) ([]MarshalPanic, error) ArgUnmarshal(ctx context.Context, obj *Panics, u []MarshalPanic) (bool, error) } type PetResolver interface { Friends(ctx context.Context, obj *Pet, limit *int) ([]*Pet, error) } type PrimitiveResolver interface { Value(ctx context.Context, obj *Primitive) (int, error) } type PrimitiveStringResolver interface { Value(ctx context.Context, obj *PrimitiveString) (string, error) Len(ctx context.Context, obj *PrimitiveString) (int, error) } type QueryResolver interface { InvalidIdentifier(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) Collision(ctx context.Context) (*introspection1.It, error) MapInput(ctx context.Context, input map[string]any) (*bool, error) Recursive(ctx context.Context, input *RecursiveInputSlice) (*bool, error) NestedInputs(ctx context.Context, input [][]*OuterInput) (*bool, error) NestedOutputs(ctx context.Context) ([][]*OuterObject, error) ModelMethods(ctx context.Context) (*ModelMethods, error) User(ctx context.Context, id int) (*User, error) NullableArg(ctx context.Context, arg *int) (*string, error) InputSlice(ctx context.Context, arg []string) (bool, error) InputNullableSlice(ctx context.Context, arg []string) (bool, error) InputOmittable(ctx context.Context, arg OmittableInput) (string, error) ShapeUnion(ctx context.Context) (ShapeUnion, error) Autobind(ctx context.Context) (*Autobind, error) DeprecatedField(ctx context.Context) (string, error) FieldWithDeprecatedArg(ctx context.Context, oldArg *int, newArg *int) (*string, error) Overlapping(ctx context.Context) (*OverlappingFields, error) DefaultParameters(ctx context.Context, falsyBoolean *bool, truthyBoolean *bool) (*DefaultParametersMirror, error) DeferSingle(ctx context.Context) (*DeferModel, error) DeferMultiple(ctx context.Context) ([]*DeferModel, error) DirectiveArg(ctx context.Context, arg string) (*string, error) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (*string, error) DirectiveSingleNullableArg(ctx context.Context, arg1 *string) (*string, error) DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) DirectiveInputType(ctx context.Context, arg InnerInput) (*string, error) DirectiveInputOuter(ctx context.Context, arg OuterWrapperInput) (*string, error) DirectiveObject(ctx context.Context) (*ObjectDirectives, error) DirectiveObjectWithCustomGoModel(ctx context.Context) (*ObjectDirectivesWithCustomGoModel, error) DirectiveFieldDef(ctx context.Context, ret string) (string, error) DirectiveField(ctx context.Context) (*string, error) DirectiveDouble(ctx context.Context) (*string, error) DirectiveUnimplemented(ctx context.Context) (*string, error) EmbeddedCase1(ctx context.Context) (*EmbeddedCase1, error) EmbeddedCase2(ctx context.Context) (*EmbeddedCase2, error) EmbeddedCase3(ctx context.Context) (*EmbeddedCase3, error) EnumInInput(ctx context.Context, input *InputWithEnumValue) (EnumTest, error) SearchProducts(ctx context.Context, filters map[string]interface{}) ([]string, error) SearchRequired(ctx context.Context, filters map[string]interface{}) ([]string, error) SearchProductsNormal(ctx context.Context, filters map[string]any) ([]string, error) SearchWithDefaults(ctx context.Context, filters map[string]interface{}) ([]string, error) SearchMixed(ctx context.Context, filters map[string]interface{}, limit *int, offset *int, sortBy *string) ([]string, error) FilterProducts(ctx context.Context, filters map[string]interface{}) ([]string, error) FindProducts(ctx context.Context, filters map[string]interface{}) ([]string, error) SearchWithDirectives(ctx context.Context, input map[string]interface{}) ([]string, error) Shapes(ctx context.Context) ([]Shape, error) NoShape(ctx context.Context) (Shape, error) Node(ctx context.Context) (Node, error) NoShapeTypedNil(ctx context.Context) (Shape, error) Animal(ctx context.Context) (Animal, error) NotAnInterface(ctx context.Context) (BackedByInterface, error) Dog(ctx context.Context) (*Dog, error) Issue896a(ctx context.Context) ([]*CheckIssue896, error) MapStringInterface(ctx context.Context, in map[string]any) (map[string]any, error) MapNestedStringInterface(ctx context.Context, in *NestedMapInput) (map[string]any, error) MapNestedMapSlice(ctx context.Context, input map[string]any) (*bool, error) ErrorBubble(ctx context.Context) (*Error, error) ErrorBubbleList(ctx context.Context) ([]*Error, error) ErrorList(ctx context.Context) ([]*Error, error) Errors(ctx context.Context) (*Errors, error) Valid(ctx context.Context) (string, error) Invalid(ctx context.Context) (string, error) Panics(ctx context.Context) (*Panics, error) PrimitiveObject(ctx context.Context) ([]Primitive, error) PrimitiveStringObject(ctx context.Context) ([]PrimitiveString, error) PtrToAnyContainer(ctx context.Context) (*PtrToAnyContainer, error) PtrToSliceContainer(ctx context.Context) (*PtrToSliceContainer, error) Infinity(ctx context.Context) (float64, error) StringFromContextInterface(ctx context.Context) (*StringFromContextInterface, error) StringFromContextFunction(ctx context.Context) (string, error) DefaultScalar(ctx context.Context, arg string) (string, error) SkipInclude(ctx context.Context) (*SkipIncludeTestType, error) Slices(ctx context.Context) (*Slices, error) ScalarSlice(ctx context.Context) ([]byte, error) Fallback(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) OptionalUnion(ctx context.Context) (TestUnion, error) VOkCaseValue(ctx context.Context) (*VOkCaseValue, error) VOkCaseNil(ctx context.Context) (*VOkCaseNil, error) ValidType(ctx context.Context) (*ValidType, error) VariadicModel(ctx context.Context) (*VariadicModel, error) WrappedStruct(ctx context.Context) (*WrappedStruct, error) WrappedScalar(ctx context.Context) (otherpkg.Scalar, error) WrappedMap(ctx context.Context) (WrappedMap, error) WrappedSlice(ctx context.Context) (WrappedSlice, error) } type SubscriptionResolver interface { Updated(ctx context.Context) (<-chan string, error) InitPayload(ctx context.Context) (<-chan string, error) DirectiveArg(ctx context.Context, arg string) (<-chan *string, error) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (<-chan *string, error) DirectiveDouble(ctx context.Context) (<-chan *string, error) DirectiveUnimplemented(ctx context.Context) (<-chan *string, error) Issue896b(ctx context.Context) (<-chan []*CheckIssue896, error) ErrorRequired(ctx context.Context) (<-chan *Error, error) } type UserResolver interface { Friends(ctx context.Context, obj *User) ([]*User, error) Pets(ctx context.Context, obj *User, limit *int) ([]*Pet, error) } type WrappedMapResolver interface { Get(ctx context.Context, obj WrappedMap, key string) (string, error) } type WrappedSliceResolver interface { Get(ctx context.Context, obj WrappedSlice, idx int) (string, error) } type FieldsOrderInputResolver interface { OverrideFirstField(ctx context.Context, obj *FieldsOrderInput, data *string) error } type executableSchema 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 "A.id": if e.ComplexityRoot.A.ID == nil { break } return e.ComplexityRoot.A.ID(childComplexity), true case "AIt.id": if e.ComplexityRoot.AIt.ID == nil { break } return e.ComplexityRoot.AIt.ID(childComplexity), true case "AbIt.id": if e.ComplexityRoot.AbIt.ID == nil { break } return e.ComplexityRoot.AbIt.ID(childComplexity), true case "Autobind.idInt": if e.ComplexityRoot.Autobind.IdInt == nil { break } return e.ComplexityRoot.Autobind.IdInt(childComplexity), true case "Autobind.idStr": if e.ComplexityRoot.Autobind.IdStr == nil { break } return e.ComplexityRoot.Autobind.IdStr(childComplexity), true case "Autobind.int": if e.ComplexityRoot.Autobind.Int == nil { break } return e.ComplexityRoot.Autobind.Int(childComplexity), true case "Autobind.int32": if e.ComplexityRoot.Autobind.Int32 == nil { break } return e.ComplexityRoot.Autobind.Int32(childComplexity), true case "Autobind.int64": if e.ComplexityRoot.Autobind.Int64 == nil { break } return e.ComplexityRoot.Autobind.Int64(childComplexity), true case "B.id": if e.ComplexityRoot.B.ID == nil { break } return e.ComplexityRoot.B.ID(childComplexity), true case "BackedByInterface.id": if e.ComplexityRoot.BackedByInterface.ID == nil { break } return e.ComplexityRoot.BackedByInterface.ID(childComplexity), true case "BackedByInterface.thisShouldBind": if e.ComplexityRoot.BackedByInterface.ThisShouldBind == nil { break } return e.ComplexityRoot.BackedByInterface.ThisShouldBind(childComplexity), true case "BackedByInterface.thisShouldBindWithError": if e.ComplexityRoot.BackedByInterface.ThisShouldBindWithError == nil { break } return e.ComplexityRoot.BackedByInterface.ThisShouldBindWithError(childComplexity), true case "Cat.catBreed": if e.ComplexityRoot.Cat.CatBreed == nil { break } return e.ComplexityRoot.Cat.CatBreed(childComplexity), true case "Cat.size": if e.ComplexityRoot.Cat.Size == nil { break } return e.ComplexityRoot.Cat.Size(childComplexity), true case "Cat.species": if e.ComplexityRoot.Cat.Species == nil { break } return e.ComplexityRoot.Cat.Species(childComplexity), true case "CheckIssue896.id": if e.ComplexityRoot.CheckIssue896.ID == nil { break } return e.ComplexityRoot.CheckIssue896.ID(childComplexity), true case "Circle.area": if e.ComplexityRoot.Circle.Area == nil { break } return e.ComplexityRoot.Circle.Area(childComplexity), true case "Circle.coordinates": if e.ComplexityRoot.Circle.Coordinates == nil { break } return e.ComplexityRoot.Circle.Coordinates(childComplexity), true case "Circle.radius": if e.ComplexityRoot.Circle.Radius == nil { break } return e.ComplexityRoot.Circle.Radius(childComplexity), true case "ConcreteNodeA.child": if e.ComplexityRoot.ConcreteNodeA.Child == nil { break } return e.ComplexityRoot.ConcreteNodeA.Child(childComplexity), true case "ConcreteNodeA.id": if e.ComplexityRoot.ConcreteNodeA.ID == nil { break } return e.ComplexityRoot.ConcreteNodeA.ID(childComplexity), true case "ConcreteNodeA.name": if e.ComplexityRoot.ConcreteNodeA.Name == nil { break } return e.ComplexityRoot.ConcreteNodeA.Name(childComplexity), true case "ConcreteNodeInterface.child": if e.ComplexityRoot.ConcreteNodeInterface.Child == nil { break } return e.ComplexityRoot.ConcreteNodeInterface.Child(childComplexity), true case "ConcreteNodeInterface.id": if e.ComplexityRoot.ConcreteNodeInterface.ID == nil { break } return e.ComplexityRoot.ConcreteNodeInterface.ID(childComplexity), true case "Content_Post.foo": if e.ComplexityRoot.Content_Post.Foo == nil { break } return e.ComplexityRoot.Content_Post.Foo(childComplexity), true case "Content_User.foo": if e.ComplexityRoot.Content_User.Foo == nil { break } return e.ComplexityRoot.Content_User.Foo(childComplexity), true case "Coordinates.x": if e.ComplexityRoot.Coordinates.X == nil { break } return e.ComplexityRoot.Coordinates.X(childComplexity), true case "Coordinates.y": if e.ComplexityRoot.Coordinates.Y == nil { break } return e.ComplexityRoot.Coordinates.Y(childComplexity), true case "DefaultParametersMirror.falsyBoolean": if e.ComplexityRoot.DefaultParametersMirror.FalsyBoolean == nil { break } return e.ComplexityRoot.DefaultParametersMirror.FalsyBoolean(childComplexity), true case "DefaultParametersMirror.truthyBoolean": if e.ComplexityRoot.DefaultParametersMirror.TruthyBoolean == nil { break } return e.ComplexityRoot.DefaultParametersMirror.TruthyBoolean(childComplexity), true case "DeferModel.id": if e.ComplexityRoot.DeferModel.ID == nil { break } return e.ComplexityRoot.DeferModel.ID(childComplexity), true case "DeferModel.name": if e.ComplexityRoot.DeferModel.Name == nil { break } return e.ComplexityRoot.DeferModel.Name(childComplexity), true case "DeferModel.values": if e.ComplexityRoot.DeferModel.Values == nil { break } return e.ComplexityRoot.DeferModel.Values(childComplexity), true case "Dog.dogBreed": if e.ComplexityRoot.Dog.DogBreed == nil { break } return e.ComplexityRoot.Dog.DogBreed(childComplexity), true case "Dog.size": if e.ComplexityRoot.Dog.Size == nil { break } return e.ComplexityRoot.Dog.Size(childComplexity), true case "Dog.species": if e.ComplexityRoot.Dog.Species == nil { break } return e.ComplexityRoot.Dog.Species(childComplexity), true case "EmbeddedCase1.exportedEmbeddedPointerExportedMethod": if e.ComplexityRoot.EmbeddedCase1.ExportedEmbeddedPointerExportedMethod == nil { break } return e.ComplexityRoot.EmbeddedCase1.ExportedEmbeddedPointerExportedMethod(childComplexity), true case "EmbeddedCase2.unexportedEmbeddedPointerExportedMethod": if e.ComplexityRoot.EmbeddedCase2.UnexportedEmbeddedPointerExportedMethod == nil { break } return e.ComplexityRoot.EmbeddedCase2.UnexportedEmbeddedPointerExportedMethod(childComplexity), true case "EmbeddedCase3.unexportedEmbeddedInterfaceExportedMethod": if e.ComplexityRoot.EmbeddedCase3.UnexportedEmbeddedInterfaceExportedMethod == nil { break } return e.ComplexityRoot.EmbeddedCase3.UnexportedEmbeddedInterfaceExportedMethod(childComplexity), true case "EmbeddedDefaultScalar.value": if e.ComplexityRoot.EmbeddedDefaultScalar.Value == nil { break } return e.ComplexityRoot.EmbeddedDefaultScalar.Value(childComplexity), true case "EmbeddedPointer.ID": if e.ComplexityRoot.EmbeddedPointer.ID == nil { break } return e.ComplexityRoot.EmbeddedPointer.ID(childComplexity), true case "EmbeddedPointer.Title": if e.ComplexityRoot.EmbeddedPointer.Title == nil { break } return e.ComplexityRoot.EmbeddedPointer.Title(childComplexity), true case "Error.errorOnNonRequiredField": if e.ComplexityRoot.Error.ErrorOnNonRequiredField == nil { break } return e.ComplexityRoot.Error.ErrorOnNonRequiredField(childComplexity), true case "Error.errorOnRequiredField": if e.ComplexityRoot.Error.ErrorOnRequiredField == nil { break } return e.ComplexityRoot.Error.ErrorOnRequiredField(childComplexity), true case "Error.id": if e.ComplexityRoot.Error.ID == nil { break } return e.ComplexityRoot.Error.ID(childComplexity), true case "Error.nilOnRequiredField": if e.ComplexityRoot.Error.NilOnRequiredField == nil { break } return e.ComplexityRoot.Error.NilOnRequiredField(childComplexity), true case "Errors.a": if e.ComplexityRoot.Errors.A == nil { break } return e.ComplexityRoot.Errors.A(childComplexity), true case "Errors.b": if e.ComplexityRoot.Errors.B == nil { break } return e.ComplexityRoot.Errors.B(childComplexity), true case "Errors.c": if e.ComplexityRoot.Errors.C == nil { break } return e.ComplexityRoot.Errors.C(childComplexity), true case "Errors.d": if e.ComplexityRoot.Errors.D == nil { break } return e.ComplexityRoot.Errors.D(childComplexity), true case "Errors.e": if e.ComplexityRoot.Errors.E == nil { break } return e.ComplexityRoot.Errors.E(childComplexity), true case "FieldsOrderPayload.firstFieldValue": if e.ComplexityRoot.FieldsOrderPayload.FirstFieldValue == nil { break } return e.ComplexityRoot.FieldsOrderPayload.FirstFieldValue(childComplexity), true case "ForcedResolver.field": if e.ComplexityRoot.ForcedResolver.Field == nil { break } return e.ComplexityRoot.ForcedResolver.Field(childComplexity), true case "Horse.horseBreed": if e.ComplexityRoot.Horse.HorseBreed == nil { break } return e.ComplexityRoot.Horse.HorseBreed(childComplexity), true case "Horse.size": if e.ComplexityRoot.Horse.Size == nil { break } return e.ComplexityRoot.Horse.Size(childComplexity), true case "Horse.species": if e.ComplexityRoot.Horse.Species == nil { break } return e.ComplexityRoot.Horse.Species(childComplexity), true case "InnerObject.id": if e.ComplexityRoot.InnerObject.ID == nil { break } return e.ComplexityRoot.InnerObject.ID(childComplexity), true case "InvalidIdentifier.id": if e.ComplexityRoot.InvalidIdentifier.ID == nil { break } return e.ComplexityRoot.InvalidIdentifier.ID(childComplexity), true case "It.id": if e.ComplexityRoot.It.ID == nil { break } return e.ComplexityRoot.It.ID(childComplexity), true case "LoopA.b": if e.ComplexityRoot.LoopA.B == nil { break } return e.ComplexityRoot.LoopA.B(childComplexity), true case "LoopB.a": if e.ComplexityRoot.LoopB.A == nil { break } return e.ComplexityRoot.LoopB.A(childComplexity), true case "Map.id": if e.ComplexityRoot.Map.ID == nil { break } return e.ComplexityRoot.Map.ID(childComplexity), true case "MapNested.value": if e.ComplexityRoot.MapNested.Value == nil { break } return e.ComplexityRoot.MapNested.Value(childComplexity), true case "MapStringInterfaceType.a": if e.ComplexityRoot.MapStringInterfaceType.A == nil { break } return e.ComplexityRoot.MapStringInterfaceType.A(childComplexity), true case "MapStringInterfaceType.b": if e.ComplexityRoot.MapStringInterfaceType.B == nil { break } return e.ComplexityRoot.MapStringInterfaceType.B(childComplexity), true case "MapStringInterfaceType.c": if e.ComplexityRoot.MapStringInterfaceType.C == nil { break } return e.ComplexityRoot.MapStringInterfaceType.C(childComplexity), true case "MapStringInterfaceType.nested": if e.ComplexityRoot.MapStringInterfaceType.Nested == nil { break } return e.ComplexityRoot.MapStringInterfaceType.Nested(childComplexity), true case "ModelMethods.noContext": if e.ComplexityRoot.ModelMethods.NoContext == nil { break } return e.ComplexityRoot.ModelMethods.NoContext(childComplexity), true case "ModelMethods.resolverField": if e.ComplexityRoot.ModelMethods.ResolverField == nil { break } return e.ComplexityRoot.ModelMethods.ResolverField(childComplexity), true case "ModelMethods.withContext": if e.ComplexityRoot.ModelMethods.WithContext == nil { break } return e.ComplexityRoot.ModelMethods.WithContext(childComplexity), true case "Mutation.defaultInput": if e.ComplexityRoot.Mutation.DefaultInput == nil { break } args, err := ec.field_Mutation_defaultInput_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Mutation.DefaultInput(childComplexity, args["input"].(DefaultInput)), true case "Mutation.issue4053": if e.ComplexityRoot.Mutation.Issue4053 == nil { break } args, err := ec.field_Mutation_issue4053_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Mutation.Issue4053(childComplexity, args["input"].(*Issue4053Input1)), true case "Mutation.overrideValueViaInput": if e.ComplexityRoot.Mutation.OverrideValueViaInput == nil { break } args, err := ec.field_Mutation_overrideValueViaInput_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Mutation.OverrideValueViaInput(childComplexity, args["input"].(FieldsOrderInput)), true case "Mutation.updateProduct": if e.ComplexityRoot.Mutation.UpdateProduct == nil { break } args, err := ec.field_Mutation_updateProduct_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Mutation.UpdateProduct(childComplexity, args["id"].(string), args["name"].(*string), args["price"].(*float64)), true case "Mutation.updatePtrToPtr": if e.ComplexityRoot.Mutation.UpdatePtrToPtr == nil { break } args, err := ec.field_Mutation_updatePtrToPtr_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Mutation.UpdatePtrToPtr(childComplexity, args["input"].(UpdatePtrToPtrOuter)), true case "Mutation.updateSomething": if e.ComplexityRoot.Mutation.UpdateSomething == nil { break } args, err := ec.field_Mutation_updateSomething_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Mutation.UpdateSomething(childComplexity, args["input"].(SpecialInput)), true case "ObjectDirectives.nullableText": if e.ComplexityRoot.ObjectDirectives.NullableText == nil { break } return e.ComplexityRoot.ObjectDirectives.NullableText(childComplexity), true case "ObjectDirectives.order": if e.ComplexityRoot.ObjectDirectives.Order == nil { break } return e.ComplexityRoot.ObjectDirectives.Order(childComplexity), true case "ObjectDirectives.text": if e.ComplexityRoot.ObjectDirectives.Text == nil { break } return e.ComplexityRoot.ObjectDirectives.Text(childComplexity), true case "ObjectDirectivesWithCustomGoModel.nullableText": if e.ComplexityRoot.ObjectDirectivesWithCustomGoModel.NullableText == nil { break } return e.ComplexityRoot.ObjectDirectivesWithCustomGoModel.NullableText(childComplexity), true case "OuterObject.inner": if e.ComplexityRoot.OuterObject.Inner == nil { break } return e.ComplexityRoot.OuterObject.Inner(childComplexity), true case "OverlappingFields.oneFoo", "OverlappingFields.twoFoo": if e.ComplexityRoot.OverlappingFields.Foo == nil { break } return e.ComplexityRoot.OverlappingFields.Foo(childComplexity), true case "OverlappingFields.newFoo", "OverlappingFields.new_foo": if e.ComplexityRoot.OverlappingFields.NewFoo == nil { break } return e.ComplexityRoot.OverlappingFields.NewFoo(childComplexity), true case "OverlappingFields.oldFoo": if e.ComplexityRoot.OverlappingFields.OldFoo == nil { break } return e.ComplexityRoot.OverlappingFields.OldFoo(childComplexity), true case "Panics.argUnmarshal": if e.ComplexityRoot.Panics.ArgUnmarshal == nil { break } args, err := ec.field_Panics_argUnmarshal_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Panics.ArgUnmarshal(childComplexity, args["u"].([]MarshalPanic)), true case "Panics.fieldFuncMarshal": if e.ComplexityRoot.Panics.FieldFuncMarshal == nil { break } args, err := ec.field_Panics_fieldFuncMarshal_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Panics.FieldFuncMarshal(childComplexity, args["u"].([]MarshalPanic)), true case "Panics.fieldScalarMarshal": if e.ComplexityRoot.Panics.FieldScalarMarshal == nil { break } return e.ComplexityRoot.Panics.FieldScalarMarshal(childComplexity), true case "Pet.friends": if e.ComplexityRoot.Pet.Friends == nil { break } args, err := ec.field_Pet_friends_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Pet.Friends(childComplexity, args["limit"].(*int)), true case "Pet.id": if e.ComplexityRoot.Pet.ID == nil { break } return e.ComplexityRoot.Pet.ID(childComplexity), true case "Primitive.squared": if e.ComplexityRoot.Primitive.Squared == nil { break } return e.ComplexityRoot.Primitive.Squared(childComplexity), true case "Primitive.value": if e.ComplexityRoot.Primitive.Value == nil { break } return e.ComplexityRoot.Primitive.Value(childComplexity), true case "PrimitiveString.doubled": if e.ComplexityRoot.PrimitiveString.Doubled == nil { break } return e.ComplexityRoot.PrimitiveString.Doubled(childComplexity), true case "PrimitiveString.len": if e.ComplexityRoot.PrimitiveString.Len == nil { break } return e.ComplexityRoot.PrimitiveString.Len(childComplexity), true case "PrimitiveString.value": if e.ComplexityRoot.PrimitiveString.Value == nil { break } return e.ComplexityRoot.PrimitiveString.Value(childComplexity), true case "PtrToAnyContainer.binding": if e.ComplexityRoot.PtrToAnyContainer.Binding == nil { break } return e.ComplexityRoot.PtrToAnyContainer.Binding(childComplexity), true case "PtrToAnyContainer.ptrToAny": if e.ComplexityRoot.PtrToAnyContainer.PtrToAny == nil { break } return e.ComplexityRoot.PtrToAnyContainer.PtrToAny(childComplexity), true case "PtrToPtrInner.key": if e.ComplexityRoot.PtrToPtrInner.Key == nil { break } return e.ComplexityRoot.PtrToPtrInner.Key(childComplexity), true case "PtrToPtrInner.value": if e.ComplexityRoot.PtrToPtrInner.Value == nil { break } return e.ComplexityRoot.PtrToPtrInner.Value(childComplexity), true case "PtrToPtrOuter.inner": if e.ComplexityRoot.PtrToPtrOuter.Inner == nil { break } return e.ComplexityRoot.PtrToPtrOuter.Inner(childComplexity), true case "PtrToPtrOuter.name": if e.ComplexityRoot.PtrToPtrOuter.Name == nil { break } return e.ComplexityRoot.PtrToPtrOuter.Name(childComplexity), true case "PtrToPtrOuter.stupidInner": if e.ComplexityRoot.PtrToPtrOuter.StupidInner == nil { break } return e.ComplexityRoot.PtrToPtrOuter.StupidInner(childComplexity), true case "PtrToSliceContainer.ptrToSlice": if e.ComplexityRoot.PtrToSliceContainer.PtrToSlice == nil { break } return e.ComplexityRoot.PtrToSliceContainer.PtrToSlice(childComplexity), true case "Query.animal": if e.ComplexityRoot.Query.Animal == nil { break } return e.ComplexityRoot.Query.Animal(childComplexity), true case "Query.autobind": if e.ComplexityRoot.Query.Autobind == nil { break } return e.ComplexityRoot.Query.Autobind(childComplexity), true case "Query.collision": if e.ComplexityRoot.Query.Collision == nil { break } return e.ComplexityRoot.Query.Collision(childComplexity), true case "Query.defaultParameters": if e.ComplexityRoot.Query.DefaultParameters == nil { break } args, err := ec.field_Query_defaultParameters_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.DefaultParameters(childComplexity, args["falsyBoolean"].(*bool), args["truthyBoolean"].(*bool)), true case "Query.defaultScalar": if e.ComplexityRoot.Query.DefaultScalar == nil { break } args, err := ec.field_Query_defaultScalar_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.DefaultScalar(childComplexity, args["arg"].(string)), true case "Query.deferMultiple": if e.ComplexityRoot.Query.DeferMultiple == nil { break } return e.ComplexityRoot.Query.DeferMultiple(childComplexity), true case "Query.deferSingle": if e.ComplexityRoot.Query.DeferSingle == nil { break } return e.ComplexityRoot.Query.DeferSingle(childComplexity), true case "Query.deprecatedField": if e.ComplexityRoot.Query.DeprecatedField == nil { break } return e.ComplexityRoot.Query.DeprecatedField(childComplexity), true case "Query.directiveArg": if e.ComplexityRoot.Query.DirectiveArg == nil { break } args, err := ec.field_Query_directiveArg_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.DirectiveArg(childComplexity, args["arg"].(string)), true case "Query.directiveDouble": if e.ComplexityRoot.Query.DirectiveDouble == nil { break } return e.ComplexityRoot.Query.DirectiveDouble(childComplexity), true case "Query.directiveField": if e.ComplexityRoot.Query.DirectiveField == nil { break } return e.ComplexityRoot.Query.DirectiveField(childComplexity), true case "Query.directiveFieldDef": if e.ComplexityRoot.Query.DirectiveFieldDef == nil { break } args, err := ec.field_Query_directiveFieldDef_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.DirectiveFieldDef(childComplexity, args["ret"].(string)), true case "Query.directiveInput": if e.ComplexityRoot.Query.DirectiveInput == nil { break } args, err := ec.field_Query_directiveInput_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.DirectiveInput(childComplexity, args["arg"].(InputDirectives)), true case "Query.directiveInputNullable": if e.ComplexityRoot.Query.DirectiveInputNullable == nil { break } args, err := ec.field_Query_directiveInputNullable_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.DirectiveInputNullable(childComplexity, args["arg"].(*InputDirectives)), true case "Query.directiveInputOuter": if e.ComplexityRoot.Query.DirectiveInputOuter == nil { break } args, err := ec.field_Query_directiveInputOuter_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.DirectiveInputOuter(childComplexity, args["arg"].(OuterWrapperInput)), true case "Query.directiveInputType": if e.ComplexityRoot.Query.DirectiveInputType == nil { break } args, err := ec.field_Query_directiveInputType_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.DirectiveInputType(childComplexity, args["arg"].(InnerInput)), true case "Query.directiveNullableArg": if e.ComplexityRoot.Query.DirectiveNullableArg == nil { break } args, err := ec.field_Query_directiveNullableArg_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.DirectiveNullableArg(childComplexity, args["arg"].(*int), args["arg2"].(*int), args["arg3"].(*string)), true case "Query.directiveObject": if e.ComplexityRoot.Query.DirectiveObject == nil { break } return e.ComplexityRoot.Query.DirectiveObject(childComplexity), true case "Query.directiveObjectWithCustomGoModel": if e.ComplexityRoot.Query.DirectiveObjectWithCustomGoModel == nil { break } return e.ComplexityRoot.Query.DirectiveObjectWithCustomGoModel(childComplexity), true case "Query.directiveSingleNullableArg": if e.ComplexityRoot.Query.DirectiveSingleNullableArg == nil { break } args, err := ec.field_Query_directiveSingleNullableArg_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.DirectiveSingleNullableArg(childComplexity, args["arg1"].(*string)), true case "Query.directiveUnimplemented": if e.ComplexityRoot.Query.DirectiveUnimplemented == nil { break } return e.ComplexityRoot.Query.DirectiveUnimplemented(childComplexity), true case "Query.dog": if e.ComplexityRoot.Query.Dog == nil { break } return e.ComplexityRoot.Query.Dog(childComplexity), true case "Query.embeddedCase1": if e.ComplexityRoot.Query.EmbeddedCase1 == nil { break } return e.ComplexityRoot.Query.EmbeddedCase1(childComplexity), true case "Query.embeddedCase2": if e.ComplexityRoot.Query.EmbeddedCase2 == nil { break } return e.ComplexityRoot.Query.EmbeddedCase2(childComplexity), true case "Query.embeddedCase3": if e.ComplexityRoot.Query.EmbeddedCase3 == nil { break } return e.ComplexityRoot.Query.EmbeddedCase3(childComplexity), true case "Query.enumInInput": if e.ComplexityRoot.Query.EnumInInput == nil { break } args, err := ec.field_Query_enumInInput_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.EnumInInput(childComplexity, args["input"].(*InputWithEnumValue)), true case "Query.errorBubble": if e.ComplexityRoot.Query.ErrorBubble == nil { break } return e.ComplexityRoot.Query.ErrorBubble(childComplexity), true case "Query.errorBubbleList": if e.ComplexityRoot.Query.ErrorBubbleList == nil { break } return e.ComplexityRoot.Query.ErrorBubbleList(childComplexity), true case "Query.errorList": if e.ComplexityRoot.Query.ErrorList == nil { break } return e.ComplexityRoot.Query.ErrorList(childComplexity), true case "Query.errors": if e.ComplexityRoot.Query.Errors == nil { break } return e.ComplexityRoot.Query.Errors(childComplexity), true case "Query.fallback": if e.ComplexityRoot.Query.Fallback == nil { break } args, err := ec.field_Query_fallback_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.Fallback(childComplexity, args["arg"].(FallbackToStringEncoding)), true case "Query.fieldWithDeprecatedArg": if e.ComplexityRoot.Query.FieldWithDeprecatedArg == nil { break } args, err := ec.field_Query_fieldWithDeprecatedArg_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.FieldWithDeprecatedArg(childComplexity, args["oldArg"].(*int), args["newArg"].(*int)), true case "Query.filterProducts": if e.ComplexityRoot.Query.FilterProducts == nil { break } args, err := ec.field_Query_filterProducts_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.FilterProducts(childComplexity, args["query"].(*string), args["category"].(*string), args["minPrice"].(*int)), true case "Query.findProducts": if e.ComplexityRoot.Query.FindProducts == nil { break } args, err := ec.field_Query_findProducts_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.FindProducts(childComplexity, args["query"].(*string), args["category"].(*string), args["minPrice"].(*int)), true case "Query.infinity": if e.ComplexityRoot.Query.Infinity == nil { break } return e.ComplexityRoot.Query.Infinity(childComplexity), true case "Query.inputNullableSlice": if e.ComplexityRoot.Query.InputNullableSlice == nil { break } args, err := ec.field_Query_inputNullableSlice_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.InputNullableSlice(childComplexity, args["arg"].([]string)), true case "Query.inputOmittable": if e.ComplexityRoot.Query.InputOmittable == nil { break } args, err := ec.field_Query_inputOmittable_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.InputOmittable(childComplexity, args["arg"].(OmittableInput)), true case "Query.inputSlice": if e.ComplexityRoot.Query.InputSlice == nil { break } args, err := ec.field_Query_inputSlice_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.InputSlice(childComplexity, args["arg"].([]string)), true case "Query.invalid": if e.ComplexityRoot.Query.Invalid == nil { break } return e.ComplexityRoot.Query.Invalid(childComplexity), true case "Query.invalidIdentifier": if e.ComplexityRoot.Query.InvalidIdentifier == nil { break } return e.ComplexityRoot.Query.InvalidIdentifier(childComplexity), true case "Query.issue896a": if e.ComplexityRoot.Query.Issue896a == nil { break } return e.ComplexityRoot.Query.Issue896a(childComplexity), true case "Query.mapInput": if e.ComplexityRoot.Query.MapInput == nil { break } args, err := ec.field_Query_mapInput_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.MapInput(childComplexity, args["input"].(map[string]any)), true case "Query.mapNestedMapSlice": if e.ComplexityRoot.Query.MapNestedMapSlice == nil { break } args, err := ec.field_Query_mapNestedMapSlice_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.MapNestedMapSlice(childComplexity, args["input"].(map[string]any)), true case "Query.mapNestedStringInterface": if e.ComplexityRoot.Query.MapNestedStringInterface == nil { break } args, err := ec.field_Query_mapNestedStringInterface_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.MapNestedStringInterface(childComplexity, args["in"].(*NestedMapInput)), true case "Query.mapStringInterface": if e.ComplexityRoot.Query.MapStringInterface == nil { break } args, err := ec.field_Query_mapStringInterface_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.MapStringInterface(childComplexity, args["in"].(map[string]any)), true case "Query.modelMethods": if e.ComplexityRoot.Query.ModelMethods == nil { break } return e.ComplexityRoot.Query.ModelMethods(childComplexity), true case "Query.nestedInputs": if e.ComplexityRoot.Query.NestedInputs == nil { break } args, err := ec.field_Query_nestedInputs_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.NestedInputs(childComplexity, args["input"].([][]*OuterInput)), true case "Query.nestedOutputs": if e.ComplexityRoot.Query.NestedOutputs == nil { break } return e.ComplexityRoot.Query.NestedOutputs(childComplexity), true case "Query.noShape": if e.ComplexityRoot.Query.NoShape == nil { break } return e.ComplexityRoot.Query.NoShape(childComplexity), true case "Query.noShapeTypedNil": if e.ComplexityRoot.Query.NoShapeTypedNil == nil { break } return e.ComplexityRoot.Query.NoShapeTypedNil(childComplexity), true case "Query.node": if e.ComplexityRoot.Query.Node == nil { break } return e.ComplexityRoot.Query.Node(childComplexity), true case "Query.notAnInterface": if e.ComplexityRoot.Query.NotAnInterface == nil { break } return e.ComplexityRoot.Query.NotAnInterface(childComplexity), true case "Query.nullableArg": if e.ComplexityRoot.Query.NullableArg == nil { break } args, err := ec.field_Query_nullableArg_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.NullableArg(childComplexity, args["arg"].(*int)), true case "Query.optionalUnion": if e.ComplexityRoot.Query.OptionalUnion == nil { break } return e.ComplexityRoot.Query.OptionalUnion(childComplexity), true case "Query.overlapping": if e.ComplexityRoot.Query.Overlapping == nil { break } return e.ComplexityRoot.Query.Overlapping(childComplexity), true case "Query.panics": if e.ComplexityRoot.Query.Panics == nil { break } return e.ComplexityRoot.Query.Panics(childComplexity), true case "Query.primitiveObject": if e.ComplexityRoot.Query.PrimitiveObject == nil { break } return e.ComplexityRoot.Query.PrimitiveObject(childComplexity), true case "Query.primitiveStringObject": if e.ComplexityRoot.Query.PrimitiveStringObject == nil { break } return e.ComplexityRoot.Query.PrimitiveStringObject(childComplexity), true case "Query.ptrToAnyContainer": if e.ComplexityRoot.Query.PtrToAnyContainer == nil { break } return e.ComplexityRoot.Query.PtrToAnyContainer(childComplexity), true case "Query.ptrToSliceContainer": if e.ComplexityRoot.Query.PtrToSliceContainer == nil { break } return e.ComplexityRoot.Query.PtrToSliceContainer(childComplexity), true case "Query.recursive": if e.ComplexityRoot.Query.Recursive == nil { break } args, err := ec.field_Query_recursive_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.Recursive(childComplexity, args["input"].(*RecursiveInputSlice)), true case "Query.scalarSlice": if e.ComplexityRoot.Query.ScalarSlice == nil { break } return e.ComplexityRoot.Query.ScalarSlice(childComplexity), true case "Query.searchMixed": if e.ComplexityRoot.Query.SearchMixed == nil { break } args, err := ec.field_Query_searchMixed_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.SearchMixed(childComplexity, args["query"].(*string), args["category"].(*string), args["minPrice"].(*int), args["limit"].(*int), args["offset"].(*int), args["sortBy"].(*string)), true case "Query.searchProducts": if e.ComplexityRoot.Query.SearchProducts == nil { break } args, err := ec.field_Query_searchProducts_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.SearchProducts(childComplexity, args["query"].(*string), args["category"].(*string), args["minPrice"].(*int)), true case "Query.searchProductsNormal": if e.ComplexityRoot.Query.SearchProductsNormal == nil { break } args, err := ec.field_Query_searchProductsNormal_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.SearchProductsNormal(childComplexity, args["filters"].(map[string]any)), true case "Query.searchRequired": if e.ComplexityRoot.Query.SearchRequired == nil { break } args, err := ec.field_Query_searchRequired_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.SearchRequired(childComplexity, args["name"].(string), args["age"].(int)), true case "Query.searchWithDefaults": if e.ComplexityRoot.Query.SearchWithDefaults == nil { break } args, err := ec.field_Query_searchWithDefaults_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.SearchWithDefaults(childComplexity, args["query"].(*string), args["limit"].(*int), args["includeArchived"].(*bool)), true case "Query.searchWithDirectives": if e.ComplexityRoot.Query.SearchWithDirectives == nil { break } args, err := ec.field_Query_searchWithDirectives_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.SearchWithDirectives(childComplexity, args["oldField"].(*string), args["newField"].(*string)), true case "Query.shapeUnion": if e.ComplexityRoot.Query.ShapeUnion == nil { break } return e.ComplexityRoot.Query.ShapeUnion(childComplexity), true case "Query.shapes": if e.ComplexityRoot.Query.Shapes == nil { break } return e.ComplexityRoot.Query.Shapes(childComplexity), true case "Query.skipInclude": if e.ComplexityRoot.Query.SkipInclude == nil { break } return e.ComplexityRoot.Query.SkipInclude(childComplexity), true case "Query.slices": if e.ComplexityRoot.Query.Slices == nil { break } return e.ComplexityRoot.Query.Slices(childComplexity), true case "Query.stringFromContextFunction": if e.ComplexityRoot.Query.StringFromContextFunction == nil { break } return e.ComplexityRoot.Query.StringFromContextFunction(childComplexity), true case "Query.stringFromContextInterface": if e.ComplexityRoot.Query.StringFromContextInterface == nil { break } return e.ComplexityRoot.Query.StringFromContextInterface(childComplexity), true case "Query.user": if e.ComplexityRoot.Query.User == nil { break } args, err := ec.field_Query_user_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.User(childComplexity, args["id"].(int)), true case "Query.vOkCaseNil": if e.ComplexityRoot.Query.VOkCaseNil == nil { break } return e.ComplexityRoot.Query.VOkCaseNil(childComplexity), true case "Query.vOkCaseValue": if e.ComplexityRoot.Query.VOkCaseValue == nil { break } return e.ComplexityRoot.Query.VOkCaseValue(childComplexity), true case "Query.valid": if e.ComplexityRoot.Query.Valid == nil { break } return e.ComplexityRoot.Query.Valid(childComplexity), true case "Query.validType": if e.ComplexityRoot.Query.ValidType == nil { break } return e.ComplexityRoot.Query.ValidType(childComplexity), true case "Query.variadicModel": if e.ComplexityRoot.Query.VariadicModel == nil { break } return e.ComplexityRoot.Query.VariadicModel(childComplexity), true case "Query.wrappedMap": if e.ComplexityRoot.Query.WrappedMap == nil { break } return e.ComplexityRoot.Query.WrappedMap(childComplexity), true case "Query.wrappedScalar": if e.ComplexityRoot.Query.WrappedScalar == nil { break } return e.ComplexityRoot.Query.WrappedScalar(childComplexity), true case "Query.wrappedSlice": if e.ComplexityRoot.Query.WrappedSlice == nil { break } return e.ComplexityRoot.Query.WrappedSlice(childComplexity), true case "Query.wrappedStruct": if e.ComplexityRoot.Query.WrappedStruct == nil { break } return e.ComplexityRoot.Query.WrappedStruct(childComplexity), true case "Rectangle.area": if e.ComplexityRoot.Rectangle.Area == nil { break } return e.ComplexityRoot.Rectangle.Area(childComplexity), true case "Rectangle.coordinates": if e.ComplexityRoot.Rectangle.Coordinates == nil { break } return e.ComplexityRoot.Rectangle.Coordinates(childComplexity), true case "Rectangle.length": if e.ComplexityRoot.Rectangle.Length == nil { break } return e.ComplexityRoot.Rectangle.Length(childComplexity), true case "Rectangle.width": if e.ComplexityRoot.Rectangle.Width == nil { break } return e.ComplexityRoot.Rectangle.Width(childComplexity), true case "Size.height": if e.ComplexityRoot.Size.Height == nil { break } return e.ComplexityRoot.Size.Height(childComplexity), true case "Size.weight": if e.ComplexityRoot.Size.Weight == nil { break } return e.ComplexityRoot.Size.Weight(childComplexity), true case "SkipIncludeTestType.a": if e.ComplexityRoot.SkipIncludeTestType.A == nil { break } return e.ComplexityRoot.SkipIncludeTestType.A(childComplexity), true case "SkipIncludeTestType.b": if e.ComplexityRoot.SkipIncludeTestType.B == nil { break } return e.ComplexityRoot.SkipIncludeTestType.B(childComplexity), true case "Slices.test1": if e.ComplexityRoot.Slices.Test1 == nil { break } return e.ComplexityRoot.Slices.Test1(childComplexity), true case "Slices.test2": if e.ComplexityRoot.Slices.Test2 == nil { break } return e.ComplexityRoot.Slices.Test2(childComplexity), true case "Slices.test3": if e.ComplexityRoot.Slices.Test3 == nil { break } return e.ComplexityRoot.Slices.Test3(childComplexity), true case "Slices.test4": if e.ComplexityRoot.Slices.Test4 == nil { break } return e.ComplexityRoot.Slices.Test4(childComplexity), true case "Subscription.directiveArg": if e.ComplexityRoot.Subscription.DirectiveArg == nil { break } args, err := ec.field_Subscription_directiveArg_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Subscription.DirectiveArg(childComplexity, args["arg"].(string)), true case "Subscription.directiveDouble": if e.ComplexityRoot.Subscription.DirectiveDouble == nil { break } return e.ComplexityRoot.Subscription.DirectiveDouble(childComplexity), true case "Subscription.directiveNullableArg": if e.ComplexityRoot.Subscription.DirectiveNullableArg == nil { break } args, err := ec.field_Subscription_directiveNullableArg_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Subscription.DirectiveNullableArg(childComplexity, args["arg"].(*int), args["arg2"].(*int), args["arg3"].(*string)), true case "Subscription.directiveUnimplemented": if e.ComplexityRoot.Subscription.DirectiveUnimplemented == nil { break } return e.ComplexityRoot.Subscription.DirectiveUnimplemented(childComplexity), true case "Subscription.errorRequired": if e.ComplexityRoot.Subscription.ErrorRequired == nil { break } return e.ComplexityRoot.Subscription.ErrorRequired(childComplexity), true case "Subscription.initPayload": if e.ComplexityRoot.Subscription.InitPayload == nil { break } return e.ComplexityRoot.Subscription.InitPayload(childComplexity), true case "Subscription.issue896b": if e.ComplexityRoot.Subscription.Issue896b == nil { break } return e.ComplexityRoot.Subscription.Issue896b(childComplexity), true case "Subscription.updated": if e.ComplexityRoot.Subscription.Updated == nil { break } return e.ComplexityRoot.Subscription.Updated(childComplexity), true case "User.created": if e.ComplexityRoot.User.Created == nil { break } return e.ComplexityRoot.User.Created(childComplexity), true case "User.friends": if e.ComplexityRoot.User.Friends == nil { break } return e.ComplexityRoot.User.Friends(childComplexity), true case "User.id": if e.ComplexityRoot.User.ID == nil { break } return e.ComplexityRoot.User.ID(childComplexity), true case "User.pets": if e.ComplexityRoot.User.Pets == nil { break } args, err := ec.field_User_pets_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.User.Pets(childComplexity, args["limit"].(*int)), true case "User.updated": if e.ComplexityRoot.User.Updated == nil { break } return e.ComplexityRoot.User.Updated(childComplexity), true case "VOkCaseNil.value": if e.ComplexityRoot.VOkCaseNil.Value == nil { break } return e.ComplexityRoot.VOkCaseNil.Value(childComplexity), true case "VOkCaseValue.value": if e.ComplexityRoot.VOkCaseValue.Value == nil { break } return e.ComplexityRoot.VOkCaseValue.Value(childComplexity), true case "ValidType.differentCase": if e.ComplexityRoot.ValidType.DifferentCase == nil { break } return e.ComplexityRoot.ValidType.DifferentCase(childComplexity), true case "ValidType.different_case": if e.ComplexityRoot.ValidType.DifferentCaseOld == nil { break } return e.ComplexityRoot.ValidType.DifferentCaseOld(childComplexity), true case "ValidType.validArgs": if e.ComplexityRoot.ValidType.ValidArgs == nil { break } args, err := ec.field_ValidType_validArgs_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.ValidType.ValidArgs(childComplexity, args["break"].(string), args["default"].(string), args["func"].(string), args["interface"].(string), args["select"].(string), args["case"].(string), args["defer"].(string), args["go"].(string), args["map"].(string), args["struct"].(string), args["chan"].(string), args["else"].(string), args["goto"].(string), args["package"].(string), args["switch"].(string), args["const"].(string), args["fallthrough"].(string), args["if"].(string), args["range"].(string), args["type"].(string), args["continue"].(string), args["for"].(string), args["import"].(string), args["return"].(string), args["var"].(string), args["_"].(string)), true case "ValidType.validInputKeywords": if e.ComplexityRoot.ValidType.ValidInputKeywords == nil { break } args, err := ec.field_ValidType_validInputKeywords_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.ValidType.ValidInputKeywords(childComplexity, args["input"].(*ValidInput)), true case "VariadicModel.value": if e.ComplexityRoot.VariadicModel.Value == nil { break } args, err := ec.field_VariadicModel_value_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.VariadicModel.Value(childComplexity, args["rank"].(int)), true case "WrappedMap.get": if e.ComplexityRoot.WrappedMap.Get == nil { break } args, err := ec.field_WrappedMap_get_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.WrappedMap.Get(childComplexity, args["key"].(string)), true case "WrappedSlice.get": if e.ComplexityRoot.WrappedSlice.Get == nil { break } args, err := ec.field_WrappedSlice_get_args(ctx, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.WrappedSlice.Get(childComplexity, args["idx"].(int)), true case "WrappedStruct.desc": if e.ComplexityRoot.WrappedStruct.Desc == nil { break } return e.ComplexityRoot.WrappedStruct.Desc(childComplexity), true case "WrappedStruct.name": if e.ComplexityRoot.WrappedStruct.Name == nil { break } return e.ComplexityRoot.WrappedStruct.Name(childComplexity), true case "XXIt.id": if e.ComplexityRoot.XXIt.ID == nil { break } return e.ComplexityRoot.XXIt.ID(childComplexity), true case "XxIt.id": if e.ComplexityRoot.XxIt.ID == nil { break } return e.ComplexityRoot.XxIt.ID(childComplexity), true case "asdfIt.id": if e.ComplexityRoot.AsdfIt.ID == nil { break } return e.ComplexityRoot.AsdfIt.ID(childComplexity), true case "iIt.id": if e.ComplexityRoot.IIt.ID == nil { break } return e.ComplexityRoot.IIt.ID(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.unmarshalInputChanges, ec.unmarshalInputDefaultInput, ec.unmarshalInputDirectiveInput, ec.unmarshalInputFieldsOrderInput, ec.unmarshalInputInnerDirectives, ec.unmarshalInputInnerInput, ec.unmarshalInputInputDirectives, ec.unmarshalInputInputWithEnumValue, ec.unmarshalInputIssue4053Input1, ec.unmarshalInputIssue4053Input2, ec.unmarshalInputMapNestedInput, ec.unmarshalInputMapNestedMapSliceInput, ec.unmarshalInputMapStringInterfaceInput, ec.unmarshalInputNestedInput, ec.unmarshalInputNestedMapInput, ec.unmarshalInputOmittableInput, ec.unmarshalInputOuterInput, ec.unmarshalInputOuterWrapperInput, ec.unmarshalInputRecursiveInputSlice, ec.unmarshalInputRequiredFilters, ec.unmarshalInputSearchFilters, ec.unmarshalInputSearchWithDefaults, ec.unmarshalInputSpecialInput, ec.unmarshalInputUpdateProductInput, ec.unmarshalInputUpdatePtrToPtrInner, ec.unmarshalInputUpdatePtrToPtrOuter, ec.unmarshalInputValidInput, ) 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._Subscription(ctx, opCtx.Operation.SelectionSet) var buf bytes.Buffer return func(ctx context.Context) *graphql.Response { buf.Reset() data := next(ctx) if data == nil { return nil } data.MarshalGQL(&buf) return &graphql.Response{ Data: buf.Bytes(), } } default: return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) } } type executionContext struct { *graphql.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: "inline_arguments_transformed_schema.graphql", Input: `directive @custom on ARGUMENT_DEFINITION directive @defer(if: Boolean = true, label: String) on FRAGMENT_SPREAD | INLINE_FRAGMENT directive @directive1 on FIELD_DEFINITION directive @directive2 on FIELD_DEFINITION directive @directive3 on INPUT_OBJECT directive @goField(forceResolver: Boolean, name: String, omittable: Boolean, type: String) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION directive @inlineArguments on ARGUMENT_DEFINITION directive @length(min: Int!, max: Int, message: String) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | FIELD_DEFINITION directive @logged(id: UUID!) on FIELD directive @makeNil on FIELD_DEFINITION directive @makeTypedNil on FIELD_DEFINITION directive @noop on ARGUMENT_DEFINITION directive @order1(location: String!) repeatable on FIELD_DEFINITION | OBJECT directive @order2(location: String!) on OBJECT directive @populate(value: String!) on ARGUMENT_DEFINITION directive @range(min: Int = 0, max: Int) on ARGUMENT_DEFINITION directive @toNull on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | FIELD_DEFINITION directive @unimplemented on FIELD_DEFINITION type A { id: ID! } type AIt { id: ID! } type AbIt { id: ID! } interface Animal { species: String! size: Size! } scalar Any type Autobind { int: Int! int32: Int! int64: Int! idStr: ID! idInt: ID! } type B { id: ID! } type BackedByInterface { id: String! thisShouldBind: String! thisShouldBindWithError: String! } scalar Bytes type Cat implements Animal { species: String! size: Size! catBreed: String! } input Changes @goModel(model: "map[string]interface{}") { a: Int b: Int } type CheckIssue896 { id: Int } type Circle implements Shape { radius: Float area: Float coordinates: Coordinates } type ConcreteNodeA implements Node { id: ID! child: Node! name: String! } """ Implements the Node interface with another interface """ type ConcreteNodeInterface implements Node { id: ID! child: Node! } union Content_Child = Content_User | Content_Post type Content_Post { foo: String } type Content_User { foo: String } type Coordinates { x: Float! y: Float! } scalar CustomScalar @goModel(model: "singlefile.CustomScalar") input DefaultInput { falsyBoolean: Boolean = false truthyBoolean: Boolean = true } type DefaultParametersMirror { falsyBoolean: Boolean truthyBoolean: Boolean } """ This doesnt have an implementation in the typemap, so it should act like a string """ scalar DefaultScalarImplementation type DeferModel { id: ID! name: String! values: [String!]! @goField(forceResolver: true) } input DirectiveInput @goModel(model: "map[string]interface{}") { oldField: String @deprecated(reason: "Use newField instead") newField: String } type Dog implements Animal { species: String! size: Size! dogBreed: String! } scalar Email type EmbeddedCase1 @goModel(model: "singlefile.EmbeddedCase1") { exportedEmbeddedPointerExportedMethod: String! } type EmbeddedCase2 @goModel(model: "singlefile.EmbeddedCase2") { unexportedEmbeddedPointerExportedMethod: String! } type EmbeddedCase3 @goModel(model: "singlefile.EmbeddedCase3") { unexportedEmbeddedInterfaceExportedMethod: String! } type EmbeddedDefaultScalar { value: DefaultScalarImplementation } type EmbeddedPointer @goModel(model: "singlefile.EmbeddedPointerModel") { ID: String Title: String } enum EnumTest { OK NG } type Error { id: ID! errorOnNonRequiredField: String errorOnRequiredField: String! nilOnRequiredField: String! } type Errors { a: Error! b: Error! c: Error! d: Error! e: Error! } enum FallbackToStringEncoding { A B C } input FieldsOrderInput { firstField: String overrideFirstField: String } type FieldsOrderPayload { firstFieldValue: String } type ForcedResolver { field: Circle @goField(forceResolver: true) } type Horse implements Mammalian & Animal { species: String! size: Size! horseBreed: String! } input InnerDirectives { message: String! @length(min: 1, message: "not valid") } input InnerInput { id: Int! } type InnerObject { id: Int! } input InputDirectives @directive3 { text: String! @length(min: 0, max: 7, message: "not valid") nullableText: String @toNull inner: InnerDirectives! innerNullable: InnerDirectives thirdParty: ThirdParty @length(min: 0, max: 7) } input InputWithEnumValue { enum: EnumTest! } type InvalidIdentifier { id: Int! } input Issue4053Input1 { input2: Issue4053Input2 } input Issue4053Input2 { hello: String helloWithDefault: String = "world" } type It { id: ID! } type LoopA { b: LoopB! } type LoopB { a: LoopA! } interface Mammalian implements Animal { species: String! size: Size! } """ Since gqlgen defines default implementation for a Map scalar, this tests that the builtin is _not_ added to the TypeMap """ type Map { id: ID! } type MapNested @goModel(model: "singlefile.MapNested") { value: CustomScalar! } input MapNestedInput @goModel(model: "singlefile.MapNested") { value: CustomScalar! } input MapNestedMapSliceInput @goModel(model: "map[string]interface{}") { name: String recurse: [MapNestedMapSliceInput!] } input MapStringInterfaceInput @goModel(model: "map[string]interface{}") { a: String! b: Int c: CustomScalar nested: MapNestedInput } type MapStringInterfaceType @goModel(model: "map[string]interface{}") { a: String b: Int c: CustomScalar nested: MapNested } scalar MarshalPanic type ModelMethods { resolverField: Boolean! noContext: Boolean! withContext: Boolean! } type Mutation { defaultInput(input: DefaultInput!): DefaultParametersMirror! overrideValueViaInput(input: FieldsOrderInput!): FieldsOrderPayload! updateProduct(id: ID!, name: String, price: Float): String! issue4053(input: Issue4053Input1): Boolean! updateSomething(input: SpecialInput!): String! updatePtrToPtr(input: UpdatePtrToPtrOuter!): PtrToPtrOuter! } input NestedInput { field: Email! } input NestedMapInput { map: MapStringInterfaceInput } interface Node { id: ID! child: Node! } type ObjectDirectives @order1(location: "order1_1") @order1(location: "order1_2") @order2(location: "order2_1") { text: String! @length(min: 0, max: 7, message: "not valid") nullableText: String @toNull order: [String!]! } type ObjectDirectivesWithCustomGoModel { nullableText: String @toNull } input OmittableInput { id: ID @goField(omittable: true) bool: Boolean @goField(omittable: true) str: String @goField(omittable: true) int: Int @goField(omittable: true) time: Time @goField(omittable: true) enum: Status @goField(omittable: true) scalar: ThirdParty @goField(omittable: true) object: OuterInput @goField(omittable: true) } input OuterInput { inner: InnerInput! } type OuterObject { inner: InnerObject! } input OuterWrapperInput { inner: InputDirectives! } type OverlappingFields { oneFoo: Int! @goField(name: "foo") twoFoo: Int! @goField(name: "foo") oldFoo: Int! @goField(name: "foo", forceResolver: true) newFoo: Int! new_foo: Int! } type Panics { fieldScalarMarshal: [MarshalPanic!]! fieldFuncMarshal(u: [MarshalPanic!]!): [MarshalPanic!]! argUnmarshal(u: [MarshalPanic!]!): Boolean! } type Pet { id: Int! friends(limit: Int): [Pet!] @goField(forceResolver: true) } type Primitive { value: Int! squared: Int! } type PrimitiveString { value: String! doubled: String! len: Int! } type PtrToAnyContainer { ptrToAny: Any binding: Any } type PtrToPtrInner { key: String! value: String! } type PtrToPtrOuter { name: String! inner: PtrToPtrInner stupidInner: PtrToPtrInner } type PtrToSliceContainer { ptrToSlice: [String!] } type Query { invalidIdentifier: InvalidIdentifier collision: It mapInput(input: Changes): Boolean recursive(input: RecursiveInputSlice): Boolean nestedInputs(input: [[OuterInput]] = [[{inner:{id:1}}]]): Boolean nestedOutputs: [[OuterObject]] modelMethods: ModelMethods user(id: Int!): User! nullableArg(arg: Int = 123): String inputSlice(arg: [String!]!): Boolean! inputNullableSlice(arg: [String!]): Boolean! inputOmittable(arg: OmittableInput!): String! shapeUnion: ShapeUnion! autobind: Autobind deprecatedField: String! @deprecated(reason: "test deprecated directive") fieldWithDeprecatedArg(oldArg: Int @deprecated(reason: "old arg"), newArg: Int): String overlapping: OverlappingFields defaultParameters(falsyBoolean: Boolean = false, truthyBoolean: Boolean = true): DefaultParametersMirror! deferSingle: DeferModel deferMultiple: [DeferModel!] directiveArg(arg: String! @length(min: 1, max: 255, message: "invalid length")): String directiveNullableArg(arg: Int @range(min: 0), arg2: Int @range, arg3: String @toNull): String directiveSingleNullableArg(arg1: String @populate(value: "test") @noop): String directiveInputNullable(arg: InputDirectives): String directiveInput(arg: InputDirectives!): String directiveInputType(arg: InnerInput! @custom): String directiveInputOuter(arg: OuterWrapperInput!): String directiveObject: ObjectDirectives @order1(location: "Query_field") directiveObjectWithCustomGoModel: ObjectDirectivesWithCustomGoModel directiveFieldDef(ret: String!): String! @length(min: 1, message: "not valid") directiveField: String directiveDouble: String @directive1 @directive2 directiveUnimplemented: String @unimplemented embeddedCase1: EmbeddedCase1 embeddedCase2: EmbeddedCase2 embeddedCase3: EmbeddedCase3 enumInInput(input: InputWithEnumValue): EnumTest! searchProducts(query: String, category: String, minPrice: Int): [String!]! searchRequired(name: String!, age: Int!): [String!]! searchProductsNormal(filters: SearchFilters): [String!]! searchWithDefaults(query: String = "default search", limit: Int = 20, includeArchived: Boolean = false): [String!]! searchMixed(query: String, category: String, minPrice: Int, limit: Int = 10, offset: Int = 0, sortBy: String): [String!]! filterProducts(query: String, category: String, minPrice: Int): [String!]! findProducts(query: String, category: String, minPrice: Int): [String!]! searchWithDirectives(oldField: String @deprecated(reason: "Use newField instead"), newField: String): [String!]! shapes: [Shape] noShape: Shape @makeNil node: Node! noShapeTypedNil: Shape @makeTypedNil animal: Animal @makeTypedNil notAnInterface: BackedByInterface dog: Dog issue896a: [CheckIssue896!] mapStringInterface(in: MapStringInterfaceInput): MapStringInterfaceType mapNestedStringInterface(in: NestedMapInput): MapStringInterfaceType mapNestedMapSlice(input: MapNestedMapSliceInput): Boolean errorBubble: Error errorBubbleList: [Error!] errorList: [Error] errors: Errors valid: String! invalid: String! panics: Panics primitiveObject: [Primitive!]! primitiveStringObject: [PrimitiveString!]! ptrToAnyContainer: PtrToAnyContainer! ptrToSliceContainer: PtrToSliceContainer! infinity: Float! stringFromContextInterface: StringFromContextInterface! stringFromContextFunction: StringFromContextFunction! defaultScalar(arg: DefaultScalarImplementation! = "default"): DefaultScalarImplementation! skipInclude: SkipIncludeTestType slices: Slices scalarSlice: Bytes! fallback(arg: FallbackToStringEncoding!): FallbackToStringEncoding! optionalUnion: TestUnion vOkCaseValue: VOkCaseValue vOkCaseNil: VOkCaseNil validType: ValidType variadicModel: VariadicModel wrappedStruct: WrappedStruct! wrappedScalar: WrappedScalar! wrappedMap: WrappedMap! wrappedSlice: WrappedSlice! } type Rectangle implements Shape { length: Float width: Float area: Float coordinates: Coordinates } input RecursiveInputSlice { self: [RecursiveInputSlice!] } input RequiredFilters @goModel(model: "map[string]interface{}") { name: String! age: Int! } input SearchFilters @goModel(model: "map[string]interface{}") { query: String category: String minPrice: Int } input SearchWithDefaults @goModel(model: "map[string]interface{}") { query: String = "default search" limit: Int = 20 includeArchived: Boolean = false } interface Shape { area: Float coordinates: Coordinates } union ShapeUnion @goModel(model: "singlefile.ShapeUnion") = Circle | Rectangle type Size { height: Int! weight: Int! } type SkipIncludeTestType { a: String b: String } type Slices { test1: [String] test2: [String!] test3: [String]! test4: [String!]! } input SpecialInput { nesting: NestedInput! } enum Status { OK ERROR } scalar StringFromContextFunction scalar StringFromContextInterface type Subscription { updated: String! initPayload: String! directiveArg(arg: String! @length(min: 1, max: 255, message: "invalid length")): String directiveNullableArg(arg: Int @range(min: 0), arg2: Int @range, arg3: String @toNull): String directiveDouble: String @directive1 @directive2 directiveUnimplemented: String @unimplemented issue896b: [CheckIssue896] errorRequired: Error! } union TestUnion = A | B scalar ThirdParty @goModel(model: "singlefile.ThirdParty") scalar Time scalar UUID input UpdateProductInput @goModel(model: "map[string]interface{}") { id: ID! name: String price: Float } input UpdatePtrToPtrInner { key: String value: String } input UpdatePtrToPtrOuter { name: String inner: UpdatePtrToPtrInner stupidInner: UpdatePtrToPtrInner } type User { id: Int! friends: [User!]! @goField(forceResolver: true) created: Time! updated: Time pets(limit: Int): [Pet!] @goField(forceResolver: true) } type VOkCaseNil @goModel(model: "singlefile.VOkCaseNil") { value: String } type VOkCaseValue @goModel(model: "singlefile.VOkCaseValue") { value: String } input ValidInput { break: String! default: String! func: String! interface: String! select: String! case: String! defer: String! go: String! map: String! struct: String! chan: String! else: String! goto: String! package: String! switch: String! const: String! fallthrough: String! if: String! range: String! type: String! continue: String! for: String! import: String! return: String! var: String! _: String! @goField(name: "Underscore") } """ These things are all valid, but without care generate invalid go code """ type ValidType { differentCase: String! different_case: String! @goField(name: "DifferentCaseOld") validInputKeywords(input: ValidInput): Boolean! validArgs(break: String!, default: String!, func: String!, interface: String!, select: String!, case: String!, defer: String!, go: String!, map: String!, struct: String!, chan: String!, else: String!, goto: String!, package: String!, switch: String!, const: String!, fallthrough: String!, if: String!, range: String!, type: String!, continue: String!, for: String!, import: String!, return: String!, var: String!, _: String!): Boolean! } type VariadicModel { value(rank: Int!): String } type WrappedMap { get(key: String!): String! } scalar WrappedScalar type WrappedSlice { get(idx: Int!): String! } type WrappedStruct { name: WrappedScalar! desc: WrappedScalar } type XXIt { id: ID! } type XxIt { id: ID! } type asdfIt { id: ID! } type iIt { id: ID! } `, BuiltIn: true}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) dir_defer_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, "if", ec.unmarshalOBoolean2ᚖbool) if err != nil { return nil, err } args["if"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "label", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["label"] = arg1 return args, nil } func (ec *executionContext) dir_length_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, "min", ec.unmarshalNInt2int) if err != nil { return nil, err } args["min"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "max", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["max"] = arg1 arg2, err := graphql.ProcessArgField(ctx, rawArgs, "message", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["message"] = arg2 return args, nil } func (ec *executionContext) dir_logged_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.unmarshalNUUID2string) if err != nil { return nil, err } args["id"] = arg0 return args, nil } func (ec *executionContext) dir_order1_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, "location", ec.unmarshalNString2string) if err != nil { return nil, err } args["location"] = arg0 return args, nil } func (ec *executionContext) dir_order2_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, "location", ec.unmarshalNString2string) if err != nil { return nil, err } args["location"] = arg0 return args, nil } func (ec *executionContext) dir_populate_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.unmarshalNString2string) if err != nil { return nil, err } args["value"] = arg0 return args, nil } func (ec *executionContext) dir_range_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, "min", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["min"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "max", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["max"] = arg1 return args, nil } func (ec *executionContext) field_Mutation_defaultInput_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalNDefaultInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDefaultInput) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Mutation_issue4053_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, "input", ec.unmarshalOIssue4053Input12ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐIssue4053Input1) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Mutation_overrideValueViaInput_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalNFieldsOrderInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐFieldsOrderInput) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Mutation_updateProduct_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.unmarshalNID2string) if err != nil { return nil, err } args["id"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "name", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["name"] = arg1 arg2, err := graphql.ProcessArgField(ctx, rawArgs, "price", ec.unmarshalOFloat2ᚖfloat64) if err != nil { return nil, err } args["price"] = arg2 return args, nil } func (ec *executionContext) field_Mutation_updatePtrToPtr_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, "input", ec.unmarshalNUpdatePtrToPtrOuter2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrOuter) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Mutation_updateSomething_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalNSpecialInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐSpecialInput) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Panics_argUnmarshal_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "u", ec.unmarshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanicᚄ) if err != nil { return nil, err } args["u"] = arg0 return args, nil } func (ec *executionContext) field_Panics_fieldFuncMarshal_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "u", ec.unmarshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanicᚄ) if err != nil { return nil, err } args["u"] = arg0 return args, nil } func (ec *executionContext) field_Pet_friends_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "limit", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["limit"] = arg0 return args, nil } func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]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_defaultParameters_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, "falsyBoolean", ec.unmarshalOBoolean2ᚖbool) if err != nil { return nil, err } args["falsyBoolean"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "truthyBoolean", ec.unmarshalOBoolean2ᚖbool) if err != nil { return nil, err } args["truthyBoolean"] = arg1 return args, nil } func (ec *executionContext) field_Query_defaultScalar_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "arg", ec.unmarshalNDefaultScalarImplementation2string) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_directiveArg_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Query_directiveArg_argsArg(ctx, rawArgs) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_directiveArg_argsArg( ctx context.Context, rawArgs map[string]any, ) (string, error) { if _, ok := rawArgs["arg"]; !ok { var zeroVal string return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("arg")) directive0 := func(ctx context.Context) (any, error) { tmp, ok := rawArgs["arg"] if !ok { var zeroVal string return zeroVal, nil } return ec.unmarshalNString2string(ctx, tmp) } directive1 := func(ctx context.Context) (any, error) { min, err := ec.unmarshalNInt2int(ctx, 1) if err != nil { var zeroVal string return zeroVal, err } max, err := ec.unmarshalOInt2ᚖint(ctx, 255) if err != nil { var zeroVal string return zeroVal, err } message, err := ec.unmarshalOString2ᚖstring(ctx, "invalid length") if err != nil { var zeroVal string return zeroVal, err } if ec.Directives.Length == nil { var zeroVal string return zeroVal, errors.New("directive length is not implemented") } return ec.Directives.Length(ctx, rawArgs, directive0, min, max, message) } tmp, err := directive1(ctx) if err != nil { var zeroVal string return zeroVal, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(string); ok { return data, nil } else { var zeroVal string return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp)) } } func (ec *executionContext) field_Query_directiveFieldDef_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, "ret", ec.unmarshalNString2string) if err != nil { return nil, err } args["ret"] = arg0 return args, nil } func (ec *executionContext) field_Query_directiveInputNullable_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "arg", ec.unmarshalOInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInputDirectives) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_directiveInputOuter_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, "arg", ec.unmarshalNOuterWrapperInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterWrapperInput) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_directiveInputType_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Query_directiveInputType_argsArg(ctx, rawArgs) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_directiveInputType_argsArg( ctx context.Context, rawArgs map[string]any, ) (InnerInput, error) { if _, ok := rawArgs["arg"]; !ok { var zeroVal InnerInput return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("arg")) directive0 := func(ctx context.Context) (any, error) { tmp, ok := rawArgs["arg"] if !ok { var zeroVal InnerInput return zeroVal, nil } return ec.unmarshalNInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInnerInput(ctx, tmp) } directive1 := func(ctx context.Context) (any, error) { if ec.Directives.Custom == nil { var zeroVal InnerInput return zeroVal, errors.New("directive custom is not implemented") } return ec.Directives.Custom(ctx, rawArgs, directive0) } tmp, err := directive1(ctx) if err != nil { var zeroVal InnerInput return zeroVal, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(InnerInput); ok { return data, nil } else { var zeroVal InnerInput return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be github.com/99designs/gqlgen/codegen/testserver/singlefile.InnerInput`, tmp)) } } func (ec *executionContext) field_Query_directiveInput_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, "arg", ec.unmarshalNInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInputDirectives) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_directiveNullableArg_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Query_directiveNullableArg_argsArg(ctx, rawArgs) if err != nil { return nil, err } args["arg"] = arg0 arg1, err := ec.field_Query_directiveNullableArg_argsArg2(ctx, rawArgs) if err != nil { return nil, err } args["arg2"] = arg1 arg2, err := ec.field_Query_directiveNullableArg_argsArg3(ctx, rawArgs) if err != nil { return nil, err } args["arg3"] = arg2 return args, nil } func (ec *executionContext) field_Query_directiveNullableArg_argsArg( ctx context.Context, rawArgs map[string]any, ) (*int, error) { if _, ok := rawArgs["arg"]; !ok { var zeroVal *int return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("arg")) directive0 := func(ctx context.Context) (any, error) { tmp, ok := rawArgs["arg"] if !ok { var zeroVal *int return zeroVal, nil } return ec.unmarshalOInt2ᚖint(ctx, tmp) } directive1 := func(ctx context.Context) (any, error) { min, err := ec.unmarshalOInt2ᚖint(ctx, 0) if err != nil { var zeroVal *int return zeroVal, err } if ec.Directives.Range == nil { var zeroVal *int return zeroVal, errors.New("directive range is not implemented") } return ec.Directives.Range(ctx, rawArgs, directive0, min, nil) } tmp, err := directive1(ctx) if err != nil { var zeroVal *int return zeroVal, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(*int); ok { return data, nil } else if tmp == nil { var zeroVal *int return zeroVal, nil } else { var zeroVal *int return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be *int`, tmp)) } } func (ec *executionContext) field_Query_directiveNullableArg_argsArg2( ctx context.Context, rawArgs map[string]any, ) (*int, error) { if _, ok := rawArgs["arg2"]; !ok { var zeroVal *int return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("arg2")) directive0 := func(ctx context.Context) (any, error) { tmp, ok := rawArgs["arg2"] if !ok { var zeroVal *int return zeroVal, nil } return ec.unmarshalOInt2ᚖint(ctx, tmp) } directive1 := func(ctx context.Context) (any, error) { min, err := ec.unmarshalOInt2ᚖint(ctx, 0) if err != nil { var zeroVal *int return zeroVal, err } if ec.Directives.Range == nil { var zeroVal *int return zeroVal, errors.New("directive range is not implemented") } return ec.Directives.Range(ctx, rawArgs, directive0, min, nil) } tmp, err := directive1(ctx) if err != nil { var zeroVal *int return zeroVal, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(*int); ok { return data, nil } else if tmp == nil { var zeroVal *int return zeroVal, nil } else { var zeroVal *int return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be *int`, tmp)) } } func (ec *executionContext) field_Query_directiveNullableArg_argsArg3( ctx context.Context, rawArgs map[string]any, ) (*string, error) { if _, ok := rawArgs["arg3"]; !ok { var zeroVal *string return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("arg3")) directive0 := func(ctx context.Context) (any, error) { tmp, ok := rawArgs["arg3"] if !ok { var zeroVal *string return zeroVal, nil } return ec.unmarshalOString2ᚖstring(ctx, tmp) } directive1 := func(ctx context.Context) (any, error) { if ec.Directives.ToNull == nil { var zeroVal *string return zeroVal, errors.New("directive toNull is not implemented") } return ec.Directives.ToNull(ctx, rawArgs, directive0) } tmp, err := directive1(ctx) if err != nil { var zeroVal *string return zeroVal, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(*string); ok { return data, nil } else if tmp == nil { var zeroVal *string return zeroVal, nil } else { var zeroVal *string return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp)) } } func (ec *executionContext) field_Query_directiveSingleNullableArg_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Query_directiveSingleNullableArg_argsArg1(ctx, rawArgs) if err != nil { return nil, err } args["arg1"] = arg0 return args, nil } func (ec *executionContext) field_Query_directiveSingleNullableArg_argsArg1( ctx context.Context, rawArgs map[string]any, ) (*string, error) { if _, ok := rawArgs["arg1"]; !ok { var zeroVal *string return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("arg1")) directive0 := func(ctx context.Context) (any, error) { tmp, ok := rawArgs["arg1"] if !ok { var zeroVal *string return zeroVal, nil } return ec.unmarshalOString2ᚖstring(ctx, tmp) } directive1 := func(ctx context.Context) (any, error) { value, err := ec.unmarshalNString2string(ctx, "test") if err != nil { var zeroVal *string return zeroVal, err } if ec.Directives.Populate == nil { var zeroVal *string return zeroVal, errors.New("directive populate is not implemented") } return ec.Directives.Populate(ctx, rawArgs, directive0, value) } directive2 := func(ctx context.Context) (any, error) { if ec.Directives.Noop == nil { var zeroVal *string return zeroVal, errors.New("directive noop is not implemented") } return ec.Directives.Noop(ctx, rawArgs, directive1) } tmp, err := directive2(ctx) if err != nil { var zeroVal *string return zeroVal, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(*string); ok { return data, nil } else if tmp == nil { var zeroVal *string return zeroVal, nil } else { var zeroVal *string return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp)) } } func (ec *executionContext) field_Query_enumInInput_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, "input", ec.unmarshalOInputWithEnumValue2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInputWithEnumValue) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Query_fallback_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "arg", ec.unmarshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐFallbackToStringEncoding) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_fieldWithDeprecatedArg_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, "oldArg", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["oldArg"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "newArg", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["newArg"] = arg1 return args, nil } func (ec *executionContext) field_Query_filterProducts_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, "query", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["query"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "category", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["category"] = arg1 arg2, err := graphql.ProcessArgField(ctx, rawArgs, "minPrice", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["minPrice"] = arg2 return args, nil } func (ec *executionContext) field_Query_findProducts_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, "query", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["query"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "category", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["category"] = arg1 arg2, err := graphql.ProcessArgField(ctx, rawArgs, "minPrice", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["minPrice"] = arg2 return args, nil } func (ec *executionContext) field_Query_inputNullableSlice_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, "arg", ec.unmarshalOString2ᚕstringᚄ) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_inputOmittable_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "arg", ec.unmarshalNOmittableInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOmittableInput) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_inputSlice_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "arg", ec.unmarshalNString2ᚕstringᚄ) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_mapInput_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalOChanges2map) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Query_mapNestedMapSlice_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, "input", ec.unmarshalOMapNestedMapSliceInput2map) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Query_mapNestedStringInterface_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "in", ec.unmarshalONestedMapInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐNestedMapInput) if err != nil { return nil, err } args["in"] = arg0 return args, nil } func (ec *executionContext) field_Query_mapStringInterface_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "in", ec.unmarshalOMapStringInterfaceInput2map) if err != nil { return nil, err } args["in"] = arg0 return args, nil } func (ec *executionContext) field_Query_nestedInputs_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalOOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterInput) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Query_nullableArg_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "arg", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Query_recursive_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", ec.unmarshalORecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐRecursiveInputSlice) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_Query_searchMixed_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, "query", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["query"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "category", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["category"] = arg1 arg2, err := graphql.ProcessArgField(ctx, rawArgs, "minPrice", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["minPrice"] = arg2 arg3, err := graphql.ProcessArgField(ctx, rawArgs, "limit", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["limit"] = arg3 arg4, err := graphql.ProcessArgField(ctx, rawArgs, "offset", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["offset"] = arg4 arg5, err := graphql.ProcessArgField(ctx, rawArgs, "sortBy", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["sortBy"] = arg5 return args, nil } func (ec *executionContext) field_Query_searchProductsNormal_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, "filters", ec.unmarshalOSearchFilters2map) if err != nil { return nil, err } args["filters"] = arg0 return args, nil } func (ec *executionContext) field_Query_searchProducts_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, "query", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["query"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "category", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["category"] = arg1 arg2, err := graphql.ProcessArgField(ctx, rawArgs, "minPrice", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["minPrice"] = arg2 return args, nil } func (ec *executionContext) field_Query_searchRequired_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 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "age", ec.unmarshalNInt2int) if err != nil { return nil, err } args["age"] = arg1 return args, nil } func (ec *executionContext) field_Query_searchWithDefaults_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, "query", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["query"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "limit", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["limit"] = arg1 arg2, err := graphql.ProcessArgField(ctx, rawArgs, "includeArchived", ec.unmarshalOBoolean2ᚖbool) if err != nil { return nil, err } args["includeArchived"] = arg2 return args, nil } func (ec *executionContext) field_Query_searchWithDirectives_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, "oldField", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["oldField"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "newField", ec.unmarshalOString2ᚖstring) if err != nil { return nil, err } args["newField"] = arg1 return args, nil } func (ec *executionContext) field_Query_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, "id", ec.unmarshalNInt2int) if err != nil { return nil, err } args["id"] = arg0 return args, nil } func (ec *executionContext) field_Subscription_directiveArg_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Subscription_directiveArg_argsArg(ctx, rawArgs) if err != nil { return nil, err } args["arg"] = arg0 return args, nil } func (ec *executionContext) field_Subscription_directiveArg_argsArg( ctx context.Context, rawArgs map[string]any, ) (string, error) { if _, ok := rawArgs["arg"]; !ok { var zeroVal string return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("arg")) directive0 := func(ctx context.Context) (any, error) { tmp, ok := rawArgs["arg"] if !ok { var zeroVal string return zeroVal, nil } return ec.unmarshalNString2string(ctx, tmp) } directive1 := func(ctx context.Context) (any, error) { min, err := ec.unmarshalNInt2int(ctx, 1) if err != nil { var zeroVal string return zeroVal, err } max, err := ec.unmarshalOInt2ᚖint(ctx, 255) if err != nil { var zeroVal string return zeroVal, err } message, err := ec.unmarshalOString2ᚖstring(ctx, "invalid length") if err != nil { var zeroVal string return zeroVal, err } if ec.Directives.Length == nil { var zeroVal string return zeroVal, errors.New("directive length is not implemented") } return ec.Directives.Length(ctx, rawArgs, directive0, min, max, message) } tmp, err := directive1(ctx) if err != nil { var zeroVal string return zeroVal, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(string); ok { return data, nil } else { var zeroVal string return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp)) } } func (ec *executionContext) field_Subscription_directiveNullableArg_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := ec.field_Subscription_directiveNullableArg_argsArg(ctx, rawArgs) if err != nil { return nil, err } args["arg"] = arg0 arg1, err := ec.field_Subscription_directiveNullableArg_argsArg2(ctx, rawArgs) if err != nil { return nil, err } args["arg2"] = arg1 arg2, err := ec.field_Subscription_directiveNullableArg_argsArg3(ctx, rawArgs) if err != nil { return nil, err } args["arg3"] = arg2 return args, nil } func (ec *executionContext) field_Subscription_directiveNullableArg_argsArg( ctx context.Context, rawArgs map[string]any, ) (*int, error) { if _, ok := rawArgs["arg"]; !ok { var zeroVal *int return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("arg")) directive0 := func(ctx context.Context) (any, error) { tmp, ok := rawArgs["arg"] if !ok { var zeroVal *int return zeroVal, nil } return ec.unmarshalOInt2ᚖint(ctx, tmp) } directive1 := func(ctx context.Context) (any, error) { min, err := ec.unmarshalOInt2ᚖint(ctx, 0) if err != nil { var zeroVal *int return zeroVal, err } if ec.Directives.Range == nil { var zeroVal *int return zeroVal, errors.New("directive range is not implemented") } return ec.Directives.Range(ctx, rawArgs, directive0, min, nil) } tmp, err := directive1(ctx) if err != nil { var zeroVal *int return zeroVal, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(*int); ok { return data, nil } else if tmp == nil { var zeroVal *int return zeroVal, nil } else { var zeroVal *int return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be *int`, tmp)) } } func (ec *executionContext) field_Subscription_directiveNullableArg_argsArg2( ctx context.Context, rawArgs map[string]any, ) (*int, error) { if _, ok := rawArgs["arg2"]; !ok { var zeroVal *int return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("arg2")) directive0 := func(ctx context.Context) (any, error) { tmp, ok := rawArgs["arg2"] if !ok { var zeroVal *int return zeroVal, nil } return ec.unmarshalOInt2ᚖint(ctx, tmp) } directive1 := func(ctx context.Context) (any, error) { min, err := ec.unmarshalOInt2ᚖint(ctx, 0) if err != nil { var zeroVal *int return zeroVal, err } if ec.Directives.Range == nil { var zeroVal *int return zeroVal, errors.New("directive range is not implemented") } return ec.Directives.Range(ctx, rawArgs, directive0, min, nil) } tmp, err := directive1(ctx) if err != nil { var zeroVal *int return zeroVal, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(*int); ok { return data, nil } else if tmp == nil { var zeroVal *int return zeroVal, nil } else { var zeroVal *int return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be *int`, tmp)) } } func (ec *executionContext) field_Subscription_directiveNullableArg_argsArg3( ctx context.Context, rawArgs map[string]any, ) (*string, error) { if _, ok := rawArgs["arg3"]; !ok { var zeroVal *string return zeroVal, nil } ctx = graphql.WithPathContext(ctx, graphql.NewPathWithField("arg3")) directive0 := func(ctx context.Context) (any, error) { tmp, ok := rawArgs["arg3"] if !ok { var zeroVal *string return zeroVal, nil } return ec.unmarshalOString2ᚖstring(ctx, tmp) } directive1 := func(ctx context.Context) (any, error) { if ec.Directives.ToNull == nil { var zeroVal *string return zeroVal, errors.New("directive toNull is not implemented") } return ec.Directives.ToNull(ctx, rawArgs, directive0) } tmp, err := directive1(ctx) if err != nil { var zeroVal *string return zeroVal, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(*string); ok { return data, nil } else if tmp == nil { var zeroVal *string return zeroVal, nil } else { var zeroVal *string return zeroVal, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp)) } } func (ec *executionContext) field_User_pets_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, "limit", ec.unmarshalOInt2ᚖint) if err != nil { return nil, err } args["limit"] = arg0 return args, nil } func (ec *executionContext) field_ValidType_validArgs_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "break", ec.unmarshalNString2string) if err != nil { return nil, err } args["break"] = arg0 arg1, err := graphql.ProcessArgField(ctx, rawArgs, "default", ec.unmarshalNString2string) if err != nil { return nil, err } args["default"] = arg1 arg2, err := graphql.ProcessArgField(ctx, rawArgs, "func", ec.unmarshalNString2string) if err != nil { return nil, err } args["func"] = arg2 arg3, err := graphql.ProcessArgField(ctx, rawArgs, "interface", ec.unmarshalNString2string) if err != nil { return nil, err } args["interface"] = arg3 arg4, err := graphql.ProcessArgField(ctx, rawArgs, "select", ec.unmarshalNString2string) if err != nil { return nil, err } args["select"] = arg4 arg5, err := graphql.ProcessArgField(ctx, rawArgs, "case", ec.unmarshalNString2string) if err != nil { return nil, err } args["case"] = arg5 arg6, err := graphql.ProcessArgField(ctx, rawArgs, "defer", ec.unmarshalNString2string) if err != nil { return nil, err } args["defer"] = arg6 arg7, err := graphql.ProcessArgField(ctx, rawArgs, "go", ec.unmarshalNString2string) if err != nil { return nil, err } args["go"] = arg7 arg8, err := graphql.ProcessArgField(ctx, rawArgs, "map", ec.unmarshalNString2string) if err != nil { return nil, err } args["map"] = arg8 arg9, err := graphql.ProcessArgField(ctx, rawArgs, "struct", ec.unmarshalNString2string) if err != nil { return nil, err } args["struct"] = arg9 arg10, err := graphql.ProcessArgField(ctx, rawArgs, "chan", ec.unmarshalNString2string) if err != nil { return nil, err } args["chan"] = arg10 arg11, err := graphql.ProcessArgField(ctx, rawArgs, "else", ec.unmarshalNString2string) if err != nil { return nil, err } args["else"] = arg11 arg12, err := graphql.ProcessArgField(ctx, rawArgs, "goto", ec.unmarshalNString2string) if err != nil { return nil, err } args["goto"] = arg12 arg13, err := graphql.ProcessArgField(ctx, rawArgs, "package", ec.unmarshalNString2string) if err != nil { return nil, err } args["package"] = arg13 arg14, err := graphql.ProcessArgField(ctx, rawArgs, "switch", ec.unmarshalNString2string) if err != nil { return nil, err } args["switch"] = arg14 arg15, err := graphql.ProcessArgField(ctx, rawArgs, "const", ec.unmarshalNString2string) if err != nil { return nil, err } args["const"] = arg15 arg16, err := graphql.ProcessArgField(ctx, rawArgs, "fallthrough", ec.unmarshalNString2string) if err != nil { return nil, err } args["fallthrough"] = arg16 arg17, err := graphql.ProcessArgField(ctx, rawArgs, "if", ec.unmarshalNString2string) if err != nil { return nil, err } args["if"] = arg17 arg18, err := graphql.ProcessArgField(ctx, rawArgs, "range", ec.unmarshalNString2string) if err != nil { return nil, err } args["range"] = arg18 arg19, err := graphql.ProcessArgField(ctx, rawArgs, "type", ec.unmarshalNString2string) if err != nil { return nil, err } args["type"] = arg19 arg20, err := graphql.ProcessArgField(ctx, rawArgs, "continue", ec.unmarshalNString2string) if err != nil { return nil, err } args["continue"] = arg20 arg21, err := graphql.ProcessArgField(ctx, rawArgs, "for", ec.unmarshalNString2string) if err != nil { return nil, err } args["for"] = arg21 arg22, err := graphql.ProcessArgField(ctx, rawArgs, "import", ec.unmarshalNString2string) if err != nil { return nil, err } args["import"] = arg22 arg23, err := graphql.ProcessArgField(ctx, rawArgs, "return", ec.unmarshalNString2string) if err != nil { return nil, err } args["return"] = arg23 arg24, err := graphql.ProcessArgField(ctx, rawArgs, "var", ec.unmarshalNString2string) if err != nil { return nil, err } args["var"] = arg24 arg25, err := graphql.ProcessArgField(ctx, rawArgs, "_", ec.unmarshalNString2string) if err != nil { return nil, err } args["_"] = arg25 return args, nil } func (ec *executionContext) field_ValidType_validInputKeywords_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, "input", ec.unmarshalOValidInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐValidInput) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func (ec *executionContext) field_VariadicModel_value_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "rank", ec.unmarshalNInt2int) if err != nil { return nil, err } args["rank"] = arg0 return args, nil } func (ec *executionContext) field_WrappedMap_get_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "key", ec.unmarshalNString2string) if err != nil { return nil, err } args["key"] = arg0 return args, nil } func (ec *executionContext) field_WrappedSlice_get_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} arg0, err := graphql.ProcessArgField(ctx, rawArgs, "idx", ec.unmarshalNInt2int) if err != nil { return nil, err } args["idx"] = 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) _fieldMiddleware(ctx context.Context, obj any, next graphql.Resolver) graphql.Resolver { fc := graphql.GetFieldContext(ctx) for _, d := range fc.Field.Directives { switch d.Name { case "logged": rawArgs := d.ArgumentMap(ec.Variables) args, err := ec.dir_logged_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return nil } n := next next = func(ctx context.Context) (any, error) { if ec.Directives.Logged == nil { return nil, errors.New("directive logged is not implemented") } return ec.Directives.Logged(ctx, obj, n, args["id"].(string)) } } } return next } // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _A_id(ctx context.Context, field graphql.CollectedField, obj *A) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_A_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_A_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "A", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _AIt_id(ctx context.Context, field graphql.CollectedField, obj *AIt) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_AIt_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_AIt_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AIt", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _AbIt_id(ctx context.Context, field graphql.CollectedField, obj *AbIt) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_AbIt_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_AbIt_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "AbIt", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _Autobind_int(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Autobind_int, func(ctx context.Context) (any, error) { return obj.Int, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_Autobind_int(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Autobind", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _Autobind_int32(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Autobind_int32, func(ctx context.Context) (any, error) { return obj.Int32, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int32, true, true, ) } func (ec *executionContext) fieldContext_Autobind_int32(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Autobind", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _Autobind_int64(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Autobind_int64, func(ctx context.Context) (any, error) { return obj.Int64, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int64, true, true, ) } func (ec *executionContext) fieldContext_Autobind_int64(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Autobind", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _Autobind_idStr(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Autobind_idStr, func(ctx context.Context) (any, error) { return obj.IdStr, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_Autobind_idStr(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Autobind", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _Autobind_idInt(ctx context.Context, field graphql.CollectedField, obj *Autobind) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Autobind_idInt, func(ctx context.Context) (any, error) { return obj.IdInt, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2int, true, true, ) } func (ec *executionContext) fieldContext_Autobind_idInt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Autobind", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _B_id(ctx context.Context, field graphql.CollectedField, obj *B) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_B_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_B_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "B", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _BackedByInterface_id(ctx context.Context, field graphql.CollectedField, obj BackedByInterface) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_BackedByInterface_id, func(ctx context.Context) (any, error) { return ec.Resolvers.BackedByInterface().ID(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_BackedByInterface_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "BackedByInterface", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _BackedByInterface_thisShouldBind(ctx context.Context, field graphql.CollectedField, obj BackedByInterface) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_BackedByInterface_thisShouldBind, func(ctx context.Context) (any, error) { return obj.ThisShouldBind(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_BackedByInterface_thisShouldBind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "BackedByInterface", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _BackedByInterface_thisShouldBindWithError(ctx context.Context, field graphql.CollectedField, obj BackedByInterface) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_BackedByInterface_thisShouldBindWithError, func(ctx context.Context) (any, error) { return obj.ThisShouldBindWithError() }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_BackedByInterface_thisShouldBindWithError(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "BackedByInterface", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Cat_species(ctx context.Context, field graphql.CollectedField, obj *Cat) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Cat_species, func(ctx context.Context) (any, error) { return obj.Species, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Cat_species(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Cat", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Cat_size(ctx context.Context, field graphql.CollectedField, obj *Cat) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Cat_size, func(ctx context.Context) (any, error) { return obj.Size, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNSize2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐSize, true, true, ) } func (ec *executionContext) fieldContext_Cat_size(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Cat", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "height": return ec.fieldContext_Size_height(ctx, field) case "weight": return ec.fieldContext_Size_weight(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Size", field.Name) }, } return fc, nil } func (ec *executionContext) _Cat_catBreed(ctx context.Context, field graphql.CollectedField, obj *Cat) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Cat_catBreed, func(ctx context.Context) (any, error) { return obj.CatBreed, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Cat_catBreed(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Cat", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _CheckIssue896_id(ctx context.Context, field graphql.CollectedField, obj *CheckIssue896) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_CheckIssue896_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOInt2ᚖint, true, false, ) } func (ec *executionContext) fieldContext_CheckIssue896_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "CheckIssue896", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.CollectedField, obj *Circle) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Circle_radius, func(ctx context.Context) (any, error) { return obj.Radius, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOFloat2float64, true, false, ) } func (ec *executionContext) fieldContext_Circle_radius(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Circle", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Float does not have child fields") }, } return fc, nil } func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.CollectedField, obj *Circle) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Circle_area, func(ctx context.Context) (any, error) { return obj.Area(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOFloat2float64, true, false, ) } func (ec *executionContext) fieldContext_Circle_area(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Circle", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Float does not have child fields") }, } return fc, nil } func (ec *executionContext) _Circle_coordinates(ctx context.Context, field graphql.CollectedField, obj *Circle) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Circle_coordinates, func(ctx context.Context) (any, error) { return obj.Coordinates, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOCoordinates2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCoordinates, true, false, ) } func (ec *executionContext) fieldContext_Circle_coordinates(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Circle", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "x": return ec.fieldContext_Coordinates_x(ctx, field) case "y": return ec.fieldContext_Coordinates_y(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Coordinates", field.Name) }, } return fc, nil } func (ec *executionContext) _ConcreteNodeA_id(ctx context.Context, field graphql.CollectedField, obj *ConcreteNodeA) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ConcreteNodeA_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_ConcreteNodeA_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ConcreteNodeA", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _ConcreteNodeA_child(ctx context.Context, field graphql.CollectedField, obj *ConcreteNodeA) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ConcreteNodeA_child, func(ctx context.Context) (any, error) { return obj.Child() }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐNode, true, true, ) } func (ec *executionContext) fieldContext_ConcreteNodeA_child(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ConcreteNodeA", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } return fc, nil } func (ec *executionContext) _ConcreteNodeA_name(ctx context.Context, field graphql.CollectedField, obj *ConcreteNodeA) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ConcreteNodeA_name, func(ctx context.Context) (any, error) { return obj.Name, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_ConcreteNodeA_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ConcreteNodeA", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _ConcreteNodeInterface_id(ctx context.Context, field graphql.CollectedField, obj ConcreteNodeInterface) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ConcreteNodeInterface_id, func(ctx context.Context) (any, error) { return obj.ID(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_ConcreteNodeInterface_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ConcreteNodeInterface", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _ConcreteNodeInterface_child(ctx context.Context, field graphql.CollectedField, obj ConcreteNodeInterface) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ConcreteNodeInterface_child, func(ctx context.Context) (any, error) { return obj.Child() }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐNode, true, true, ) } func (ec *executionContext) fieldContext_ConcreteNodeInterface_child(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ConcreteNodeInterface", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } return fc, nil } func (ec *executionContext) _Content_Post_foo(ctx context.Context, field graphql.CollectedField, obj *ContentPost) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Content_Post_foo, func(ctx context.Context) (any, error) { return obj.Foo, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Content_Post_foo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Content_Post", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Content_User_foo(ctx context.Context, field graphql.CollectedField, obj *ContentUser) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Content_User_foo, func(ctx context.Context) (any, error) { return obj.Foo, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Content_User_foo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Content_User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Coordinates_x(ctx context.Context, field graphql.CollectedField, obj *Coordinates) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Coordinates_x, func(ctx context.Context) (any, error) { return obj.X, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNFloat2float64, true, true, ) } func (ec *executionContext) fieldContext_Coordinates_x(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Coordinates", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Float does not have child fields") }, } return fc, nil } func (ec *executionContext) _Coordinates_y(ctx context.Context, field graphql.CollectedField, obj *Coordinates) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Coordinates_y, func(ctx context.Context) (any, error) { return obj.Y, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNFloat2float64, true, true, ) } func (ec *executionContext) fieldContext_Coordinates_y(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Coordinates", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Float does not have child fields") }, } return fc, nil } func (ec *executionContext) _DefaultParametersMirror_falsyBoolean(ctx context.Context, field graphql.CollectedField, obj *DefaultParametersMirror) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_DefaultParametersMirror_falsyBoolean, func(ctx context.Context) (any, error) { return obj.FalsyBoolean, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOBoolean2ᚖbool, true, false, ) } func (ec *executionContext) fieldContext_DefaultParametersMirror_falsyBoolean(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "DefaultParametersMirror", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } func (ec *executionContext) _DefaultParametersMirror_truthyBoolean(ctx context.Context, field graphql.CollectedField, obj *DefaultParametersMirror) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_DefaultParametersMirror_truthyBoolean, func(ctx context.Context) (any, error) { return obj.TruthyBoolean, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOBoolean2ᚖbool, true, false, ) } func (ec *executionContext) fieldContext_DefaultParametersMirror_truthyBoolean(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "DefaultParametersMirror", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } func (ec *executionContext) _DeferModel_id(ctx context.Context, field graphql.CollectedField, obj *DeferModel) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_DeferModel_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_DeferModel_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "DeferModel", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _DeferModel_name(ctx context.Context, field graphql.CollectedField, obj *DeferModel) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_DeferModel_name, func(ctx context.Context) (any, error) { return obj.Name, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_DeferModel_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "DeferModel", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _DeferModel_values(ctx context.Context, field graphql.CollectedField, obj *DeferModel) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_DeferModel_values, func(ctx context.Context) (any, error) { return ec.Resolvers.DeferModel().Values(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2ᚕstringᚄ, true, true, ) } func (ec *executionContext) fieldContext_DeferModel_values(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "DeferModel", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Dog_species(ctx context.Context, field graphql.CollectedField, obj *Dog) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Dog_species, func(ctx context.Context) (any, error) { return obj.Species, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Dog_species(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Dog", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Dog_size(ctx context.Context, field graphql.CollectedField, obj *Dog) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Dog_size, func(ctx context.Context) (any, error) { return obj.Size, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNSize2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐSize, true, true, ) } func (ec *executionContext) fieldContext_Dog_size(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Dog", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "height": return ec.fieldContext_Size_height(ctx, field) case "weight": return ec.fieldContext_Size_weight(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Size", field.Name) }, } return fc, nil } func (ec *executionContext) _Dog_dogBreed(ctx context.Context, field graphql.CollectedField, obj *Dog) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Dog_dogBreed, func(ctx context.Context) (any, error) { return obj.DogBreed, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Dog_dogBreed(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Dog", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _EmbeddedCase1_exportedEmbeddedPointerExportedMethod(ctx context.Context, field graphql.CollectedField, obj *EmbeddedCase1) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_EmbeddedCase1_exportedEmbeddedPointerExportedMethod, func(ctx context.Context) (any, error) { return obj.ExportedEmbeddedPointerExportedMethod(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_EmbeddedCase1_exportedEmbeddedPointerExportedMethod(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "EmbeddedCase1", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _EmbeddedCase2_unexportedEmbeddedPointerExportedMethod(ctx context.Context, field graphql.CollectedField, obj *EmbeddedCase2) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_EmbeddedCase2_unexportedEmbeddedPointerExportedMethod, func(ctx context.Context) (any, error) { return obj.UnexportedEmbeddedPointerExportedMethod(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_EmbeddedCase2_unexportedEmbeddedPointerExportedMethod(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "EmbeddedCase2", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _EmbeddedCase3_unexportedEmbeddedInterfaceExportedMethod(ctx context.Context, field graphql.CollectedField, obj *EmbeddedCase3) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_EmbeddedCase3_unexportedEmbeddedInterfaceExportedMethod, func(ctx context.Context) (any, error) { return obj.UnexportedEmbeddedInterfaceExportedMethod(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_EmbeddedCase3_unexportedEmbeddedInterfaceExportedMethod(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "EmbeddedCase3", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _EmbeddedDefaultScalar_value(ctx context.Context, field graphql.CollectedField, obj *EmbeddedDefaultScalar) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_EmbeddedDefaultScalar_value, func(ctx context.Context) (any, error) { return obj.Value, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalODefaultScalarImplementation2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_EmbeddedDefaultScalar_value(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "EmbeddedDefaultScalar", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type DefaultScalarImplementation does not have child fields") }, } return fc, nil } func (ec *executionContext) _EmbeddedPointer_ID(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_EmbeddedPointer_ID, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2string, true, false, ) } func (ec *executionContext) fieldContext_EmbeddedPointer_ID(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "EmbeddedPointer", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _EmbeddedPointer_Title(ctx context.Context, field graphql.CollectedField, obj *EmbeddedPointerModel) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_EmbeddedPointer_Title, func(ctx context.Context) (any, error) { return obj.Title, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2string, true, false, ) } func (ec *executionContext) fieldContext_EmbeddedPointer_Title(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "EmbeddedPointer", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Error_id(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Error_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_Error_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Error", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _Error_errorOnNonRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Error_errorOnNonRequiredField, func(ctx context.Context) (any, error) { return obj.ErrorOnNonRequiredField() }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2string, true, false, ) } func (ec *executionContext) fieldContext_Error_errorOnNonRequiredField(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Error", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Error_errorOnRequiredField, func(ctx context.Context) (any, error) { return obj.ErrorOnRequiredField() }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Error_errorOnRequiredField(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Error", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Error_nilOnRequiredField(ctx context.Context, field graphql.CollectedField, obj *Error) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Error_nilOnRequiredField, func(ctx context.Context) (any, error) { return obj.NilOnRequiredField(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2ᚖstring, true, true, ) } func (ec *executionContext) fieldContext_Error_nilOnRequiredField(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Error", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Errors_a(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Errors_a, func(ctx context.Context) (any, error) { return ec.Resolvers.Errors().A(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError, true, true, ) } func (ec *executionContext) fieldContext_Errors_a(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Errors", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Error_id(ctx, field) case "errorOnNonRequiredField": return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) case "errorOnRequiredField": return ec.fieldContext_Error_errorOnRequiredField(ctx, field) case "nilOnRequiredField": return ec.fieldContext_Error_nilOnRequiredField(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) }, } return fc, nil } func (ec *executionContext) _Errors_b(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Errors_b, func(ctx context.Context) (any, error) { return ec.Resolvers.Errors().B(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError, true, true, ) } func (ec *executionContext) fieldContext_Errors_b(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Errors", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Error_id(ctx, field) case "errorOnNonRequiredField": return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) case "errorOnRequiredField": return ec.fieldContext_Error_errorOnRequiredField(ctx, field) case "nilOnRequiredField": return ec.fieldContext_Error_nilOnRequiredField(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) }, } return fc, nil } func (ec *executionContext) _Errors_c(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Errors_c, func(ctx context.Context) (any, error) { return ec.Resolvers.Errors().C(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError, true, true, ) } func (ec *executionContext) fieldContext_Errors_c(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Errors", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Error_id(ctx, field) case "errorOnNonRequiredField": return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) case "errorOnRequiredField": return ec.fieldContext_Error_errorOnRequiredField(ctx, field) case "nilOnRequiredField": return ec.fieldContext_Error_nilOnRequiredField(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) }, } return fc, nil } func (ec *executionContext) _Errors_d(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Errors_d, func(ctx context.Context) (any, error) { return ec.Resolvers.Errors().D(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError, true, true, ) } func (ec *executionContext) fieldContext_Errors_d(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Errors", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Error_id(ctx, field) case "errorOnNonRequiredField": return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) case "errorOnRequiredField": return ec.fieldContext_Error_errorOnRequiredField(ctx, field) case "nilOnRequiredField": return ec.fieldContext_Error_nilOnRequiredField(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) }, } return fc, nil } func (ec *executionContext) _Errors_e(ctx context.Context, field graphql.CollectedField, obj *Errors) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Errors_e, func(ctx context.Context) (any, error) { return ec.Resolvers.Errors().E(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError, true, true, ) } func (ec *executionContext) fieldContext_Errors_e(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Errors", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Error_id(ctx, field) case "errorOnNonRequiredField": return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) case "errorOnRequiredField": return ec.fieldContext_Error_errorOnRequiredField(ctx, field) case "nilOnRequiredField": return ec.fieldContext_Error_nilOnRequiredField(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) }, } return fc, nil } func (ec *executionContext) _FieldsOrderPayload_firstFieldValue(ctx context.Context, field graphql.CollectedField, obj *FieldsOrderPayload) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_FieldsOrderPayload_firstFieldValue, func(ctx context.Context) (any, error) { return obj.FirstFieldValue, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_FieldsOrderPayload_firstFieldValue(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "FieldsOrderPayload", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field graphql.CollectedField, obj *ForcedResolver) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ForcedResolver_field, func(ctx context.Context) (any, error) { return ec.Resolvers.ForcedResolver().Field(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOCircle2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCircle, true, false, ) } func (ec *executionContext) fieldContext_ForcedResolver_field(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ForcedResolver", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "radius": return ec.fieldContext_Circle_radius(ctx, field) case "area": return ec.fieldContext_Circle_area(ctx, field) case "coordinates": return ec.fieldContext_Circle_coordinates(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Circle", field.Name) }, } return fc, nil } func (ec *executionContext) _Horse_species(ctx context.Context, field graphql.CollectedField, obj *Horse) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Horse_species, func(ctx context.Context) (any, error) { return obj.Species, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Horse_species(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Horse", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Horse_size(ctx context.Context, field graphql.CollectedField, obj *Horse) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Horse_size, func(ctx context.Context) (any, error) { return obj.Size, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNSize2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐSize, true, true, ) } func (ec *executionContext) fieldContext_Horse_size(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Horse", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "height": return ec.fieldContext_Size_height(ctx, field) case "weight": return ec.fieldContext_Size_weight(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Size", field.Name) }, } return fc, nil } func (ec *executionContext) _Horse_horseBreed(ctx context.Context, field graphql.CollectedField, obj *Horse) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Horse_horseBreed, func(ctx context.Context) (any, error) { return obj.HorseBreed, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Horse_horseBreed(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Horse", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _InnerObject_id(ctx context.Context, field graphql.CollectedField, obj *InnerObject) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_InnerObject_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_InnerObject_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "InnerObject", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _InvalidIdentifier_id(ctx context.Context, field graphql.CollectedField, obj *invalid_packagename.InvalidIdentifier) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_InvalidIdentifier_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_InvalidIdentifier_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "InvalidIdentifier", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedField, obj *introspection1.It) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_It_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_It_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "It", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _LoopA_b(ctx context.Context, field graphql.CollectedField, obj *LoopA) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_LoopA_b, func(ctx context.Context) (any, error) { return obj.B, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNLoopB2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐLoopB, true, true, ) } func (ec *executionContext) fieldContext_LoopA_b(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "LoopA", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "a": return ec.fieldContext_LoopB_a(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type LoopB", field.Name) }, } return fc, nil } func (ec *executionContext) _LoopB_a(ctx context.Context, field graphql.CollectedField, obj *LoopB) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_LoopB_a, func(ctx context.Context) (any, error) { return obj.A, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNLoopA2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐLoopA, true, true, ) } func (ec *executionContext) fieldContext_LoopB_a(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "LoopB", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "b": return ec.fieldContext_LoopA_b(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type LoopA", field.Name) }, } return fc, nil } func (ec *executionContext) _Map_id(ctx context.Context, field graphql.CollectedField, obj *Map) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Map_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_Map_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Map", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _MapNested_value(ctx context.Context, field graphql.CollectedField, obj *MapNested) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_MapNested_value, func(ctx context.Context) (any, error) { return obj.Value, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNCustomScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCustomScalar, true, true, ) } func (ec *executionContext) fieldContext_MapNested_value(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MapNested", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type CustomScalar does not have child fields") }, } return fc, nil } func (ec *executionContext) _MapStringInterfaceType_a(ctx context.Context, field graphql.CollectedField, obj map[string]any) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_MapStringInterfaceType_a, func(ctx context.Context) (any, error) { switch v := obj["a"].(type) { case *string: return v, nil case string: return &v, nil case nil: return (*string)(nil), nil default: return nil, fmt.Errorf("unexpected type %T for field %s", v, "a") } }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_MapStringInterfaceType_a(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MapStringInterfaceType", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _MapStringInterfaceType_b(ctx context.Context, field graphql.CollectedField, obj map[string]any) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_MapStringInterfaceType_b, func(ctx context.Context) (any, error) { switch v := obj["b"].(type) { case *int: return v, nil case int: return &v, nil case nil: return (*int)(nil), nil default: return nil, fmt.Errorf("unexpected type %T for field %s", v, "b") } }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOInt2ᚖint, true, false, ) } func (ec *executionContext) fieldContext_MapStringInterfaceType_b(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MapStringInterfaceType", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _MapStringInterfaceType_c(ctx context.Context, field graphql.CollectedField, obj map[string]any) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_MapStringInterfaceType_c, func(ctx context.Context) (any, error) { switch v := obj["c"].(type) { case *CustomScalar: return v, nil case CustomScalar: return &v, nil case nil: return (*CustomScalar)(nil), nil default: return nil, fmt.Errorf("unexpected type %T for field %s", v, "c") } }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOCustomScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCustomScalar, true, false, ) } func (ec *executionContext) fieldContext_MapStringInterfaceType_c(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MapStringInterfaceType", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type CustomScalar does not have child fields") }, } return fc, nil } func (ec *executionContext) _MapStringInterfaceType_nested(ctx context.Context, field graphql.CollectedField, obj map[string]any) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_MapStringInterfaceType_nested, func(ctx context.Context) (any, error) { switch v := obj["nested"].(type) { case *MapNested: return v, nil case MapNested: return &v, nil case nil: return (*MapNested)(nil), nil default: return nil, fmt.Errorf("unexpected type %T for field %s", v, "nested") } }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOMapNested2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMapNested, true, false, ) } func (ec *executionContext) fieldContext_MapStringInterfaceType_nested(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MapStringInterfaceType", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "value": return ec.fieldContext_MapNested_value(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type MapNested", field.Name) }, } return fc, nil } func (ec *executionContext) _ModelMethods_resolverField(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ModelMethods_resolverField, func(ctx context.Context) (any, error) { return ec.Resolvers.ModelMethods().ResolverField(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNBoolean2bool, true, true, ) } func (ec *executionContext) fieldContext_ModelMethods_resolverField(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ModelMethods", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } func (ec *executionContext) _ModelMethods_noContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ModelMethods_noContext, func(ctx context.Context) (any, error) { return obj.NoContext(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNBoolean2bool, true, true, ) } func (ec *executionContext) fieldContext_ModelMethods_noContext(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ModelMethods", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } func (ec *executionContext) _ModelMethods_withContext(ctx context.Context, field graphql.CollectedField, obj *ModelMethods) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ModelMethods_withContext, func(ctx context.Context) (any, error) { return obj.WithContext(ctx), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNBoolean2bool, true, true, ) } func (ec *executionContext) fieldContext_ModelMethods_withContext(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ModelMethods", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } func (ec *executionContext) _Mutation_defaultInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Mutation_defaultInput, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Mutation().DefaultInput(ctx, fc.Args["input"].(DefaultInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNDefaultParametersMirror2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDefaultParametersMirror, true, true, ) } func (ec *executionContext) fieldContext_Mutation_defaultInput(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "falsyBoolean": return ec.fieldContext_DefaultParametersMirror_falsyBoolean(ctx, field) case "truthyBoolean": return ec.fieldContext_DefaultParametersMirror_truthyBoolean(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type DefaultParametersMirror", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_defaultInput_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Mutation_overrideValueViaInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Mutation_overrideValueViaInput, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Mutation().OverrideValueViaInput(ctx, fc.Args["input"].(FieldsOrderInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNFieldsOrderPayload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐFieldsOrderPayload, true, true, ) } func (ec *executionContext) fieldContext_Mutation_overrideValueViaInput(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "firstFieldValue": return ec.fieldContext_FieldsOrderPayload_firstFieldValue(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type FieldsOrderPayload", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_overrideValueViaInput_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Mutation_updateProduct(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Mutation_updateProduct, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Mutation().UpdateProduct(ctx, map[string]interface{}{ "id": fc.Args["id"].(string), "name": fc.Args["name"].(*string), "price": fc.Args["price"].(*float64), }) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Mutation_updateProduct(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_updateProduct_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Mutation_issue4053(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Mutation_issue4053, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Mutation().Issue4053(ctx, fc.Args["input"].(*Issue4053Input1)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNBoolean2bool, true, true, ) } func (ec *executionContext) fieldContext_Mutation_issue4053(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type 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_Mutation_issue4053_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Mutation_updateSomething(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Mutation_updateSomething, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Mutation().UpdateSomething(ctx, fc.Args["input"].(SpecialInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Mutation_updateSomething(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_updateSomething_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Mutation_updatePtrToPtr(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Mutation_updatePtrToPtr, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Mutation().UpdatePtrToPtr(ctx, fc.Args["input"].(UpdatePtrToPtrOuter)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNPtrToPtrOuter2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrOuter, true, true, ) } func (ec *executionContext) fieldContext_Mutation_updatePtrToPtr(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "name": return ec.fieldContext_PtrToPtrOuter_name(ctx, field) case "inner": return ec.fieldContext_PtrToPtrOuter_inner(ctx, field) case "stupidInner": return ec.fieldContext_PtrToPtrOuter_stupidInner(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type PtrToPtrOuter", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Mutation_updatePtrToPtr_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _ObjectDirectives_text(ctx context.Context, field graphql.CollectedField, obj *ObjectDirectives) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ObjectDirectives_text, func(ctx context.Context) (any, error) { return obj.Text, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { min, err := ec.unmarshalNInt2int(ctx, 0) if err != nil { var zeroVal string return zeroVal, err } max, err := ec.unmarshalOInt2ᚖint(ctx, 7) if err != nil { var zeroVal string return zeroVal, err } message, err := ec.unmarshalOString2ᚖstring(ctx, "not valid") if err != nil { var zeroVal string return zeroVal, err } if ec.Directives.Length == nil { var zeroVal string return zeroVal, errors.New("directive length is not implemented") } return ec.Directives.Length(ctx, obj, directive0, min, max, message) } next = directive1 return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_ObjectDirectives_text(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ObjectDirectives", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _ObjectDirectives_nullableText(ctx context.Context, field graphql.CollectedField, obj *ObjectDirectives) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ObjectDirectives_nullableText, func(ctx context.Context) (any, error) { return obj.NullableText, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { if ec.Directives.ToNull == nil { var zeroVal *string return zeroVal, errors.New("directive toNull is not implemented") } return ec.Directives.ToNull(ctx, obj, directive0) } next = directive1 return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_ObjectDirectives_nullableText(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ObjectDirectives", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _ObjectDirectives_order(ctx context.Context, field graphql.CollectedField, obj *ObjectDirectives) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ObjectDirectives_order, func(ctx context.Context) (any, error) { return obj.Order, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2ᚕstringᚄ, true, true, ) } func (ec *executionContext) fieldContext_ObjectDirectives_order(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ObjectDirectives", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _ObjectDirectivesWithCustomGoModel_nullableText(ctx context.Context, field graphql.CollectedField, obj *ObjectDirectivesWithCustomGoModel) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ObjectDirectivesWithCustomGoModel_nullableText, func(ctx context.Context) (any, error) { return obj.NullableText, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { if ec.Directives.ToNull == nil { var zeroVal string return zeroVal, errors.New("directive toNull is not implemented") } return ec.Directives.ToNull(ctx, obj, directive0) } next = directive1 return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2string, true, false, ) } func (ec *executionContext) fieldContext_ObjectDirectivesWithCustomGoModel_nullableText(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ObjectDirectivesWithCustomGoModel", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphql.CollectedField, obj *OuterObject) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_OuterObject_inner, func(ctx context.Context) (any, error) { return obj.Inner, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInnerObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInnerObject, true, true, ) } func (ec *executionContext) fieldContext_OuterObject_inner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "OuterObject", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_InnerObject_id(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type InnerObject", field.Name) }, } return fc, nil } func (ec *executionContext) _OverlappingFields_oneFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_OverlappingFields_oneFoo, func(ctx context.Context) (any, error) { return obj.Foo, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_OverlappingFields_oneFoo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "OverlappingFields", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _OverlappingFields_twoFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_OverlappingFields_twoFoo, func(ctx context.Context) (any, error) { return obj.Foo, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_OverlappingFields_twoFoo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "OverlappingFields", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _OverlappingFields_oldFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_OverlappingFields_oldFoo, func(ctx context.Context) (any, error) { return ec.Resolvers.OverlappingFields().OldFoo(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_OverlappingFields_oldFoo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "OverlappingFields", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _OverlappingFields_newFoo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_OverlappingFields_newFoo, func(ctx context.Context) (any, error) { return obj.NewFoo, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_OverlappingFields_newFoo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "OverlappingFields", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _OverlappingFields_new_foo(ctx context.Context, field graphql.CollectedField, obj *OverlappingFields) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_OverlappingFields_new_foo, func(ctx context.Context) (any, error) { return obj.NewFoo, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_OverlappingFields_new_foo(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "OverlappingFields", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _Panics_fieldScalarMarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Panics_fieldScalarMarshal, func(ctx context.Context) (any, error) { return ec.Resolvers.Panics().FieldScalarMarshal(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanicᚄ, true, true, ) } func (ec *executionContext) fieldContext_Panics_fieldScalarMarshal(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Panics", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type MarshalPanic does not have child fields") }, } return fc, nil } func (ec *executionContext) _Panics_fieldFuncMarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Panics_fieldFuncMarshal, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return obj.FieldFuncMarshal(ctx, fc.Args["u"].([]MarshalPanic)), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanicᚄ, true, true, ) } func (ec *executionContext) fieldContext_Panics_fieldFuncMarshal(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Panics", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type MarshalPanic does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Panics_fieldFuncMarshal_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Panics_argUnmarshal(ctx context.Context, field graphql.CollectedField, obj *Panics) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Panics_argUnmarshal, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Panics().ArgUnmarshal(ctx, obj, fc.Args["u"].([]MarshalPanic)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNBoolean2bool, true, true, ) } func (ec *executionContext) fieldContext_Panics_argUnmarshal(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Panics", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Panics_argUnmarshal_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Pet_id(ctx context.Context, field graphql.CollectedField, obj *Pet) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Pet_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_Pet_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Pet", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _Pet_friends(ctx context.Context, field graphql.CollectedField, obj *Pet) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Pet_friends, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Pet().Friends(ctx, obj, fc.Args["limit"].(*int)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOPet2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPetᚄ, true, false, ) } func (ec *executionContext) fieldContext_Pet_friends(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Pet", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Pet_id(ctx, field) case "friends": return ec.fieldContext_Pet_friends(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Pet", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Pet_friends_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Primitive_value(ctx context.Context, field graphql.CollectedField, obj *Primitive) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Primitive_value, func(ctx context.Context) (any, error) { return ec.Resolvers.Primitive().Value(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_Primitive_value(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Primitive", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _Primitive_squared(ctx context.Context, field graphql.CollectedField, obj *Primitive) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Primitive_squared, func(ctx context.Context) (any, error) { return obj.Squared(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_Primitive_squared(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Primitive", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _PrimitiveString_value(ctx context.Context, field graphql.CollectedField, obj *PrimitiveString) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PrimitiveString_value, func(ctx context.Context) (any, error) { return ec.Resolvers.PrimitiveString().Value(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_PrimitiveString_value(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PrimitiveString", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _PrimitiveString_doubled(ctx context.Context, field graphql.CollectedField, obj *PrimitiveString) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PrimitiveString_doubled, func(ctx context.Context) (any, error) { return obj.Doubled(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_PrimitiveString_doubled(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PrimitiveString", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _PrimitiveString_len(ctx context.Context, field graphql.CollectedField, obj *PrimitiveString) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PrimitiveString_len, func(ctx context.Context) (any, error) { return ec.Resolvers.PrimitiveString().Len(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_PrimitiveString_len(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PrimitiveString", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _PtrToAnyContainer_ptrToAny(ctx context.Context, field graphql.CollectedField, obj *PtrToAnyContainer) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PtrToAnyContainer_ptrToAny, func(ctx context.Context) (any, error) { return obj.PtrToAny, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOAny2ᚖinterface, true, false, ) } func (ec *executionContext) fieldContext_PtrToAnyContainer_ptrToAny(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PtrToAnyContainer", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Any does not have child fields") }, } return fc, nil } func (ec *executionContext) _PtrToAnyContainer_binding(ctx context.Context, field graphql.CollectedField, obj *PtrToAnyContainer) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PtrToAnyContainer_binding, func(ctx context.Context) (any, error) { return obj.Binding(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOAny2ᚖinterface, true, false, ) } func (ec *executionContext) fieldContext_PtrToAnyContainer_binding(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PtrToAnyContainer", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Any does not have child fields") }, } return fc, nil } func (ec *executionContext) _PtrToPtrInner_key(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrInner) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PtrToPtrInner_key, func(ctx context.Context) (any, error) { return obj.Key, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_PtrToPtrInner_key(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PtrToPtrInner", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _PtrToPtrInner_value(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrInner) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PtrToPtrInner_value, func(ctx context.Context) (any, error) { return obj.Value, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_PtrToPtrInner_value(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PtrToPtrInner", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _PtrToPtrOuter_name(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrOuter) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PtrToPtrOuter_name, func(ctx context.Context) (any, error) { return obj.Name, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_PtrToPtrOuter_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PtrToPtrOuter", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _PtrToPtrOuter_inner(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrOuter) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PtrToPtrOuter_inner, func(ctx context.Context) (any, error) { return obj.Inner, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOPtrToPtrInner2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner, true, false, ) } func (ec *executionContext) fieldContext_PtrToPtrOuter_inner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PtrToPtrOuter", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "key": return ec.fieldContext_PtrToPtrInner_key(ctx, field) case "value": return ec.fieldContext_PtrToPtrInner_value(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type PtrToPtrInner", field.Name) }, } return fc, nil } func (ec *executionContext) _PtrToPtrOuter_stupidInner(ctx context.Context, field graphql.CollectedField, obj *PtrToPtrOuter) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PtrToPtrOuter_stupidInner, func(ctx context.Context) (any, error) { return obj.StupidInner, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner, true, false, ) } func (ec *executionContext) fieldContext_PtrToPtrOuter_stupidInner(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PtrToPtrOuter", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "key": return ec.fieldContext_PtrToPtrInner_key(ctx, field) case "value": return ec.fieldContext_PtrToPtrInner_value(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type PtrToPtrInner", field.Name) }, } return fc, nil } func (ec *executionContext) _PtrToSliceContainer_ptrToSlice(ctx context.Context, field graphql.CollectedField, obj *PtrToSliceContainer) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_PtrToSliceContainer_ptrToSlice, func(ctx context.Context) (any, error) { return obj.PtrToSlice, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2ᚖᚕstringᚄ, true, false, ) } func (ec *executionContext) fieldContext_PtrToSliceContainer_ptrToSlice(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "PtrToSliceContainer", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_invalidIdentifier, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().InvalidIdentifier(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOInvalidIdentifier2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋinvalidᚑpackagenameᚐInvalidIdentifier, true, false, ) } func (ec *executionContext) fieldContext_Query_invalidIdentifier(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_InvalidIdentifier_id(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type InvalidIdentifier", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_collision(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_collision, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Collision(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOIt2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋintrospectionᚐIt, true, false, ) } func (ec *executionContext) fieldContext_Query_collision(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_It_id(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type It", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_mapInput, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().MapInput(ctx, fc.Args["input"].(map[string]any)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOBoolean2ᚖbool, true, false, ) } func (ec *executionContext) fieldContext_Query_mapInput(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_mapInput_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_recursive, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().Recursive(ctx, fc.Args["input"].(*RecursiveInputSlice)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOBoolean2ᚖbool, true, false, ) } func (ec *executionContext) fieldContext_Query_recursive(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_recursive_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_nestedInputs, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().NestedInputs(ctx, fc.Args["input"].([][]*OuterInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOBoolean2ᚖbool, true, false, ) } func (ec *executionContext) fieldContext_Query_nestedInputs(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_nestedInputs_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_nestedOutputs, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().NestedOutputs(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOOuterObject2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterObject, true, false, ) } func (ec *executionContext) fieldContext_Query_nestedOutputs(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "inner": return ec.fieldContext_OuterObject_inner(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type OuterObject", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_modelMethods(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_modelMethods, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().ModelMethods(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOModelMethods2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐModelMethods, true, false, ) } func (ec *executionContext) fieldContext_Query_modelMethods(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "resolverField": return ec.fieldContext_ModelMethods_resolverField(ctx, field) case "noContext": return ec.fieldContext_ModelMethods_noContext(ctx, field) case "withContext": return ec.fieldContext_ModelMethods_withContext(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type ModelMethods", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_user, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().User(ctx, fc.Args["id"].(int)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUser, true, true, ) } func (ec *executionContext) fieldContext_Query_user(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_User_id(ctx, field) case "friends": return ec.fieldContext_User_friends(ctx, field) case "created": return ec.fieldContext_User_created(ctx, field) case "updated": return ec.fieldContext_User_updated(ctx, field) case "pets": return ec.fieldContext_User_pets(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_user_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_nullableArg(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_nullableArg, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().NullableArg(ctx, fc.Args["arg"].(*int)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_nullableArg(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_nullableArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_inputSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_inputSlice, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().InputSlice(ctx, fc.Args["arg"].([]string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNBoolean2bool, true, true, ) } func (ec *executionContext) fieldContext_Query_inputSlice(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_inputSlice_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_inputNullableSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_inputNullableSlice, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().InputNullableSlice(ctx, fc.Args["arg"].([]string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNBoolean2bool, true, true, ) } func (ec *executionContext) fieldContext_Query_inputNullableSlice(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_inputNullableSlice_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_inputOmittable(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_inputOmittable, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().InputOmittable(ctx, fc.Args["arg"].(OmittableInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Query_inputOmittable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_inputOmittable_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_shapeUnion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_shapeUnion, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().ShapeUnion(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNShapeUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐShapeUnion, true, true, ) } func (ec *executionContext) fieldContext_Query_shapeUnion(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ShapeUnion does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_autobind(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_autobind, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Autobind(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOAutobind2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐAutobind, true, false, ) } func (ec *executionContext) fieldContext_Query_autobind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "int": return ec.fieldContext_Autobind_int(ctx, field) case "int32": return ec.fieldContext_Autobind_int32(ctx, field) case "int64": return ec.fieldContext_Autobind_int64(ctx, field) case "idStr": return ec.fieldContext_Autobind_idStr(ctx, field) case "idInt": return ec.fieldContext_Autobind_idInt(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Autobind", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_deprecatedField(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_deprecatedField, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().DeprecatedField(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Query_deprecatedField(_ 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_fieldWithDeprecatedArg(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_fieldWithDeprecatedArg, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().FieldWithDeprecatedArg(ctx, fc.Args["oldArg"].(*int), fc.Args["newArg"].(*int)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_fieldWithDeprecatedArg(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_fieldWithDeprecatedArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_overlapping(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_overlapping, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Overlapping(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOOverlappingFields2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOverlappingFields, true, false, ) } func (ec *executionContext) fieldContext_Query_overlapping(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "oneFoo": return ec.fieldContext_OverlappingFields_oneFoo(ctx, field) case "twoFoo": return ec.fieldContext_OverlappingFields_twoFoo(ctx, field) case "oldFoo": return ec.fieldContext_OverlappingFields_oldFoo(ctx, field) case "newFoo": return ec.fieldContext_OverlappingFields_newFoo(ctx, field) case "new_foo": return ec.fieldContext_OverlappingFields_new_foo(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type OverlappingFields", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_defaultParameters(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_defaultParameters, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().DefaultParameters(ctx, fc.Args["falsyBoolean"].(*bool), fc.Args["truthyBoolean"].(*bool)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNDefaultParametersMirror2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDefaultParametersMirror, true, true, ) } func (ec *executionContext) fieldContext_Query_defaultParameters(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "falsyBoolean": return ec.fieldContext_DefaultParametersMirror_falsyBoolean(ctx, field) case "truthyBoolean": return ec.fieldContext_DefaultParametersMirror_truthyBoolean(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type DefaultParametersMirror", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_defaultParameters_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_deferSingle(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_deferSingle, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().DeferSingle(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalODeferModel2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDeferModel, true, false, ) } func (ec *executionContext) fieldContext_Query_deferSingle(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_DeferModel_id(ctx, field) case "name": return ec.fieldContext_DeferModel_name(ctx, field) case "values": return ec.fieldContext_DeferModel_values(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type DeferModel", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_deferMultiple(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_deferMultiple, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().DeferMultiple(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalODeferModel2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDeferModelᚄ, true, false, ) } func (ec *executionContext) fieldContext_Query_deferMultiple(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_DeferModel_id(ctx, field) case "name": return ec.fieldContext_DeferModel_name(ctx, field) case "values": return ec.fieldContext_DeferModel_values(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type DeferModel", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_directiveArg(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveArg, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().DirectiveArg(ctx, fc.Args["arg"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_directiveArg(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_directiveArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_directiveNullableArg(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveNullableArg, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().DirectiveNullableArg(ctx, fc.Args["arg"].(*int), fc.Args["arg2"].(*int), fc.Args["arg3"].(*string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_directiveNullableArg(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_directiveNullableArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_directiveSingleNullableArg(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveSingleNullableArg, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().DirectiveSingleNullableArg(ctx, fc.Args["arg1"].(*string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_directiveSingleNullableArg(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_directiveSingleNullableArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_directiveInputNullable(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveInputNullable, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().DirectiveInputNullable(ctx, fc.Args["arg"].(*InputDirectives)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_directiveInputNullable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_directiveInputNullable_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_directiveInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveInput, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().DirectiveInput(ctx, fc.Args["arg"].(InputDirectives)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_directiveInput(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_directiveInput_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_directiveInputType(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveInputType, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().DirectiveInputType(ctx, fc.Args["arg"].(InnerInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_directiveInputType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_directiveInputType_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_directiveInputOuter(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveInputOuter, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().DirectiveInputOuter(ctx, fc.Args["arg"].(OuterWrapperInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_directiveInputOuter(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_directiveInputOuter_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_directiveObject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveObject, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().DirectiveObject(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { location, err := ec.unmarshalNString2string(ctx, "order1_1") if err != nil { var zeroVal *ObjectDirectives return zeroVal, err } if ec.Directives.Order1 == nil { var zeroVal *ObjectDirectives return zeroVal, errors.New("directive order1 is not implemented") } return ec.Directives.Order1(ctx, nil, directive0, location) } directive2 := func(ctx context.Context) (any, error) { location, err := ec.unmarshalNString2string(ctx, "order1_2") if err != nil { var zeroVal *ObjectDirectives return zeroVal, err } if ec.Directives.Order1 == nil { var zeroVal *ObjectDirectives return zeroVal, errors.New("directive order1 is not implemented") } return ec.Directives.Order1(ctx, nil, directive1, location) } directive3 := func(ctx context.Context) (any, error) { location, err := ec.unmarshalNString2string(ctx, "order2_1") if err != nil { var zeroVal *ObjectDirectives return zeroVal, err } if ec.Directives.Order2 == nil { var zeroVal *ObjectDirectives return zeroVal, errors.New("directive order2 is not implemented") } return ec.Directives.Order2(ctx, nil, directive2, location) } directive4 := func(ctx context.Context) (any, error) { location, err := ec.unmarshalNString2string(ctx, "Query_field") if err != nil { var zeroVal *ObjectDirectives return zeroVal, err } if ec.Directives.Order1 == nil { var zeroVal *ObjectDirectives return zeroVal, errors.New("directive order1 is not implemented") } return ec.Directives.Order1(ctx, nil, directive3, location) } next = directive4 return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOObjectDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐObjectDirectives, true, false, ) } func (ec *executionContext) fieldContext_Query_directiveObject(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "text": return ec.fieldContext_ObjectDirectives_text(ctx, field) case "nullableText": return ec.fieldContext_ObjectDirectives_nullableText(ctx, field) case "order": return ec.fieldContext_ObjectDirectives_order(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type ObjectDirectives", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_directiveObjectWithCustomGoModel(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveObjectWithCustomGoModel, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().DirectiveObjectWithCustomGoModel(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOObjectDirectivesWithCustomGoModel2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐObjectDirectivesWithCustomGoModel, true, false, ) } func (ec *executionContext) fieldContext_Query_directiveObjectWithCustomGoModel(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "nullableText": return ec.fieldContext_ObjectDirectivesWithCustomGoModel_nullableText(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type ObjectDirectivesWithCustomGoModel", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_directiveFieldDef(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveFieldDef, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().DirectiveFieldDef(ctx, fc.Args["ret"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { min, err := ec.unmarshalNInt2int(ctx, 1) if err != nil { var zeroVal string return zeroVal, err } message, err := ec.unmarshalOString2ᚖstring(ctx, "not valid") if err != nil { var zeroVal string return zeroVal, err } if ec.Directives.Length == nil { var zeroVal string return zeroVal, errors.New("directive length is not implemented") } return ec.Directives.Length(ctx, nil, directive0, min, nil, message) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Query_directiveFieldDef(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_directiveFieldDef_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_directiveField(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveField, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().DirectiveField(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_directiveField(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_directiveDouble(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveDouble, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().DirectiveDouble(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { if ec.Directives.Directive1 == nil { var zeroVal *string return zeroVal, errors.New("directive directive1 is not implemented") } return ec.Directives.Directive1(ctx, nil, directive0) } directive2 := func(ctx context.Context) (any, error) { if ec.Directives.Directive2 == nil { var zeroVal *string return zeroVal, errors.New("directive directive2 is not implemented") } return ec.Directives.Directive2(ctx, nil, directive1) } next = directive2 return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_directiveDouble(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_directiveUnimplemented(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_directiveUnimplemented, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().DirectiveUnimplemented(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { if ec.Directives.Unimplemented == nil { var zeroVal *string return zeroVal, errors.New("directive unimplemented is not implemented") } return ec.Directives.Unimplemented(ctx, nil, directive0) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Query_directiveUnimplemented(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_embeddedCase1(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_embeddedCase1, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().EmbeddedCase1(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOEmbeddedCase12ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEmbeddedCase1, true, false, ) } func (ec *executionContext) fieldContext_Query_embeddedCase1(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "exportedEmbeddedPointerExportedMethod": return ec.fieldContext_EmbeddedCase1_exportedEmbeddedPointerExportedMethod(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type EmbeddedCase1", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_embeddedCase2(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_embeddedCase2, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().EmbeddedCase2(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOEmbeddedCase22ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEmbeddedCase2, true, false, ) } func (ec *executionContext) fieldContext_Query_embeddedCase2(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "unexportedEmbeddedPointerExportedMethod": return ec.fieldContext_EmbeddedCase2_unexportedEmbeddedPointerExportedMethod(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type EmbeddedCase2", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_embeddedCase3(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_embeddedCase3, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().EmbeddedCase3(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOEmbeddedCase32ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEmbeddedCase3, true, false, ) } func (ec *executionContext) fieldContext_Query_embeddedCase3(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "unexportedEmbeddedInterfaceExportedMethod": return ec.fieldContext_EmbeddedCase3_unexportedEmbeddedInterfaceExportedMethod(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type EmbeddedCase3", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_enumInInput(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_enumInInput, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().EnumInInput(ctx, fc.Args["input"].(*InputWithEnumValue)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNEnumTest2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEnumTest, true, true, ) } func (ec *executionContext) fieldContext_Query_enumInInput(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type EnumTest does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_enumInInput_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_searchProducts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_searchProducts, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().SearchProducts(ctx, map[string]interface{}{ "query": fc.Args["query"].(*string), "category": fc.Args["category"].(*string), "minPrice": fc.Args["minPrice"].(*int), }) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2ᚕstringᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_searchProducts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_searchProducts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_searchRequired(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_searchRequired, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().SearchRequired(ctx, map[string]interface{}{ "name": fc.Args["name"].(string), "age": fc.Args["age"].(int), }) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2ᚕstringᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_searchRequired(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_searchRequired_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_searchProductsNormal(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_searchProductsNormal, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().SearchProductsNormal(ctx, fc.Args["filters"].(map[string]any)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2ᚕstringᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_searchProductsNormal(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_searchProductsNormal_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_searchWithDefaults(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_searchWithDefaults, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().SearchWithDefaults(ctx, map[string]interface{}{ "query": fc.Args["query"].(*string), "limit": fc.Args["limit"].(*int), "includeArchived": fc.Args["includeArchived"].(*bool), }) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2ᚕstringᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_searchWithDefaults(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_searchWithDefaults_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_searchMixed(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_searchMixed, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().SearchMixed(ctx, map[string]interface{}{ "query": fc.Args["query"].(*string), "category": fc.Args["category"].(*string), "minPrice": fc.Args["minPrice"].(*int), }, fc.Args["limit"].(*int), fc.Args["offset"].(*int), fc.Args["sortBy"].(*string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2ᚕstringᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_searchMixed(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_searchMixed_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_filterProducts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_filterProducts, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().FilterProducts(ctx, map[string]interface{}{ "query": fc.Args["query"].(*string), "category": fc.Args["category"].(*string), "minPrice": fc.Args["minPrice"].(*int), }) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2ᚕstringᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_filterProducts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_filterProducts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_findProducts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_findProducts, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().FindProducts(ctx, map[string]interface{}{ "query": fc.Args["query"].(*string), "category": fc.Args["category"].(*string), "minPrice": fc.Args["minPrice"].(*int), }) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2ᚕstringᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_findProducts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_findProducts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_searchWithDirectives(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_searchWithDirectives, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().SearchWithDirectives(ctx, map[string]interface{}{ "oldField": fc.Args["oldField"].(*string), "newField": fc.Args["newField"].(*string), }) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2ᚕstringᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_searchWithDirectives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_searchWithDirectives_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_shapes, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Shapes(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐShape, true, false, ) } func (ec *executionContext) fieldContext_Query_shapes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } return fc, nil } func (ec *executionContext) _Query_noShape(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_noShape, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().NoShape(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { if ec.Directives.MakeNil == nil { var zeroVal Shape return zeroVal, errors.New("directive makeNil is not implemented") } return ec.Directives.MakeNil(ctx, nil, directive0) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐShape, true, false, ) } func (ec *executionContext) fieldContext_Query_noShape(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } return fc, nil } func (ec *executionContext) _Query_node(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_node, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Node(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐNode, true, true, ) } func (ec *executionContext) fieldContext_Query_node(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } return fc, nil } func (ec *executionContext) _Query_noShapeTypedNil(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_noShapeTypedNil, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().NoShapeTypedNil(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { if ec.Directives.MakeTypedNil == nil { var zeroVal Shape return zeroVal, errors.New("directive makeTypedNil is not implemented") } return ec.Directives.MakeTypedNil(ctx, nil, directive0) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐShape, true, false, ) } func (ec *executionContext) fieldContext_Query_noShapeTypedNil(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } return fc, nil } func (ec *executionContext) _Query_animal(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_animal, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Animal(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { if ec.Directives.MakeTypedNil == nil { var zeroVal Animal return zeroVal, errors.New("directive makeTypedNil is not implemented") } return ec.Directives.MakeTypedNil(ctx, nil, directive0) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOAnimal2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐAnimal, true, false, ) } func (ec *executionContext) fieldContext_Query_animal(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } return fc, nil } func (ec *executionContext) _Query_notAnInterface(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_notAnInterface, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().NotAnInterface(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOBackedByInterface2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐBackedByInterface, true, false, ) } func (ec *executionContext) fieldContext_Query_notAnInterface(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_BackedByInterface_id(ctx, field) case "thisShouldBind": return ec.fieldContext_BackedByInterface_thisShouldBind(ctx, field) case "thisShouldBindWithError": return ec.fieldContext_BackedByInterface_thisShouldBindWithError(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type BackedByInterface", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_dog(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_dog, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Dog(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalODog2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDog, true, false, ) } func (ec *executionContext) fieldContext_Query_dog(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "species": return ec.fieldContext_Dog_species(ctx, field) case "size": return ec.fieldContext_Dog_size(ctx, field) case "dogBreed": return ec.fieldContext_Dog_dogBreed(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Dog", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_issue896a(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_issue896a, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Issue896a(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCheckIssue896ᚄ, true, false, ) } func (ec *executionContext) fieldContext_Query_issue896a(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_CheckIssue896_id(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type CheckIssue896", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_mapStringInterface(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_mapStringInterface, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().MapStringInterface(ctx, fc.Args["in"].(map[string]any)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOMapStringInterfaceType2map, true, false, ) } func (ec *executionContext) fieldContext_Query_mapStringInterface(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "a": return ec.fieldContext_MapStringInterfaceType_a(ctx, field) case "b": return ec.fieldContext_MapStringInterfaceType_b(ctx, field) case "c": return ec.fieldContext_MapStringInterfaceType_c(ctx, field) case "nested": return ec.fieldContext_MapStringInterfaceType_nested(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type MapStringInterfaceType", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_mapStringInterface_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_mapNestedStringInterface(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_mapNestedStringInterface, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().MapNestedStringInterface(ctx, fc.Args["in"].(*NestedMapInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOMapStringInterfaceType2map, true, false, ) } func (ec *executionContext) fieldContext_Query_mapNestedStringInterface(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "a": return ec.fieldContext_MapStringInterfaceType_a(ctx, field) case "b": return ec.fieldContext_MapStringInterfaceType_b(ctx, field) case "c": return ec.fieldContext_MapStringInterfaceType_c(ctx, field) case "nested": return ec.fieldContext_MapStringInterfaceType_nested(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type MapStringInterfaceType", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_mapNestedStringInterface_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_mapNestedMapSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_mapNestedMapSlice, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().MapNestedMapSlice(ctx, fc.Args["input"].(map[string]any)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOBoolean2ᚖbool, true, false, ) } func (ec *executionContext) fieldContext_Query_mapNestedMapSlice(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_mapNestedMapSlice_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_errorBubble(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_errorBubble, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().ErrorBubble(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError, true, false, ) } func (ec *executionContext) fieldContext_Query_errorBubble(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Error_id(ctx, field) case "errorOnNonRequiredField": return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) case "errorOnRequiredField": return ec.fieldContext_Error_errorOnRequiredField(ctx, field) case "nilOnRequiredField": return ec.fieldContext_Error_nilOnRequiredField(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_errorBubbleList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_errorBubbleList, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().ErrorBubbleList(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐErrorᚄ, true, false, ) } func (ec *executionContext) fieldContext_Query_errorBubbleList(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Error_id(ctx, field) case "errorOnNonRequiredField": return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) case "errorOnRequiredField": return ec.fieldContext_Error_errorOnRequiredField(ctx, field) case "nilOnRequiredField": return ec.fieldContext_Error_nilOnRequiredField(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_errorList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_errorList, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().ErrorList(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError, true, false, ) } func (ec *executionContext) fieldContext_Query_errorList(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Error_id(ctx, field) case "errorOnNonRequiredField": return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) case "errorOnRequiredField": return ec.fieldContext_Error_errorOnRequiredField(ctx, field) case "nilOnRequiredField": return ec.fieldContext_Error_nilOnRequiredField(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_errors(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_errors, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Errors(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOErrors2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐErrors, true, false, ) } func (ec *executionContext) fieldContext_Query_errors(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "a": return ec.fieldContext_Errors_a(ctx, field) case "b": return ec.fieldContext_Errors_b(ctx, field) case "c": return ec.fieldContext_Errors_c(ctx, field) case "d": return ec.fieldContext_Errors_d(ctx, field) case "e": return ec.fieldContext_Errors_e(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Errors", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_valid, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Valid(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Query_valid(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_invalid(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_invalid, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Invalid(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Query_invalid(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_panics(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_panics, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Panics(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOPanics2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPanics, true, false, ) } func (ec *executionContext) fieldContext_Query_panics(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "fieldScalarMarshal": return ec.fieldContext_Panics_fieldScalarMarshal(ctx, field) case "fieldFuncMarshal": return ec.fieldContext_Panics_fieldFuncMarshal(ctx, field) case "argUnmarshal": return ec.fieldContext_Panics_argUnmarshal(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Panics", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_primitiveObject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_primitiveObject, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().PrimitiveObject(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNPrimitive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPrimitiveᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_primitiveObject(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "value": return ec.fieldContext_Primitive_value(ctx, field) case "squared": return ec.fieldContext_Primitive_squared(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Primitive", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_primitiveStringObject(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_primitiveStringObject, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().PrimitiveStringObject(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNPrimitiveString2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPrimitiveStringᚄ, true, true, ) } func (ec *executionContext) fieldContext_Query_primitiveStringObject(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "value": return ec.fieldContext_PrimitiveString_value(ctx, field) case "doubled": return ec.fieldContext_PrimitiveString_doubled(ctx, field) case "len": return ec.fieldContext_PrimitiveString_len(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type PrimitiveString", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_ptrToAnyContainer(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_ptrToAnyContainer, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().PtrToAnyContainer(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNPtrToAnyContainer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToAnyContainer, true, true, ) } func (ec *executionContext) fieldContext_Query_ptrToAnyContainer(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "ptrToAny": return ec.fieldContext_PtrToAnyContainer_ptrToAny(ctx, field) case "binding": return ec.fieldContext_PtrToAnyContainer_binding(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type PtrToAnyContainer", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_ptrToSliceContainer(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_ptrToSliceContainer, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().PtrToSliceContainer(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNPtrToSliceContainer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToSliceContainer, true, true, ) } func (ec *executionContext) fieldContext_Query_ptrToSliceContainer(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "ptrToSlice": return ec.fieldContext_PtrToSliceContainer_ptrToSlice(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type PtrToSliceContainer", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_infinity(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_infinity, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Infinity(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNFloat2float64, true, true, ) } func (ec *executionContext) fieldContext_Query_infinity(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Float does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_stringFromContextInterface(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_stringFromContextInterface, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().StringFromContextInterface(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNStringFromContextInterface2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐStringFromContextInterface, true, true, ) } func (ec *executionContext) fieldContext_Query_stringFromContextInterface(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type StringFromContextInterface does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_stringFromContextFunction(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_stringFromContextFunction, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().StringFromContextFunction(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNStringFromContextFunction2string, true, true, ) } func (ec *executionContext) fieldContext_Query_stringFromContextFunction(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type StringFromContextFunction does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_defaultScalar(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_defaultScalar, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().DefaultScalar(ctx, fc.Args["arg"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNDefaultScalarImplementation2string, true, true, ) } func (ec *executionContext) fieldContext_Query_defaultScalar(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type DefaultScalarImplementation does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_defaultScalar_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_skipInclude(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_skipInclude, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().SkipInclude(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOSkipIncludeTestType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐSkipIncludeTestType, true, false, ) } func (ec *executionContext) fieldContext_Query_skipInclude(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "a": return ec.fieldContext_SkipIncludeTestType_a(ctx, field) case "b": return ec.fieldContext_SkipIncludeTestType_b(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type SkipIncludeTestType", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_slices(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_slices, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().Slices(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOSlices2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐSlices, true, false, ) } func (ec *executionContext) fieldContext_Query_slices(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "test1": return ec.fieldContext_Slices_test1(ctx, field) case "test2": return ec.fieldContext_Slices_test2(ctx, field) case "test3": return ec.fieldContext_Slices_test3(ctx, field) case "test4": return ec.fieldContext_Slices_test4(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Slices", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_scalarSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_scalarSlice, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().ScalarSlice(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNBytes2ᚕbyte, true, true, ) } func (ec *executionContext) fieldContext_Query_scalarSlice(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Bytes does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_fallback(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_fallback, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().Fallback(ctx, fc.Args["arg"].(FallbackToStringEncoding)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐFallbackToStringEncoding, true, true, ) } func (ec *executionContext) fieldContext_Query_fallback(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type FallbackToStringEncoding does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Query_fallback_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Query_optionalUnion(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_optionalUnion, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().OptionalUnion(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOTestUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐTestUnion, true, false, ) } func (ec *executionContext) fieldContext_Query_optionalUnion(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type TestUnion does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_vOkCaseValue(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_vOkCaseValue, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().VOkCaseValue(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOVOkCaseValue2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐVOkCaseValue, true, false, ) } func (ec *executionContext) fieldContext_Query_vOkCaseValue(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "value": return ec.fieldContext_VOkCaseValue_value(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type VOkCaseValue", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_vOkCaseNil(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_vOkCaseNil, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().VOkCaseNil(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOVOkCaseNil2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐVOkCaseNil, true, false, ) } func (ec *executionContext) fieldContext_Query_vOkCaseNil(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "value": return ec.fieldContext_VOkCaseNil_value(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type VOkCaseNil", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_validType(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_validType, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().ValidType(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOValidType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐValidType, true, false, ) } func (ec *executionContext) fieldContext_Query_validType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "differentCase": return ec.fieldContext_ValidType_differentCase(ctx, field) case "different_case": return ec.fieldContext_ValidType_different_case(ctx, field) case "validInputKeywords": return ec.fieldContext_ValidType_validInputKeywords(ctx, field) case "validArgs": return ec.fieldContext_ValidType_validArgs(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type ValidType", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_variadicModel(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_variadicModel, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().VariadicModel(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOVariadicModel2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐVariadicModel, true, false, ) } func (ec *executionContext) fieldContext_Query_variadicModel(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "value": return ec.fieldContext_VariadicModel_value(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type VariadicModel", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_wrappedStruct(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_wrappedStruct, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().WrappedStruct(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNWrappedStruct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐWrappedStruct, true, true, ) } func (ec *executionContext) fieldContext_Query_wrappedStruct(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "name": return ec.fieldContext_WrappedStruct_name(ctx, field) case "desc": return ec.fieldContext_WrappedStruct_desc(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type WrappedStruct", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_wrappedScalar(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_wrappedScalar, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().WrappedScalar(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋotherpkgᚐScalar, true, true, ) } func (ec *executionContext) fieldContext_Query_wrappedScalar(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type WrappedScalar does not have child fields") }, } return fc, nil } func (ec *executionContext) _Query_wrappedMap(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_wrappedMap, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().WrappedMap(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNWrappedMap2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐWrappedMap, true, true, ) } func (ec *executionContext) fieldContext_Query_wrappedMap(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "get": return ec.fieldContext_WrappedMap_get(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type WrappedMap", field.Name) }, } return fc, nil } func (ec *executionContext) _Query_wrappedSlice(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Query_wrappedSlice, func(ctx context.Context) (any, error) { return ec.Resolvers.Query().WrappedSlice(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNWrappedSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐWrappedSlice, true, true, ) } func (ec *executionContext) fieldContext_Query_wrappedSlice(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "get": return ec.fieldContext_WrappedSlice_get(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type WrappedSlice", field.Name) }, } return fc, nil } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { 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)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, 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() }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, 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) _Rectangle_length(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Rectangle_length, func(ctx context.Context) (any, error) { return obj.Length, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOFloat2float64, true, false, ) } func (ec *executionContext) fieldContext_Rectangle_length(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Rectangle", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Float does not have child fields") }, } return fc, nil } func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Rectangle_width, func(ctx context.Context) (any, error) { return obj.Width, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOFloat2float64, true, false, ) } func (ec *executionContext) fieldContext_Rectangle_width(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Rectangle", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Float does not have child fields") }, } return fc, nil } func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Rectangle_area, func(ctx context.Context) (any, error) { return obj.Area(), nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOFloat2float64, true, false, ) } func (ec *executionContext) fieldContext_Rectangle_area(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Rectangle", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Float does not have child fields") }, } return fc, nil } func (ec *executionContext) _Rectangle_coordinates(ctx context.Context, field graphql.CollectedField, obj *Rectangle) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Rectangle_coordinates, func(ctx context.Context) (any, error) { return obj.Coordinates, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOCoordinates2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCoordinates, true, false, ) } func (ec *executionContext) fieldContext_Rectangle_coordinates(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Rectangle", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "x": return ec.fieldContext_Coordinates_x(ctx, field) case "y": return ec.fieldContext_Coordinates_y(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Coordinates", field.Name) }, } return fc, nil } func (ec *executionContext) _Size_height(ctx context.Context, field graphql.CollectedField, obj *Size) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Size_height, func(ctx context.Context) (any, error) { return obj.Height, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_Size_height(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Size", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _Size_weight(ctx context.Context, field graphql.CollectedField, obj *Size) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Size_weight, func(ctx context.Context) (any, error) { return obj.Weight, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_Size_weight(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Size", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _SkipIncludeTestType_a(ctx context.Context, field graphql.CollectedField, obj *SkipIncludeTestType) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_SkipIncludeTestType_a, func(ctx context.Context) (any, error) { return obj.A, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_SkipIncludeTestType_a(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "SkipIncludeTestType", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _SkipIncludeTestType_b(ctx context.Context, field graphql.CollectedField, obj *SkipIncludeTestType) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_SkipIncludeTestType_b, func(ctx context.Context) (any, error) { return obj.B, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_SkipIncludeTestType_b(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "SkipIncludeTestType", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Slices_test1(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Slices_test1, func(ctx context.Context) (any, error) { return obj.Test1, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2ᚕᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Slices_test1(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Slices", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Slices_test2(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Slices_test2, func(ctx context.Context) (any, error) { return obj.Test2, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2ᚕstringᚄ, true, false, ) } func (ec *executionContext) fieldContext_Slices_test2(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Slices", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Slices_test3(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Slices_test3, func(ctx context.Context) (any, error) { return obj.Test3, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2ᚕᚖstring, true, true, ) } func (ec *executionContext) fieldContext_Slices_test3(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Slices", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Slices_test4(ctx context.Context, field graphql.CollectedField, obj *Slices) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_Slices_test4, func(ctx context.Context) (any, error) { return obj.Test4, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2ᚕstringᚄ, true, true, ) } func (ec *executionContext) fieldContext_Slices_test4(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Slices", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Subscription_updated(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { return graphql.ResolveFieldStream( ctx, ec.OperationContext, field, ec.fieldContext_Subscription_updated, func(ctx context.Context) (any, error) { return ec.Resolvers.Subscription().Updated(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Subscription_updated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Subscription", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Subscription_initPayload(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { return graphql.ResolveFieldStream( ctx, ec.OperationContext, field, ec.fieldContext_Subscription_initPayload, func(ctx context.Context) (any, error) { return ec.Resolvers.Subscription().InitPayload(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_Subscription_initPayload(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Subscription", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Subscription_directiveArg(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { return graphql.ResolveFieldStream( ctx, ec.OperationContext, field, ec.fieldContext_Subscription_directiveArg, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Subscription().DirectiveArg(ctx, fc.Args["arg"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Subscription_directiveArg(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Subscription", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Subscription_directiveArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Subscription_directiveNullableArg(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { return graphql.ResolveFieldStream( ctx, ec.OperationContext, field, ec.fieldContext_Subscription_directiveNullableArg, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Subscription().DirectiveNullableArg(ctx, fc.Args["arg"].(*int), fc.Args["arg2"].(*int), fc.Args["arg3"].(*string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Subscription_directiveNullableArg(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Subscription", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_Subscription_directiveNullableArg_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _Subscription_directiveDouble(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { return graphql.ResolveFieldStream( ctx, ec.OperationContext, field, ec.fieldContext_Subscription_directiveDouble, func(ctx context.Context) (any, error) { return ec.Resolvers.Subscription().DirectiveDouble(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { if ec.Directives.Directive1 == nil { var zeroVal *string return zeroVal, errors.New("directive directive1 is not implemented") } return ec.Directives.Directive1(ctx, nil, directive0) } directive2 := func(ctx context.Context) (any, error) { if ec.Directives.Directive2 == nil { var zeroVal *string return zeroVal, errors.New("directive directive2 is not implemented") } return ec.Directives.Directive2(ctx, nil, directive1) } next = directive2 return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Subscription_directiveDouble(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Subscription", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Subscription_directiveUnimplemented(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { return graphql.ResolveFieldStream( ctx, ec.OperationContext, field, ec.fieldContext_Subscription_directiveUnimplemented, func(ctx context.Context) (any, error) { return ec.Resolvers.Subscription().DirectiveUnimplemented(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { if ec.Directives.Unimplemented == nil { var zeroVal *string return zeroVal, errors.New("directive unimplemented is not implemented") } return ec.Directives.Unimplemented(ctx, nil, directive0) } next = directive1 return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOString2ᚖstring, true, false, ) } func (ec *executionContext) fieldContext_Subscription_directiveUnimplemented(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Subscription", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _Subscription_issue896b(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { return graphql.ResolveFieldStream( ctx, ec.OperationContext, field, ec.fieldContext_Subscription_issue896b, func(ctx context.Context) (any, error) { return ec.Resolvers.Subscription().Issue896b(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCheckIssue896, true, false, ) } func (ec *executionContext) fieldContext_Subscription_issue896b(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Subscription", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_CheckIssue896_id(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type CheckIssue896", field.Name) }, } return fc, nil } func (ec *executionContext) _Subscription_errorRequired(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { return graphql.ResolveFieldStream( ctx, ec.OperationContext, field, ec.fieldContext_Subscription_errorRequired, func(ctx context.Context) (any, error) { return ec.Resolvers.Subscription().ErrorRequired(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, nil, next) }, ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError, true, true, ) } func (ec *executionContext) fieldContext_Subscription_errorRequired(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Subscription", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Error_id(ctx, field) case "errorOnNonRequiredField": return ec.fieldContext_Error_errorOnNonRequiredField(ctx, field) case "errorOnRequiredField": return ec.fieldContext_Error_errorOnRequiredField(ctx, field) case "nilOnRequiredField": return ec.fieldContext_Error_nilOnRequiredField(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Error", field.Name) }, } return fc, nil } func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNInt2int, true, true, ) } func (ec *executionContext) fieldContext_User_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func (ec *executionContext) _User_friends(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_friends, func(ctx context.Context) (any, error) { return ec.Resolvers.User().Friends(ctx, obj) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUserᚄ, true, true, ) } func (ec *executionContext) fieldContext_User_friends(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_User_id(ctx, field) case "friends": return ec.fieldContext_User_friends(ctx, field) case "created": return ec.fieldContext_User_created(ctx, field) case "updated": return ec.fieldContext_User_updated(ctx, field) case "pets": return ec.fieldContext_User_pets(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } func (ec *executionContext) _User_created(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_created, func(ctx context.Context) (any, error) { return obj.Created, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNTime2timeᚐTime, true, true, ) } func (ec *executionContext) fieldContext_User_created(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } func (ec *executionContext) _User_updated(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_updated, func(ctx context.Context) (any, error) { return obj.Updated, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOTime2ᚖtimeᚐTime, true, false, ) } func (ec *executionContext) fieldContext_User_updated(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } func (ec *executionContext) _User_pets(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_User_pets, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.User().Pets(ctx, obj, fc.Args["limit"].(*int)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOPet2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPetᚄ, true, false, ) } func (ec *executionContext) fieldContext_User_pets(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": return ec.fieldContext_Pet_id(ctx, field) case "friends": return ec.fieldContext_Pet_friends(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Pet", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_User_pets_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _VOkCaseNil_value(ctx context.Context, field graphql.CollectedField, obj *VOkCaseNil) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_VOkCaseNil_value, func(ctx context.Context) (any, error) { v, ok := obj.Value() if !ok { return nil, nil } return v, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2string, true, false, ) } func (ec *executionContext) fieldContext_VOkCaseNil_value(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "VOkCaseNil", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _VOkCaseValue_value(ctx context.Context, field graphql.CollectedField, obj *VOkCaseValue) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_VOkCaseValue_value, func(ctx context.Context) (any, error) { v, ok := obj.Value() if !ok { return nil, nil } return v, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2string, true, false, ) } func (ec *executionContext) fieldContext_VOkCaseValue_value(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "VOkCaseValue", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _ValidType_differentCase(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ValidType_differentCase, func(ctx context.Context) (any, error) { return obj.DifferentCase, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_ValidType_differentCase(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ValidType", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _ValidType_different_case(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ValidType_different_case, func(ctx context.Context) (any, error) { return obj.DifferentCaseOld, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_ValidType_different_case(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ValidType", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func (ec *executionContext) _ValidType_validInputKeywords(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ValidType_validInputKeywords, func(ctx context.Context) (any, error) { return obj.ValidInputKeywords, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNBoolean2bool, true, true, ) } func (ec *executionContext) fieldContext_ValidType_validInputKeywords(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ValidType", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_ValidType_validInputKeywords_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _ValidType_validArgs(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_ValidType_validArgs, func(ctx context.Context) (any, error) { return obj.ValidArgs, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNBoolean2bool, true, true, ) } func (ec *executionContext) fieldContext_ValidType_validArgs(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "ValidType", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Boolean does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_ValidType_validArgs_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _VariadicModel_value(ctx context.Context, field graphql.CollectedField, obj *VariadicModel) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_VariadicModel_value, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return obj.Value(ctx, fc.Args["rank"].(int)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOString2string, true, false, ) } func (ec *executionContext) fieldContext_VariadicModel_value(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "VariadicModel", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_VariadicModel_value_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _WrappedMap_get(ctx context.Context, field graphql.CollectedField, obj WrappedMap) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_WrappedMap_get, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.WrappedMap().Get(ctx, obj, fc.Args["key"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_WrappedMap_get(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "WrappedMap", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_WrappedMap_get_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _WrappedSlice_get(ctx context.Context, field graphql.CollectedField, obj WrappedSlice) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_WrappedSlice_get, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.WrappedSlice().Get(ctx, obj, fc.Args["idx"].(int)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNString2string, true, true, ) } func (ec *executionContext) fieldContext_WrappedSlice_get(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "WrappedSlice", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = ec.field_WrappedSlice_get_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func (ec *executionContext) _WrappedStruct_name(ctx context.Context, field graphql.CollectedField, obj *WrappedStruct) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_WrappedStruct_name, func(ctx context.Context) (any, error) { return obj.Name, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋotherpkgᚐScalar, true, true, ) } func (ec *executionContext) fieldContext_WrappedStruct_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "WrappedStruct", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type WrappedScalar does not have child fields") }, } return fc, nil } func (ec *executionContext) _WrappedStruct_desc(ctx context.Context, field graphql.CollectedField, obj *WrappedStruct) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_WrappedStruct_desc, func(ctx context.Context) (any, error) { return obj.Desc, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalOWrappedScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋotherpkgᚐScalar, true, false, ) } func (ec *executionContext) fieldContext_WrappedStruct_desc(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "WrappedStruct", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type WrappedScalar does not have child fields") }, } return fc, nil } func (ec *executionContext) _XXIt_id(ctx context.Context, field graphql.CollectedField, obj *XXIt) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_XXIt_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_XXIt_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "XXIt", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _XxIt_id(ctx context.Context, field graphql.CollectedField, obj *XxIt) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_XxIt_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_XxIt_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "XxIt", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext___Directive_name, func(ctx context.Context) (any, error) { return obj.Name, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, 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 } func (ec *executionContext) _asdfIt_id(ctx context.Context, field graphql.CollectedField, obj *AsdfIt) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_asdfIt_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_asdfIt_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "asdfIt", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } func (ec *executionContext) _iIt_id(ctx context.Context, field graphql.CollectedField, obj *IIt) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, ec.fieldContext_iIt_id, func(ctx context.Context) (any, error) { return obj.ID, nil }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { return ec._fieldMiddleware(ctx, obj, next) }, ec.marshalNID2string, true, true, ) } func (ec *executionContext) fieldContext_iIt_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "iIt", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** func (ec *executionContext) unmarshalInputChanges(ctx context.Context, obj any) (map[string]any, error) { var it map[string]any if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"a", "b"} it = make(map[string]any, len(asMap)) for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "a": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("a")) data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } it["a"] = data case "b": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("b")) data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } it["b"] = data } } return it, nil } func (ec *executionContext) unmarshalInputDefaultInput(ctx context.Context, obj any) (DefaultInput, error) { var it DefaultInput if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } if _, present := asMap["falsyBoolean"]; !present { asMap["falsyBoolean"] = false } if _, present := asMap["truthyBoolean"]; !present { asMap["truthyBoolean"] = true } fieldsInOrder := [...]string{"falsyBoolean", "truthyBoolean"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "falsyBoolean": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("falsyBoolean")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } it.FalsyBoolean = data case "truthyBoolean": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("truthyBoolean")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } it.TruthyBoolean = data } } return it, nil } func (ec *executionContext) unmarshalInputDirectiveInput(ctx context.Context, obj any) (map[string]any, error) { var it map[string]any if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"oldField", "newField"} it = make(map[string]any, len(asMap)) for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "oldField": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("oldField")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it["oldField"] = data case "newField": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("newField")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it["newField"] = data } } return it, nil } func (ec *executionContext) unmarshalInputFieldsOrderInput(ctx context.Context, obj any) (FieldsOrderInput, error) { var it FieldsOrderInput if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"firstField", "overrideFirstField"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "firstField": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("firstField")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it.FirstField = data case "overrideFirstField": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("overrideFirstField")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } if err = ec.Resolvers.FieldsOrderInput().OverrideFirstField(ctx, &it, data); err != nil { return it, err } } } return it, nil } func (ec *executionContext) unmarshalInputInnerDirectives(ctx context.Context, obj any) (InnerDirectives, error) { var it InnerDirectives if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"message"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "message": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("message")) directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalNString2string(ctx, v) } directive1 := func(ctx context.Context) (any, error) { min, err := ec.unmarshalNInt2int(ctx, 1) if err != nil { var zeroVal string return zeroVal, err } message, err := ec.unmarshalOString2ᚖstring(ctx, "not valid") if err != nil { var zeroVal string return zeroVal, err } if ec.Directives.Length == nil { var zeroVal string return zeroVal, errors.New("directive length is not implemented") } return ec.Directives.Length(ctx, obj, directive0, min, nil, message) } tmp, err := directive1(ctx) if err != nil { return it, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(string); ok { it.Message = data } else { err := fmt.Errorf(`unexpected type %T from directive, should be string`, tmp) return it, graphql.ErrorOnPath(ctx, err) } } } return it, nil } func (ec *executionContext) unmarshalInputInnerInput(ctx context.Context, obj any) (InnerInput, error) { var it InnerInput if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"id"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "id": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) data, err := ec.unmarshalNInt2int(ctx, v) if err != nil { return it, err } it.ID = data } } return it, nil } func (ec *executionContext) unmarshalInputInputDirectives(ctx context.Context, obj any) (InputDirectives, error) { var it InputDirectives if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"text", "nullableText", "inner", "innerNullable", "thirdParty"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "text": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalNString2string(ctx, v) } directive1 := func(ctx context.Context) (any, error) { min, err := ec.unmarshalNInt2int(ctx, 0) if err != nil { var zeroVal string return zeroVal, err } max, err := ec.unmarshalOInt2ᚖint(ctx, 7) if err != nil { var zeroVal string return zeroVal, err } message, err := ec.unmarshalOString2ᚖstring(ctx, "not valid") if err != nil { var zeroVal string return zeroVal, err } if ec.Directives.Length == nil { var zeroVal string return zeroVal, errors.New("directive length is not implemented") } return ec.Directives.Length(ctx, obj, directive0, min, max, message) } tmp, err := directive1(ctx) if err != nil { return it, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(string); ok { it.Text = data } else { err := fmt.Errorf(`unexpected type %T from directive, should be string`, tmp) return it, graphql.ErrorOnPath(ctx, err) } case "nullableText": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nullableText")) directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOString2ᚖstring(ctx, v) } directive1 := func(ctx context.Context) (any, error) { if ec.Directives.ToNull == nil { var zeroVal *string return zeroVal, errors.New("directive toNull is not implemented") } return ec.Directives.ToNull(ctx, obj, directive0) } tmp, err := directive1(ctx) if err != nil { return it, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(*string); ok { it.NullableText = data } else if tmp == nil { it.NullableText = nil } else { err := fmt.Errorf(`unexpected type %T from directive, should be *string`, tmp) return it, graphql.ErrorOnPath(ctx, err) } case "inner": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("inner")) data, err := ec.unmarshalNInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInnerDirectives(ctx, v) if err != nil { return it, err } it.Inner = data case "innerNullable": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("innerNullable")) data, err := ec.unmarshalOInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInnerDirectives(ctx, v) if err != nil { return it, err } it.InnerNullable = data case "thirdParty": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("thirdParty")) directive0 := func(ctx context.Context) (any, error) { return ec.unmarshalOThirdParty2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐThirdParty(ctx, v) } directive1 := func(ctx context.Context) (any, error) { min, err := ec.unmarshalNInt2int(ctx, 0) if err != nil { var zeroVal *ThirdParty return zeroVal, err } max, err := ec.unmarshalOInt2ᚖint(ctx, 7) if err != nil { var zeroVal *ThirdParty return zeroVal, err } if ec.Directives.Length == nil { var zeroVal *ThirdParty return zeroVal, errors.New("directive length is not implemented") } return ec.Directives.Length(ctx, obj, directive0, min, max, nil) } tmp, err := directive1(ctx) if err != nil { return it, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(*ThirdParty); ok { it.ThirdParty = data } else if tmp == nil { it.ThirdParty = nil } else { err := fmt.Errorf(`unexpected type %T from directive, should be *github.com/99designs/gqlgen/codegen/testserver/singlefile.ThirdParty`, tmp) return it, graphql.ErrorOnPath(ctx, err) } } } // Execute INPUT_OBJECT level directives (e.g., @oneOf, @directive3) // These run after all fields have been unmarshaled directive0 := func(ctx context.Context) (any, error) { return it, nil } directive1 := func(ctx context.Context) (any, error) { if ec.Directives.Directive3 == nil { return it, errors.New("directive directive3 is not implemented") } return ec.Directives.Directive3(ctx, asMap, directive0) } tmp, err := directive1(ctx) if err != nil { return it, graphql.ErrorOnPath(ctx, err) } if data, ok := tmp.(InputDirectives); ok { return data, nil } return it, graphql.ErrorOnPath(ctx, fmt.Errorf(`unexpected type %T from INPUT_OBJECT directive, should be InputDirectives`, tmp)) } func (ec *executionContext) unmarshalInputInputWithEnumValue(ctx context.Context, obj any) (InputWithEnumValue, error) { var it InputWithEnumValue if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"enum"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "enum": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("enum")) data, err := ec.unmarshalNEnumTest2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEnumTest(ctx, v) if err != nil { return it, err } it.Enum = data } } return it, nil } func (ec *executionContext) unmarshalInputIssue4053Input1(ctx context.Context, obj any) (Issue4053Input1, error) { var it Issue4053Input1 if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"input2"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "input2": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("input2")) data, err := ec.unmarshalOIssue4053Input22githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐIssue4053Input2(ctx, v) if err != nil { return it, err } it.Input2 = data } } return it, nil } func (ec *executionContext) unmarshalInputIssue4053Input2(ctx context.Context, obj any) (Issue4053Input2, error) { var it Issue4053Input2 if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } if _, present := asMap["helloWithDefault"]; !present { asMap["helloWithDefault"] = "world" } fieldsInOrder := [...]string{"hello", "helloWithDefault"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "hello": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hello")) data, err := ec.unmarshalOString2string(ctx, v) if err != nil { return it, err } it.Hello = data case "helloWithDefault": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("helloWithDefault")) data, err := ec.unmarshalOString2string(ctx, v) if err != nil { return it, err } it.HelloWithDefault = data } } return it, nil } func (ec *executionContext) unmarshalInputMapNestedInput(ctx context.Context, obj any) (MapNested, error) { var it MapNested if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"value"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "value": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("value")) data, err := ec.unmarshalNCustomScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCustomScalar(ctx, v) if err != nil { return it, err } it.Value = data } } return it, nil } func (ec *executionContext) unmarshalInputMapNestedMapSliceInput(ctx context.Context, obj any) (map[string]any, error) { var it map[string]any if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"name", "recurse"} it = make(map[string]any, len(asMap)) for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "name": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it["name"] = data case "recurse": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("recurse")) data, err := ec.unmarshalOMapNestedMapSliceInput2ᚕmapᚄ(ctx, v) if err != nil { return it, err } it["recurse"] = data } } return it, nil } func (ec *executionContext) unmarshalInputMapStringInterfaceInput(ctx context.Context, obj any) (map[string]any, error) { var it map[string]any if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"a", "b", "c", "nested"} it = make(map[string]any, len(asMap)) for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "a": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("a")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it["a"] = data case "b": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("b")) data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } it["b"] = data case "c": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("c")) data, err := ec.unmarshalOCustomScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCustomScalar(ctx, v) if err != nil { return it, err } it["c"] = data case "nested": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nested")) data, err := ec.unmarshalOMapNestedInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMapNested(ctx, v) if err != nil { return it, err } it["nested"] = data } } return it, nil } func (ec *executionContext) unmarshalInputNestedInput(ctx context.Context, obj any) (NestedInput, error) { var it NestedInput if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"field"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "field": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) data, err := ec.unmarshalNEmail2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEmail(ctx, v) if err != nil { return it, err } it.Field = data } } return it, nil } func (ec *executionContext) unmarshalInputNestedMapInput(ctx context.Context, obj any) (NestedMapInput, error) { var it NestedMapInput if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"map"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "map": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("map")) data, err := ec.unmarshalOMapStringInterfaceInput2map(ctx, v) if err != nil { return it, err } it.Map = data } } return it, nil } func (ec *executionContext) unmarshalInputOmittableInput(ctx context.Context, obj any) (OmittableInput, error) { var it OmittableInput if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"id", "bool", "str", "int", "time", "enum", "scalar", "object"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "id": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) data, err := ec.unmarshalOID2ᚖstring(ctx, v) if err != nil { return it, err } it.ID = graphql.OmittableOf(data) case "bool": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("bool")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } it.Bool = graphql.OmittableOf(data) case "str": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("str")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it.Str = graphql.OmittableOf(data) case "int": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("int")) data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } it.Int = graphql.OmittableOf(data) case "time": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("time")) data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } it.Time = graphql.OmittableOf(data) case "enum": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("enum")) data, err := ec.unmarshalOStatus2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐStatus(ctx, v) if err != nil { return it, err } it.Enum = graphql.OmittableOf(data) case "scalar": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("scalar")) data, err := ec.unmarshalOThirdParty2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐThirdParty(ctx, v) if err != nil { return it, err } it.Scalar = graphql.OmittableOf(data) case "object": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("object")) data, err := ec.unmarshalOOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterInput(ctx, v) if err != nil { return it, err } it.Object = graphql.OmittableOf(data) } } return it, nil } func (ec *executionContext) unmarshalInputOuterInput(ctx context.Context, obj any) (OuterInput, error) { var it OuterInput if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"inner"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "inner": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("inner")) data, err := ec.unmarshalNInnerInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInnerInput(ctx, v) if err != nil { return it, err } it.Inner = data } } return it, nil } func (ec *executionContext) unmarshalInputOuterWrapperInput(ctx context.Context, obj any) (OuterWrapperInput, error) { var it OuterWrapperInput if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"inner"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "inner": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("inner")) data, err := ec.unmarshalNInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInputDirectives(ctx, v) if err != nil { return it, err } it.Inner = data } } return it, nil } func (ec *executionContext) unmarshalInputRecursiveInputSlice(ctx context.Context, obj any) (RecursiveInputSlice, error) { var it RecursiveInputSlice if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"self"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "self": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("self")) data, err := ec.unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐRecursiveInputSliceᚄ(ctx, v) if err != nil { return it, err } it.Self = data } } return it, nil } func (ec *executionContext) unmarshalInputRequiredFilters(ctx context.Context, obj any) (map[string]any, error) { var it map[string]any if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"name", "age"} it = make(map[string]any, len(asMap)) 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 case "age": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("age")) data, err := ec.unmarshalNInt2int(ctx, v) if err != nil { return it, err } it["age"] = data } } return it, nil } func (ec *executionContext) unmarshalInputSearchFilters(ctx context.Context, obj any) (map[string]any, error) { var it map[string]any if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"query", "category", "minPrice"} it = make(map[string]any, len(asMap)) for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "query": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("query")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it["query"] = data case "category": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("category")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it["category"] = data case "minPrice": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("minPrice")) data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } it["minPrice"] = data } } return it, nil } func (ec *executionContext) unmarshalInputSearchWithDefaults(ctx context.Context, obj any) (map[string]any, error) { var it map[string]any if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } if _, present := asMap["query"]; !present { asMap["query"] = "default search" } if _, present := asMap["limit"]; !present { asMap["limit"] = 20 } if _, present := asMap["includeArchived"]; !present { asMap["includeArchived"] = false } fieldsInOrder := [...]string{"query", "limit", "includeArchived"} it = make(map[string]any, len(asMap)) for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "query": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("query")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it["query"] = data case "limit": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("limit")) data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } it["limit"] = data case "includeArchived": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeArchived")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } it["includeArchived"] = data } } return it, nil } func (ec *executionContext) unmarshalInputSpecialInput(ctx context.Context, obj any) (SpecialInput, error) { var it SpecialInput if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"nesting"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "nesting": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nesting")) data, err := ec.unmarshalNNestedInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐNestedInput(ctx, v) if err != nil { return it, err } it.Nesting = data } } return it, nil } func (ec *executionContext) unmarshalInputUpdateProductInput(ctx context.Context, obj any) (map[string]any, error) { var it map[string]any if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"id", "name", "price"} it = make(map[string]any, len(asMap)) for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "id": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) data, err := ec.unmarshalNID2string(ctx, v) if err != nil { return it, err } it["id"] = data case "name": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it["name"] = data case "price": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("price")) data, err := ec.unmarshalOFloat2ᚖfloat64(ctx, v) if err != nil { return it, err } it["price"] = data } } return it, nil } func (ec *executionContext) unmarshalInputUpdatePtrToPtrInner(ctx context.Context, obj any) (UpdatePtrToPtrInner, error) { var it UpdatePtrToPtrInner if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"key", "value"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "key": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("key")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it.Key = data case "value": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("value")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it.Value = data } } return it, nil } func (ec *executionContext) unmarshalInputUpdatePtrToPtrOuter(ctx context.Context, obj any) (UpdatePtrToPtrOuter, error) { var it UpdatePtrToPtrOuter if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"name", "inner", "stupidInner"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "name": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } it.Name = data case "inner": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("inner")) data, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx, v) if err != nil { return it, err } it.Inner = data case "stupidInner": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("stupidInner")) data, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx, v) if err != nil { return it, err } it.StupidInner = data } } return it, nil } func (ec *executionContext) unmarshalInputValidInput(ctx context.Context, obj any) (ValidInput, error) { var it ValidInput if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } fieldsInOrder := [...]string{"break", "default", "func", "interface", "select", "case", "defer", "go", "map", "struct", "chan", "else", "goto", "package", "switch", "const", "fallthrough", "if", "range", "type", "continue", "for", "import", "return", "var", "_"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "break": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("break")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Break = data case "default": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("default")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Default = data case "func": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("func")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Func = data case "interface": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("interface")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Interface = data case "select": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("select")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Select = data case "case": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("case")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Case = data case "defer": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("defer")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Defer = data case "go": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("go")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Go = data case "map": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("map")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Map = data case "struct": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("struct")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Struct = data case "chan": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("chan")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Chan = data case "else": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("else")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Else = data case "goto": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("goto")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Goto = data case "package": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("package")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Package = data case "switch": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("switch")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Switch = data case "const": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("const")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Const = data case "fallthrough": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fallthrough")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Fallthrough = data case "if": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("if")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.If = data case "range": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("range")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Range = data case "type": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("type")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Type = data case "continue": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("continue")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Continue = data case "for": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("for")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.For = data case "import": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("import")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Import = data case "return": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("return")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Return = data case "var": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("var")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Var = data case "_": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("_")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } it.Underscore = data } } return it, nil } // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** func (ec *executionContext) _Animal(ctx context.Context, sel ast.SelectionSet, obj Animal) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null case Horse: return ec._Horse(ctx, sel, &obj) case *Horse: if obj == nil { return graphql.Null } return ec._Horse(ctx, sel, obj) case Mammalian: if obj == nil { return graphql.Null } return ec._Mammalian(ctx, sel, obj) case Dog: return ec._Dog(ctx, sel, &obj) case *Dog: if obj == nil { return graphql.Null } return ec._Dog(ctx, sel, obj) case Cat: return ec._Cat(ctx, sel, &obj) case *Cat: if obj == nil { return graphql.Null } return ec._Cat(ctx, sel, obj) default: if typedObj, ok := obj.(graphql.Marshaler); ok { return typedObj } else { panic(fmt.Errorf("unexpected type %T; non-generated variants of Animal must implement graphql.Marshaler", obj)) } } } func (ec *executionContext) _Content_Child(ctx context.Context, sel ast.SelectionSet, obj ContentChild) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null case ContentUser: return ec._Content_User(ctx, sel, &obj) case *ContentUser: if obj == nil { return graphql.Null } return ec._Content_User(ctx, sel, obj) case ContentPost: return ec._Content_Post(ctx, sel, &obj) case *ContentPost: if obj == nil { return graphql.Null } return ec._Content_Post(ctx, sel, obj) default: if typedObj, ok := obj.(graphql.Marshaler); ok { return typedObj } else { panic(fmt.Errorf("unexpected type %T; non-generated variants of Content_Child must implement graphql.Marshaler", obj)) } } } func (ec *executionContext) _Mammalian(ctx context.Context, sel ast.SelectionSet, obj Mammalian) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null case Horse: return ec._Horse(ctx, sel, &obj) case *Horse: if obj == nil { return graphql.Null } return ec._Horse(ctx, sel, obj) default: if typedObj, ok := obj.(graphql.Marshaler); ok { return typedObj } else { panic(fmt.Errorf("unexpected type %T; non-generated variants of Mammalian must implement graphql.Marshaler", obj)) } } } func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj Node) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null case ConcreteNodeInterface: if obj == nil { return graphql.Null } return ec._ConcreteNodeInterface(ctx, sel, obj) case *ConcreteNodeA: if obj == nil { return graphql.Null } return ec._ConcreteNodeA(ctx, sel, obj) default: if typedObj, ok := obj.(graphql.Marshaler); ok { return typedObj } else { panic(fmt.Errorf("unexpected type %T; non-generated variants of Node must implement graphql.Marshaler", obj)) } } } func (ec *executionContext) _Shape(ctx context.Context, sel ast.SelectionSet, obj Shape) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null case *Rectangle: if obj == nil { return graphql.Null } return ec._Rectangle(ctx, sel, obj) case *Circle: if obj == nil { return graphql.Null } return ec._Circle(ctx, sel, obj) default: if typedObj, ok := obj.(graphql.Marshaler); ok { return typedObj } else { panic(fmt.Errorf("unexpected type %T; non-generated variants of Shape must implement graphql.Marshaler", obj)) } } } func (ec *executionContext) _ShapeUnion(ctx context.Context, sel ast.SelectionSet, obj ShapeUnion) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null case *Rectangle: if obj == nil { return graphql.Null } return ec._Rectangle(ctx, sel, obj) case *Circle: if obj == nil { return graphql.Null } return ec._Circle(ctx, sel, obj) default: if typedObj, ok := obj.(graphql.Marshaler); ok { return typedObj } else { panic(fmt.Errorf("unexpected type %T; non-generated variants of ShapeUnion must implement graphql.Marshaler", obj)) } } } func (ec *executionContext) _TestUnion(ctx context.Context, sel ast.SelectionSet, obj TestUnion) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null case B: return ec._B(ctx, sel, &obj) case *B: if obj == nil { return graphql.Null } return ec._B(ctx, sel, obj) case A: return ec._A(ctx, sel, &obj) case *A: if obj == nil { return graphql.Null } return ec._A(ctx, sel, obj) default: if typedObj, ok := obj.(graphql.Marshaler); ok { return typedObj } else { panic(fmt.Errorf("unexpected type %T; non-generated variants of TestUnion must implement graphql.Marshaler", obj)) } } } // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var aImplementors = []string{"A", "TestUnion"} func (ec *executionContext) _A(ctx context.Context, sel ast.SelectionSet, obj *A) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, aImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("A") case "id": out.Values[i] = ec._A_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var aItImplementors = []string{"AIt"} func (ec *executionContext) _AIt(ctx context.Context, sel ast.SelectionSet, obj *AIt) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, aItImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("AIt") case "id": out.Values[i] = ec._AIt_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var abItImplementors = []string{"AbIt"} func (ec *executionContext) _AbIt(ctx context.Context, sel ast.SelectionSet, obj *AbIt) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, abItImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("AbIt") case "id": out.Values[i] = ec._AbIt_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var autobindImplementors = []string{"Autobind"} func (ec *executionContext) _Autobind(ctx context.Context, sel ast.SelectionSet, obj *Autobind) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, autobindImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Autobind") case "int": out.Values[i] = ec._Autobind_int(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "int32": out.Values[i] = ec._Autobind_int32(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "int64": out.Values[i] = ec._Autobind_int64(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "idStr": out.Values[i] = ec._Autobind_idStr(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "idInt": out.Values[i] = ec._Autobind_idInt(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var bImplementors = []string{"B", "TestUnion"} func (ec *executionContext) _B(ctx context.Context, sel ast.SelectionSet, obj *B) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, bImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("B") case "id": out.Values[i] = ec._B_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var backedByInterfaceImplementors = []string{"BackedByInterface"} func (ec *executionContext) _BackedByInterface(ctx context.Context, sel ast.SelectionSet, obj BackedByInterface) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, backedByInterfaceImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("BackedByInterface") case "id": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._BackedByInterface_id(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "thisShouldBind": out.Values[i] = ec._BackedByInterface_thisShouldBind(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "thisShouldBindWithError": out.Values[i] = ec._BackedByInterface_thisShouldBindWithError(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var catImplementors = []string{"Cat", "Animal"} func (ec *executionContext) _Cat(ctx context.Context, sel ast.SelectionSet, obj *Cat) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, catImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Cat") case "species": out.Values[i] = ec._Cat_species(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "size": out.Values[i] = ec._Cat_size(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "catBreed": out.Values[i] = ec._Cat_catBreed(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var checkIssue896Implementors = []string{"CheckIssue896"} func (ec *executionContext) _CheckIssue896(ctx context.Context, sel ast.SelectionSet, obj *CheckIssue896) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, checkIssue896Implementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("CheckIssue896") case "id": out.Values[i] = ec._CheckIssue896_id(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var circleImplementors = []string{"Circle", "Shape", "ShapeUnion"} func (ec *executionContext) _Circle(ctx context.Context, sel ast.SelectionSet, obj *Circle) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, circleImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Circle") case "radius": out.Values[i] = ec._Circle_radius(ctx, field, obj) case "area": out.Values[i] = ec._Circle_area(ctx, field, obj) case "coordinates": out.Values[i] = ec._Circle_coordinates(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var concreteNodeAImplementors = []string{"ConcreteNodeA", "Node"} func (ec *executionContext) _ConcreteNodeA(ctx context.Context, sel ast.SelectionSet, obj *ConcreteNodeA) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, concreteNodeAImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("ConcreteNodeA") case "id": out.Values[i] = ec._ConcreteNodeA_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "child": out.Values[i] = ec._ConcreteNodeA_child(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "name": out.Values[i] = ec._ConcreteNodeA_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var concreteNodeInterfaceImplementors = []string{"ConcreteNodeInterface", "Node"} func (ec *executionContext) _ConcreteNodeInterface(ctx context.Context, sel ast.SelectionSet, obj ConcreteNodeInterface) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, concreteNodeInterfaceImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("ConcreteNodeInterface") case "id": out.Values[i] = ec._ConcreteNodeInterface_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "child": out.Values[i] = ec._ConcreteNodeInterface_child(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var content_PostImplementors = []string{"Content_Post", "Content_Child"} func (ec *executionContext) _Content_Post(ctx context.Context, sel ast.SelectionSet, obj *ContentPost) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, content_PostImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Content_Post") case "foo": out.Values[i] = ec._Content_Post_foo(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var content_UserImplementors = []string{"Content_User", "Content_Child"} func (ec *executionContext) _Content_User(ctx context.Context, sel ast.SelectionSet, obj *ContentUser) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, content_UserImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Content_User") case "foo": out.Values[i] = ec._Content_User_foo(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var coordinatesImplementors = []string{"Coordinates"} func (ec *executionContext) _Coordinates(ctx context.Context, sel ast.SelectionSet, obj *Coordinates) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, coordinatesImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Coordinates") case "x": out.Values[i] = ec._Coordinates_x(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "y": out.Values[i] = ec._Coordinates_y(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var defaultParametersMirrorImplementors = []string{"DefaultParametersMirror"} func (ec *executionContext) _DefaultParametersMirror(ctx context.Context, sel ast.SelectionSet, obj *DefaultParametersMirror) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, defaultParametersMirrorImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("DefaultParametersMirror") case "falsyBoolean": out.Values[i] = ec._DefaultParametersMirror_falsyBoolean(ctx, field, obj) case "truthyBoolean": out.Values[i] = ec._DefaultParametersMirror_truthyBoolean(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var deferModelImplementors = []string{"DeferModel"} func (ec *executionContext) _DeferModel(ctx context.Context, sel ast.SelectionSet, obj *DeferModel) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, deferModelImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("DeferModel") case "id": out.Values[i] = ec._DeferModel_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "name": out.Values[i] = ec._DeferModel_name(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "values": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._DeferModel_values(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var dogImplementors = []string{"Dog", "Animal"} func (ec *executionContext) _Dog(ctx context.Context, sel ast.SelectionSet, obj *Dog) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, dogImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Dog") case "species": out.Values[i] = ec._Dog_species(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "size": out.Values[i] = ec._Dog_size(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "dogBreed": out.Values[i] = ec._Dog_dogBreed(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var embeddedCase1Implementors = []string{"EmbeddedCase1"} func (ec *executionContext) _EmbeddedCase1(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedCase1) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, embeddedCase1Implementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("EmbeddedCase1") case "exportedEmbeddedPointerExportedMethod": out.Values[i] = ec._EmbeddedCase1_exportedEmbeddedPointerExportedMethod(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var embeddedCase2Implementors = []string{"EmbeddedCase2"} func (ec *executionContext) _EmbeddedCase2(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedCase2) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, embeddedCase2Implementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("EmbeddedCase2") case "unexportedEmbeddedPointerExportedMethod": out.Values[i] = ec._EmbeddedCase2_unexportedEmbeddedPointerExportedMethod(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var embeddedCase3Implementors = []string{"EmbeddedCase3"} func (ec *executionContext) _EmbeddedCase3(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedCase3) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, embeddedCase3Implementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("EmbeddedCase3") case "unexportedEmbeddedInterfaceExportedMethod": out.Values[i] = ec._EmbeddedCase3_unexportedEmbeddedInterfaceExportedMethod(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var embeddedDefaultScalarImplementors = []string{"EmbeddedDefaultScalar"} func (ec *executionContext) _EmbeddedDefaultScalar(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedDefaultScalar) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, embeddedDefaultScalarImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("EmbeddedDefaultScalar") case "value": out.Values[i] = ec._EmbeddedDefaultScalar_value(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var embeddedPointerImplementors = []string{"EmbeddedPointer"} func (ec *executionContext) _EmbeddedPointer(ctx context.Context, sel ast.SelectionSet, obj *EmbeddedPointerModel) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, embeddedPointerImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("EmbeddedPointer") case "ID": out.Values[i] = ec._EmbeddedPointer_ID(ctx, field, obj) case "Title": out.Values[i] = ec._EmbeddedPointer_Title(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var errorImplementors = []string{"Error"} func (ec *executionContext) _Error(ctx context.Context, sel ast.SelectionSet, obj *Error) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, errorImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Error") case "id": out.Values[i] = ec._Error_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "errorOnNonRequiredField": out.Values[i] = ec._Error_errorOnNonRequiredField(ctx, field, obj) case "errorOnRequiredField": out.Values[i] = ec._Error_errorOnRequiredField(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "nilOnRequiredField": out.Values[i] = ec._Error_nilOnRequiredField(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var errorsImplementors = []string{"Errors"} func (ec *executionContext) _Errors(ctx context.Context, sel ast.SelectionSet, obj *Errors) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, errorsImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Errors") case "a": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Errors_a(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "b": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Errors_b(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "c": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Errors_c(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "d": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Errors_d(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "e": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Errors_e(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var fieldsOrderPayloadImplementors = []string{"FieldsOrderPayload"} func (ec *executionContext) _FieldsOrderPayload(ctx context.Context, sel ast.SelectionSet, obj *FieldsOrderPayload) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, fieldsOrderPayloadImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("FieldsOrderPayload") case "firstFieldValue": out.Values[i] = ec._FieldsOrderPayload_firstFieldValue(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var forcedResolverImplementors = []string{"ForcedResolver"} func (ec *executionContext) _ForcedResolver(ctx context.Context, sel ast.SelectionSet, obj *ForcedResolver) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, forcedResolverImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("ForcedResolver") case "field": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._ForcedResolver_field(ctx, field, obj) return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var horseImplementors = []string{"Horse", "Mammalian", "Animal"} func (ec *executionContext) _Horse(ctx context.Context, sel ast.SelectionSet, obj *Horse) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, horseImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Horse") case "species": out.Values[i] = ec._Horse_species(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "size": out.Values[i] = ec._Horse_size(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "horseBreed": out.Values[i] = ec._Horse_horseBreed(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var innerObjectImplementors = []string{"InnerObject"} func (ec *executionContext) _InnerObject(ctx context.Context, sel ast.SelectionSet, obj *InnerObject) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, innerObjectImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("InnerObject") case "id": out.Values[i] = ec._InnerObject_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var invalidIdentifierImplementors = []string{"InvalidIdentifier"} func (ec *executionContext) _InvalidIdentifier(ctx context.Context, sel ast.SelectionSet, obj *invalid_packagename.InvalidIdentifier) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, invalidIdentifierImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("InvalidIdentifier") case "id": out.Values[i] = ec._InvalidIdentifier_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var itImplementors = []string{"It"} func (ec *executionContext) _It(ctx context.Context, sel ast.SelectionSet, obj *introspection1.It) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, itImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("It") case "id": out.Values[i] = ec._It_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var loopAImplementors = []string{"LoopA"} func (ec *executionContext) _LoopA(ctx context.Context, sel ast.SelectionSet, obj *LoopA) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, loopAImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("LoopA") case "b": out.Values[i] = ec._LoopA_b(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var loopBImplementors = []string{"LoopB"} func (ec *executionContext) _LoopB(ctx context.Context, sel ast.SelectionSet, obj *LoopB) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, loopBImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("LoopB") case "a": out.Values[i] = ec._LoopB_a(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var mapImplementors = []string{"Map"} func (ec *executionContext) _Map(ctx context.Context, sel ast.SelectionSet, obj *Map) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, mapImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Map") case "id": out.Values[i] = ec._Map_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var mapNestedImplementors = []string{"MapNested"} func (ec *executionContext) _MapNested(ctx context.Context, sel ast.SelectionSet, obj *MapNested) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, mapNestedImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("MapNested") case "value": out.Values[i] = ec._MapNested_value(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var mapStringInterfaceTypeImplementors = []string{"MapStringInterfaceType"} func (ec *executionContext) _MapStringInterfaceType(ctx context.Context, sel ast.SelectionSet, obj map[string]any) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, mapStringInterfaceTypeImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("MapStringInterfaceType") case "a": out.Values[i] = ec._MapStringInterfaceType_a(ctx, field, obj) case "b": out.Values[i] = ec._MapStringInterfaceType_b(ctx, field, obj) case "c": out.Values[i] = ec._MapStringInterfaceType_c(ctx, field, obj) case "nested": out.Values[i] = ec._MapStringInterfaceType_nested(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var modelMethodsImplementors = []string{"ModelMethods"} func (ec *executionContext) _ModelMethods(ctx context.Context, sel ast.SelectionSet, obj *ModelMethods) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, modelMethodsImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("ModelMethods") case "resolverField": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._ModelMethods_resolverField(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "noContext": out.Values[i] = ec._ModelMethods_noContext(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "withContext": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._ModelMethods_withContext(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var mutationImplementors = []string{"Mutation"} func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, mutationImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Mutation", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Mutation") case "defaultInput": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_defaultInput(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } case "overrideValueViaInput": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_overrideValueViaInput(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } case "updateProduct": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_updateProduct(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } case "issue4053": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_issue4053(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } case "updateSomething": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_updateSomething(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } case "updatePtrToPtr": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_updatePtrToPtr(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var objectDirectivesImplementors = []string{"ObjectDirectives"} func (ec *executionContext) _ObjectDirectives(ctx context.Context, sel ast.SelectionSet, obj *ObjectDirectives) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, objectDirectivesImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("ObjectDirectives") case "text": out.Values[i] = ec._ObjectDirectives_text(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "nullableText": out.Values[i] = ec._ObjectDirectives_nullableText(ctx, field, obj) case "order": out.Values[i] = ec._ObjectDirectives_order(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var objectDirectivesWithCustomGoModelImplementors = []string{"ObjectDirectivesWithCustomGoModel"} func (ec *executionContext) _ObjectDirectivesWithCustomGoModel(ctx context.Context, sel ast.SelectionSet, obj *ObjectDirectivesWithCustomGoModel) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, objectDirectivesWithCustomGoModelImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("ObjectDirectivesWithCustomGoModel") case "nullableText": out.Values[i] = ec._ObjectDirectivesWithCustomGoModel_nullableText(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var outerObjectImplementors = []string{"OuterObject"} func (ec *executionContext) _OuterObject(ctx context.Context, sel ast.SelectionSet, obj *OuterObject) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, outerObjectImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("OuterObject") case "inner": out.Values[i] = ec._OuterObject_inner(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var overlappingFieldsImplementors = []string{"OverlappingFields"} func (ec *executionContext) _OverlappingFields(ctx context.Context, sel ast.SelectionSet, obj *OverlappingFields) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, overlappingFieldsImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("OverlappingFields") case "oneFoo": out.Values[i] = ec._OverlappingFields_oneFoo(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "twoFoo": out.Values[i] = ec._OverlappingFields_twoFoo(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "oldFoo": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._OverlappingFields_oldFoo(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "newFoo": out.Values[i] = ec._OverlappingFields_newFoo(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "new_foo": out.Values[i] = ec._OverlappingFields_new_foo(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var panicsImplementors = []string{"Panics"} func (ec *executionContext) _Panics(ctx context.Context, sel ast.SelectionSet, obj *Panics) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, panicsImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Panics") case "fieldScalarMarshal": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Panics_fieldScalarMarshal(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "fieldFuncMarshal": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Panics_fieldFuncMarshal(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "argUnmarshal": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Panics_argUnmarshal(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var petImplementors = []string{"Pet"} func (ec *executionContext) _Pet(ctx context.Context, sel ast.SelectionSet, obj *Pet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, petImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Pet") case "id": out.Values[i] = ec._Pet_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "friends": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Pet_friends(ctx, field, obj) return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var primitiveImplementors = []string{"Primitive"} func (ec *executionContext) _Primitive(ctx context.Context, sel ast.SelectionSet, obj *Primitive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, primitiveImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Primitive") case "value": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Primitive_value(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "squared": out.Values[i] = ec._Primitive_squared(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var primitiveStringImplementors = []string{"PrimitiveString"} func (ec *executionContext) _PrimitiveString(ctx context.Context, sel ast.SelectionSet, obj *PrimitiveString) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, primitiveStringImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("PrimitiveString") case "value": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._PrimitiveString_value(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "doubled": out.Values[i] = ec._PrimitiveString_doubled(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "len": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._PrimitiveString_len(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var ptrToAnyContainerImplementors = []string{"PtrToAnyContainer"} func (ec *executionContext) _PtrToAnyContainer(ctx context.Context, sel ast.SelectionSet, obj *PtrToAnyContainer) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, ptrToAnyContainerImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("PtrToAnyContainer") case "ptrToAny": out.Values[i] = ec._PtrToAnyContainer_ptrToAny(ctx, field, obj) case "binding": out.Values[i] = ec._PtrToAnyContainer_binding(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var ptrToPtrInnerImplementors = []string{"PtrToPtrInner"} func (ec *executionContext) _PtrToPtrInner(ctx context.Context, sel ast.SelectionSet, obj *PtrToPtrInner) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, ptrToPtrInnerImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("PtrToPtrInner") case "key": out.Values[i] = ec._PtrToPtrInner_key(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "value": out.Values[i] = ec._PtrToPtrInner_value(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var ptrToPtrOuterImplementors = []string{"PtrToPtrOuter"} func (ec *executionContext) _PtrToPtrOuter(ctx context.Context, sel ast.SelectionSet, obj *PtrToPtrOuter) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, ptrToPtrOuterImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("PtrToPtrOuter") case "name": out.Values[i] = ec._PtrToPtrOuter_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "inner": out.Values[i] = ec._PtrToPtrOuter_inner(ctx, field, obj) case "stupidInner": out.Values[i] = ec._PtrToPtrOuter_stupidInner(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var ptrToSliceContainerImplementors = []string{"PtrToSliceContainer"} func (ec *executionContext) _PtrToSliceContainer(ctx context.Context, sel ast.SelectionSet, obj *PtrToSliceContainer) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, ptrToSliceContainerImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("PtrToSliceContainer") case "ptrToSlice": out.Values[i] = ec._PtrToSliceContainer_ptrToSlice(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Query", }) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, Field: field, }) switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "invalidIdentifier": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_invalidIdentifier(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "collision": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_collision(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "mapInput": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_mapInput(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "recursive": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_recursive(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "nestedInputs": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_nestedInputs(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "nestedOutputs": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_nestedOutputs(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "modelMethods": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_modelMethods(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "user": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_user(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "nullableArg": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_nullableArg(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "inputSlice": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_inputSlice(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "inputNullableSlice": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_inputNullableSlice(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "inputOmittable": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_inputOmittable(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "shapeUnion": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_shapeUnion(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "autobind": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_autobind(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "deprecatedField": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_deprecatedField(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "fieldWithDeprecatedArg": 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_fieldWithDeprecatedArg(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 "overlapping": 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_overlapping(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "defaultParameters": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_defaultParameters(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "deferSingle": 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_deferSingle(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 "deferMultiple": 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_deferMultiple(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveArg": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_directiveArg(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveNullableArg": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_directiveNullableArg(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveSingleNullableArg": 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_directiveSingleNullableArg(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveInputNullable": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_directiveInputNullable(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveInput": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_directiveInput(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveInputType": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_directiveInputType(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveInputOuter": 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_directiveInputOuter(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveObject": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_directiveObject(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveObjectWithCustomGoModel": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_directiveObjectWithCustomGoModel(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveFieldDef": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_directiveFieldDef(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveField": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_directiveField(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveDouble": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_directiveDouble(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "directiveUnimplemented": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_directiveUnimplemented(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "embeddedCase1": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_embeddedCase1(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "embeddedCase2": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_embeddedCase2(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "embeddedCase3": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_embeddedCase3(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "enumInInput": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_enumInInput(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "searchProducts": field := field innerFunc := func(ctx 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_searchProducts(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 "searchRequired": field := field innerFunc := func(ctx 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_searchRequired(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 "searchProductsNormal": field := field innerFunc := func(ctx 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_searchProductsNormal(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 "searchWithDefaults": field := field innerFunc := func(ctx 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_searchWithDefaults(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 "searchMixed": field := field innerFunc := func(ctx 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_searchMixed(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 "filterProducts": field := field innerFunc := func(ctx 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_filterProducts(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 "findProducts": field := field innerFunc := func(ctx 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_findProducts(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 "searchWithDirectives": field := field innerFunc := func(ctx 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_searchWithDirectives(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "shapes": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_shapes(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "noShape": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_noShape(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "node": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_node(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "noShapeTypedNil": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_noShapeTypedNil(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "animal": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_animal(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "notAnInterface": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_notAnInterface(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "dog": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_dog(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "issue896a": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_issue896a(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "mapStringInterface": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_mapStringInterface(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "mapNestedStringInterface": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_mapNestedStringInterface(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "mapNestedMapSlice": 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_mapNestedMapSlice(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "errorBubble": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_errorBubble(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "errorBubbleList": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_errorBubbleList(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "errorList": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_errorList(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "errors": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_errors(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "valid": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_valid(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "invalid": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_invalid(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "panics": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_panics(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "primitiveObject": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_primitiveObject(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "primitiveStringObject": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_primitiveStringObject(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "ptrToAnyContainer": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_ptrToAnyContainer(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "ptrToSliceContainer": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_ptrToSliceContainer(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "infinity": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_infinity(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "stringFromContextInterface": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_stringFromContextInterface(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "stringFromContextFunction": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_stringFromContextFunction(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "defaultScalar": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_defaultScalar(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "skipInclude": 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_skipInclude(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 "slices": 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_slices(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "scalarSlice": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_scalarSlice(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "fallback": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_fallback(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "optionalUnion": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_optionalUnion(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "vOkCaseValue": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_vOkCaseValue(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "vOkCaseNil": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_vOkCaseNil(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "validType": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_validType(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "variadicModel": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_variadicModel(ctx, field) return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "wrappedStruct": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_wrappedStruct(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "wrappedScalar": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_wrappedScalar(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "wrappedMap": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_wrappedMap(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "wrappedSlice": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_wrappedSlice(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } rrm := func(ctx context.Context) graphql.Marshaler { return ec.OperationContext.RootResolverMiddleware(ctx, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___type(ctx, field) }) case "__schema": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Query___schema(ctx, field) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var rectangleImplementors = []string{"Rectangle", "Shape", "ShapeUnion"} func (ec *executionContext) _Rectangle(ctx context.Context, sel ast.SelectionSet, obj *Rectangle) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, rectangleImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Rectangle") case "length": out.Values[i] = ec._Rectangle_length(ctx, field, obj) case "width": out.Values[i] = ec._Rectangle_width(ctx, field, obj) case "area": out.Values[i] = ec._Rectangle_area(ctx, field, obj) case "coordinates": out.Values[i] = ec._Rectangle_coordinates(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var sizeImplementors = []string{"Size"} func (ec *executionContext) _Size(ctx context.Context, sel ast.SelectionSet, obj *Size) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, sizeImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Size") case "height": out.Values[i] = ec._Size_height(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "weight": out.Values[i] = ec._Size_weight(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var skipIncludeTestTypeImplementors = []string{"SkipIncludeTestType"} func (ec *executionContext) _SkipIncludeTestType(ctx context.Context, sel ast.SelectionSet, obj *SkipIncludeTestType) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, skipIncludeTestTypeImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("SkipIncludeTestType") case "a": out.Values[i] = ec._SkipIncludeTestType_a(ctx, field, obj) case "b": out.Values[i] = ec._SkipIncludeTestType_b(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 slicesImplementors = []string{"Slices"} func (ec *executionContext) _Slices(ctx context.Context, sel ast.SelectionSet, obj *Slices) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, slicesImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Slices") case "test1": out.Values[i] = ec._Slices_test1(ctx, field, obj) case "test2": out.Values[i] = ec._Slices_test2(ctx, field, obj) case "test3": out.Values[i] = ec._Slices_test3(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "test4": out.Values[i] = ec._Slices_test4(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var subscriptionImplementors = []string{"Subscription"} func (ec *executionContext) _Subscription(ctx context.Context, sel ast.SelectionSet) func(ctx context.Context) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, subscriptionImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ Object: "Subscription", }) if len(fields) != 1 { graphql.AddErrorf(ctx, "must subscribe to exactly one stream") return nil } switch fields[0].Name { case "updated": return ec._Subscription_updated(ctx, fields[0]) case "initPayload": return ec._Subscription_initPayload(ctx, fields[0]) case "directiveArg": return ec._Subscription_directiveArg(ctx, fields[0]) case "directiveNullableArg": return ec._Subscription_directiveNullableArg(ctx, fields[0]) case "directiveDouble": return ec._Subscription_directiveDouble(ctx, fields[0]) case "directiveUnimplemented": return ec._Subscription_directiveUnimplemented(ctx, fields[0]) case "issue896b": return ec._Subscription_issue896b(ctx, fields[0]) case "errorRequired": return ec._Subscription_errorRequired(ctx, fields[0]) default: panic("unknown field " + strconv.Quote(fields[0].Name)) } } var userImplementors = []string{"User"} func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *User) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("User") case "id": out.Values[i] = ec._User_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "friends": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._User_friends(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "created": out.Values[i] = ec._User_created(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "updated": out.Values[i] = ec._User_updated(ctx, field, obj) case "pets": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._User_pets(ctx, field, obj) return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var vOkCaseNilImplementors = []string{"VOkCaseNil"} func (ec *executionContext) _VOkCaseNil(ctx context.Context, sel ast.SelectionSet, obj *VOkCaseNil) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, vOkCaseNilImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("VOkCaseNil") case "value": out.Values[i] = ec._VOkCaseNil_value(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var vOkCaseValueImplementors = []string{"VOkCaseValue"} func (ec *executionContext) _VOkCaseValue(ctx context.Context, sel ast.SelectionSet, obj *VOkCaseValue) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, vOkCaseValueImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("VOkCaseValue") case "value": out.Values[i] = ec._VOkCaseValue_value(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var validTypeImplementors = []string{"ValidType"} func (ec *executionContext) _ValidType(ctx context.Context, sel ast.SelectionSet, obj *ValidType) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, validTypeImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("ValidType") case "differentCase": out.Values[i] = ec._ValidType_differentCase(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "different_case": out.Values[i] = ec._ValidType_different_case(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "validInputKeywords": out.Values[i] = ec._ValidType_validInputKeywords(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "validArgs": out.Values[i] = ec._ValidType_validArgs(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var variadicModelImplementors = []string{"VariadicModel"} func (ec *executionContext) _VariadicModel(ctx context.Context, sel ast.SelectionSet, obj *VariadicModel) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, variadicModelImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("VariadicModel") case "value": field := field innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._VariadicModel_value(ctx, field, obj) return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var wrappedMapImplementors = []string{"WrappedMap"} func (ec *executionContext) _WrappedMap(ctx context.Context, sel ast.SelectionSet, obj WrappedMap) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, wrappedMapImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("WrappedMap") case "get": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._WrappedMap_get(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var wrappedSliceImplementors = []string{"WrappedSlice"} func (ec *executionContext) _WrappedSlice(ctx context.Context, sel ast.SelectionSet, obj WrappedSlice) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, wrappedSliceImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("WrappedSlice") case "get": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._WrappedSlice_get(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } return res } if field.Deferrable != nil { dfs, ok := deferred[field.Deferrable.Label] di := 0 if ok { dfs.AddField(field) di = len(dfs.Values) - 1 } else { dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) deferred[field.Deferrable.Label] = dfs } dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, dfs) }) // don't run the out.Concurrently() call below out.Values[i] = graphql.Null continue } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var wrappedStructImplementors = []string{"WrappedStruct"} func (ec *executionContext) _WrappedStruct(ctx context.Context, sel ast.SelectionSet, obj *WrappedStruct) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, wrappedStructImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("WrappedStruct") case "name": out.Values[i] = ec._WrappedStruct_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "desc": out.Values[i] = ec._WrappedStruct_desc(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var xXItImplementors = []string{"XXIt"} func (ec *executionContext) _XXIt(ctx context.Context, sel ast.SelectionSet, obj *XXIt) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, xXItImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("XXIt") case "id": out.Values[i] = ec._XXIt_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var xxItImplementors = []string{"XxIt"} func (ec *executionContext) _XxIt(ctx context.Context, sel ast.SelectionSet, obj *XxIt) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, xxItImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("XxIt") case "id": out.Values[i] = ec._XxIt_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var __DirectiveImplementors = []string{"__Directive"} func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Directive") case "name": out.Values[i] = ec.___Directive_name(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "description": out.Values[i] = ec.___Directive_description(ctx, field, obj) case "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 } var asdfItImplementors = []string{"asdfIt"} func (ec *executionContext) _asdfIt(ctx context.Context, sel ast.SelectionSet, obj *AsdfIt) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, asdfItImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("asdfIt") case "id": out.Values[i] = ec._asdfIt_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } var iItImplementors = []string{"iIt"} func (ec *executionContext) _iIt(ctx context.Context, sel ast.SelectionSet, obj *IIt) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, iItImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("iIt") case "id": out.Values[i] = ec._iIt_id(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch(ctx) if out.Invalids > 0 { return graphql.Null } atomic.AddInt32(&ec.Deferred, int32(len(deferred))) for label, dfs := range deferred { ec.ProcessDeferredGroup(graphql.DeferredGroup{ Label: label, Path: graphql.GetPath(ctx), FieldSet: dfs, Context: ctx, }) } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v 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) unmarshalNBytes2ᚕbyte(ctx context.Context, v any) ([]byte, error) { res, err := UnmarshalBytes(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNBytes2ᚕbyte(ctx context.Context, sel ast.SelectionSet, v []byte) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } _ = sel res := MarshalBytes(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) marshalNCheckIssue8962ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCheckIssue896(ctx context.Context, sel ast.SelectionSet, v *CheckIssue896) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._CheckIssue896(ctx, sel, v) } func (ec *executionContext) unmarshalNCustomScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCustomScalar(ctx context.Context, v any) (CustomScalar, error) { var res CustomScalar err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNCustomScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCustomScalar(ctx context.Context, sel ast.SelectionSet, v CustomScalar) graphql.Marshaler { return v } func (ec *executionContext) unmarshalNDefaultInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDefaultInput(ctx context.Context, v any) (DefaultInput, error) { res, err := ec.unmarshalInputDefaultInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNDefaultParametersMirror2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDefaultParametersMirror(ctx context.Context, sel ast.SelectionSet, v DefaultParametersMirror) graphql.Marshaler { return ec._DefaultParametersMirror(ctx, sel, &v) } func (ec *executionContext) marshalNDefaultParametersMirror2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDefaultParametersMirror(ctx context.Context, sel ast.SelectionSet, v *DefaultParametersMirror) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._DefaultParametersMirror(ctx, sel, v) } func (ec *executionContext) unmarshalNDefaultScalarImplementation2string(ctx context.Context, v any) (string, error) { res, err := graphql.UnmarshalString(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNDefaultScalarImplementation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { _ = 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) marshalNDeferModel2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDeferModel(ctx context.Context, sel ast.SelectionSet, v *DeferModel) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._DeferModel(ctx, sel, v) } func (ec *executionContext) unmarshalNEmail2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEmail(ctx context.Context, v any) (Email, error) { var res Email err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNEmail2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEmail(ctx context.Context, sel ast.SelectionSet, v Email) graphql.Marshaler { return v } func (ec *executionContext) unmarshalNEnumTest2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEnumTest(ctx context.Context, v any) (EnumTest, error) { var res EnumTest err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNEnumTest2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEnumTest(ctx context.Context, sel ast.SelectionSet, v EnumTest) graphql.Marshaler { return v } func (ec *executionContext) marshalNError2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx context.Context, sel ast.SelectionSet, v Error) graphql.Marshaler { return ec._Error(ctx, sel, &v) } func (ec *executionContext) marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx context.Context, sel ast.SelectionSet, v *Error) 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._Error(ctx, sel, v) } func (ec *executionContext) unmarshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐFallbackToStringEncoding(ctx context.Context, v any) (FallbackToStringEncoding, error) { tmp, err := graphql.UnmarshalString(v) res := FallbackToStringEncoding(tmp) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNFallbackToStringEncoding2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐFallbackToStringEncoding(ctx context.Context, sel ast.SelectionSet, v FallbackToStringEncoding) graphql.Marshaler { _ = sel res := graphql.MarshalString(string(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) unmarshalNFieldsOrderInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐFieldsOrderInput(ctx context.Context, v any) (FieldsOrderInput, error) { res, err := ec.unmarshalInputFieldsOrderInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNFieldsOrderPayload2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐFieldsOrderPayload(ctx context.Context, sel ast.SelectionSet, v FieldsOrderPayload) graphql.Marshaler { return ec._FieldsOrderPayload(ctx, sel, &v) } func (ec *executionContext) marshalNFieldsOrderPayload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐFieldsOrderPayload(ctx context.Context, sel ast.SelectionSet, v *FieldsOrderPayload) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._FieldsOrderPayload(ctx, sel, v) } func (ec *executionContext) unmarshalNFloat2float64(ctx context.Context, v 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) unmarshalNID2int(ctx context.Context, v any) (int, error) { res, err := graphql.UnmarshalIntID(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNID2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { _ = sel res := graphql.MarshalIntID(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) unmarshalNInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInnerDirectives(ctx context.Context, v any) (*InnerDirectives, error) { res, err := ec.unmarshalInputInnerDirectives(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalNInnerInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInnerInput(ctx context.Context, v any) (InnerInput, error) { res, err := ec.unmarshalInputInnerInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalNInnerInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInnerInput(ctx context.Context, v any) (*InnerInput, error) { res, err := ec.unmarshalInputInnerInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNInnerObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInnerObject(ctx context.Context, sel ast.SelectionSet, v *InnerObject) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._InnerObject(ctx, sel, v) } func (ec *executionContext) unmarshalNInputDirectives2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInputDirectives(ctx context.Context, v any) (InputDirectives, error) { res, err := ec.unmarshalInputInputDirectives(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalNInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInputDirectives(ctx context.Context, v any) (*InputDirectives, error) { res, err := ec.unmarshalInputInputDirectives(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } 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) unmarshalNInt2int32(ctx context.Context, v any) (int32, error) { res, err := graphql.UnmarshalInt32(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNInt2int32(ctx context.Context, sel ast.SelectionSet, v int32) graphql.Marshaler { _ = sel res := graphql.MarshalInt32(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) unmarshalNInt2int64(ctx context.Context, v any) (int64, error) { res, err := graphql.UnmarshalInt64(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNInt2int64(ctx context.Context, sel ast.SelectionSet, v int64) graphql.Marshaler { _ = sel res := graphql.MarshalInt64(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) marshalNLoopA2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐLoopA(ctx context.Context, sel ast.SelectionSet, v *LoopA) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._LoopA(ctx, sel, v) } func (ec *executionContext) marshalNLoopB2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐLoopB(ctx context.Context, sel ast.SelectionSet, v *LoopB) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._LoopB(ctx, sel, v) } func (ec *executionContext) unmarshalNMapNestedMapSliceInput2map(ctx context.Context, v any) (map[string]any, error) { res, err := ec.unmarshalInputMapNestedMapSliceInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanic(ctx context.Context, v any) (MarshalPanic, error) { var res MarshalPanic err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanic(ctx context.Context, sel ast.SelectionSet, v MarshalPanic) graphql.Marshaler { return v } func (ec *executionContext) unmarshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanicᚄ(ctx context.Context, v any) ([]MarshalPanic, error) { var vSlice []any vSlice = graphql.CoerceList(v) var err error res := make([]MarshalPanic, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) res[i], err = ec.unmarshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanic(ctx, vSlice[i]) if err != nil { return nil, err } } return res, nil } func (ec *executionContext) marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanicᚄ(ctx context.Context, sel ast.SelectionSet, v []MarshalPanic) graphql.Marshaler { ret := make(graphql.Array, len(v)) for i := range v { ret[i] = ec.marshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMarshalPanic(ctx, sel, v[i]) } for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) unmarshalNNestedInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐNestedInput(ctx context.Context, v any) (*NestedInput, error) { res, err := ec.unmarshalInputNestedInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNNode2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐNode(ctx context.Context, sel ast.SelectionSet, v Node) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._Node(ctx, sel, v) } func (ec *executionContext) unmarshalNOmittableInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOmittableInput(ctx context.Context, v any) (OmittableInput, error) { res, err := ec.unmarshalInputOmittableInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalNOuterWrapperInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterWrapperInput(ctx context.Context, v any) (OuterWrapperInput, error) { res, err := ec.unmarshalInputOuterWrapperInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNPet2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPet(ctx context.Context, sel ast.SelectionSet, v *Pet) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._Pet(ctx, sel, v) } func (ec *executionContext) marshalNPrimitive2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPrimitive(ctx context.Context, sel ast.SelectionSet, v Primitive) graphql.Marshaler { return ec._Primitive(ctx, sel, &v) } func (ec *executionContext) marshalNPrimitive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPrimitiveᚄ(ctx context.Context, sel ast.SelectionSet, v []Primitive) 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.marshalNPrimitive2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPrimitive(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalNPrimitiveString2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPrimitiveString(ctx context.Context, sel ast.SelectionSet, v PrimitiveString) graphql.Marshaler { return ec._PrimitiveString(ctx, sel, &v) } func (ec *executionContext) marshalNPrimitiveString2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPrimitiveStringᚄ(ctx context.Context, sel ast.SelectionSet, v []PrimitiveString) 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.marshalNPrimitiveString2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPrimitiveString(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalNPtrToAnyContainer2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToAnyContainer(ctx context.Context, sel ast.SelectionSet, v PtrToAnyContainer) graphql.Marshaler { return ec._PtrToAnyContainer(ctx, sel, &v) } func (ec *executionContext) marshalNPtrToAnyContainer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToAnyContainer(ctx context.Context, sel ast.SelectionSet, v *PtrToAnyContainer) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._PtrToAnyContainer(ctx, sel, v) } func (ec *executionContext) marshalNPtrToPtrOuter2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrOuter(ctx context.Context, sel ast.SelectionSet, v PtrToPtrOuter) graphql.Marshaler { return ec._PtrToPtrOuter(ctx, sel, &v) } func (ec *executionContext) marshalNPtrToPtrOuter2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrOuter(ctx context.Context, sel ast.SelectionSet, v *PtrToPtrOuter) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._PtrToPtrOuter(ctx, sel, v) } func (ec *executionContext) marshalNPtrToSliceContainer2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToSliceContainer(ctx context.Context, sel ast.SelectionSet, v PtrToSliceContainer) graphql.Marshaler { return ec._PtrToSliceContainer(ctx, sel, &v) } func (ec *executionContext) marshalNPtrToSliceContainer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToSliceContainer(ctx context.Context, sel ast.SelectionSet, v *PtrToSliceContainer) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._PtrToSliceContainer(ctx, sel, v) } func (ec *executionContext) unmarshalNRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐRecursiveInputSlice(ctx context.Context, v any) (RecursiveInputSlice, error) { res, err := ec.unmarshalInputRecursiveInputSlice(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNShapeUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐShapeUnion(ctx context.Context, sel ast.SelectionSet, v ShapeUnion) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._ShapeUnion(ctx, sel, v) } func (ec *executionContext) marshalNSize2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐSize(ctx context.Context, sel ast.SelectionSet, v *Size) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._Size(ctx, sel, v) } func (ec *executionContext) unmarshalNSpecialInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐSpecialInput(ctx context.Context, v any) (SpecialInput, error) { res, err := ec.unmarshalInputSpecialInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } 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) 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.unmarshalOString2ᚖstring(ctx, vSlice[i]) if err != nil { return nil, err } } return res, nil } func (ec *executionContext) marshalNString2ᚕᚖstring(ctx context.Context, sel ast.SelectionSet, v []*string) graphql.Marshaler { ret := make(graphql.Array, len(v)) for i := range v { ret[i] = ec.marshalOString2ᚖstring(ctx, sel, v[i]) } return ret } func (ec *executionContext) unmarshalNString2ᚖstring(ctx context.Context, v any) (*string, error) { res, err := graphql.UnmarshalString(v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } _ = 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) unmarshalNStringFromContextFunction2string(ctx context.Context, v any) (string, error) { res, err := UnmarshalStringFromContextFunction(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNStringFromContextFunction2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { _ = sel res := MarshalStringFromContextFunction(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) unmarshalNStringFromContextInterface2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐStringFromContextInterface(ctx context.Context, v any) (StringFromContextInterface, error) { var res StringFromContextInterface err := res.UnmarshalGQLContext(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNStringFromContextInterface2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐStringFromContextInterface(ctx context.Context, sel ast.SelectionSet, v StringFromContextInterface) graphql.Marshaler { return graphql.WrapContextMarshaler(ctx, v) } func (ec *executionContext) unmarshalNStringFromContextInterface2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐStringFromContextInterface(ctx context.Context, v any) (*StringFromContextInterface, error) { var res = new(StringFromContextInterface) err := res.UnmarshalGQLContext(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNStringFromContextInterface2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐStringFromContextInterface(ctx context.Context, sel ast.SelectionSet, v *StringFromContextInterface) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return graphql.WrapContextMarshaler(ctx, v) } func (ec *executionContext) unmarshalNTime2timeᚐTime(ctx context.Context, v 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) unmarshalNUUID2string(ctx context.Context, v any) (string, error) { res, err := graphql.UnmarshalString(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNUUID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { _ = 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) unmarshalNUpdatePtrToPtrOuter2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrOuter(ctx context.Context, v any) (UpdatePtrToPtrOuter, error) { res, err := ec.unmarshalInputUpdatePtrToPtrOuter(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNUser2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler { return ec._User(ctx, sel, &v) } func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUserᚄ(ctx context.Context, sel ast.SelectionSet, v []*User) 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.marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐ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ᚋcodegenᚋtestserverᚋsinglefileᚐ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) marshalNWrappedMap2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐWrappedMap(ctx context.Context, sel ast.SelectionSet, v WrappedMap) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._WrappedMap(ctx, sel, v) } func (ec *executionContext) unmarshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋotherpkgᚐScalar(ctx context.Context, v any) (otherpkg.Scalar, error) { tmp, err := graphql.UnmarshalString(v) res := otherpkg.Scalar(tmp) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalNWrappedScalar2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋotherpkgᚐScalar(ctx context.Context, sel ast.SelectionSet, v otherpkg.Scalar) graphql.Marshaler { _ = sel res := graphql.MarshalString(string(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) marshalNWrappedSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐWrappedSlice(ctx context.Context, sel ast.SelectionSet, v WrappedSlice) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } return ec._WrappedSlice(ctx, sel, v) } func (ec *executionContext) marshalNWrappedStruct2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐWrappedStruct(ctx context.Context, sel ast.SelectionSet, v WrappedStruct) graphql.Marshaler { return ec._WrappedStruct(ctx, sel, &v) } func (ec *executionContext) marshalNWrappedStruct2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐWrappedStruct(ctx context.Context, sel ast.SelectionSet, v *WrappedStruct) 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._WrappedStruct(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) marshalOAnimal2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐAnimal(ctx context.Context, sel ast.SelectionSet, v Animal) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Animal(ctx, sel, v) } func (ec *executionContext) unmarshalOAny2interface(ctx context.Context, v any) (any, error) { if v == nil { return nil, nil } res, err := graphql.UnmarshalAny(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOAny2interface(ctx context.Context, sel ast.SelectionSet, v any) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel _ = ctx res := graphql.MarshalAny(v) return res } func (ec *executionContext) unmarshalOAny2ᚖinterface(ctx context.Context, v any) (*any, error) { if v == nil { return nil, nil } res, err := ec.unmarshalOAny2interface(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOAny2ᚖinterface(ctx context.Context, sel ast.SelectionSet, v *any) graphql.Marshaler { return ec.marshalOAny2interface(ctx, sel, *v) } func (ec *executionContext) marshalOAutobind2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐAutobind(ctx context.Context, sel ast.SelectionSet, v *Autobind) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Autobind(ctx, sel, v) } func (ec *executionContext) marshalOBackedByInterface2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐBackedByInterface(ctx context.Context, sel ast.SelectionSet, v BackedByInterface) graphql.Marshaler { if v == nil { return graphql.Null } return ec._BackedByInterface(ctx, sel, v) } func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v 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) unmarshalOChanges2map(ctx context.Context, v any) (map[string]any, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputChanges(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCheckIssue896(ctx context.Context, sel ast.SelectionSet, v []*CheckIssue896) 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.marshalOCheckIssue8962ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCheckIssue896(ctx, sel, v[i]) }) return ret } func (ec *executionContext) marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCheckIssue896ᚄ(ctx context.Context, sel ast.SelectionSet, v []*CheckIssue896) graphql.Marshaler { if v == nil { return graphql.Null } 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.marshalNCheckIssue8962ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCheckIssue896(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalOCheckIssue8962ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCheckIssue896(ctx context.Context, sel ast.SelectionSet, v *CheckIssue896) graphql.Marshaler { if v == nil { return graphql.Null } return ec._CheckIssue896(ctx, sel, v) } func (ec *executionContext) marshalOCircle2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCircle(ctx context.Context, sel ast.SelectionSet, v *Circle) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Circle(ctx, sel, v) } func (ec *executionContext) marshalOCoordinates2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCoordinates(ctx context.Context, sel ast.SelectionSet, v Coordinates) graphql.Marshaler { return ec._Coordinates(ctx, sel, &v) } func (ec *executionContext) unmarshalOCustomScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCustomScalar(ctx context.Context, v any) (*CustomScalar, error) { if v == nil { return nil, nil } var res = new(CustomScalar) err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOCustomScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐCustomScalar(ctx context.Context, sel ast.SelectionSet, v *CustomScalar) graphql.Marshaler { if v == nil { return graphql.Null } return v } func (ec *executionContext) unmarshalODefaultScalarImplementation2ᚖstring(ctx context.Context, v any) (*string, error) { if v == nil { return nil, nil } res, err := graphql.UnmarshalString(v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalODefaultScalarImplementation2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel _ = ctx res := graphql.MarshalString(*v) return res } func (ec *executionContext) marshalODeferModel2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDeferModelᚄ(ctx context.Context, sel ast.SelectionSet, v []*DeferModel) 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.marshalNDeferModel2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDeferModel(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalODeferModel2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDeferModel(ctx context.Context, sel ast.SelectionSet, v *DeferModel) graphql.Marshaler { if v == nil { return graphql.Null } return ec._DeferModel(ctx, sel, v) } func (ec *executionContext) marshalODog2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐDog(ctx context.Context, sel ast.SelectionSet, v *Dog) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Dog(ctx, sel, v) } func (ec *executionContext) marshalOEmbeddedCase12ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEmbeddedCase1(ctx context.Context, sel ast.SelectionSet, v *EmbeddedCase1) graphql.Marshaler { if v == nil { return graphql.Null } return ec._EmbeddedCase1(ctx, sel, v) } func (ec *executionContext) marshalOEmbeddedCase22ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEmbeddedCase2(ctx context.Context, sel ast.SelectionSet, v *EmbeddedCase2) graphql.Marshaler { if v == nil { return graphql.Null } return ec._EmbeddedCase2(ctx, sel, v) } func (ec *executionContext) marshalOEmbeddedCase32ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐEmbeddedCase3(ctx context.Context, sel ast.SelectionSet, v *EmbeddedCase3) graphql.Marshaler { if v == nil { return graphql.Null } return ec._EmbeddedCase3(ctx, sel, v) } func (ec *executionContext) marshalOError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx context.Context, sel ast.SelectionSet, v []*Error) 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.marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx, sel, v[i]) }) return ret } func (ec *executionContext) marshalOError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐErrorᚄ(ctx context.Context, sel ast.SelectionSet, v []*Error) graphql.Marshaler { if v == nil { return graphql.Null } ret := 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.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐError(ctx context.Context, sel ast.SelectionSet, v *Error) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Error(ctx, sel, v) } func (ec *executionContext) marshalOErrors2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐErrors(ctx context.Context, sel ast.SelectionSet, v *Errors) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Errors(ctx, sel, v) } func (ec *executionContext) unmarshalOFloat2float64(ctx context.Context, v any) (float64, error) { res, err := graphql.UnmarshalFloatContext(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { _ = sel res := graphql.MarshalFloatContext(v) return graphql.WrapContextMarshaler(ctx, res) } func (ec *executionContext) unmarshalOFloat2ᚖfloat64(ctx context.Context, v any) (*float64, error) { if v == nil { return nil, nil } res, err := graphql.UnmarshalFloatContext(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOFloat2ᚖfloat64(ctx context.Context, sel ast.SelectionSet, v *float64) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel res := graphql.MarshalFloatContext(*v) return graphql.WrapContextMarshaler(ctx, res) } func (ec *executionContext) unmarshalOID2ᚖstring(ctx context.Context, v any) (*string, error) { if v == nil { return nil, nil } res, err := graphql.UnmarshalID(v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOID2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel _ = ctx res := graphql.MarshalID(*v) return res } func (ec *executionContext) unmarshalOInnerDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInnerDirectives(ctx context.Context, v any) (*InnerDirectives, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputInnerDirectives(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalOInputDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInputDirectives(ctx context.Context, v any) (*InputDirectives, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputInputDirectives(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalOInputWithEnumValue2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐInputWithEnumValue(ctx context.Context, v any) (*InputWithEnumValue, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputInputWithEnumValue(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v 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) marshalOInvalidIdentifier2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋinvalidᚑpackagenameᚐInvalidIdentifier(ctx context.Context, sel ast.SelectionSet, v *invalid_packagename.InvalidIdentifier) graphql.Marshaler { if v == nil { return graphql.Null } return ec._InvalidIdentifier(ctx, sel, v) } func (ec *executionContext) unmarshalOIssue4053Input12ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐIssue4053Input1(ctx context.Context, v any) (*Issue4053Input1, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputIssue4053Input1(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalOIssue4053Input22githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐIssue4053Input2(ctx context.Context, v any) (Issue4053Input2, error) { res, err := ec.unmarshalInputIssue4053Input2(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOIt2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋintrospectionᚐIt(ctx context.Context, sel ast.SelectionSet, v *introspection1.It) graphql.Marshaler { if v == nil { return graphql.Null } return ec._It(ctx, sel, v) } func (ec *executionContext) marshalOMapNested2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMapNested(ctx context.Context, sel ast.SelectionSet, v *MapNested) graphql.Marshaler { if v == nil { return graphql.Null } return ec._MapNested(ctx, sel, v) } func (ec *executionContext) unmarshalOMapNestedInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐMapNested(ctx context.Context, v any) (*MapNested, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputMapNestedInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalOMapNestedMapSliceInput2map(ctx context.Context, v any) (map[string]any, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputMapNestedMapSliceInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalOMapNestedMapSliceInput2ᚕ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.unmarshalNMapNestedMapSliceInput2map(ctx, vSlice[i]) if err != nil { return nil, err } } return res, nil } func (ec *executionContext) unmarshalOMapStringInterfaceInput2map(ctx context.Context, v any) (map[string]any, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputMapStringInterfaceInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOMapStringInterfaceType2map(ctx context.Context, sel ast.SelectionSet, v map[string]any) graphql.Marshaler { if v == nil { return graphql.Null } return ec._MapStringInterfaceType(ctx, sel, v) } func (ec *executionContext) marshalOModelMethods2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐModelMethods(ctx context.Context, sel ast.SelectionSet, v *ModelMethods) graphql.Marshaler { if v == nil { return graphql.Null } return ec._ModelMethods(ctx, sel, v) } func (ec *executionContext) unmarshalONestedMapInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐNestedMapInput(ctx context.Context, v any) (*NestedMapInput, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputNestedMapInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOObjectDirectives2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐObjectDirectives(ctx context.Context, sel ast.SelectionSet, v *ObjectDirectives) graphql.Marshaler { if v == nil { return graphql.Null } return ec._ObjectDirectives(ctx, sel, v) } func (ec *executionContext) marshalOObjectDirectivesWithCustomGoModel2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐObjectDirectivesWithCustomGoModel(ctx context.Context, sel ast.SelectionSet, v *ObjectDirectivesWithCustomGoModel) graphql.Marshaler { if v == nil { return graphql.Null } return ec._ObjectDirectivesWithCustomGoModel(ctx, sel, v) } func (ec *executionContext) unmarshalOOuterInput2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterInput(ctx context.Context, v any) ([][]*OuterInput, error) { if v == nil { return nil, nil } var vSlice []any vSlice = graphql.CoerceList(v) var err error res := make([][]*OuterInput, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) res[i], err = ec.unmarshalOOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterInput(ctx, vSlice[i]) if err != nil { return nil, err } } return res, nil } func (ec *executionContext) unmarshalOOuterInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterInput(ctx context.Context, v any) ([]*OuterInput, error) { if v == nil { return nil, nil } var vSlice []any vSlice = graphql.CoerceList(v) var err error res := make([]*OuterInput, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) res[i], err = ec.unmarshalOOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterInput(ctx, vSlice[i]) if err != nil { return nil, err } } return res, nil } func (ec *executionContext) unmarshalOOuterInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterInput(ctx context.Context, v any) (*OuterInput, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputOuterInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOOuterObject2ᚕᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v [][]*OuterObject) 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.marshalOOuterObject2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterObject(ctx, sel, v[i]) }) return ret } func (ec *executionContext) marshalOOuterObject2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v []*OuterObject) graphql.Marshaler { if v == nil { return graphql.Null } 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.marshalOOuterObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterObject(ctx, sel, v[i]) }) return ret } func (ec *executionContext) marshalOOuterObject2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOuterObject(ctx context.Context, sel ast.SelectionSet, v *OuterObject) graphql.Marshaler { if v == nil { return graphql.Null } return ec._OuterObject(ctx, sel, v) } func (ec *executionContext) marshalOOverlappingFields2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐOverlappingFields(ctx context.Context, sel ast.SelectionSet, v *OverlappingFields) graphql.Marshaler { if v == nil { return graphql.Null } return ec._OverlappingFields(ctx, sel, v) } func (ec *executionContext) marshalOPanics2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPanics(ctx context.Context, sel ast.SelectionSet, v *Panics) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Panics(ctx, sel, v) } func (ec *executionContext) marshalOPet2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPetᚄ(ctx context.Context, sel ast.SelectionSet, v []*Pet) 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.marshalNPet2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPet(ctx, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func (ec *executionContext) marshalOPtrToPtrInner2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v *PtrToPtrInner) graphql.Marshaler { if v == nil { return graphql.Null } return ec._PtrToPtrInner(ctx, sel, v) } func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v **PtrToPtrInner) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOPtrToPtrInner2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx, sel, *v) } func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v ***PtrToPtrInner) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOPtrToPtrInner2ᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx, sel, *v) } func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v ****PtrToPtrInner) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOPtrToPtrInner2ᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx, sel, *v) } func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v *****PtrToPtrInner) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOPtrToPtrInner2ᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx, sel, *v) } func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v ******PtrToPtrInner) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx, sel, *v) } func (ec *executionContext) marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx context.Context, sel ast.SelectionSet, v *******PtrToPtrInner) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOPtrToPtrInner2ᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐPtrToPtrInner(ctx, sel, *v) } func (ec *executionContext) unmarshalORecursiveInputSlice2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐRecursiveInputSliceᚄ(ctx context.Context, v any) ([]RecursiveInputSlice, error) { if v == nil { return nil, nil } var vSlice []any vSlice = graphql.CoerceList(v) var err error res := make([]RecursiveInputSlice, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) res[i], err = ec.unmarshalNRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐRecursiveInputSlice(ctx, vSlice[i]) if err != nil { return nil, err } } return res, nil } func (ec *executionContext) unmarshalORecursiveInputSlice2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐRecursiveInputSlice(ctx context.Context, v any) (*RecursiveInputSlice, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputRecursiveInputSlice(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalOSearchFilters2map(ctx context.Context, v any) (map[string]any, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputSearchFilters(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐShape(ctx context.Context, sel ast.SelectionSet, v Shape) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Shape(ctx, sel, v) } func (ec *executionContext) marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐShape(ctx context.Context, sel ast.SelectionSet, v []Shape) 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.marshalOShape2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐShape(ctx, sel, v[i]) }) return ret } func (ec *executionContext) marshalOSkipIncludeTestType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐSkipIncludeTestType(ctx context.Context, sel ast.SelectionSet, v *SkipIncludeTestType) graphql.Marshaler { if v == nil { return graphql.Null } return ec._SkipIncludeTestType(ctx, sel, v) } func (ec *executionContext) marshalOSlices2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐSlices(ctx context.Context, sel ast.SelectionSet, v *Slices) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Slices(ctx, sel, v) } func (ec *executionContext) unmarshalOStatus2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐStatus(ctx context.Context, v any) (*Status, error) { if v == nil { return nil, nil } var res = new(Status) err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOStatus2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐStatus(ctx context.Context, sel ast.SelectionSet, v *Status) graphql.Marshaler { if v == nil { return graphql.Null } return v } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v 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 } 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) unmarshalOString2ᚖᚕstringᚄ(ctx context.Context, v any) (*[]string, error) { if v == nil { return nil, nil } res, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOString2ᚖᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v *[]string) graphql.Marshaler { return ec.marshalOString2ᚕstringᚄ(ctx, sel, *v) } func (ec *executionContext) marshalOTestUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐTestUnion(ctx context.Context, sel ast.SelectionSet, v TestUnion) graphql.Marshaler { if v == nil { return graphql.Null } return ec._TestUnion(ctx, sel, v) } func (ec *executionContext) unmarshalOThirdParty2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐThirdParty(ctx context.Context, v any) (*ThirdParty, error) { if v == nil { return nil, nil } res, err := UnmarshalThirdParty(v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOThirdParty2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐThirdParty(ctx context.Context, sel ast.SelectionSet, v *ThirdParty) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel _ = ctx res := MarshalThirdParty(*v) return res } func (ec *executionContext) unmarshalOTime2ᚖtimeᚐTime(ctx context.Context, v any) (*time.Time, error) { if v == nil { return nil, nil } res, err := graphql.UnmarshalTime(v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOTime2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel _ = ctx res := graphql.MarshalTime(*v) return res } func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx context.Context, v any) (*UpdatePtrToPtrInner, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputUpdatePtrToPtrInner(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx context.Context, v any) (**UpdatePtrToPtrInner, error) { var pres *UpdatePtrToPtrInner if v != nil { res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx, v) if err != nil { return nil, graphql.ErrorOnPath(ctx, err) } pres = res } return &pres, nil } func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx context.Context, v any) (***UpdatePtrToPtrInner, error) { var pres **UpdatePtrToPtrInner if v != nil { res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx, v) if err != nil { return nil, graphql.ErrorOnPath(ctx, err) } pres = res } return &pres, nil } func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx context.Context, v any) (****UpdatePtrToPtrInner, error) { var pres ***UpdatePtrToPtrInner if v != nil { res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx, v) if err != nil { return nil, graphql.ErrorOnPath(ctx, err) } pres = res } return &pres, nil } func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx context.Context, v any) (*****UpdatePtrToPtrInner, error) { var pres ****UpdatePtrToPtrInner if v != nil { res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx, v) if err != nil { return nil, graphql.ErrorOnPath(ctx, err) } pres = res } return &pres, nil } func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx context.Context, v any) (******UpdatePtrToPtrInner, error) { var pres *****UpdatePtrToPtrInner if v != nil { res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx, v) if err != nil { return nil, graphql.ErrorOnPath(ctx, err) } pres = res } return &pres, nil } func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx context.Context, v any) (*******UpdatePtrToPtrInner, error) { var pres ******UpdatePtrToPtrInner if v != nil { res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx, v) if err != nil { return nil, graphql.ErrorOnPath(ctx, err) } pres = res } return &pres, nil } func (ec *executionContext) unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx context.Context, v any) (********UpdatePtrToPtrInner, error) { var pres *******UpdatePtrToPtrInner if v != nil { res, err := ec.unmarshalOUpdatePtrToPtrInner2ᚖᚖᚖᚖᚖᚖᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐUpdatePtrToPtrInner(ctx, v) if err != nil { return nil, graphql.ErrorOnPath(ctx, err) } pres = res } return &pres, nil } func (ec *executionContext) marshalOVOkCaseNil2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐVOkCaseNil(ctx context.Context, sel ast.SelectionSet, v *VOkCaseNil) graphql.Marshaler { if v == nil { return graphql.Null } return ec._VOkCaseNil(ctx, sel, v) } func (ec *executionContext) marshalOVOkCaseValue2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐVOkCaseValue(ctx context.Context, sel ast.SelectionSet, v *VOkCaseValue) graphql.Marshaler { if v == nil { return graphql.Null } return ec._VOkCaseValue(ctx, sel, v) } func (ec *executionContext) unmarshalOValidInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐValidInput(ctx context.Context, v any) (*ValidInput, error) { if v == nil { return nil, nil } res, err := ec.unmarshalInputValidInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOValidType2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐValidType(ctx context.Context, sel ast.SelectionSet, v *ValidType) graphql.Marshaler { if v == nil { return graphql.Null } return ec._ValidType(ctx, sel, v) } func (ec *executionContext) marshalOVariadicModel2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚐVariadicModel(ctx context.Context, sel ast.SelectionSet, v *VariadicModel) graphql.Marshaler { if v == nil { return graphql.Null } return ec._VariadicModel(ctx, sel, v) } func (ec *executionContext) unmarshalOWrappedScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋotherpkgᚐScalar(ctx context.Context, v any) (*otherpkg.Scalar, error) { if v == nil { return nil, nil } tmp, err := graphql.UnmarshalString(v) res := otherpkg.Scalar(tmp) return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) marshalOWrappedScalar2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋsinglefileᚋotherpkgᚐScalar(ctx context.Context, sel ast.SelectionSet, v *otherpkg.Scalar) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel _ = ctx res := graphql.MarshalString(string(*v)) return res } func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { 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: codegen/testserver/singlefile/generated_test.go ================================================ //go:generate rm -f resolver.go //go:generate go run ../../../testdata/gqlgen.go -config gqlgen.yml -stub stub.go package singlefile import ( "context" "reflect" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestForcedResolverFieldIsPointer(t *testing.T) { field, ok := reflect.TypeFor[ForcedResolverResolver]().MethodByName("Field") require.True(t, ok) require.Equal(t, "*singlefile.Circle", field.Type.Out(0).String()) } func TestEnums(t *testing.T) { t.Run("list of enums", func(t *testing.T) { require.Equal(t, StatusOk, AllStatus[0]) require.Equal(t, StatusError, AllStatus[1]) }) t.Run("invalid enum values", func(t *testing.T) { require.Equal(t, StatusOk, AllStatus[0]) require.Equal(t, StatusError, AllStatus[1]) }) } func TestUnionFragments(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.ShapeUnion = func(ctx context.Context) (ShapeUnion, error) { return &Circle{Radius: 32}, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("inline fragment on union", func(t *testing.T) { var resp struct { ShapeUnion struct { Radius float64 } } c.MustPost(`query { shapeUnion { ... on Circle { radius } } } `, &resp) require.NotEmpty(t, resp.ShapeUnion.Radius) }) t.Run("named fragment", func(t *testing.T) { var resp struct { ShapeUnion struct { Radius float64 } } c.MustPost(`query { shapeUnion { ...C } } fragment C on ShapeUnion { ... on Circle { radius } } `, &resp) require.NotEmpty(t, resp.ShapeUnion.Radius) }) } ================================================ FILE: codegen/testserver/singlefile/gqlgen.yml ================================================ schema: - "*.graphql" skip_validation: true exec: filename: generated.go package: singlefile model: filename: models-gen.go package: singlefile resolver: filename: resolver.go package: singlefile type: Resolver autobind: - "github.com/99designs/gqlgen/codegen/testserver" - "github.com/99designs/gqlgen/codegen/testserver/singlefile" - "github.com/99designs/gqlgen/codegen/testserver/singlefile/introspection" - "github.com/99designs/gqlgen/codegen/testserver/singlefile/invalid-packagename" models: Email: model: "github.com/99designs/gqlgen/codegen/testserver/singlefile.Email" StringFromContextFunction: model: "github.com/99designs/gqlgen/codegen/testserver/singlefile.StringFromContextFunction" ================================================ FILE: codegen/testserver/singlefile/inline_arguments.graphql ================================================ directive @inlineArguments on ARGUMENT_DEFINITION input SearchFilters @goModel(model: "map[string]interface{}") { query: String category: String minPrice: Int } input RequiredFilters @goModel(model: "map[string]interface{}") { name: String! age: Int! } input UpdateProductInput @goModel(model: "map[string]interface{}") { id: ID! name: String price: Float } input SearchWithDefaults @goModel(model: "map[string]interface{}") { query: String = "default search" limit: Int = 20 includeArchived: Boolean = false } input DirectiveInput @goModel(model: "map[string]interface{}") { oldField: String @deprecated(reason: "Use newField instead") newField: String } extend type Query { searchProducts(filters: SearchFilters @inlineArguments): [String!]! searchRequired(filters: RequiredFilters! @inlineArguments): [String!]! searchProductsNormal(filters: SearchFilters): [String!]! searchWithDefaults(filters: SearchWithDefaults @inlineArguments): [String!]! searchMixed( filters: SearchFilters @inlineArguments, limit: Int = 10, offset: Int = 0, sortBy: String ): [String!]! filterProducts(filters: SearchFilters @inlineArguments): [String!]! findProducts(filters: SearchFilters @inlineArguments): [String!]! searchWithDirectives(input: DirectiveInput @inlineArguments): [String!]! } extend type Mutation { updateProduct(input: UpdateProductInput @inlineArguments): String! } ================================================ FILE: codegen/testserver/singlefile/input_test.go ================================================ package singlefile import ( "context" "strconv" "testing" "time" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestInput(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("when function errors on directives", func(t *testing.T) { resolvers.QueryResolver.InputSlice = func(ctx context.Context, arg []string) (b bool, e error) { return true, nil } var resp struct { DirectiveArg *string } err := c.Post(`query { inputSlice(arg: ["ok", 1, 2, "ok"]) }`, &resp) require.EqualError( t, err, `http 422: {"errors":[{"message":"String cannot represent a non string value: 1","locations":[{"line":1,"column":32}],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}},{"message":"String cannot represent a non string value: 2","locations":[{"line":1,"column":35}],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}],"data":null}`, ) require.Nil(t, resp.DirectiveArg) }) t.Run("when input slice nullable", func(t *testing.T) { resolvers.QueryResolver.InputNullableSlice = func(ctx context.Context, arg []string) (b bool, e error) { return arg == nil, nil } var resp struct { InputNullableSlice bool } var err error err = c.Post(`query { inputNullableSlice(arg: null) }`, &resp) require.NoError(t, err) require.True(t, resp.InputNullableSlice) err = c.Post(`query { inputNullableSlice(arg: []) }`, &resp) require.NoError(t, err) require.False(t, resp.InputNullableSlice) }) t.Run("coerce single value to slice", func(t *testing.T) { check := func(ctx context.Context, arg []string) (b bool, e error) { return len(arg) == 1 && arg[0] == "coerced", nil } resolvers.QueryResolver.InputSlice = check resolvers.QueryResolver.InputNullableSlice = check var resp struct { Coerced bool } var err error err = c.Post(`query { coerced: inputSlice(arg: "coerced") }`, &resp) require.NoError(t, err) require.True(t, resp.Coerced) err = c.Post(`query { coerced: inputNullableSlice(arg: "coerced") }`, &resp) require.NoError(t, err) require.True(t, resp.Coerced) }) } func TestInputOmittable(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("id field", func(t *testing.T) { resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { value, isSet := arg.ID.ValueOK() if !isSet { return "", nil } if value == nil { return "", nil } return *value, nil } var resp struct { InputOmittable string } var err error err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { id: null }) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { id: "foo" }) }`, &resp) require.NoError(t, err) require.Equal(t, "foo", resp.InputOmittable) }) t.Run("bool field", func(t *testing.T) { resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { value, isSet := arg.Bool.ValueOK() if !isSet { return "", nil } if value == nil { return "", nil } return strconv.FormatBool(*value), nil } var resp struct { InputOmittable string } var err error err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { bool: null }) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { bool: false }) }`, &resp) require.NoError(t, err) require.Equal(t, "false", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { bool: true }) }`, &resp) require.NoError(t, err) require.Equal(t, "true", resp.InputOmittable) }) t.Run("str field", func(t *testing.T) { resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { value, isSet := arg.Str.ValueOK() if !isSet { return "", nil } if value == nil { return "", nil } return *value, nil } var resp struct { InputOmittable string } var err error err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { str: null }) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { str: "bar" }) }`, &resp) require.NoError(t, err) require.Equal(t, "bar", resp.InputOmittable) }) t.Run("int field", func(t *testing.T) { resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { value, isSet := arg.Int.ValueOK() if !isSet { return "", nil } if value == nil { return "", nil } return strconv.Itoa(*value), nil } var resp struct { InputOmittable string } var err error err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { int: null }) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { int: 42 }) }`, &resp) require.NoError(t, err) require.Equal(t, "42", resp.InputOmittable) }) t.Run("time field", func(t *testing.T) { resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { value, isSet := arg.Time.ValueOK() if !isSet { return "", nil } if value == nil { return "", nil } return value.UTC().Format(time.RFC3339), nil } var resp struct { InputOmittable string } var err error err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { time: null }) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { time: "2011-04-05T16:01:33Z" }) }`, &resp) require.NoError(t, err) require.Equal(t, "2011-04-05T16:01:33Z", resp.InputOmittable) }) t.Run("enum field", func(t *testing.T) { resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { value, isSet := arg.Enum.ValueOK() if !isSet { return "", nil } if value == nil { return "", nil } return value.String(), nil } var resp struct { InputOmittable string } var err error err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { enum: null }) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { enum: OK }) }`, &resp) require.NoError(t, err) require.Equal(t, "OK", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { enum: ERROR }) }`, &resp) require.NoError(t, err) require.Equal(t, "ERROR", resp.InputOmittable) }) t.Run("scalar field", func(t *testing.T) { resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { value, isSet := arg.Scalar.ValueOK() if !isSet { return "", nil } if value == nil { return "", nil } return value.str, nil } var resp struct { InputOmittable string } var err error err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { scalar: null }) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { scalar: "baz" }) }`, &resp) require.NoError(t, err) require.Equal(t, "baz", resp.InputOmittable) }) t.Run("object field", func(t *testing.T) { resolvers.QueryResolver.InputOmittable = func(ctx context.Context, arg OmittableInput) (string, error) { value, isSet := arg.Object.ValueOK() if !isSet { return "", nil } if value == nil { return "", nil } return strconv.Itoa(value.Inner.ID), nil } var resp struct { InputOmittable string } var err error err = c.Post(`query { inputOmittable(arg: {}) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { object: null }) }`, &resp) require.NoError(t, err) require.Equal(t, "", resp.InputOmittable) err = c.Post(`query { inputOmittable(arg: { object: { inner: { id: 21 } } }) }`, &resp) require.NoError(t, err) require.Equal(t, "21", resp.InputOmittable) }) } ================================================ FILE: codegen/testserver/singlefile/interfaces.go ================================================ package singlefile import "math" type Shape interface { Area() float64 isShape() } type ShapeUnion interface { Area() float64 isShapeUnion() } type Circle struct { Radius float64 Coordinates } func (c *Circle) Area() float64 { return c.Radius * math.Pi * math.Pi } func (c *Circle) isShapeUnion() {} func (c *Circle) isShape() {} type Rectangle struct { Length, Width float64 Coordinates } func (r *Rectangle) Area() float64 { return r.Length * r.Width } func (r *Rectangle) isShapeUnion() {} func (r *Rectangle) isShape() {} type Node interface { Child() (Node, error) } type ConcreteNodeA struct { ID string Name string child Node } func (n *ConcreteNodeA) Child() (Node, error) { return n.child, nil } // Implements the Node interface with another interface type ConcreteNodeInterface interface { Node ID() string } type ConcreteNodeInterfaceImplementor struct{} func (c ConcreteNodeInterfaceImplementor) ID() string { return "CNII" } func (c ConcreteNodeInterfaceImplementor) Child() (Node, error) { return &ConcreteNodeA{ ID: "Child", Name: "child", }, nil } type BackedByInterface interface { ThisShouldBind() string ThisShouldBindWithError() (string, error) } type BackedByInterfaceImpl struct { Value string Error error } func (b *BackedByInterfaceImpl) ThisShouldBind() string { return b.Value } func (b *BackedByInterfaceImpl) ThisShouldBindWithError() (string, error) { return b.Value, b.Error } ================================================ FILE: codegen/testserver/singlefile/interfaces.graphql ================================================ extend type Query { shapes: [Shape] noShape: Shape @makeNil node: Node! noShapeTypedNil: Shape @makeTypedNil animal: Animal @makeTypedNil notAnInterface: BackedByInterface dog: Dog } interface Animal { species: String! size: Size! } type Size { height: Int! weight: Int! } type BackedByInterface { id: String! thisShouldBind: String! thisShouldBindWithError: String! } type Dog implements Animal { species: String! size: Size! dogBreed: String! } type Cat implements Animal { species: String! size: Size! catBreed: String! } type Coordinates { x: Float! y: Float! } interface Shape { area: Float coordinates: Coordinates } type Circle implements Shape { radius: Float area: Float coordinates: Coordinates } type Rectangle implements Shape { length: Float width: Float area: Float coordinates: Coordinates } union ShapeUnion @goModel(model: "singlefile.ShapeUnion") = Circle | Rectangle directive @makeNil on FIELD_DEFINITION directive @makeTypedNil on FIELD_DEFINITION interface Node { id: ID! child: Node! } type ConcreteNodeA implements Node { id: ID! child: Node! name: String! } " Implements the Node interface with another interface " type ConcreteNodeInterface implements Node { id: ID! child: Node! } interface Mammalian implements Animal { species: String! size: Size! } # Types with multiple interfaces are evaluated first in the case statement type Horse implements Mammalian & Animal { species: String! size: Size! horseBreed: String! } ================================================ FILE: codegen/testserver/singlefile/interfaces_test.go ================================================ package singlefile import ( "context" "errors" "reflect" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestInterfaces(t *testing.T) { t.Run("slices of interfaces are not pointers", func(t *testing.T) { field, ok := reflect.TypeFor[QueryResolver]().MethodByName("Shapes") require.True(t, ok) require.Equal(t, "[]singlefile.Shape", field.Type.Out(0).String()) }) t.Run("models returning interfaces", func(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.Node = func(ctx context.Context) (node Node, err error) { return &ConcreteNodeA{ ID: "1234", Name: "asdf", child: &ConcreteNodeA{ ID: "5678", Name: "hjkl", child: nil, }, }, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) var resp struct { Node struct { ID string Child struct { ID string } } } c.MustPost(`{ node { id, child { id } } }`, &resp) require.Equal(t, "1234", resp.Node.ID) require.Equal(t, "5678", resp.Node.Child.ID) }) t.Run("interfaces can be nil", func(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.NoShape = func(ctx context.Context) (shapes Shape, e error) { return nil, nil } srv := handler.New( NewExecutableSchema(Config{ Resolvers: resolvers, Directives: DirectiveRoot{ MakeNil: func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) { return nil, nil }, }, }), ) srv.AddTransport(transport.POST{}) c := client.New(srv) var resp any c.MustPost(`{ noShape { area } }`, &resp) }) t.Run("interfaces can be typed nil", func(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.NoShapeTypedNil = func(ctx context.Context) (shapes Shape, e error) { t.Fatal("should not be called") return shapes, e } srv := handler.New( NewExecutableSchema(Config{ Resolvers: resolvers, Directives: DirectiveRoot{ MakeTypedNil: func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) { var circle *Circle return circle, nil }, }, }), ) srv.AddTransport(transport.POST{}) c := client.New(srv) var resp any c.MustPost(`{ noShapeTypedNil { area } }`, &resp) }) t.Run("interfaces can be nil (test with code-generated resolver)", func(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.Animal = func(ctx context.Context) (animal Animal, e error) { t.Fatal("should not be called") return animal, e } srv := handler.New( NewExecutableSchema(Config{ Resolvers: resolvers, Directives: DirectiveRoot{ MakeTypedNil: func(ctx context.Context, obj any, next graphql.Resolver) (res any, err error) { var dog *Dog // return a typed nil, not just nil return dog, nil }, }, }), ) srv.AddTransport(transport.POST{}) c := client.New(srv) var resp any c.MustPost(`{ animal { species } }`, &resp) }) t.Run("can bind to interfaces even when the graphql is not", func(t *testing.T) { resolvers := &Stub{} resolvers.BackedByInterfaceResolver.ID = func(ctx context.Context, obj BackedByInterface) (s string, err error) { return "ID:" + obj.ThisShouldBind(), nil } resolvers.QueryResolver.NotAnInterface = func(ctx context.Context) (byInterface BackedByInterface, err error) { return &BackedByInterfaceImpl{ Value: "A", Error: nil, }, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) var resp struct { NotAnInterface struct { ID string ThisShouldBind string ThisShouldBindWithError string } } c.MustPost(`{ notAnInterface { id, thisShouldBind, thisShouldBindWithError } }`, &resp) require.Equal(t, "ID:A", resp.NotAnInterface.ID) require.Equal(t, "A", resp.NotAnInterface.ThisShouldBind) require.Equal(t, "A", resp.NotAnInterface.ThisShouldBindWithError) }) t.Run("can return errors from interface funcs", func(t *testing.T) { resolvers := &Stub{} resolvers.BackedByInterfaceResolver.ID = func(ctx context.Context, obj BackedByInterface) (s string, err error) { return "ID:" + obj.ThisShouldBind(), nil } resolvers.QueryResolver.NotAnInterface = func(ctx context.Context) (byInterface BackedByInterface, err error) { return &BackedByInterfaceImpl{ Value: "A", Error: errors.New("boom"), }, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) var resp struct { NotAnInterface struct { ID string ThisShouldBind string ThisShouldBindWithError string } } err := c.Post(`{ notAnInterface { id, thisShouldBind, thisShouldBindWithError } }`, &resp) require.EqualError( t, err, `[{"message":"boom","path":["notAnInterface","thisShouldBindWithError"]}]`, ) }) t.Run("interfaces can implement other interfaces", func(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.Node = func(ctx context.Context) (node Node, err error) { return ConcreteNodeInterfaceImplementor{}, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) var resp struct { Node struct { ID string Child struct { ID string } } } c.MustPost(`{ node { id, child { id } } }`, &resp) require.Equal(t, "CNII", resp.Node.ID) require.Equal(t, "Child", resp.Node.Child.ID) }) t.Run("interface implementors should return merged base fields", func(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.Shapes = func(ctx context.Context) (shapes []Shape, err error) { return []Shape{ &Rectangle{ Coordinates: Coordinates{ X: -1, Y: -1, }, }, &Circle{ Coordinates: Coordinates{ X: 1, Y: 1, }, }, }, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) var resp struct { Shapes []struct { Coordinates struct { X float64 Y float64 } } } c.MustPost(` { shapes { coordinates { x } ... on Rectangle { coordinates { x } } ... on Circle { coordinates { y } } } } `, &resp) require.Len(t, resp.Shapes, 2) require.InDelta(t, float64(-1), resp.Shapes[0].Coordinates.X, 0.02) require.InDelta(t, float64(0), resp.Shapes[0].Coordinates.Y, 0.02) require.InDelta(t, float64(1), resp.Shapes[1].Coordinates.X, 0.02) require.InDelta(t, float64(1), resp.Shapes[1].Coordinates.Y, 0.02) }) t.Run("fragment on interface must return merged fields", func(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.Dog = func(ctx context.Context) (dog *Dog, err error) { return &Dog{ Size: &Size{ Height: 100, Weight: 35, }, }, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) var resp struct { Dog struct { Size struct { Height int Weight int } } } c.MustPost(` { dog { size { height } ...AnimalWeight } } fragment AnimalWeight on Animal { size { weight } } `, &resp) require.Equal(t, 100, resp.Dog.Size.Height) require.Equal(t, 35, resp.Dog.Size.Weight) }) } ================================================ FILE: codegen/testserver/singlefile/introspection/it.go ================================================ package introspection type It struct { ID string } ================================================ FILE: codegen/testserver/singlefile/introspection_test.go ================================================ package singlefile import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "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/introspection" ) func TestIntrospection(t *testing.T) { t.Run("disabled when creating your own server", func(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) var resp any err := c.Post(introspection.Query, &resp) require.EqualError( t, err, "[{\"message\":\"introspection disabled\",\"path\":[\"__schema\"]}]", ) }) t.Run("enabled by default", func(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) srv.Use(extension.Introspection{}) c := client.New(srv) var resp any err := c.Post(introspection.Query, &resp) require.NoError(t, err) t.Run("does not return empty deprecation strings", func(t *testing.T) { q := `{ __type(name:"InnerObject") { fields { name deprecationReason } } }` var resp struct { Type struct { Fields []struct { Name string DeprecationReason *string } } `json:"__type"` } err := c.Post(q, &resp) require.NoError(t, err) require.Equal(t, "id", resp.Type.Fields[0].Name) require.Nil(t, resp.Type.Fields[0].DeprecationReason) }) t.Run("chained interface possibleTypes", func(t *testing.T) { var resp struct { Type struct { PossibleTypes []struct { Name string } } `json:"__type"` } err := c.Post(`{ __type(name: "Animal") { possibleTypes { name } } }`, &resp) require.NoError(t, err) names := make([]string, len(resp.Type.PossibleTypes)) for i, pt := range resp.Type.PossibleTypes { names[i] = pt.Name } require.Contains(t, names, "Dog") require.Contains(t, names, "Cat") // Horse implements Animal transitively via Mammalian require.Contains(t, names, "Horse") }) t.Run("deprecated arguments", func(t *testing.T) { var resp struct { Type struct { Fields []struct { Name string Args []struct { Name string DeprecationReason *string } } } `json:"__type"` } err := c.Post( `{ __type(name:"Query") { fields { name args { name deprecationReason }}}}`, &resp, ) require.NoError(t, err) var args []struct { Name string DeprecationReason *string } for _, f := range resp.Type.Fields { if f.Name == "fieldWithDeprecatedArg" { args = f.Args break } } require.Len(t, args, 2) require.Equal(t, "oldArg", args[0].Name) require.NotNil(t, args[0].DeprecationReason) require.Equal(t, "old arg", *args[0].DeprecationReason) require.Equal(t, "newArg", args[1].Name) require.Nil(t, args[1].DeprecationReason) }) }) t.Run("disabled by middleware", func(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) srv.AroundOperations( func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler { graphql.GetOperationContext(ctx).DisableIntrospection = true return next(ctx) }, ) c := client.New(srv) var resp any err := c.Post(introspection.Query, &resp) require.EqualError( t, err, "[{\"message\":\"introspection disabled\",\"path\":[\"__schema\"]}]", ) }) } ================================================ FILE: codegen/testserver/singlefile/invalid-packagename/invalid-identifier.go ================================================ package invalid_packagename type InvalidIdentifier struct { ID int } ================================================ FILE: codegen/testserver/singlefile/issue4053.go ================================================ package singlefile type Issue4053Input1 struct { Input2 Issue4053Input2 } type Issue4053Input2 struct { Hello string HelloWithDefault string } ================================================ FILE: codegen/testserver/singlefile/issue4053.graphql ================================================ # This is a reproduction of https://github.com/99designs/gqlgen/issues/4053 extend type Mutation { issue4053(input: Issue4053Input1): Boolean! } input Issue4053Input1 { input2: Issue4053Input2 } # Issue4053Input2 exists in issue4053.go input Issue4053Input2 { hello: String helloWithDefault: String = "world" } ================================================ FILE: codegen/testserver/singlefile/issue4053_test.go ================================================ package singlefile import ( "context" "testing" "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 TestIssue4053(t *testing.T) { t.Run("sending null input2 should not panic", func(t *testing.T) { resolver := &Stub{} resolver.MutationResolver.Issue4053 = func(ctx context.Context, input *Issue4053Input1) (bool, error) { require.NotNil(t, input, "input should not be nil") assert.Zero(t, input.Input2, "input2 should be zero value when null is passed") return true, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolver})) srv.AddTransport(transport.POST{}) srv.SetRecoverFunc(nil) // disable panic recovery to allow test to fail if a panic occurs c := client.New(srv) require.NotPanics(t, func() { var resp struct { Issue4053 bool } err := c.Post(`mutation { issue4053(input: { input2: null }) }`, &resp) assert.NoError(t, err) assert.True(t, resp.Issue4053) }, "should not panic when input2 is null") }) t.Run("not sending input1 should yield nil Issue4053Input1", func(t *testing.T) { resolver := &Stub{} resolver.MutationResolver.Issue4053 = func(ctx context.Context, input *Issue4053Input1) (bool, error) { require.Nil(t, input, "input should be nil when not sent") return true, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolver})) srv.AddTransport(transport.POST{}) srv.SetRecoverFunc(nil) // disable panic recovery to allow test to fail if a panic occurs c := client.New(srv) require.NotPanics(t, func() { var resp struct { Issue4053 bool } err := c.Post(`mutation { issue4053 }`, &resp) assert.NoError(t, err) assert.True(t, resp.Issue4053) }, "should not panic when input2 is null") }) t.Run("sending empty input1 should yield zero value of Issue4053Input2", func(t *testing.T) { resolver := &Stub{} resolver.MutationResolver.Issue4053 = func(ctx context.Context, input *Issue4053Input1) (bool, error) { require.NotNil(t, input, "input should not be nil") assert.Zero(t, input.Input2, "input2 should be zero value when empty input is passed") return true, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolver})) srv.AddTransport(transport.POST{}) srv.SetRecoverFunc(nil) // disable panic recovery to allow test to fail if a panic occurs c := client.New(srv) require.NotPanics(t, func() { var resp struct { Issue4053 bool } err := c.Post(`mutation { issue4053(input: {}) }`, &resp) assert.NoError(t, err) assert.True(t, resp.Issue4053) }, "should not panic when input2 is null") }) t.Run("sending empty input2 should yield default values", func(t *testing.T) { resolver := &Stub{} resolver.MutationResolver.Issue4053 = func(ctx context.Context, input *Issue4053Input1) (bool, error) { require.NotNil(t, input, "input should not be nil") expected := Issue4053Input2{ Hello: "", HelloWithDefault: "world", } assert.Equal(t, expected, input.Input2, "input2 should have default values when empty input is passed") return true, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolver})) srv.AddTransport(transport.POST{}) srv.SetRecoverFunc(nil) // disable panic recovery to allow test to fail if a panic occurs c := client.New(srv) require.NotPanics(t, func() { var resp struct { Issue4053 bool } err := c.Post(`mutation { issue4053(input: {input2: {}}) }`, &resp) assert.NoError(t, err) assert.True(t, resp.Issue4053) }, "should not panic when input2 is null") }) } ================================================ FILE: codegen/testserver/singlefile/issue896.graphql ================================================ # This example should build stable output. If the file content starts # alternating nondeterministically between two outputs, then see # https://github.com/99designs/gqlgen/issues/896. extend schema { query: Query subscription: Subscription } type CheckIssue896 {id: Int} extend type Query { issue896a: [CheckIssue896!] # Note the "!" or lack thereof. } extend type Subscription { issue896b: [CheckIssue896] # Note the "!" or lack thereof. } ================================================ FILE: codegen/testserver/singlefile/loops.graphql ================================================ type LoopA { b: LoopB! } type LoopB { a: LoopA! } ================================================ FILE: codegen/testserver/singlefile/map_nested_map_slice_test.go ================================================ package singlefile import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestMapNestedMapSlice(t *testing.T) { resolver := &Stub{} resolver.QueryResolver.MapNestedMapSlice = func(ctx context.Context, input map[string]any) (*bool, error) { require.NotNil(t, input, "expected input") require.NotNil(t, input["recurse"], "expected recurse") require.IsType( t, []map[string]any{}, input["recurse"], "expected recurse as [][]map[string]any", ) recurse := input["recurse"].([]map[string]any) require.Len(t, recurse, 1, "expected 1 item in recurse") return nil, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolver})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("recursive input", func(t *testing.T) { var resp struct { MapNestedMapSlice bool } // recurse is [MapNestedMapSlice!] err := c.Post( `query { mapNestedMapSlice(input: { recurse: [{ name: "child" }] }) }`, &resp, ) require.NoError(t, err) }) } ================================================ FILE: codegen/testserver/singlefile/maps.go ================================================ package singlefile import ( "io" "strconv" ) type MapNested struct { Value CustomScalar } type CustomScalar struct { value int64 } func (s *CustomScalar) UnmarshalGQL(v any) (err error) { switch v := v.(type) { case string: s.value, err = strconv.ParseInt(v, 10, 64) case int64: s.value = v } return err } func (s CustomScalar) MarshalGQL(w io.Writer) { _, _ = w.Write([]byte(strconv.Quote(strconv.FormatInt(s.value, 10)))) } ================================================ FILE: codegen/testserver/singlefile/maps.graphql ================================================ extend type Query { mapStringInterface(in: MapStringInterfaceInput): MapStringInterfaceType mapNestedStringInterface(in: NestedMapInput): MapStringInterfaceType } type MapStringInterfaceType @goModel(model: "map[string]interface{}") { a: String b: Int c: CustomScalar nested: MapNested } type MapNested @goModel(model: "singlefile.MapNested") { value: CustomScalar! } input MapStringInterfaceInput @goModel(model: "map[string]interface{}") { a: String! b: Int c: CustomScalar nested: MapNestedInput } input MapNestedInput @goModel(model: "singlefile.MapNested") { value: CustomScalar! } scalar CustomScalar @goModel(model: "singlefile.CustomScalar") input NestedMapInput { map: MapStringInterfaceInput } input MapNestedMapSliceInput @goModel(model: "map[string]interface{}") { name: String recurse: [MapNestedMapSliceInput!] } extend type Query { mapNestedMapSlice(input: MapNestedMapSliceInput): Boolean } ================================================ FILE: codegen/testserver/singlefile/maps_test.go ================================================ package singlefile import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestMaps(t *testing.T) { resolver := &Stub{} resolver.QueryResolver.MapStringInterface = func(ctx context.Context, in map[string]any) (i map[string]any, e error) { validateMapItemsType(t, in) return in, nil } resolver.QueryResolver.MapNestedStringInterface = func(ctx context.Context, in *NestedMapInput) (i map[string]any, e error) { if in == nil { return nil, nil } validateMapItemsType(t, in.Map) return in.Map, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolver})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("unset", func(t *testing.T) { var resp struct { MapStringInterface map[string]any } err := c.Post(`query { mapStringInterface { a, b, c, nested { value } } }`, &resp) require.NoError(t, err) require.Nil(t, resp.MapStringInterface) }) t.Run("nil", func(t *testing.T) { var resp struct { MapStringInterface map[string]any } err := c.Post(`query { mapStringInterface(in: null) { a, b, c, nested { value } } }`, &resp) require.NoError(t, err) require.Nil(t, resp.MapStringInterface) }) t.Run("values", func(t *testing.T) { var resp struct { MapStringInterface map[string]any } err := c.Post( `query($value: CustomScalar!) { mapStringInterface(in: { a: "a", b: null, c: 42, nested: { value: $value } }) { a, b, c, nested { value } } }`, &resp, client.Var("value", "17"), ) require.NoError(t, err) require.Equal(t, "a", resp.MapStringInterface["a"]) require.Nil(t, resp.MapStringInterface["b"]) require.Equal(t, "42", resp.MapStringInterface["c"]) require.NotNil(t, resp.MapStringInterface["nested"]) require.IsType(t, map[string]any{}, resp.MapStringInterface["nested"]) require.Equal(t, "17", (resp.MapStringInterface["nested"].(map[string]any))["value"]) }) t.Run("nested", func(t *testing.T) { var resp struct { MapNestedStringInterface map[string]any } err := c.Post( `query { mapNestedStringInterface(in: { map: { a: "a", c: "42", nested: { value: 31 } } }) { a, b, c, nested { value } } }`, &resp, ) require.NoError(t, err) require.Equal(t, "a", resp.MapNestedStringInterface["a"]) require.Nil(t, resp.MapNestedStringInterface["b"]) require.Equal(t, "42", resp.MapNestedStringInterface["c"]) require.NotNil(t, resp.MapNestedStringInterface["nested"]) require.IsType(t, map[string]any{}, resp.MapNestedStringInterface["nested"]) require.Equal(t, "31", (resp.MapNestedStringInterface["nested"].(map[string]any))["value"]) }) t.Run("nested nil", func(t *testing.T) { var resp struct { MapNestedStringInterface map[string]any } err := c.Post( `query { mapNestedStringInterface(in: { map: null }) { a, b, c, nested { value } } }`, &resp, ) require.NoError(t, err) require.Nil(t, resp.MapNestedStringInterface) }) } func validateMapItemsType(t *testing.T, in map[string]any) { for k, v := range in { switch k { case "a": require.IsType(t, "", v) case "b": require.IsType(t, new(int), v) case "c": require.IsType(t, new(CustomScalar), v) case "nested": require.IsType(t, new(MapNested), v) default: require.Failf(t, "unexpected key in map", "key %q was not expected in map", k) } } } ================================================ FILE: codegen/testserver/singlefile/middleware_test.go ================================================ package singlefile import ( "context" "sync" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestMiddleware(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.ErrorBubble = func(ctx context.Context) (i *Error, e error) { return &Error{ID: "E1234"}, nil } resolvers.QueryResolver.User = func(ctx context.Context, id int) (user *User, e error) { return &User{ID: 1}, nil } resolvers.UserResolver.Friends = func(ctx context.Context, obj *User) (users []*User, e error) { return []*User{{ID: 1}}, nil } resolvers.UserResolver.Pets = func(ctx context.Context, obj *User, limit *int) ([]*Pet, error) { return []*Pet{{ID: 10}}, nil } resolvers.PetResolver.Friends = func(ctx context.Context, obj *Pet, limit *int) ([]*Pet, error) { return []*Pet{}, nil } resolvers.QueryResolver.ModelMethods = func(ctx context.Context) (methods *ModelMethods, e error) { return &ModelMethods{}, nil } var mu sync.Mutex areMethods := map[string]bool{} areResolvers := map[string]bool{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res any, err error) { path, _ := ctx.Value(ckey("path")).([]int) return next(context.WithValue(ctx, ckey("path"), append(path, 1))) }) srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res any, err error) { path, _ := ctx.Value(ckey("path")).([]int) return next(context.WithValue(ctx, ckey("path"), append(path, 2))) }) srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res any, err error) { fc := graphql.GetFieldContext(ctx) mu.Lock() areMethods[fc.Field.Name] = fc.IsMethod areResolvers[fc.Field.Name] = fc.IsResolver mu.Unlock() return next(ctx) }) srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res any, err error) { fc := graphql.GetFieldContext(ctx) if fc.Field.Name != "user" { return next(ctx) } opCtx := graphql.GetOperationContext(ctx) collected := graphql.CollectFields(opCtx, fc.Field.Selections, []string{"User"}) require.Len(t, collected, 3) require.Equal(t, "pets", collected[2].Name) child, err := fc.Child(ctx, collected[2]) require.NoError(t, err) require.Equal(t, 2, *child.Args["limit"].(*int)) collected = graphql.CollectFields(opCtx, child.Field.Selections, []string{"Pet"}) require.Len(t, collected, 2) require.Equal(t, "friends", collected[1].Name) child, err = child.Child(ctx, collected[1]) require.NoError(t, err) require.Equal(t, 10, *child.Args["limit"].(*int)) return next(ctx) }) c := client.New(srv) var resp struct { User struct { ID int Friends []struct { ID int } Pets []struct { ID int Friends []struct { ID int } } } ModelMethods struct { NoContext bool } } called := false resolvers.UserResolver.Friends = func(ctx context.Context, obj *User) ([]*User, error) { assert.Equal(t, []int{1, 2, 1, 2}, ctx.Value(ckey("path"))) called = true return []*User{}, nil } err := c.Post(`query { user(id: 1) { id, friends { id } pets (limit: 2) { id friends(limit: 10) { id } } } modelMethods { noContext } }`, &resp) assert.Equal(t, map[string]bool{ "user": true, "pets": true, "id": false, "friends": true, "modelMethods": true, "noContext": true, }, areMethods) assert.Equal(t, map[string]bool{ "user": true, "pets": true, "id": false, "friends": true, "modelMethods": true, "noContext": false, }, areResolvers) require.NoError(t, err) require.True(t, called) } ================================================ FILE: codegen/testserver/singlefile/modelmethod_test.go ================================================ package singlefile import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestModelMethods(t *testing.T) { resolver := &Stub{} resolver.QueryResolver.ModelMethods = func(ctx context.Context) (methods *ModelMethods, e error) { return &ModelMethods{}, nil } resolver.ModelMethodsResolver.ResolverField = func(ctx context.Context, obj *ModelMethods) (b bool, e error) { return true, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolver})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("without context", func(t *testing.T) { var resp struct { ModelMethods struct { NoContext bool } } err := c.Post(`query { modelMethods{ noContext } }`, &resp) require.NoError(t, err) require.True(t, resp.ModelMethods.NoContext) }) t.Run("with context", func(t *testing.T) { var resp struct { ModelMethods struct { WithContext bool } } err := c.Post(`query { modelMethods{ withContext } }`, &resp) require.NoError(t, err) require.True(t, resp.ModelMethods.WithContext) }) } ================================================ FILE: codegen/testserver/singlefile/models-gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package singlefile import ( "bytes" "fmt" "io" "strconv" "time" "github.com/99designs/gqlgen/graphql" ) type Animal interface { IsAnimal() GetSpecies() string GetSize() *Size } type ContentChild interface { IsContentChild() } type Mammalian interface { IsAnimal() IsMammalian() GetSpecies() string GetSize() *Size } type TestUnion interface { IsTestUnion() } type A struct { ID string `json:"id"` } func (A) IsTestUnion() {} type AIt struct { ID string `json:"id"` } type AbIt struct { ID string `json:"id"` } type B struct { ID string `json:"id"` } func (B) IsTestUnion() {} type Cat struct { Species string `json:"species"` Size *Size `json:"size"` CatBreed string `json:"catBreed"` } func (Cat) IsAnimal() {} func (this Cat) GetSpecies() string { return this.Species } func (this Cat) GetSize() *Size { return this.Size } type CheckIssue896 struct { ID *int `json:"id,omitempty"` } type ContentPost struct { Foo *string `json:"foo,omitempty"` } func (ContentPost) IsContentChild() {} type ContentUser struct { Foo *string `json:"foo,omitempty"` } func (ContentUser) IsContentChild() {} type Coordinates struct { X float64 `json:"x"` Y float64 `json:"y"` } type DefaultInput struct { FalsyBoolean *bool `json:"falsyBoolean,omitempty"` TruthyBoolean *bool `json:"truthyBoolean,omitempty"` } type DefaultParametersMirror struct { FalsyBoolean *bool `json:"falsyBoolean,omitempty"` TruthyBoolean *bool `json:"truthyBoolean,omitempty"` } type DeferModel struct { ID string `json:"id"` Name string `json:"name"` Values []string `json:"values"` } type Dog struct { Species string `json:"species"` Size *Size `json:"size"` DogBreed string `json:"dogBreed"` } func (Dog) IsAnimal() {} func (this Dog) GetSpecies() string { return this.Species } func (this Dog) GetSize() *Size { return this.Size } type EmbeddedDefaultScalar struct { Value *string `json:"value,omitempty"` } type FieldsOrderPayload struct { FirstFieldValue *string `json:"firstFieldValue,omitempty"` } type Horse struct { Species string `json:"species"` Size *Size `json:"size"` HorseBreed string `json:"horseBreed"` } func (Horse) IsMammalian() {} func (this Horse) GetSpecies() string { return this.Species } func (this Horse) GetSize() *Size { return this.Size } func (Horse) IsAnimal() {} type InnerDirectives struct { Message string `json:"message"` } type InnerInput struct { ID int `json:"id"` } type InnerObject struct { ID int `json:"id"` } type InputDirectives struct { Text string `json:"text"` NullableText *string `json:"nullableText,omitempty"` Inner *InnerDirectives `json:"inner"` InnerNullable *InnerDirectives `json:"innerNullable,omitempty"` ThirdParty *ThirdParty `json:"thirdParty,omitempty"` } type InputWithEnumValue struct { Enum EnumTest `json:"enum"` } type LoopA struct { B *LoopB `json:"b"` } type LoopB struct { A *LoopA `json:"a"` } // Since gqlgen defines default implementation for a Map scalar, this tests that the builtin is _not_ // added to the TypeMap type Map struct { ID string `json:"id"` } type Mutation struct { } type NestedInput struct { Field Email `json:"field"` } type NestedMapInput struct { Map map[string]any `json:"map,omitempty"` } type ObjectDirectives struct { Text string `json:"text"` NullableText *string `json:"nullableText,omitempty"` Order []string `json:"order"` } type OmittableInput struct { ID graphql.Omittable[*string] `json:"id,omitempty"` Bool graphql.Omittable[*bool] `json:"bool,omitempty"` Str graphql.Omittable[*string] `json:"str,omitempty"` Int graphql.Omittable[*int] `json:"int,omitempty"` Time graphql.Omittable[*time.Time] `json:"time,omitempty"` Enum graphql.Omittable[*Status] `json:"enum,omitempty"` Scalar graphql.Omittable[*ThirdParty] `json:"scalar,omitempty"` Object graphql.Omittable[*OuterInput] `json:"object,omitempty"` } type OuterInput struct { Inner *InnerInput `json:"inner"` } type OuterObject struct { Inner *InnerObject `json:"inner"` } type OuterWrapperInput struct { Inner *InputDirectives `json:"inner"` } type Pet struct { ID int `json:"id"` Friends []*Pet `json:"friends,omitempty"` } type Query struct { } type Size struct { Height int `json:"height"` Weight int `json:"weight"` } type SkipIncludeTestType struct { A *string `json:"a,omitempty"` B *string `json:"b,omitempty"` } type Slices struct { Test1 []*string `json:"test1,omitempty"` Test2 []string `json:"test2,omitempty"` Test3 []*string `json:"test3"` Test4 []string `json:"test4"` } type SpecialInput struct { Nesting *NestedInput `json:"nesting"` } type Subscription struct { } type User struct { ID int `json:"id"` Friends []*User `json:"friends"` Created time.Time `json:"created"` Updated *time.Time `json:"updated,omitempty"` Pets []*Pet `json:"pets,omitempty"` } type ValidInput struct { Break string `json:"break"` Default string `json:"default"` Func string `json:"func"` Interface string `json:"interface"` Select string `json:"select"` Case string `json:"case"` Defer string `json:"defer"` Go string `json:"go"` Map string `json:"map"` Struct string `json:"struct"` Chan string `json:"chan"` Else string `json:"else"` Goto string `json:"goto"` Package string `json:"package"` Switch string `json:"switch"` Const string `json:"const"` Fallthrough string `json:"fallthrough"` If string `json:"if"` Range string `json:"range"` Type string `json:"type"` Continue string `json:"continue"` For string `json:"for"` Import string `json:"import"` Return string `json:"return"` Var string `json:"var"` Underscore string `json:"_"` } // These things are all valid, but without care generate invalid go code type ValidType struct { DifferentCase string `json:"differentCase"` DifferentCaseOld string `json:"different_case"` ValidInputKeywords bool `json:"validInputKeywords"` ValidArgs bool `json:"validArgs"` } type XXIt struct { ID string `json:"id"` } type XxIt struct { ID string `json:"id"` } type AsdfIt struct { ID string `json:"id"` } type IIt struct { ID string `json:"id"` } type EnumTest string const ( EnumTestOk EnumTest = "OK" EnumTestNg EnumTest = "NG" ) var AllEnumTest = []EnumTest{ EnumTestOk, EnumTestNg, } func (e EnumTest) IsValid() bool { switch e { case EnumTestOk, EnumTestNg: return true } return false } func (e EnumTest) String() string { return string(e) } func (e *EnumTest) UnmarshalGQL(v any) error { str, ok := v.(string) if !ok { return fmt.Errorf("enums must be strings") } *e = EnumTest(str) if !e.IsValid() { return fmt.Errorf("%s is not a valid EnumTest", str) } return nil } func (e EnumTest) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } func (e *EnumTest) UnmarshalJSON(b []byte) error { s, err := strconv.Unquote(string(b)) if err != nil { return err } return e.UnmarshalGQL(s) } func (e EnumTest) MarshalJSON() ([]byte, error) { var buf bytes.Buffer e.MarshalGQL(&buf) return buf.Bytes(), nil } type Status string const ( StatusOk Status = "OK" StatusError Status = "ERROR" ) var AllStatus = []Status{ StatusOk, StatusError, } func (e Status) IsValid() bool { switch e { case StatusOk, StatusError: return true } return false } func (e Status) String() string { return string(e) } func (e *Status) UnmarshalGQL(v any) error { str, ok := v.(string) if !ok { return fmt.Errorf("enums must be strings") } *e = Status(str) if !e.IsValid() { return fmt.Errorf("%s is not a valid Status", str) } return nil } func (e Status) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } func (e *Status) UnmarshalJSON(b []byte) error { s, err := strconv.Unquote(string(b)) if err != nil { return err } return e.UnmarshalGQL(s) } func (e Status) MarshalJSON() ([]byte, error) { var buf bytes.Buffer e.MarshalGQL(&buf) return buf.Bytes(), nil } ================================================ FILE: codegen/testserver/singlefile/models.go ================================================ package singlefile import ( "context" "errors" "io" ) type ForcedResolver struct { Field Circle } type ModelMethods struct{} func (m ModelMethods) NoContext() bool { return true } func (m ModelMethods) WithContext(_ context.Context) bool { return true } type Errors struct{} type Error struct { ID string } func (Error) ErrorOnRequiredField() (string, error) { return "", errors.New("boom") } func (Error) ErrorOnNonRequiredField() (string, error) { return "", errors.New("boom") } func (Error) NilOnRequiredField() *string { return nil } type EmbeddedPointerModel struct { *EmbeddedPointer ID string } type EmbeddedPointer struct { Title string } type MarshalPanic string func (m *MarshalPanic) UnmarshalGQL(v any) error { panic("BOOM") } func (m MarshalPanic) MarshalGQL(w io.Writer) { panic("BOOM") } type Panics struct{} func (p *Panics) FieldFuncMarshal(ctx context.Context, u []MarshalPanic) []MarshalPanic { return []MarshalPanic{MarshalPanic("aa"), MarshalPanic("bb")} } type Autobind struct { Int int Int32 int32 Int64 int64 IdStr string IdInt int } type OverlappingFields struct { Foo int NewFoo int } type ObjectDirectivesWithCustomGoModel struct { NullableText string // not *string, but schema is `String @toNull` type. } type FallbackToStringEncoding string const ( FallbackToStringEncodingA FallbackToStringEncoding = "A" FallbackToStringEncodingB FallbackToStringEncoding = "B" FallbackToStringEncodingC FallbackToStringEncoding = "C" ) type Primitive int func (p Primitive) Squared() int { return int(p) * int(p) } type PrimitiveString string func (s PrimitiveString) Doubled() string { return string(s) + string(s) } type Bytes []byte ================================================ FILE: codegen/testserver/singlefile/mutation_with_custom_scalar.go ================================================ package singlefile import ( "encoding/json" "errors" "io" "regexp" ) var re = regexp.MustCompile( "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$", ) type Email string func (value *Email) UnmarshalGQL(v any) error { input, ok := v.(string) if !ok { return errors.New("email expects a string value") } if !re.MatchString(input) { return errors.New("invalid email format") } *value = Email(input) return nil } func (value Email) MarshalGQL(w io.Writer) { output, _ := json.Marshal(string(value)) w.Write(output) } ================================================ FILE: codegen/testserver/singlefile/mutation_with_custom_scalar.graphql ================================================ extend type Mutation { updateSomething(input: SpecialInput!): String! } scalar Email input SpecialInput { nesting: NestedInput! } input NestedInput { field: Email! } ================================================ FILE: codegen/testserver/singlefile/mutation_with_custom_scalar_test.go ================================================ package singlefile import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestErrorInsideMutationArgument(t *testing.T) { resolvers := &Stub{} resolvers.MutationResolver.UpdateSomething = func(_ context.Context, input SpecialInput) (s string, err error) { return "Hello world", nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("mutation with correct input doesn't return error", func(t *testing.T) { var resp map[string]any input := map[string]any{ "nesting": map[string]any{ "field": "email@example.com", }, } err := c.Post( `mutation TestMutation($input: SpecialInput!) { updateSomething(input: $input) }`, &resp, client.Var("input", input), ) require.Equal(t, "Hello world", resp["updateSomething"]) require.NoError(t, err) }) t.Run("mutation with incorrect input returns full path", func(t *testing.T) { var resp map[string]any input := map[string]any{ "nesting": map[string]any{ "field": "not-an-email", }, } err := c.Post( `mutation TestMutation($input: SpecialInput!) { updateSomething(input: $input) }`, &resp, client.Var("input", input), ) require.EqualError( t, err, `[{"message":"invalid email format","path":["updateSomething","input","nesting","field"]}]`, ) }) } ================================================ FILE: codegen/testserver/singlefile/nulls.graphql ================================================ extend type Query { errorBubble: Error errorBubbleList: [Error!] errorList: [Error] errors: Errors valid: String! invalid: String! } extend type Subscription { errorRequired: Error! } type Errors { a: Error! b: Error! c: Error! d: Error! e: Error! } type Error { id: ID! errorOnNonRequiredField: String errorOnRequiredField: String! nilOnRequiredField: String! } ================================================ FILE: codegen/testserver/singlefile/nulls_test.go ================================================ package singlefile import ( "context" "errors" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestNullBubbling(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.Valid = func(ctx context.Context) (s string, e error) { return "Ok", nil } resolvers.QueryResolver.Invalid = func(ctx context.Context) (s string, e error) { return "Ok", errors.New("ERROR") } resolvers.QueryResolver.Errors = func(ctx context.Context) (errors *Errors, e error) { return &Errors{}, nil } resolvers.QueryResolver.ErrorBubble = func(ctx context.Context) (i *Error, e error) { return &Error{ID: "E1234"}, nil } resolvers.QueryResolver.ErrorBubbleList = func(ctx context.Context) (i []*Error, e error) { return []*Error{{ID: "1"}, nil, nil}, nil } resolvers.QueryResolver.ErrorList = func(ctx context.Context) (i []*Error, e error) { return []*Error{nil}, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("when function errors on non required field", func(t *testing.T) { var resp struct { Valid string ErrorBubble *struct { Id string ErrorOnNonRequiredField *string } } err := c.Post(`query { valid, errorBubble { id, errorOnNonRequiredField } }`, &resp) require.EqualError( t, err, `[{"message":"boom","path":["errorBubble","errorOnNonRequiredField"]}]`, ) require.Equal(t, "E1234", resp.ErrorBubble.Id) require.Nil(t, resp.ErrorBubble.ErrorOnNonRequiredField) require.Equal(t, "Ok", resp.Valid) }) t.Run("when function errors", func(t *testing.T) { var resp struct { Valid string ErrorBubble *struct { NilOnRequiredField string } } err := c.Post(`query { valid, errorBubble { id, errorOnRequiredField } }`, &resp) require.EqualError( t, err, `[{"message":"boom","path":["errorBubble","errorOnRequiredField"]}]`, ) require.Nil(t, resp.ErrorBubble) require.Equal(t, "Ok", resp.Valid) }) t.Run("when user returns null on required field", func(t *testing.T) { var resp struct { Valid string ErrorBubble *struct { NilOnRequiredField string } } err := c.Post(`query { valid, errorBubble { id, nilOnRequiredField } }`, &resp) require.EqualError( t, err, `[{"message":"the requested element is null which the schema does not allow","path":["errorBubble","nilOnRequiredField"]}]`, ) require.Nil(t, resp.ErrorBubble) require.Equal(t, "Ok", resp.Valid) }) t.Run("when list element is null", func(t *testing.T) { var resp struct { Valid string ErrorList []*struct{} } err := c.Post(`query { valid, errorList { id } }`, &resp) require.NoError(t, err) require.Len(t, resp.ErrorList, 1) require.Nil(t, resp.ErrorList[0]) require.Equal(t, "Ok", resp.Valid) }) t.Run("when non-null list element is null", func(t *testing.T) { var resp struct { Valid string ErrorBubbleList []*struct{} } err := c.Post(`query { valid, errorBubbleList { id } }`, &resp) require.Contains( t, err.Error(), `{"message":"the requested element is null which the schema does not allow","path":["errorBubbleList",2]}`, ) require.Contains( t, err.Error(), `{"message":"the requested element is null which the schema does not allow","path":["errorBubbleList",1]}`, ) require.Nil(t, resp.ErrorBubbleList) require.Equal(t, "Ok", resp.Valid) }) t.Run("null args", func(t *testing.T) { var resp struct { NullableArg *string } resolvers.QueryResolver.NullableArg = func(ctx context.Context, arg *int) (i *string, e error) { v := "Ok" return &v, nil } err := c.Post(`query { nullableArg(arg: null) }`, &resp) require.NoError(t, err) require.Equal(t, "Ok", *resp.NullableArg) }) t.Run("concurrent null detection", func(t *testing.T) { var resp any resolvers.ErrorsResolver.A = func(ctx context.Context, obj *Errors) (i *Error, e error) { return nil, nil } resolvers.ErrorsResolver.B = func(ctx context.Context, obj *Errors) (i *Error, e error) { return nil, nil } resolvers.ErrorsResolver.C = func(ctx context.Context, obj *Errors) (i *Error, e error) { return nil, nil } resolvers.ErrorsResolver.D = func(ctx context.Context, obj *Errors) (i *Error, e error) { return nil, nil } resolvers.ErrorsResolver.E = func(ctx context.Context, obj *Errors) (i *Error, e error) { return nil, nil } err := c.Post(`{ errors { a { id }, b { id }, c { id }, d { id }, e { id }, } }`, &resp) require.Error(t, err) require.Contains( t, err.Error(), "the requested element is null which the schema does not allow", ) }) t.Run("when non-nullable field returns content while error occurred", func(t *testing.T) { var resp any err := c.Post(`query { invalid }`, &resp) require.Nil(t, resp) require.Error(t, err) require.Contains(t, err.Error(), `{"message":"ERROR","path":["invalid"]}`) }) } ================================================ FILE: codegen/testserver/singlefile/otherpkg/model.go ================================================ package otherpkg type ( Scalar string Map map[string]string Slice []string ) type Struct struct { Name Scalar Desc *Scalar } ================================================ FILE: codegen/testserver/singlefile/panics.graphql ================================================ extend type Query { panics: Panics } type Panics { fieldScalarMarshal: [MarshalPanic!]! fieldFuncMarshal(u: [MarshalPanic!]!): [MarshalPanic!]! argUnmarshal(u: [MarshalPanic!]!): Boolean! } scalar MarshalPanic ================================================ FILE: codegen/testserver/singlefile/panics_test.go ================================================ package singlefile import ( "context" "fmt" "testing" "github.com/stretchr/testify/require" "github.com/vektah/gqlparser/v2/gqlerror" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestPanics(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.Panics = func(ctx context.Context) (panics *Panics, e error) { return &Panics{}, nil } resolvers.PanicsResolver.ArgUnmarshal = func(ctx context.Context, obj *Panics, u []MarshalPanic) (b bool, e error) { return true, nil } resolvers.PanicsResolver.FieldScalarMarshal = func(ctx context.Context, obj *Panics) (marshalPanic []MarshalPanic, e error) { return []MarshalPanic{MarshalPanic("aa"), MarshalPanic("bb")}, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) srv.SetRecoverFunc(func(ctx context.Context, err any) (userMessage error) { return fmt.Errorf("panic: %v", err) }) srv.SetErrorPresenter(func(ctx context.Context, err error) *gqlerror.Error { return &gqlerror.Error{ Message: "presented: " + err.Error(), Path: graphql.GetPath(ctx), } }) c := client.New(srv) t.Run("panics in marshallers will not kill server", func(t *testing.T) { var resp any err := c.Post(`query { panics { fieldScalarMarshal } }`, &resp) require.EqualError( t, err, "http 422: {\"errors\":[{\"message\":\"presented: panic: BOOM\"}],\"data\":null}", ) }) t.Run("panics in unmarshalers will not kill server", func(t *testing.T) { var resp any err := c.Post(`query { panics { argUnmarshal(u: ["aa", "bb"]) } }`, &resp) require.EqualError( t, err, "[{\"message\":\"presented: input: panics.argUnmarshal panic: BOOM\",\"path\":[\"panics\",\"argUnmarshal\"]}]", ) }) t.Run("panics in funcs unmarshal return errors", func(t *testing.T) { var resp any err := c.Post(`query { panics { fieldFuncMarshal(u: ["aa", "bb"]) } }`, &resp) require.EqualError( t, err, "[{\"message\":\"presented: input: panics.fieldFuncMarshal panic: BOOM\",\"path\":[\"panics\",\"fieldFuncMarshal\"]}]", ) }) t.Run("panics in funcs marshal return errors", func(t *testing.T) { var resp any err := c.Post(`query { panics { fieldFuncMarshal(u: []) } }`, &resp) require.EqualError( t, err, "http 422: {\"errors\":[{\"message\":\"presented: panic: BOOM\"}],\"data\":null}", ) }) } ================================================ FILE: codegen/testserver/singlefile/primitive_objects.graphql ================================================ extend type Query { primitiveObject: [Primitive!]! primitiveStringObject: [PrimitiveString!]! } type Primitive { value: Int! squared: Int! } type PrimitiveString { value: String! doubled: String! len: Int! } ================================================ FILE: codegen/testserver/singlefile/primitive_objects_test.go ================================================ package singlefile import ( "context" "testing" "github.com/stretchr/testify/assert" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestPrimitiveObjects(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.PrimitiveObject = func(ctx context.Context) (out []Primitive, e error) { return []Primitive{2, 4}, nil } resolvers.PrimitiveResolver.Value = func(ctx context.Context, obj *Primitive) (i int, e error) { return int(*obj), nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("can fetch value", func(t *testing.T) { var resp struct { PrimitiveObject []struct { Value int Squared int } } c.MustPost(`query { primitiveObject { value, squared } }`, &resp) assert.Equal(t, 2, resp.PrimitiveObject[0].Value) assert.Equal(t, 4, resp.PrimitiveObject[0].Squared) assert.Equal(t, 4, resp.PrimitiveObject[1].Value) assert.Equal(t, 16, resp.PrimitiveObject[1].Squared) }) } func TestPrimitiveStringObjects(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.PrimitiveStringObject = func(ctx context.Context) (out []PrimitiveString, e error) { return []PrimitiveString{"hello", "world"}, nil } resolvers.PrimitiveStringResolver.Value = func(ctx context.Context, obj *PrimitiveString) (i string, e error) { return string(*obj), nil } resolvers.PrimitiveStringResolver.Len = func(ctx context.Context, obj *PrimitiveString) (i int, e error) { return len(string(*obj)), nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("can fetch value", func(t *testing.T) { var resp struct { PrimitiveStringObject []struct { Value string Doubled string Len int } } c.MustPost(`query { primitiveStringObject { value, doubled, len } }`, &resp) assert.Equal(t, "hello", resp.PrimitiveStringObject[0].Value) assert.Equal(t, "hellohello", resp.PrimitiveStringObject[0].Doubled) assert.Equal(t, 5, resp.PrimitiveStringObject[0].Len) assert.Equal(t, "world", resp.PrimitiveStringObject[1].Value) assert.Equal(t, "worldworld", resp.PrimitiveStringObject[1].Doubled) assert.Equal(t, 5, resp.PrimitiveStringObject[1].Len) }) } ================================================ FILE: codegen/testserver/singlefile/ptr_to_any.go ================================================ package singlefile type PtrToAnyContainer struct { PtrToAny *any } func (c *PtrToAnyContainer) Binding() *any { return c.PtrToAny } ================================================ FILE: codegen/testserver/singlefile/ptr_to_any.graphql ================================================ scalar Any type PtrToAnyContainer { ptrToAny: Any binding: Any } extend type Query { ptrToAnyContainer: PtrToAnyContainer! } ================================================ FILE: codegen/testserver/singlefile/ptr_to_any_test.go ================================================ package singlefile import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestPtrToAny(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) var a any = `{"some":"thing"}` resolvers.QueryResolver.PtrToAnyContainer = func(ctx context.Context) (wrappedStruct *PtrToAnyContainer, e error) { ptrToAnyContainer := PtrToAnyContainer{ PtrToAny: &a, } return &ptrToAnyContainer, nil } t.Run("binding to pointer to any", func(t *testing.T) { var resp struct { PtrToAnyContainer struct { Binding *any } } err := c.Post(`query { ptrToAnyContainer { binding }}`, &resp) require.NoError(t, err) require.Equal(t, &a, resp.PtrToAnyContainer.Binding) }) } ================================================ FILE: codegen/testserver/singlefile/ptr_to_ptr_input.go ================================================ package singlefile type PtrToPtrOuter struct { Name string Inner *PtrToPtrInner StupidInner *******PtrToPtrInner } type PtrToPtrInner struct { Key string Value string } type UpdatePtrToPtrOuter struct { Name *string Inner **UpdatePtrToPtrInner StupidInner ********UpdatePtrToPtrInner } type UpdatePtrToPtrInner struct { Key *string Value *string } ================================================ FILE: codegen/testserver/singlefile/ptr_to_ptr_input.graphql ================================================ type PtrToPtrOuter { name: String! inner: PtrToPtrInner stupidInner: PtrToPtrInner } type PtrToPtrInner { key: String! value: String! } input UpdatePtrToPtrOuter { name: String inner: UpdatePtrToPtrInner stupidInner: UpdatePtrToPtrInner } input UpdatePtrToPtrInner { key: String value: String } extend type Mutation { updatePtrToPtr(input: UpdatePtrToPtrOuter!): PtrToPtrOuter! } ================================================ FILE: codegen/testserver/singlefile/ptr_to_ptr_input_test.go ================================================ package singlefile import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) type UpdatePtrToPtrResults struct { UpdatedPtrToPtr PtrToPtrOuter `json:"updatePtrToPtr"` } func TestPtrToPtr(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) resolvers.MutationResolver.UpdatePtrToPtr = func(ctx context.Context, in UpdatePtrToPtrOuter) (ret *PtrToPtrOuter, err error) { ret = &PtrToPtrOuter{ Name: "oldName", Inner: &PtrToPtrInner{ Key: "oldKey", Value: "oldValue", }, StupidInner: nest7(&PtrToPtrInner{ Key: "oldStupidKey", Value: "oldStupidValue", }), } if in.Name != nil { ret.Name = *in.Name } if in.Inner != nil { inner := *in.Inner if inner == nil { ret.Inner = nil } else { if in.Inner == nil { ret.Inner = &PtrToPtrInner{} } if inner.Key != nil { ret.Inner.Key = *inner.Key } if inner.Value != nil { ret.Inner.Value = *inner.Value } } } if in.StupidInner != nil { si := *in.StupidInner if si == nil { ret.StupidInner = nil } else { deepIn := ******si deepOut := ******ret.StupidInner if deepIn.Key != nil { deepOut.Key = *deepIn.Key } if deepIn.Value != nil { deepOut.Value = *deepIn.Value } } } return ret, err } t.Run("pointer to pointer input missing", func(t *testing.T) { var resp UpdatePtrToPtrResults err := c.Post( `mutation { updatePtrToPtr(input: { name: "newName" }) { name, inner { key, value }, stupidInner { key, value }}}`, &resp, ) require.NoError(t, err) require.Equal(t, "newName", resp.UpdatedPtrToPtr.Name) require.NotNil(t, resp.UpdatedPtrToPtr.Inner) require.Equal(t, "oldKey", resp.UpdatedPtrToPtr.Inner.Key) require.Equal(t, "oldValue", resp.UpdatedPtrToPtr.Inner.Value) require.NotNil(t, resp.UpdatedPtrToPtr.StupidInner) require.NotNil(t, ******resp.UpdatedPtrToPtr.StupidInner) require.Equal(t, "oldStupidKey", (******resp.UpdatedPtrToPtr.StupidInner).Key) require.Equal(t, "oldStupidValue", (******resp.UpdatedPtrToPtr.StupidInner).Value) }) t.Run("pointer to pointer input non-null", func(t *testing.T) { var resp UpdatePtrToPtrResults err := c.Post(`mutation { updatePtrToPtr(input: { inner: { key: "newKey" value: "newValue" } }) { name, inner { key, value }, stupidInner { key, value }} }`, &resp) require.NoError(t, err) require.Equal(t, "oldName", resp.UpdatedPtrToPtr.Name) require.NotNil(t, resp.UpdatedPtrToPtr.Inner) require.Equal(t, "newKey", resp.UpdatedPtrToPtr.Inner.Key) require.Equal(t, "newValue", resp.UpdatedPtrToPtr.Inner.Value) require.NotNil(t, resp.UpdatedPtrToPtr.StupidInner) require.NotNil(t, ******resp.UpdatedPtrToPtr.StupidInner) require.Equal(t, "oldStupidKey", (******resp.UpdatedPtrToPtr.StupidInner).Key) require.Equal(t, "oldStupidValue", (******resp.UpdatedPtrToPtr.StupidInner).Value) }) t.Run("pointer to pointer input null", func(t *testing.T) { var resp UpdatePtrToPtrResults err := c.Post( `mutation { updatePtrToPtr(input: { inner: null }) { name, inner { key, value }, stupidInner { key, value }}}`, &resp, ) require.NoError(t, err) require.Equal(t, "oldName", resp.UpdatedPtrToPtr.Name) require.Nil(t, resp.UpdatedPtrToPtr.Inner) require.NotNil(t, resp.UpdatedPtrToPtr.StupidInner) require.NotNil(t, ******resp.UpdatedPtrToPtr.StupidInner) require.Equal(t, "oldStupidKey", (******resp.UpdatedPtrToPtr.StupidInner).Key) require.Equal(t, "oldStupidValue", (******resp.UpdatedPtrToPtr.StupidInner).Value) }) t.Run("many pointers input non-null", func(t *testing.T) { var resp UpdatePtrToPtrResults err := c.Post(`mutation { updatePtrToPtr(input: { stupidInner: { key: "newKey" value: "newValue" } }) { name, inner { key, value }, stupidInner { key, value }} }`, &resp) require.NoError(t, err) require.Equal(t, "oldName", resp.UpdatedPtrToPtr.Name) require.NotNil(t, resp.UpdatedPtrToPtr.Inner) require.Equal(t, "oldKey", resp.UpdatedPtrToPtr.Inner.Key) require.Equal(t, "oldValue", resp.UpdatedPtrToPtr.Inner.Value) require.NotNil(t, resp.UpdatedPtrToPtr.StupidInner) require.NotNil(t, ******resp.UpdatedPtrToPtr.StupidInner) require.Equal(t, "newKey", (******resp.UpdatedPtrToPtr.StupidInner).Key) require.Equal(t, "newValue", (******resp.UpdatedPtrToPtr.StupidInner).Value) }) t.Run("many pointers input null", func(t *testing.T) { var resp UpdatePtrToPtrResults err := c.Post( `mutation { updatePtrToPtr(input: { stupidInner: null }) { name, inner { key, value }, stupidInner { key, value }}}`, &resp, ) require.NoError(t, err) require.Equal(t, "oldName", resp.UpdatedPtrToPtr.Name) require.NotNil(t, resp.UpdatedPtrToPtr.Inner) require.Equal(t, "oldKey", resp.UpdatedPtrToPtr.Inner.Key) require.Equal(t, "oldValue", resp.UpdatedPtrToPtr.Inner.Value) require.Nil(t, resp.UpdatedPtrToPtr.StupidInner) }) } func nest7(in *PtrToPtrInner) *******PtrToPtrInner { si2 := &in si3 := &si2 si4 := &si3 si5 := &si4 si6 := &si5 si7 := &si6 return si7 } ================================================ FILE: codegen/testserver/singlefile/ptr_to_slice.go ================================================ package singlefile type PtrToSliceContainer struct { PtrToSlice *[]string } ================================================ FILE: codegen/testserver/singlefile/ptr_to_slice.graphql ================================================ type PtrToSliceContainer { ptrToSlice: [String!] } extend type Query { ptrToSliceContainer: PtrToSliceContainer! } ================================================ FILE: codegen/testserver/singlefile/ptr_to_slice_test.go ================================================ package singlefile import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestPtrToSlice(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) resolvers.QueryResolver.PtrToSliceContainer = func(ctx context.Context) (wrappedStruct *PtrToSliceContainer, e error) { ptrToSliceContainer := PtrToSliceContainer{ PtrToSlice: &[]string{"hello"}, } return &ptrToSliceContainer, nil } t.Run("pointer to slice", func(t *testing.T) { var resp struct { PtrToSliceContainer struct { PtrToSlice []string } } err := c.Post(`query { ptrToSliceContainer { ptrToSlice }}`, &resp) require.NoError(t, err) require.Equal(t, []string{"hello"}, resp.PtrToSliceContainer.PtrToSlice) }) } ================================================ FILE: codegen/testserver/singlefile/recursive.go ================================================ package singlefile type RecursiveInputSlice struct { Self []RecursiveInputSlice } ================================================ FILE: codegen/testserver/singlefile/resolver.go ================================================ package singlefile // 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" introspection1 "github.com/99designs/gqlgen/codegen/testserver/singlefile/introspection" invalid_packagename "github.com/99designs/gqlgen/codegen/testserver/singlefile/invalid-packagename" "github.com/99designs/gqlgen/codegen/testserver/singlefile/otherpkg" ) type Resolver struct{} // ID is the resolver for the id field. func (r *backedByInterfaceResolver) ID(ctx context.Context, obj BackedByInterface) (string, error) { panic("not implemented") } // Values is the resolver for the values field. func (r *deferModelResolver) Values(ctx context.Context, obj *DeferModel) ([]string, error) { panic("not implemented") } // A is the resolver for the a field. func (r *errorsResolver) A(ctx context.Context, obj *Errors) (*Error, error) { panic("not implemented") } // B is the resolver for the b field. func (r *errorsResolver) B(ctx context.Context, obj *Errors) (*Error, error) { panic("not implemented") } // C is the resolver for the c field. func (r *errorsResolver) C(ctx context.Context, obj *Errors) (*Error, error) { panic("not implemented") } // D is the resolver for the d field. func (r *errorsResolver) D(ctx context.Context, obj *Errors) (*Error, error) { panic("not implemented") } // E is the resolver for the e field. func (r *errorsResolver) E(ctx context.Context, obj *Errors) (*Error, error) { panic("not implemented") } // Field is the resolver for the field field. func (r *forcedResolverResolver) Field(ctx context.Context, obj *ForcedResolver) (*Circle, error) { panic("not implemented") } // ResolverField is the resolver for the resolverField field. func (r *modelMethodsResolver) ResolverField(ctx context.Context, obj *ModelMethods) (bool, error) { panic("not implemented") } // DefaultInput is the resolver for the defaultInput field. func (r *mutationResolver) DefaultInput(ctx context.Context, input DefaultInput) (*DefaultParametersMirror, error) { panic("not implemented") } // OverrideValueViaInput is the resolver for the overrideValueViaInput field. func (r *mutationResolver) OverrideValueViaInput(ctx context.Context, input FieldsOrderInput) (*FieldsOrderPayload, error) { panic("not implemented") } // UpdateProduct is the resolver for the updateProduct field. func (r *mutationResolver) UpdateProduct(ctx context.Context, input map[string]interface{}) (string, error) { panic("not implemented") } // Issue4053 is the resolver for the issue4053 field. func (r *mutationResolver) Issue4053(ctx context.Context, input *Issue4053Input1) (bool, error) { panic("not implemented") } // UpdateSomething is the resolver for the updateSomething field. func (r *mutationResolver) UpdateSomething(ctx context.Context, input SpecialInput) (string, error) { panic("not implemented") } // UpdatePtrToPtr is the resolver for the updatePtrToPtr field. func (r *mutationResolver) UpdatePtrToPtr(ctx context.Context, input UpdatePtrToPtrOuter) (*PtrToPtrOuter, error) { panic("not implemented") } // OldFoo is the resolver for the oldFoo field. func (r *overlappingFieldsResolver) OldFoo(ctx context.Context, obj *OverlappingFields) (int, error) { panic("not implemented") } // FieldScalarMarshal is the resolver for the fieldScalarMarshal field. func (r *panicsResolver) FieldScalarMarshal(ctx context.Context, obj *Panics) ([]MarshalPanic, error) { panic("not implemented") } // ArgUnmarshal is the resolver for the argUnmarshal field. func (r *panicsResolver) ArgUnmarshal(ctx context.Context, obj *Panics, u []MarshalPanic) (bool, error) { panic("not implemented") } // Friends is the resolver for the friends field. func (r *petResolver) Friends(ctx context.Context, obj *Pet, limit *int) ([]*Pet, error) { panic("not implemented") } // Value is the resolver for the value field. func (r *primitiveResolver) Value(ctx context.Context, obj *Primitive) (int, error) { panic("not implemented") } // Value is the resolver for the value field. func (r *primitiveStringResolver) Value(ctx context.Context, obj *PrimitiveString) (string, error) { panic("not implemented") } // Len is the resolver for the len field. func (r *primitiveStringResolver) Len(ctx context.Context, obj *PrimitiveString) (int, error) { panic("not implemented") } // InvalidIdentifier is the resolver for the invalidIdentifier field. func (r *queryResolver) InvalidIdentifier(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) { panic("not implemented") } // Collision is the resolver for the collision field. func (r *queryResolver) Collision(ctx context.Context) (*introspection1.It, error) { panic("not implemented") } // MapInput is the resolver for the mapInput field. func (r *queryResolver) MapInput(ctx context.Context, input map[string]any) (*bool, error) { panic("not implemented") } // Recursive is the resolver for the recursive field. func (r *queryResolver) Recursive(ctx context.Context, input *RecursiveInputSlice) (*bool, error) { panic("not implemented") } // NestedInputs is the resolver for the nestedInputs field. func (r *queryResolver) NestedInputs(ctx context.Context, input [][]*OuterInput) (*bool, error) { panic("not implemented") } // NestedOutputs is the resolver for the nestedOutputs field. func (r *queryResolver) NestedOutputs(ctx context.Context) ([][]*OuterObject, error) { panic("not implemented") } // ModelMethods is the resolver for the modelMethods field. func (r *queryResolver) ModelMethods(ctx context.Context) (*ModelMethods, error) { panic("not implemented") } // User is the resolver for the user field. func (r *queryResolver) User(ctx context.Context, id int) (*User, error) { panic("not implemented") } // NullableArg is the resolver for the nullableArg field. func (r *queryResolver) NullableArg(ctx context.Context, arg *int) (*string, error) { panic("not implemented") } // InputSlice is the resolver for the inputSlice field. func (r *queryResolver) InputSlice(ctx context.Context, arg []string) (bool, error) { panic("not implemented") } // InputNullableSlice is the resolver for the inputNullableSlice field. func (r *queryResolver) InputNullableSlice(ctx context.Context, arg []string) (bool, error) { panic("not implemented") } // InputOmittable is the resolver for the inputOmittable field. func (r *queryResolver) InputOmittable(ctx context.Context, arg OmittableInput) (string, error) { panic("not implemented") } // ShapeUnion is the resolver for the shapeUnion field. func (r *queryResolver) ShapeUnion(ctx context.Context) (ShapeUnion, error) { panic("not implemented") } // Autobind is the resolver for the autobind field. func (r *queryResolver) Autobind(ctx context.Context) (*Autobind, error) { panic("not implemented") } // DeprecatedField is the resolver for the deprecatedField field. func (r *queryResolver) DeprecatedField(ctx context.Context) (string, error) { panic("not implemented") } // FieldWithDeprecatedArg is the resolver for the fieldWithDeprecatedArg field. func (r *queryResolver) FieldWithDeprecatedArg(ctx context.Context, oldArg *int, newArg *int) (*string, error) { panic("not implemented") } // Overlapping is the resolver for the overlapping field. func (r *queryResolver) Overlapping(ctx context.Context) (*OverlappingFields, error) { panic("not implemented") } // DefaultParameters is the resolver for the defaultParameters field. func (r *queryResolver) DefaultParameters(ctx context.Context, falsyBoolean *bool, truthyBoolean *bool) (*DefaultParametersMirror, error) { panic("not implemented") } // DeferSingle is the resolver for the deferSingle field. func (r *queryResolver) DeferSingle(ctx context.Context) (*DeferModel, error) { panic("not implemented") } // DeferMultiple is the resolver for the deferMultiple field. func (r *queryResolver) DeferMultiple(ctx context.Context) ([]*DeferModel, error) { panic("not implemented") } // DirectiveArg is the resolver for the directiveArg field. func (r *queryResolver) DirectiveArg(ctx context.Context, arg string) (*string, error) { panic("not implemented") } // DirectiveNullableArg is the resolver for the directiveNullableArg field. func (r *queryResolver) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (*string, error) { panic("not implemented") } // DirectiveSingleNullableArg is the resolver for the directiveSingleNullableArg field. func (r *queryResolver) DirectiveSingleNullableArg(ctx context.Context, arg1 *string) (*string, error) { panic("not implemented") } // DirectiveInputNullable is the resolver for the directiveInputNullable field. func (r *queryResolver) DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) { panic("not implemented") } // DirectiveInput is the resolver for the directiveInput field. func (r *queryResolver) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) { panic("not implemented") } // DirectiveInputType is the resolver for the directiveInputType field. func (r *queryResolver) DirectiveInputType(ctx context.Context, arg InnerInput) (*string, error) { panic("not implemented") } // DirectiveInputOuter is the resolver for the directiveInputOuter field. func (r *queryResolver) DirectiveInputOuter(ctx context.Context, arg OuterWrapperInput) (*string, error) { panic("not implemented") } // DirectiveObject is the resolver for the directiveObject field. func (r *queryResolver) DirectiveObject(ctx context.Context) (*ObjectDirectives, error) { panic("not implemented") } // DirectiveObjectWithCustomGoModel is the resolver for the directiveObjectWithCustomGoModel field. func (r *queryResolver) DirectiveObjectWithCustomGoModel(ctx context.Context) (*ObjectDirectivesWithCustomGoModel, error) { panic("not implemented") } // DirectiveFieldDef is the resolver for the directiveFieldDef field. func (r *queryResolver) DirectiveFieldDef(ctx context.Context, ret string) (string, error) { panic("not implemented") } // DirectiveField is the resolver for the directiveField field. func (r *queryResolver) DirectiveField(ctx context.Context) (*string, error) { panic("not implemented") } // DirectiveDouble is the resolver for the directiveDouble field. func (r *queryResolver) DirectiveDouble(ctx context.Context) (*string, error) { panic("not implemented") } // DirectiveUnimplemented is the resolver for the directiveUnimplemented field. func (r *queryResolver) DirectiveUnimplemented(ctx context.Context) (*string, error) { panic("not implemented") } // EmbeddedCase1 is the resolver for the embeddedCase1 field. func (r *queryResolver) EmbeddedCase1(ctx context.Context) (*EmbeddedCase1, error) { panic("not implemented") } // EmbeddedCase2 is the resolver for the embeddedCase2 field. func (r *queryResolver) EmbeddedCase2(ctx context.Context) (*EmbeddedCase2, error) { panic("not implemented") } // EmbeddedCase3 is the resolver for the embeddedCase3 field. func (r *queryResolver) EmbeddedCase3(ctx context.Context) (*EmbeddedCase3, error) { panic("not implemented") } // EnumInInput is the resolver for the enumInInput field. func (r *queryResolver) EnumInInput(ctx context.Context, input *InputWithEnumValue) (EnumTest, error) { panic("not implemented") } // SearchProducts is the resolver for the searchProducts field. func (r *queryResolver) SearchProducts(ctx context.Context, filters map[string]interface{}) ([]string, error) { panic("not implemented") } // SearchRequired is the resolver for the searchRequired field. func (r *queryResolver) SearchRequired(ctx context.Context, filters map[string]interface{}) ([]string, error) { panic("not implemented") } // SearchProductsNormal is the resolver for the searchProductsNormal field. func (r *queryResolver) SearchProductsNormal(ctx context.Context, filters map[string]any) ([]string, error) { panic("not implemented") } // SearchWithDefaults is the resolver for the searchWithDefaults field. func (r *queryResolver) SearchWithDefaults(ctx context.Context, filters map[string]interface{}) ([]string, error) { panic("not implemented") } // SearchMixed is the resolver for the searchMixed field. func (r *queryResolver) SearchMixed(ctx context.Context, filters map[string]interface{}, limit *int, offset *int, sortBy *string) ([]string, error) { panic("not implemented") } // FilterProducts is the resolver for the filterProducts field. func (r *queryResolver) FilterProducts(ctx context.Context, filters map[string]interface{}) ([]string, error) { panic("not implemented") } // FindProducts is the resolver for the findProducts field. func (r *queryResolver) FindProducts(ctx context.Context, filters map[string]interface{}) ([]string, error) { panic("not implemented") } // SearchWithDirectives is the resolver for the searchWithDirectives field. func (r *queryResolver) SearchWithDirectives(ctx context.Context, input map[string]interface{}) ([]string, error) { panic("not implemented") } // Shapes is the resolver for the shapes field. func (r *queryResolver) Shapes(ctx context.Context) ([]Shape, error) { panic("not implemented") } // NoShape is the resolver for the noShape field. func (r *queryResolver) NoShape(ctx context.Context) (Shape, error) { panic("not implemented") } // Node is the resolver for the node field. func (r *queryResolver) Node(ctx context.Context) (Node, error) { panic("not implemented") } // NoShapeTypedNil is the resolver for the noShapeTypedNil field. func (r *queryResolver) NoShapeTypedNil(ctx context.Context) (Shape, error) { panic("not implemented") } // Animal is the resolver for the animal field. func (r *queryResolver) Animal(ctx context.Context) (Animal, error) { panic("not implemented") } // NotAnInterface is the resolver for the notAnInterface field. func (r *queryResolver) NotAnInterface(ctx context.Context) (BackedByInterface, error) { panic("not implemented") } // Dog is the resolver for the dog field. func (r *queryResolver) Dog(ctx context.Context) (*Dog, error) { panic("not implemented") } // Issue896a is the resolver for the issue896a field. func (r *queryResolver) Issue896a(ctx context.Context) ([]*CheckIssue896, error) { panic("not implemented") } // MapStringInterface is the resolver for the mapStringInterface field. func (r *queryResolver) MapStringInterface(ctx context.Context, in map[string]any) (map[string]any, error) { panic("not implemented") } // MapNestedStringInterface is the resolver for the mapNestedStringInterface field. func (r *queryResolver) MapNestedStringInterface(ctx context.Context, in *NestedMapInput) (map[string]any, error) { panic("not implemented") } // MapNestedMapSlice is the resolver for the mapNestedMapSlice field. func (r *queryResolver) MapNestedMapSlice(ctx context.Context, input map[string]any) (*bool, error) { panic("not implemented") } // ErrorBubble is the resolver for the errorBubble field. func (r *queryResolver) ErrorBubble(ctx context.Context) (*Error, error) { panic("not implemented") } // ErrorBubbleList is the resolver for the errorBubbleList field. func (r *queryResolver) ErrorBubbleList(ctx context.Context) ([]*Error, error) { panic("not implemented") } // ErrorList is the resolver for the errorList field. func (r *queryResolver) ErrorList(ctx context.Context) ([]*Error, error) { panic("not implemented") } // Errors is the resolver for the errors field. func (r *queryResolver) Errors(ctx context.Context) (*Errors, error) { panic("not implemented") } // Valid is the resolver for the valid field. func (r *queryResolver) Valid(ctx context.Context) (string, error) { panic("not implemented") } // Invalid is the resolver for the invalid field. func (r *queryResolver) Invalid(ctx context.Context) (string, error) { panic("not implemented") } // Panics is the resolver for the panics field. func (r *queryResolver) Panics(ctx context.Context) (*Panics, error) { panic("not implemented") } // PrimitiveObject is the resolver for the primitiveObject field. func (r *queryResolver) PrimitiveObject(ctx context.Context) ([]Primitive, error) { panic("not implemented") } // PrimitiveStringObject is the resolver for the primitiveStringObject field. func (r *queryResolver) PrimitiveStringObject(ctx context.Context) ([]PrimitiveString, error) { panic("not implemented") } // PtrToAnyContainer is the resolver for the ptrToAnyContainer field. func (r *queryResolver) PtrToAnyContainer(ctx context.Context) (*PtrToAnyContainer, error) { panic("not implemented") } // PtrToSliceContainer is the resolver for the ptrToSliceContainer field. func (r *queryResolver) PtrToSliceContainer(ctx context.Context) (*PtrToSliceContainer, error) { panic("not implemented") } // Infinity is the resolver for the infinity field. func (r *queryResolver) Infinity(ctx context.Context) (float64, error) { panic("not implemented") } // StringFromContextInterface is the resolver for the stringFromContextInterface field. func (r *queryResolver) StringFromContextInterface(ctx context.Context) (*StringFromContextInterface, error) { panic("not implemented") } // StringFromContextFunction is the resolver for the stringFromContextFunction field. func (r *queryResolver) StringFromContextFunction(ctx context.Context) (string, error) { panic("not implemented") } // DefaultScalar is the resolver for the defaultScalar field. func (r *queryResolver) DefaultScalar(ctx context.Context, arg string) (string, error) { panic("not implemented") } // SkipInclude is the resolver for the skipInclude field. func (r *queryResolver) SkipInclude(ctx context.Context) (*SkipIncludeTestType, error) { panic("not implemented") } // Slices is the resolver for the slices field. func (r *queryResolver) Slices(ctx context.Context) (*Slices, error) { panic("not implemented") } // ScalarSlice is the resolver for the scalarSlice field. func (r *queryResolver) ScalarSlice(ctx context.Context) ([]byte, error) { panic("not implemented") } // Fallback is the resolver for the fallback field. func (r *queryResolver) Fallback(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) { panic("not implemented") } // OptionalUnion is the resolver for the optionalUnion field. func (r *queryResolver) OptionalUnion(ctx context.Context) (TestUnion, error) { panic("not implemented") } // VOkCaseValue is the resolver for the vOkCaseValue field. func (r *queryResolver) VOkCaseValue(ctx context.Context) (*VOkCaseValue, error) { panic("not implemented") } // VOkCaseNil is the resolver for the vOkCaseNil field. func (r *queryResolver) VOkCaseNil(ctx context.Context) (*VOkCaseNil, error) { panic("not implemented") } // ValidType is the resolver for the validType field. func (r *queryResolver) ValidType(ctx context.Context) (*ValidType, error) { panic("not implemented") } // VariadicModel is the resolver for the variadicModel field. func (r *queryResolver) VariadicModel(ctx context.Context) (*VariadicModel, error) { panic("not implemented") } // WrappedStruct is the resolver for the wrappedStruct field. func (r *queryResolver) WrappedStruct(ctx context.Context) (*WrappedStruct, error) { panic("not implemented") } // WrappedScalar is the resolver for the wrappedScalar field. func (r *queryResolver) WrappedScalar(ctx context.Context) (otherpkg.Scalar, error) { panic("not implemented") } // WrappedMap is the resolver for the wrappedMap field. func (r *queryResolver) WrappedMap(ctx context.Context) (WrappedMap, error) { panic("not implemented") } // WrappedSlice is the resolver for the wrappedSlice field. func (r *queryResolver) WrappedSlice(ctx context.Context) (WrappedSlice, error) { panic("not implemented") } // Updated is the resolver for the updated field. func (r *subscriptionResolver) Updated(ctx context.Context) (<-chan string, error) { panic("not implemented") } // InitPayload is the resolver for the initPayload field. func (r *subscriptionResolver) InitPayload(ctx context.Context) (<-chan string, error) { panic("not implemented") } // DirectiveArg is the resolver for the directiveArg field. func (r *subscriptionResolver) DirectiveArg(ctx context.Context, arg string) (<-chan *string, error) { panic("not implemented") } // DirectiveNullableArg is the resolver for the directiveNullableArg field. func (r *subscriptionResolver) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (<-chan *string, error) { panic("not implemented") } // DirectiveDouble is the resolver for the directiveDouble field. func (r *subscriptionResolver) DirectiveDouble(ctx context.Context) (<-chan *string, error) { panic("not implemented") } // DirectiveUnimplemented is the resolver for the directiveUnimplemented field. func (r *subscriptionResolver) DirectiveUnimplemented(ctx context.Context) (<-chan *string, error) { panic("not implemented") } // Issue896b is the resolver for the issue896b field. func (r *subscriptionResolver) Issue896b(ctx context.Context) (<-chan []*CheckIssue896, error) { panic("not implemented") } // ErrorRequired is the resolver for the errorRequired field. func (r *subscriptionResolver) ErrorRequired(ctx context.Context) (<-chan *Error, error) { panic("not implemented") } // Friends is the resolver for the friends field. func (r *userResolver) Friends(ctx context.Context, obj *User) ([]*User, error) { panic("not implemented") } // Pets is the resolver for the pets field. func (r *userResolver) Pets(ctx context.Context, obj *User, limit *int) ([]*Pet, error) { panic("not implemented") } // Get is the resolver for the get field. func (r *wrappedMapResolver) Get(ctx context.Context, obj WrappedMap, key string) (string, error) { panic("not implemented") } // Get is the resolver for the get field. func (r *wrappedSliceResolver) Get(ctx context.Context, obj WrappedSlice, idx int) (string, error) { panic("not implemented") } // BackedByInterface returns BackedByInterfaceResolver implementation. func (r *Resolver) BackedByInterface() BackedByInterfaceResolver { return &backedByInterfaceResolver{r} } // DeferModel returns DeferModelResolver implementation. func (r *Resolver) DeferModel() DeferModelResolver { return &deferModelResolver{r} } // Errors returns ErrorsResolver implementation. func (r *Resolver) Errors() ErrorsResolver { return &errorsResolver{r} } // ForcedResolver returns ForcedResolverResolver implementation. func (r *Resolver) ForcedResolver() ForcedResolverResolver { return &forcedResolverResolver{r} } // ModelMethods returns ModelMethodsResolver implementation. func (r *Resolver) ModelMethods() ModelMethodsResolver { return &modelMethodsResolver{r} } // Mutation returns MutationResolver implementation. func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } // OverlappingFields returns OverlappingFieldsResolver implementation. func (r *Resolver) OverlappingFields() OverlappingFieldsResolver { return &overlappingFieldsResolver{r} } // Panics returns PanicsResolver implementation. func (r *Resolver) Panics() PanicsResolver { return &panicsResolver{r} } // Pet returns PetResolver implementation. func (r *Resolver) Pet() PetResolver { return &petResolver{r} } // Primitive returns PrimitiveResolver implementation. func (r *Resolver) Primitive() PrimitiveResolver { return &primitiveResolver{r} } // PrimitiveString returns PrimitiveStringResolver implementation. func (r *Resolver) PrimitiveString() PrimitiveStringResolver { return &primitiveStringResolver{r} } // Query returns QueryResolver implementation. func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } // Subscription returns SubscriptionResolver implementation. func (r *Resolver) Subscription() SubscriptionResolver { return &subscriptionResolver{r} } // User returns UserResolver implementation. func (r *Resolver) User() UserResolver { return &userResolver{r} } // WrappedMap returns WrappedMapResolver implementation. func (r *Resolver) WrappedMap() WrappedMapResolver { return &wrappedMapResolver{r} } // WrappedSlice returns WrappedSliceResolver implementation. func (r *Resolver) WrappedSlice() WrappedSliceResolver { return &wrappedSliceResolver{r} } type backedByInterfaceResolver struct{ *Resolver } type deferModelResolver struct{ *Resolver } type errorsResolver struct{ *Resolver } type forcedResolverResolver struct{ *Resolver } type modelMethodsResolver struct{ *Resolver } type mutationResolver struct{ *Resolver } type overlappingFieldsResolver struct{ *Resolver } type panicsResolver struct{ *Resolver } type petResolver struct{ *Resolver } type primitiveResolver struct{ *Resolver } type primitiveStringResolver struct{ *Resolver } type queryResolver struct{ *Resolver } type subscriptionResolver struct{ *Resolver } type userResolver struct{ *Resolver } type wrappedMapResolver struct{ *Resolver } type wrappedSliceResolver struct{ *Resolver } ================================================ FILE: codegen/testserver/singlefile/response_extension_test.go ================================================ package singlefile import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestResponseExtension(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.Valid = func(ctx context.Context) (s string, e error) { return "Ok", nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) srv.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { graphql.RegisterExtension(ctx, "example", "value") return next(ctx) }) c := client.New(srv) raw, _ := c.RawPost(`query { valid }`) require.Equal(t, "value", raw.Extensions["example"]) } ================================================ FILE: codegen/testserver/singlefile/scalar_context.go ================================================ package singlefile import ( "context" "io" "strconv" "github.com/99designs/gqlgen/graphql" ) type StringFromContextInterface struct { OperationName string } var ( _ graphql.ContextMarshaler = StringFromContextInterface{} _ graphql.ContextUnmarshaler = (*StringFromContextInterface)(nil) ) func (StringFromContextInterface) MarshalGQLContext(ctx context.Context, w io.Writer) error { io.WriteString(w, strconv.Quote(graphql.GetFieldContext(ctx).Field.Name)) return nil } func (i *StringFromContextInterface) UnmarshalGQLContext(ctx context.Context, v any) error { i.OperationName = graphql.GetFieldContext(ctx).Field.Name return nil } func MarshalStringFromContextFunction(v string) graphql.ContextMarshaler { return graphql.ContextWriterFunc(func(ctx context.Context, w io.Writer) error { io.WriteString(w, strconv.Quote(graphql.GetFieldContext(ctx).Field.Name)) return nil }) } func UnmarshalStringFromContextFunction(ctx context.Context, v any) (string, error) { return graphql.GetFieldContext(ctx).Field.Name, nil } ================================================ FILE: codegen/testserver/singlefile/scalar_context.graphql ================================================ extend type Query { infinity: Float! stringFromContextInterface: StringFromContextInterface! stringFromContextFunction: StringFromContextFunction! } scalar StringFromContextInterface scalar StringFromContextFunction ================================================ FILE: codegen/testserver/singlefile/scalar_context_test.go ================================================ package singlefile import ( "context" "math" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestFloatInfAndNaN(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) resolvers.QueryResolver.Infinity = func(ctx context.Context) (float64, error) { return math.Inf(-1), nil } t.Run("errors on marshaller with context", func(t *testing.T) { err := c.Post(`query { infinity }`, nil) require.Error(t, err) }) } func TestContextPassedToMarshal(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) resolvers.QueryResolver.StringFromContextInterface = func(ctx context.Context) (*StringFromContextInterface, error) { return &StringFromContextInterface{}, nil } resolvers.QueryResolver.StringFromContextFunction = func(ctx context.Context) (string, error) { return "", nil } var res struct { StringFromContextInterface string StringFromContextFunction string } err := c.Post(`query my_name { stringFromContextInterface stringFromContextFunction }`, &res) require.NoError(t, err) require.Equal(t, "stringFromContextInterface", res.StringFromContextInterface) require.Equal(t, "stringFromContextFunction", res.StringFromContextFunction) } ================================================ FILE: codegen/testserver/singlefile/scalar_default.graphql ================================================ extend type Query { defaultScalar(arg: DefaultScalarImplementation! = "default"): DefaultScalarImplementation! } """ This doesnt have an implementation in the typemap, so it should act like a string """ scalar DefaultScalarImplementation type EmbeddedDefaultScalar { value: DefaultScalarImplementation } ================================================ FILE: codegen/testserver/singlefile/scalar_default_test.go ================================================ package singlefile import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestDefaultScalarImplementation(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) resolvers.QueryResolver.DefaultScalar = func(ctx context.Context, arg string) (i string, e error) { return arg, nil } t.Run("with arg value", func(t *testing.T) { var resp struct{ DefaultScalar string } c.MustPost(`query { defaultScalar(arg: "fff") }`, &resp) require.Equal(t, "fff", resp.DefaultScalar) }) t.Run("with default value", func(t *testing.T) { var resp struct{ DefaultScalar string } c.MustPost(`query { defaultScalar }`, &resp) require.Equal(t, "default", resp.DefaultScalar) }) } ================================================ FILE: codegen/testserver/singlefile/schema.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 ) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION directive @defer( if: Boolean = true label: String ) on FRAGMENT_SPREAD | INLINE_FRAGMENT type Query { invalidIdentifier: InvalidIdentifier collision: It mapInput(input: Changes): Boolean recursive(input: RecursiveInputSlice): Boolean nestedInputs(input: [[OuterInput]] = [[{ inner: { id: 1 } }]]): Boolean nestedOutputs: [[OuterObject]] modelMethods: ModelMethods user(id: Int!): User! nullableArg(arg: Int = 123): String inputSlice(arg: [String!]!): Boolean! inputNullableSlice(arg: [String!]): Boolean! inputOmittable(arg: OmittableInput!): String! shapeUnion: ShapeUnion! autobind: Autobind deprecatedField: String! @deprecated(reason: "test deprecated directive") fieldWithDeprecatedArg(oldArg: Int @deprecated(reason: "old arg"), newArg: Int): String } type Subscription { updated: String! initPayload: String! } type Pet { id: Int! friends(limit: Int): [Pet!] @goField(forceResolver: true) } type User { id: Int! friends: [User!]! @goField(forceResolver: true) created: Time! updated: Time pets(limit: Int): [Pet!] @goField(forceResolver: true) } type Autobind { int: Int! int32: Int! int64: Int! idStr: ID! idInt: ID! } type ModelMethods { resolverField: Boolean! noContext: Boolean! withContext: Boolean! } type InvalidIdentifier { id: Int! } type It { id: ID! } input Changes @goModel(model: "map[string]interface{}") { a: Int b: Int } input RecursiveInputSlice { self: [RecursiveInputSlice!] } input InnerInput { id: Int! } input OuterInput { inner: InnerInput! } input OmittableInput { id: ID @goField(omittable: true) bool: Boolean @goField(omittable: true) str: String @goField(omittable: true) int: Int @goField(omittable: true) time: Time @goField(omittable: true) enum: Status @goField(omittable: true) scalar: ThirdParty @goField(omittable: true) object: OuterInput @goField(omittable: true) } scalar ThirdParty @goModel(model: "singlefile.ThirdParty") type OuterObject { inner: InnerObject! } type InnerObject { id: Int! } type ForcedResolver { field: Circle @goField(forceResolver: true) } type EmbeddedPointer @goModel(model: "singlefile.EmbeddedPointerModel") { ID: String Title: String } scalar UUID enum Status { OK ERROR } scalar Time ================================================ FILE: codegen/testserver/singlefile/skip-include.graphql ================================================ extend type Query { skipInclude: SkipIncludeTestType } type SkipIncludeTestType { a: String b: String } ================================================ FILE: codegen/testserver/singlefile/skip_include_test.go ================================================ package singlefile import ( "context" "testing" "github.com/stretchr/testify/assert" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestSkipInclude(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) a := func() *string { a := "a"; return &a }() b := func() *string { b := "b"; return &b }() resolvers.QueryResolver.SkipInclude = func(ctx context.Context) (*SkipIncludeTestType, error) { return &SkipIncludeTestType{A: a, B: b}, nil } // Taken verbatim from the test cases found at the reference graphql-js implementation at: // https://github.com/graphql/graphql-js/blob/2120ff3f08a0e379e41a33f3c1a8c6127e0e574c/src/execution/__tests__/directives-test.ts // last updated on 2022-03-28 as of 2025-05-19. t.Run("works without directives", func(t *testing.T) { var r struct{ SkipInclude *SkipIncludeTestType } c.MustPost(`query { skipInclude { a, b } }`, &r) assert.Equal(t, &SkipIncludeTestType{a, b}, r.SkipInclude) }) t.Run("works on scalars", func(t *testing.T) { t.Run("if true includes scalar", func(t *testing.T) { var r struct{ SkipInclude *SkipIncludeTestType } c.MustPost(`{ skipInclude { a, b @include(if: true) } }`, &r) assert.Equal(t, &SkipIncludeTestType{a, b}, r.SkipInclude) }) t.Run("if false omits on scalar", func(t *testing.T) { var r struct{ SkipInclude *SkipIncludeTestType } c.MustPost(`{ skipInclude{ a, b @include(if: false) } }`, &r) assert.Equal(t, &SkipIncludeTestType{A: a}, r.SkipInclude) }) t.Run("unless false includes scalar", func(t *testing.T) { var r struct{ SkipInclude *SkipIncludeTestType } c.MustPost(`{ skipInclude{ a, b @skip(if: false) } }`, &r) assert.Equal(t, &SkipIncludeTestType{a, b}, r.SkipInclude) }) t.Run("unless true omits scalar", func(t *testing.T) { var r struct{ SkipInclude *SkipIncludeTestType } c.MustPost(`{ skipInclude{ a, b @skip(if: true) } }`, &r) assert.Equal(t, &SkipIncludeTestType{A: a}, r.SkipInclude) }) }) t.Run("works on fragment spreads", func(t *testing.T) { t.Run("if false omits fragment spread", func(t *testing.T) { var r struct{ SkipInclude *SkipIncludeTestType } c.MustPost( `query { skipInclude { a ...Frag @include(if: false) } } fragment Frag on SkipIncludeTestType { b }`, &r, ) assert.Equal(t, &SkipIncludeTestType{A: a}, r.SkipInclude) }) t.Run("if true includes fragment spread", func(t *testing.T) { var r struct{ SkipInclude *SkipIncludeTestType } c.MustPost( `query { skipInclude { a ...Frag @include(if: true) } } fragment Frag on SkipIncludeTestType { b }`, &r, ) assert.Equal(t, &SkipIncludeTestType{a, b}, r.SkipInclude) }) t.Run("unless false includes fragment spread", func(t *testing.T) { var r struct{ SkipInclude *SkipIncludeTestType } c.MustPost( `query { skipInclude { a ...Frag @skip(if: false) } } fragment Frag on SkipIncludeTestType { b }`, &r, ) assert.Equal(t, &SkipIncludeTestType{a, b}, r.SkipInclude) }) t.Run("unless true omits fragment spread", func(t *testing.T) { var r struct{ SkipInclude *SkipIncludeTestType } c.MustPost( `query { skipInclude { a ...Frag @skip(if: true) } } fragment Frag on SkipIncludeTestType { b }`, &r, ) assert.Equal(t, &SkipIncludeTestType{A: a}, r.SkipInclude) }) }) t.Run("works on inline fragment", func(t *testing.T) { t.Run("if false omits inline fragment", func(t *testing.T) { var r struct{ SkipInclude *SkipIncludeTestType } c.MustPost( `query { skipInclude { a ... on SkipIncludeTestType @include(if: false) { b } } }`, &r, ) assert.Equal(t, &SkipIncludeTestType{A: a}, r.SkipInclude) }) t.Run("if true includes inline fragment", func(t *testing.T) { var r struct{ SkipInclude *SkipIncludeTestType } c.MustPost( `query { skipInclude { a ... on SkipIncludeTestType @include(if: true) { b } } }`, &r, ) assert.Equal(t, &SkipIncludeTestType{a, b}, r.SkipInclude) }) t.Run("unless false includes inline fragment", func(t *testing.T) { var r struct{ SkipInclude *SkipIncludeTestType } c.MustPost( `query { skipInclude { a ... on SkipIncludeTestType @skip(if: false) { b } } }`, &r, ) assert.Equal(t, &SkipIncludeTestType{a, b}, r.SkipInclude) }) t.Run("unless true includes inline fragment", func(t *testing.T) { var r struct{ SkipInclude *SkipIncludeTestType } c.MustPost( `query { skipInclude { a ... on SkipIncludeTestType @skip(if: true) { b } } }`, &r, ) assert.Equal(t, &SkipIncludeTestType{A: a}, r.SkipInclude) }) }) t.Run("works on anonymous inline fragment", func(t *testing.T) { t.Run("if false omits anonymous inline fragment", func(t *testing.T) { var r struct{ SkipInclude *SkipIncludeTestType } c.MustPost(`query { skipInclude { a ... @include(if: false) { b } } }`, &r) assert.Equal(t, &SkipIncludeTestType{A: a}, r.SkipInclude) }) t.Run("if true includes anonymous inline fragment", func(t *testing.T) { var r struct{ SkipInclude *SkipIncludeTestType } c.MustPost(`query { skipInclude { a ... @include(if: true) { b } } }`, &r) assert.Equal(t, &SkipIncludeTestType{a, b}, r.SkipInclude) }) t.Run("unless false includes anonymous inline fragment", func(t *testing.T) { var r struct{ SkipInclude *SkipIncludeTestType } c.MustPost(`query Q { skipInclude { a ... @skip(if: false) { b } } }`, &r) assert.Equal(t, &SkipIncludeTestType{a, b}, r.SkipInclude) }) t.Run("unless true includes anonymous inline fragment", func(t *testing.T) { var r struct{ SkipInclude *SkipIncludeTestType } c.MustPost(`query { skipInclude { a ... @skip(if: true) { b } } }`, &r) assert.Equal(t, &SkipIncludeTestType{A: a}, r.SkipInclude) }) }) t.Run("works with skip and include directives", func(t *testing.T) { t.Run("include and no skip", func(t *testing.T) { var r struct{ SkipInclude *SkipIncludeTestType } c.MustPost(`{ skipInclude{ a b @include(if: true) @skip(if: false) } }`, &r) assert.Equal(t, &SkipIncludeTestType{a, b}, r.SkipInclude) }) t.Run("include and skip", func(t *testing.T) { var r struct{ SkipInclude *SkipIncludeTestType } c.MustPost(`{ skipInclude{ a b @include(if: true) @skip(if: true) } }`, &r) assert.Equal(t, &SkipIncludeTestType{A: a}, r.SkipInclude) }) t.Run("no include or skip", func(t *testing.T) { var r struct{ SkipInclude *SkipIncludeTestType } c.MustPost(`{ skipInclude{ a b @include(if: false) @skip(if: false) } }`, &r) assert.Equal(t, &SkipIncludeTestType{A: a}, r.SkipInclude) }) }) } ================================================ FILE: codegen/testserver/singlefile/slices.graphql ================================================ extend type Query { slices: Slices scalarSlice: Bytes! } type Slices { test1: [String] test2: [String!] test3: [String]! test4: [String!]! } scalar Bytes ================================================ FILE: codegen/testserver/singlefile/slices_test.go ================================================ package singlefile import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestSlices(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("nulls vs empty slices", func(t *testing.T) { resolvers.QueryResolver.Slices = func(ctx context.Context) (slices *Slices, e error) { return &Slices{}, nil } var resp struct { Slices Slices } c.MustPost(`query { slices { test1, test2, test3, test4 }}`, &resp) require.Nil(t, resp.Slices.Test1) require.Nil(t, resp.Slices.Test2) require.NotNil(t, resp.Slices.Test3) require.NotNil(t, resp.Slices.Test4) }) t.Run("custom scalars to slices work", func(t *testing.T) { resolvers.QueryResolver.ScalarSlice = func(ctx context.Context) ([]byte, error) { return []byte("testing"), nil } var resp struct { ScalarSlice string } c.MustPost(`query { scalarSlice }`, &resp) require.Equal(t, "testing", resp.ScalarSlice) }) } ================================================ FILE: codegen/testserver/singlefile/stub.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package singlefile import ( "context" introspection1 "github.com/99designs/gqlgen/codegen/testserver/singlefile/introspection" invalid_packagename "github.com/99designs/gqlgen/codegen/testserver/singlefile/invalid-packagename" "github.com/99designs/gqlgen/codegen/testserver/singlefile/otherpkg" ) type Stub struct { BackedByInterfaceResolver struct { ID func(ctx context.Context, obj BackedByInterface) (string, error) } DeferModelResolver struct { Values func(ctx context.Context, obj *DeferModel) ([]string, error) } ErrorsResolver struct { A func(ctx context.Context, obj *Errors) (*Error, error) B func(ctx context.Context, obj *Errors) (*Error, error) C func(ctx context.Context, obj *Errors) (*Error, error) D func(ctx context.Context, obj *Errors) (*Error, error) E func(ctx context.Context, obj *Errors) (*Error, error) } ForcedResolverResolver struct { Field func(ctx context.Context, obj *ForcedResolver) (*Circle, error) } ModelMethodsResolver struct { ResolverField func(ctx context.Context, obj *ModelMethods) (bool, error) } MutationResolver struct { DefaultInput func(ctx context.Context, input DefaultInput) (*DefaultParametersMirror, error) OverrideValueViaInput func(ctx context.Context, input FieldsOrderInput) (*FieldsOrderPayload, error) UpdateProduct func(ctx context.Context, input map[string]interface{}) (string, error) Issue4053 func(ctx context.Context, input *Issue4053Input1) (bool, error) UpdateSomething func(ctx context.Context, input SpecialInput) (string, error) UpdatePtrToPtr func(ctx context.Context, input UpdatePtrToPtrOuter) (*PtrToPtrOuter, error) } OverlappingFieldsResolver struct { OldFoo func(ctx context.Context, obj *OverlappingFields) (int, error) } PanicsResolver struct { FieldScalarMarshal func(ctx context.Context, obj *Panics) ([]MarshalPanic, error) ArgUnmarshal func(ctx context.Context, obj *Panics, u []MarshalPanic) (bool, error) } PetResolver struct { Friends func(ctx context.Context, obj *Pet, limit *int) ([]*Pet, error) } PrimitiveResolver struct { Value func(ctx context.Context, obj *Primitive) (int, error) } PrimitiveStringResolver struct { Value func(ctx context.Context, obj *PrimitiveString) (string, error) Len func(ctx context.Context, obj *PrimitiveString) (int, error) } QueryResolver struct { InvalidIdentifier func(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) Collision func(ctx context.Context) (*introspection1.It, error) MapInput func(ctx context.Context, input map[string]any) (*bool, error) Recursive func(ctx context.Context, input *RecursiveInputSlice) (*bool, error) NestedInputs func(ctx context.Context, input [][]*OuterInput) (*bool, error) NestedOutputs func(ctx context.Context) ([][]*OuterObject, error) ModelMethods func(ctx context.Context) (*ModelMethods, error) User func(ctx context.Context, id int) (*User, error) NullableArg func(ctx context.Context, arg *int) (*string, error) InputSlice func(ctx context.Context, arg []string) (bool, error) InputNullableSlice func(ctx context.Context, arg []string) (bool, error) InputOmittable func(ctx context.Context, arg OmittableInput) (string, error) ShapeUnion func(ctx context.Context) (ShapeUnion, error) Autobind func(ctx context.Context) (*Autobind, error) DeprecatedField func(ctx context.Context) (string, error) FieldWithDeprecatedArg func(ctx context.Context, oldArg *int, newArg *int) (*string, error) Overlapping func(ctx context.Context) (*OverlappingFields, error) DefaultParameters func(ctx context.Context, falsyBoolean *bool, truthyBoolean *bool) (*DefaultParametersMirror, error) DeferSingle func(ctx context.Context) (*DeferModel, error) DeferMultiple func(ctx context.Context) ([]*DeferModel, error) DirectiveArg func(ctx context.Context, arg string) (*string, error) DirectiveNullableArg func(ctx context.Context, arg *int, arg2 *int, arg3 *string) (*string, error) DirectiveSingleNullableArg func(ctx context.Context, arg1 *string) (*string, error) DirectiveInputNullable func(ctx context.Context, arg *InputDirectives) (*string, error) DirectiveInput func(ctx context.Context, arg InputDirectives) (*string, error) DirectiveInputType func(ctx context.Context, arg InnerInput) (*string, error) DirectiveInputOuter func(ctx context.Context, arg OuterWrapperInput) (*string, error) DirectiveObject func(ctx context.Context) (*ObjectDirectives, error) DirectiveObjectWithCustomGoModel func(ctx context.Context) (*ObjectDirectivesWithCustomGoModel, error) DirectiveFieldDef func(ctx context.Context, ret string) (string, error) DirectiveField func(ctx context.Context) (*string, error) DirectiveDouble func(ctx context.Context) (*string, error) DirectiveUnimplemented func(ctx context.Context) (*string, error) EmbeddedCase1 func(ctx context.Context) (*EmbeddedCase1, error) EmbeddedCase2 func(ctx context.Context) (*EmbeddedCase2, error) EmbeddedCase3 func(ctx context.Context) (*EmbeddedCase3, error) EnumInInput func(ctx context.Context, input *InputWithEnumValue) (EnumTest, error) SearchProducts func(ctx context.Context, filters map[string]interface{}) ([]string, error) SearchRequired func(ctx context.Context, filters map[string]interface{}) ([]string, error) SearchProductsNormal func(ctx context.Context, filters map[string]any) ([]string, error) SearchWithDefaults func(ctx context.Context, filters map[string]interface{}) ([]string, error) SearchMixed func(ctx context.Context, filters map[string]interface{}, limit *int, offset *int, sortBy *string) ([]string, error) FilterProducts func(ctx context.Context, filters map[string]interface{}) ([]string, error) FindProducts func(ctx context.Context, filters map[string]interface{}) ([]string, error) SearchWithDirectives func(ctx context.Context, input map[string]interface{}) ([]string, error) Shapes func(ctx context.Context) ([]Shape, error) NoShape func(ctx context.Context) (Shape, error) Node func(ctx context.Context) (Node, error) NoShapeTypedNil func(ctx context.Context) (Shape, error) Animal func(ctx context.Context) (Animal, error) NotAnInterface func(ctx context.Context) (BackedByInterface, error) Dog func(ctx context.Context) (*Dog, error) Issue896a func(ctx context.Context) ([]*CheckIssue896, error) MapStringInterface func(ctx context.Context, in map[string]any) (map[string]any, error) MapNestedStringInterface func(ctx context.Context, in *NestedMapInput) (map[string]any, error) MapNestedMapSlice func(ctx context.Context, input map[string]any) (*bool, error) ErrorBubble func(ctx context.Context) (*Error, error) ErrorBubbleList func(ctx context.Context) ([]*Error, error) ErrorList func(ctx context.Context) ([]*Error, error) Errors func(ctx context.Context) (*Errors, error) Valid func(ctx context.Context) (string, error) Invalid func(ctx context.Context) (string, error) Panics func(ctx context.Context) (*Panics, error) PrimitiveObject func(ctx context.Context) ([]Primitive, error) PrimitiveStringObject func(ctx context.Context) ([]PrimitiveString, error) PtrToAnyContainer func(ctx context.Context) (*PtrToAnyContainer, error) PtrToSliceContainer func(ctx context.Context) (*PtrToSliceContainer, error) Infinity func(ctx context.Context) (float64, error) StringFromContextInterface func(ctx context.Context) (*StringFromContextInterface, error) StringFromContextFunction func(ctx context.Context) (string, error) DefaultScalar func(ctx context.Context, arg string) (string, error) SkipInclude func(ctx context.Context) (*SkipIncludeTestType, error) Slices func(ctx context.Context) (*Slices, error) ScalarSlice func(ctx context.Context) ([]byte, error) Fallback func(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) OptionalUnion func(ctx context.Context) (TestUnion, error) VOkCaseValue func(ctx context.Context) (*VOkCaseValue, error) VOkCaseNil func(ctx context.Context) (*VOkCaseNil, error) ValidType func(ctx context.Context) (*ValidType, error) VariadicModel func(ctx context.Context) (*VariadicModel, error) WrappedStruct func(ctx context.Context) (*WrappedStruct, error) WrappedScalar func(ctx context.Context) (otherpkg.Scalar, error) WrappedMap func(ctx context.Context) (WrappedMap, error) WrappedSlice func(ctx context.Context) (WrappedSlice, error) } SubscriptionResolver struct { Updated func(ctx context.Context) (<-chan string, error) InitPayload func(ctx context.Context) (<-chan string, error) DirectiveArg func(ctx context.Context, arg string) (<-chan *string, error) DirectiveNullableArg func(ctx context.Context, arg *int, arg2 *int, arg3 *string) (<-chan *string, error) DirectiveDouble func(ctx context.Context) (<-chan *string, error) DirectiveUnimplemented func(ctx context.Context) (<-chan *string, error) Issue896b func(ctx context.Context) (<-chan []*CheckIssue896, error) ErrorRequired func(ctx context.Context) (<-chan *Error, error) } UserResolver struct { Friends func(ctx context.Context, obj *User) ([]*User, error) Pets func(ctx context.Context, obj *User, limit *int) ([]*Pet, error) } WrappedMapResolver struct { Get func(ctx context.Context, obj WrappedMap, key string) (string, error) } WrappedSliceResolver struct { Get func(ctx context.Context, obj WrappedSlice, idx int) (string, error) } FieldsOrderInputResolver struct { OverrideFirstField func(ctx context.Context, obj *FieldsOrderInput, data *string) error } } func (r *Stub) BackedByInterface() BackedByInterfaceResolver { return &stubBackedByInterface{r} } func (r *Stub) DeferModel() DeferModelResolver { return &stubDeferModel{r} } func (r *Stub) Errors() ErrorsResolver { return &stubErrors{r} } func (r *Stub) ForcedResolver() ForcedResolverResolver { return &stubForcedResolver{r} } func (r *Stub) ModelMethods() ModelMethodsResolver { return &stubModelMethods{r} } func (r *Stub) Mutation() MutationResolver { return &stubMutation{r} } func (r *Stub) OverlappingFields() OverlappingFieldsResolver { return &stubOverlappingFields{r} } func (r *Stub) Panics() PanicsResolver { return &stubPanics{r} } func (r *Stub) Pet() PetResolver { return &stubPet{r} } func (r *Stub) Primitive() PrimitiveResolver { return &stubPrimitive{r} } func (r *Stub) PrimitiveString() PrimitiveStringResolver { return &stubPrimitiveString{r} } func (r *Stub) Query() QueryResolver { return &stubQuery{r} } func (r *Stub) Subscription() SubscriptionResolver { return &stubSubscription{r} } func (r *Stub) User() UserResolver { return &stubUser{r} } func (r *Stub) WrappedMap() WrappedMapResolver { return &stubWrappedMap{r} } func (r *Stub) WrappedSlice() WrappedSliceResolver { return &stubWrappedSlice{r} } func (r *Stub) FieldsOrderInput() FieldsOrderInputResolver { return &stubFieldsOrderInput{r} } type stubBackedByInterface struct{ *Stub } func (r *stubBackedByInterface) ID(ctx context.Context, obj BackedByInterface) (string, error) { return r.BackedByInterfaceResolver.ID(ctx, obj) } type stubDeferModel struct{ *Stub } func (r *stubDeferModel) Values(ctx context.Context, obj *DeferModel) ([]string, error) { return r.DeferModelResolver.Values(ctx, obj) } type stubErrors struct{ *Stub } func (r *stubErrors) A(ctx context.Context, obj *Errors) (*Error, error) { return r.ErrorsResolver.A(ctx, obj) } func (r *stubErrors) B(ctx context.Context, obj *Errors) (*Error, error) { return r.ErrorsResolver.B(ctx, obj) } func (r *stubErrors) C(ctx context.Context, obj *Errors) (*Error, error) { return r.ErrorsResolver.C(ctx, obj) } func (r *stubErrors) D(ctx context.Context, obj *Errors) (*Error, error) { return r.ErrorsResolver.D(ctx, obj) } func (r *stubErrors) E(ctx context.Context, obj *Errors) (*Error, error) { return r.ErrorsResolver.E(ctx, obj) } type stubForcedResolver struct{ *Stub } func (r *stubForcedResolver) Field(ctx context.Context, obj *ForcedResolver) (*Circle, error) { return r.ForcedResolverResolver.Field(ctx, obj) } type stubModelMethods struct{ *Stub } func (r *stubModelMethods) ResolverField(ctx context.Context, obj *ModelMethods) (bool, error) { return r.ModelMethodsResolver.ResolverField(ctx, obj) } type stubMutation struct{ *Stub } func (r *stubMutation) DefaultInput(ctx context.Context, input DefaultInput) (*DefaultParametersMirror, error) { return r.MutationResolver.DefaultInput(ctx, input) } func (r *stubMutation) OverrideValueViaInput(ctx context.Context, input FieldsOrderInput) (*FieldsOrderPayload, error) { return r.MutationResolver.OverrideValueViaInput(ctx, input) } func (r *stubMutation) UpdateProduct(ctx context.Context, input map[string]interface{}) (string, error) { return r.MutationResolver.UpdateProduct(ctx, input) } func (r *stubMutation) Issue4053(ctx context.Context, input *Issue4053Input1) (bool, error) { return r.MutationResolver.Issue4053(ctx, input) } func (r *stubMutation) UpdateSomething(ctx context.Context, input SpecialInput) (string, error) { return r.MutationResolver.UpdateSomething(ctx, input) } func (r *stubMutation) UpdatePtrToPtr(ctx context.Context, input UpdatePtrToPtrOuter) (*PtrToPtrOuter, error) { return r.MutationResolver.UpdatePtrToPtr(ctx, input) } type stubOverlappingFields struct{ *Stub } func (r *stubOverlappingFields) OldFoo(ctx context.Context, obj *OverlappingFields) (int, error) { return r.OverlappingFieldsResolver.OldFoo(ctx, obj) } type stubPanics struct{ *Stub } func (r *stubPanics) FieldScalarMarshal(ctx context.Context, obj *Panics) ([]MarshalPanic, error) { return r.PanicsResolver.FieldScalarMarshal(ctx, obj) } func (r *stubPanics) ArgUnmarshal(ctx context.Context, obj *Panics, u []MarshalPanic) (bool, error) { return r.PanicsResolver.ArgUnmarshal(ctx, obj, u) } type stubPet struct{ *Stub } func (r *stubPet) Friends(ctx context.Context, obj *Pet, limit *int) ([]*Pet, error) { return r.PetResolver.Friends(ctx, obj, limit) } type stubPrimitive struct{ *Stub } func (r *stubPrimitive) Value(ctx context.Context, obj *Primitive) (int, error) { return r.PrimitiveResolver.Value(ctx, obj) } type stubPrimitiveString struct{ *Stub } func (r *stubPrimitiveString) Value(ctx context.Context, obj *PrimitiveString) (string, error) { return r.PrimitiveStringResolver.Value(ctx, obj) } func (r *stubPrimitiveString) Len(ctx context.Context, obj *PrimitiveString) (int, error) { return r.PrimitiveStringResolver.Len(ctx, obj) } type stubQuery struct{ *Stub } func (r *stubQuery) InvalidIdentifier(ctx context.Context) (*invalid_packagename.InvalidIdentifier, error) { return r.QueryResolver.InvalidIdentifier(ctx) } func (r *stubQuery) Collision(ctx context.Context) (*introspection1.It, error) { return r.QueryResolver.Collision(ctx) } func (r *stubQuery) MapInput(ctx context.Context, input map[string]any) (*bool, error) { return r.QueryResolver.MapInput(ctx, input) } func (r *stubQuery) Recursive(ctx context.Context, input *RecursiveInputSlice) (*bool, error) { return r.QueryResolver.Recursive(ctx, input) } func (r *stubQuery) NestedInputs(ctx context.Context, input [][]*OuterInput) (*bool, error) { return r.QueryResolver.NestedInputs(ctx, input) } func (r *stubQuery) NestedOutputs(ctx context.Context) ([][]*OuterObject, error) { return r.QueryResolver.NestedOutputs(ctx) } func (r *stubQuery) ModelMethods(ctx context.Context) (*ModelMethods, error) { return r.QueryResolver.ModelMethods(ctx) } func (r *stubQuery) User(ctx context.Context, id int) (*User, error) { return r.QueryResolver.User(ctx, id) } func (r *stubQuery) NullableArg(ctx context.Context, arg *int) (*string, error) { return r.QueryResolver.NullableArg(ctx, arg) } func (r *stubQuery) InputSlice(ctx context.Context, arg []string) (bool, error) { return r.QueryResolver.InputSlice(ctx, arg) } func (r *stubQuery) InputNullableSlice(ctx context.Context, arg []string) (bool, error) { return r.QueryResolver.InputNullableSlice(ctx, arg) } func (r *stubQuery) InputOmittable(ctx context.Context, arg OmittableInput) (string, error) { return r.QueryResolver.InputOmittable(ctx, arg) } func (r *stubQuery) ShapeUnion(ctx context.Context) (ShapeUnion, error) { return r.QueryResolver.ShapeUnion(ctx) } func (r *stubQuery) Autobind(ctx context.Context) (*Autobind, error) { return r.QueryResolver.Autobind(ctx) } func (r *stubQuery) DeprecatedField(ctx context.Context) (string, error) { return r.QueryResolver.DeprecatedField(ctx) } func (r *stubQuery) FieldWithDeprecatedArg(ctx context.Context, oldArg *int, newArg *int) (*string, error) { return r.QueryResolver.FieldWithDeprecatedArg(ctx, oldArg, newArg) } func (r *stubQuery) Overlapping(ctx context.Context) (*OverlappingFields, error) { return r.QueryResolver.Overlapping(ctx) } func (r *stubQuery) DefaultParameters(ctx context.Context, falsyBoolean *bool, truthyBoolean *bool) (*DefaultParametersMirror, error) { return r.QueryResolver.DefaultParameters(ctx, falsyBoolean, truthyBoolean) } func (r *stubQuery) DeferSingle(ctx context.Context) (*DeferModel, error) { return r.QueryResolver.DeferSingle(ctx) } func (r *stubQuery) DeferMultiple(ctx context.Context) ([]*DeferModel, error) { return r.QueryResolver.DeferMultiple(ctx) } func (r *stubQuery) DirectiveArg(ctx context.Context, arg string) (*string, error) { return r.QueryResolver.DirectiveArg(ctx, arg) } func (r *stubQuery) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (*string, error) { return r.QueryResolver.DirectiveNullableArg(ctx, arg, arg2, arg3) } func (r *stubQuery) DirectiveSingleNullableArg(ctx context.Context, arg1 *string) (*string, error) { return r.QueryResolver.DirectiveSingleNullableArg(ctx, arg1) } func (r *stubQuery) DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) { return r.QueryResolver.DirectiveInputNullable(ctx, arg) } func (r *stubQuery) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) { return r.QueryResolver.DirectiveInput(ctx, arg) } func (r *stubQuery) DirectiveInputType(ctx context.Context, arg InnerInput) (*string, error) { return r.QueryResolver.DirectiveInputType(ctx, arg) } func (r *stubQuery) DirectiveInputOuter(ctx context.Context, arg OuterWrapperInput) (*string, error) { return r.QueryResolver.DirectiveInputOuter(ctx, arg) } func (r *stubQuery) DirectiveObject(ctx context.Context) (*ObjectDirectives, error) { return r.QueryResolver.DirectiveObject(ctx) } func (r *stubQuery) DirectiveObjectWithCustomGoModel(ctx context.Context) (*ObjectDirectivesWithCustomGoModel, error) { return r.QueryResolver.DirectiveObjectWithCustomGoModel(ctx) } func (r *stubQuery) DirectiveFieldDef(ctx context.Context, ret string) (string, error) { return r.QueryResolver.DirectiveFieldDef(ctx, ret) } func (r *stubQuery) DirectiveField(ctx context.Context) (*string, error) { return r.QueryResolver.DirectiveField(ctx) } func (r *stubQuery) DirectiveDouble(ctx context.Context) (*string, error) { return r.QueryResolver.DirectiveDouble(ctx) } func (r *stubQuery) DirectiveUnimplemented(ctx context.Context) (*string, error) { return r.QueryResolver.DirectiveUnimplemented(ctx) } func (r *stubQuery) EmbeddedCase1(ctx context.Context) (*EmbeddedCase1, error) { return r.QueryResolver.EmbeddedCase1(ctx) } func (r *stubQuery) EmbeddedCase2(ctx context.Context) (*EmbeddedCase2, error) { return r.QueryResolver.EmbeddedCase2(ctx) } func (r *stubQuery) EmbeddedCase3(ctx context.Context) (*EmbeddedCase3, error) { return r.QueryResolver.EmbeddedCase3(ctx) } func (r *stubQuery) EnumInInput(ctx context.Context, input *InputWithEnumValue) (EnumTest, error) { return r.QueryResolver.EnumInInput(ctx, input) } func (r *stubQuery) SearchProducts(ctx context.Context, filters map[string]interface{}) ([]string, error) { return r.QueryResolver.SearchProducts(ctx, filters) } func (r *stubQuery) SearchRequired(ctx context.Context, filters map[string]interface{}) ([]string, error) { return r.QueryResolver.SearchRequired(ctx, filters) } func (r *stubQuery) SearchProductsNormal(ctx context.Context, filters map[string]any) ([]string, error) { return r.QueryResolver.SearchProductsNormal(ctx, filters) } func (r *stubQuery) SearchWithDefaults(ctx context.Context, filters map[string]interface{}) ([]string, error) { return r.QueryResolver.SearchWithDefaults(ctx, filters) } func (r *stubQuery) SearchMixed(ctx context.Context, filters map[string]interface{}, limit *int, offset *int, sortBy *string) ([]string, error) { return r.QueryResolver.SearchMixed(ctx, filters, limit, offset, sortBy) } func (r *stubQuery) FilterProducts(ctx context.Context, filters map[string]interface{}) ([]string, error) { return r.QueryResolver.FilterProducts(ctx, filters) } func (r *stubQuery) FindProducts(ctx context.Context, filters map[string]interface{}) ([]string, error) { return r.QueryResolver.FindProducts(ctx, filters) } func (r *stubQuery) SearchWithDirectives(ctx context.Context, input map[string]interface{}) ([]string, error) { return r.QueryResolver.SearchWithDirectives(ctx, input) } func (r *stubQuery) Shapes(ctx context.Context) ([]Shape, error) { return r.QueryResolver.Shapes(ctx) } func (r *stubQuery) NoShape(ctx context.Context) (Shape, error) { return r.QueryResolver.NoShape(ctx) } func (r *stubQuery) Node(ctx context.Context) (Node, error) { return r.QueryResolver.Node(ctx) } func (r *stubQuery) NoShapeTypedNil(ctx context.Context) (Shape, error) { return r.QueryResolver.NoShapeTypedNil(ctx) } func (r *stubQuery) Animal(ctx context.Context) (Animal, error) { return r.QueryResolver.Animal(ctx) } func (r *stubQuery) NotAnInterface(ctx context.Context) (BackedByInterface, error) { return r.QueryResolver.NotAnInterface(ctx) } func (r *stubQuery) Dog(ctx context.Context) (*Dog, error) { return r.QueryResolver.Dog(ctx) } func (r *stubQuery) Issue896a(ctx context.Context) ([]*CheckIssue896, error) { return r.QueryResolver.Issue896a(ctx) } func (r *stubQuery) MapStringInterface(ctx context.Context, in map[string]any) (map[string]any, error) { return r.QueryResolver.MapStringInterface(ctx, in) } func (r *stubQuery) MapNestedStringInterface(ctx context.Context, in *NestedMapInput) (map[string]any, error) { return r.QueryResolver.MapNestedStringInterface(ctx, in) } func (r *stubQuery) MapNestedMapSlice(ctx context.Context, input map[string]any) (*bool, error) { return r.QueryResolver.MapNestedMapSlice(ctx, input) } func (r *stubQuery) ErrorBubble(ctx context.Context) (*Error, error) { return r.QueryResolver.ErrorBubble(ctx) } func (r *stubQuery) ErrorBubbleList(ctx context.Context) ([]*Error, error) { return r.QueryResolver.ErrorBubbleList(ctx) } func (r *stubQuery) ErrorList(ctx context.Context) ([]*Error, error) { return r.QueryResolver.ErrorList(ctx) } func (r *stubQuery) Errors(ctx context.Context) (*Errors, error) { return r.QueryResolver.Errors(ctx) } func (r *stubQuery) Valid(ctx context.Context) (string, error) { return r.QueryResolver.Valid(ctx) } func (r *stubQuery) Invalid(ctx context.Context) (string, error) { return r.QueryResolver.Invalid(ctx) } func (r *stubQuery) Panics(ctx context.Context) (*Panics, error) { return r.QueryResolver.Panics(ctx) } func (r *stubQuery) PrimitiveObject(ctx context.Context) ([]Primitive, error) { return r.QueryResolver.PrimitiveObject(ctx) } func (r *stubQuery) PrimitiveStringObject(ctx context.Context) ([]PrimitiveString, error) { return r.QueryResolver.PrimitiveStringObject(ctx) } func (r *stubQuery) PtrToAnyContainer(ctx context.Context) (*PtrToAnyContainer, error) { return r.QueryResolver.PtrToAnyContainer(ctx) } func (r *stubQuery) PtrToSliceContainer(ctx context.Context) (*PtrToSliceContainer, error) { return r.QueryResolver.PtrToSliceContainer(ctx) } func (r *stubQuery) Infinity(ctx context.Context) (float64, error) { return r.QueryResolver.Infinity(ctx) } func (r *stubQuery) StringFromContextInterface(ctx context.Context) (*StringFromContextInterface, error) { return r.QueryResolver.StringFromContextInterface(ctx) } func (r *stubQuery) StringFromContextFunction(ctx context.Context) (string, error) { return r.QueryResolver.StringFromContextFunction(ctx) } func (r *stubQuery) DefaultScalar(ctx context.Context, arg string) (string, error) { return r.QueryResolver.DefaultScalar(ctx, arg) } func (r *stubQuery) SkipInclude(ctx context.Context) (*SkipIncludeTestType, error) { return r.QueryResolver.SkipInclude(ctx) } func (r *stubQuery) Slices(ctx context.Context) (*Slices, error) { return r.QueryResolver.Slices(ctx) } func (r *stubQuery) ScalarSlice(ctx context.Context) ([]byte, error) { return r.QueryResolver.ScalarSlice(ctx) } func (r *stubQuery) Fallback(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) { return r.QueryResolver.Fallback(ctx, arg) } func (r *stubQuery) OptionalUnion(ctx context.Context) (TestUnion, error) { return r.QueryResolver.OptionalUnion(ctx) } func (r *stubQuery) VOkCaseValue(ctx context.Context) (*VOkCaseValue, error) { return r.QueryResolver.VOkCaseValue(ctx) } func (r *stubQuery) VOkCaseNil(ctx context.Context) (*VOkCaseNil, error) { return r.QueryResolver.VOkCaseNil(ctx) } func (r *stubQuery) ValidType(ctx context.Context) (*ValidType, error) { return r.QueryResolver.ValidType(ctx) } func (r *stubQuery) VariadicModel(ctx context.Context) (*VariadicModel, error) { return r.QueryResolver.VariadicModel(ctx) } func (r *stubQuery) WrappedStruct(ctx context.Context) (*WrappedStruct, error) { return r.QueryResolver.WrappedStruct(ctx) } func (r *stubQuery) WrappedScalar(ctx context.Context) (otherpkg.Scalar, error) { return r.QueryResolver.WrappedScalar(ctx) } func (r *stubQuery) WrappedMap(ctx context.Context) (WrappedMap, error) { return r.QueryResolver.WrappedMap(ctx) } func (r *stubQuery) WrappedSlice(ctx context.Context) (WrappedSlice, error) { return r.QueryResolver.WrappedSlice(ctx) } type stubSubscription struct{ *Stub } func (r *stubSubscription) Updated(ctx context.Context) (<-chan string, error) { return r.SubscriptionResolver.Updated(ctx) } func (r *stubSubscription) InitPayload(ctx context.Context) (<-chan string, error) { return r.SubscriptionResolver.InitPayload(ctx) } func (r *stubSubscription) DirectiveArg(ctx context.Context, arg string) (<-chan *string, error) { return r.SubscriptionResolver.DirectiveArg(ctx, arg) } func (r *stubSubscription) DirectiveNullableArg(ctx context.Context, arg *int, arg2 *int, arg3 *string) (<-chan *string, error) { return r.SubscriptionResolver.DirectiveNullableArg(ctx, arg, arg2, arg3) } func (r *stubSubscription) DirectiveDouble(ctx context.Context) (<-chan *string, error) { return r.SubscriptionResolver.DirectiveDouble(ctx) } func (r *stubSubscription) DirectiveUnimplemented(ctx context.Context) (<-chan *string, error) { return r.SubscriptionResolver.DirectiveUnimplemented(ctx) } func (r *stubSubscription) Issue896b(ctx context.Context) (<-chan []*CheckIssue896, error) { return r.SubscriptionResolver.Issue896b(ctx) } func (r *stubSubscription) ErrorRequired(ctx context.Context) (<-chan *Error, error) { return r.SubscriptionResolver.ErrorRequired(ctx) } type stubUser struct{ *Stub } func (r *stubUser) Friends(ctx context.Context, obj *User) ([]*User, error) { return r.UserResolver.Friends(ctx, obj) } func (r *stubUser) Pets(ctx context.Context, obj *User, limit *int) ([]*Pet, error) { return r.UserResolver.Pets(ctx, obj, limit) } type stubWrappedMap struct{ *Stub } func (r *stubWrappedMap) Get(ctx context.Context, obj WrappedMap, key string) (string, error) { return r.WrappedMapResolver.Get(ctx, obj, key) } type stubWrappedSlice struct{ *Stub } func (r *stubWrappedSlice) Get(ctx context.Context, obj WrappedSlice, idx int) (string, error) { return r.WrappedSliceResolver.Get(ctx, obj, idx) } type stubFieldsOrderInput struct{ *Stub } func (r *stubFieldsOrderInput) OverrideFirstField(ctx context.Context, obj *FieldsOrderInput, data *string) error { return r.FieldsOrderInputResolver.OverrideFirstField(ctx, obj, data) } ================================================ FILE: codegen/testserver/singlefile/subscription_test.go ================================================ package singlefile import ( "context" "fmt" "runtime" "sort" "testing" "time" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestSubscriptions(t *testing.T) { tick := make(chan string, 1) resolvers := &Stub{} resolvers.SubscriptionResolver.InitPayload = func(ctx context.Context) (strings <-chan string, e error) { payload := transport.GetInitPayload(ctx) channel := make(chan string, len(payload)+1) go func() { <-ctx.Done() close(channel) }() // Test the helper function separately auth := payload.Authorization() if auth != "" { channel <- "AUTH:" + auth } else { channel <- "AUTH:NONE" } // Send them over the channel in alphabetic order keys := make([]string, 0, len(payload)) for key := range payload { keys = append(keys, key) } sort.Strings(keys) for _, key := range keys { channel <- fmt.Sprintf("%s = %#+v", key, payload[key]) } return channel, nil } errorTick := make(chan *Error, 1) resolvers.SubscriptionResolver.ErrorRequired = func(ctx context.Context) (<-chan *Error, error) { res := make(chan *Error, 1) go func() { for { select { case t := <-errorTick: res <- t case <-ctx.Done(): close(res) return } } }() return res, nil } resolvers.SubscriptionResolver.Updated = func(ctx context.Context) (<-chan string, error) { res := make(chan string, 1) go func() { for { select { case t := <-tick: res <- t case <-ctx.Done(): close(res) return } } }() return res, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.Websocket{KeepAlivePingInterval: time.Second}) srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res any, err error) { path, _ := ctx.Value(ckey("path")).([]int) return next(context.WithValue(ctx, ckey("path"), append(path, 1))) }) srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res any, err error) { path, _ := ctx.Value(ckey("path")).([]int) return next(context.WithValue(ctx, ckey("path"), append(path, 2))) }) c := client.New(srv) t.Run("wont leak goroutines", func(t *testing.T) { runtime.GC() // ensure no go-routines left from preceding tests initialGoroutineCount := runtime.NumGoroutine() sub := c.Websocket(`subscription { updated }`) tick <- "message" var msg struct { resp struct { Updated string } } err := sub.Next(&msg.resp) require.NoError(t, err) require.Equal(t, "message", msg.resp.Updated) sub.Close() // need a little bit of time for goroutines to settle start := time.Now() for time.Since(start).Seconds() < 2 && initialGoroutineCount != runtime.NumGoroutine() { time.Sleep(5 * time.Millisecond) } require.Equal(t, initialGoroutineCount, runtime.NumGoroutine()) }) t.Run("will parse init payload", func(t *testing.T) { runtime.GC() // ensure no go-routines left from preceding tests initialGoroutineCount := runtime.NumGoroutine() sub := c.WebsocketWithPayload(`subscription { initPayload }`, map[string]any{ "Authorization": "Bearer of the curse", "number": 32, "strings": []string{"hello", "world"}, }) var msg struct { resp struct { InitPayload string } } err := sub.Next(&msg.resp) require.NoError(t, err) require.Equal(t, "AUTH:Bearer of the curse", msg.resp.InitPayload) err = sub.Next(&msg.resp) require.NoError(t, err) require.Equal(t, "Authorization = \"Bearer of the curse\"", msg.resp.InitPayload) err = sub.Next(&msg.resp) require.NoError(t, err) require.Equal(t, "number = 32", msg.resp.InitPayload) err = sub.Next(&msg.resp) require.NoError(t, err) require.Equal(t, "strings = []interface {}{\"hello\", \"world\"}", msg.resp.InitPayload) sub.Close() // need a little bit of time for goroutines to settle start := time.Now() for time.Since(start).Seconds() < 2 && initialGoroutineCount != runtime.NumGoroutine() { time.Sleep(5 * time.Millisecond) } require.Equal(t, initialGoroutineCount, runtime.NumGoroutine()) }) t.Run("websocket gets errors", func(t *testing.T) { runtime.GC() // ensure no go-routines left from preceding tests initialGoroutineCount := runtime.NumGoroutine() sub := c.Websocket(`subscription { errorRequired { id } }`) errorTick <- &Error{ID: "ID1234"} var msg struct { resp struct { ErrorRequired *struct { Id string } } } err := sub.Next(&msg.resp) require.NoError(t, err) require.Equal(t, "ID1234", msg.resp.ErrorRequired.Id) errorTick <- nil err = sub.Next(&msg.resp) require.Error(t, err) sub.Close() // need a little bit of time for goroutines to settle start := time.Now() for time.Since(start).Seconds() < 2 && initialGoroutineCount != runtime.NumGoroutine() { time.Sleep(5 * time.Millisecond) } require.Equal(t, initialGoroutineCount, runtime.NumGoroutine()) }) } ================================================ FILE: codegen/testserver/singlefile/thirdparty.go ================================================ package singlefile import ( "fmt" "io" "strconv" "github.com/99designs/gqlgen/graphql" ) type ThirdParty struct { str string } func MarshalThirdParty(tp ThirdParty) graphql.Marshaler { return graphql.WriterFunc(func(w io.Writer) { _, err := io.WriteString(w, strconv.Quote(tp.str)) if err != nil { panic(err) } }) } func UnmarshalThirdParty(input any) (ThirdParty, error) { switch input := input.(type) { case string: return ThirdParty{str: input}, nil default: return ThirdParty{}, fmt.Errorf("unknown type for input: %s", input) } } ================================================ FILE: codegen/testserver/singlefile/time_test.go ================================================ package singlefile import ( "context" "testing" "time" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestTime(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) resolvers.QueryResolver.User = func(ctx context.Context, id int) (user *User, e error) { return &User{}, nil } t.Run("zero value in nullable field", func(t *testing.T) { var resp struct { User struct { Updated *string } } err := c.Post(`query { user(id: 1) { updated } }`, &resp) require.NoError(t, err) require.Nil(t, resp.User.Updated) }) t.Run("zero value in non nullable field", func(t *testing.T) { var resp struct { User struct { Created *string } } err := c.Post(`query { user(id: 1) { created } }`, &resp) require.EqualError( t, err, `[{"message":"the requested element is null which the schema does not allow","path":["user","created"]}]`, ) }) t.Run("with values", func(t *testing.T) { resolvers.QueryResolver.User = func(ctx context.Context, id int) (user *User, e error) { updated := time.Date(2010, 1, 1, 0, 0, 20, 1, time.UTC) return &User{ Created: time.Date(2010, 1, 1, 0, 0, 10, 1, time.UTC), Updated: &updated, }, nil } var resp struct { User struct { Created string Updated string } } err := c.Post(`query { user(id: 1) { created, updated } }`, &resp) require.NoError(t, err) require.Equal(t, "2010-01-01T00:00:10.000000001Z", resp.User.Created) require.Equal(t, "2010-01-01T00:00:20.000000001Z", resp.User.Updated) }) } ================================================ FILE: codegen/testserver/singlefile/typefallback.graphql ================================================ extend type Query { fallback(arg: FallbackToStringEncoding!): FallbackToStringEncoding! } enum FallbackToStringEncoding { A B C } ================================================ FILE: codegen/testserver/singlefile/typefallback_test.go ================================================ package singlefile import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestTypeFallback(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) resolvers.QueryResolver.Fallback = func(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error) { return arg, nil } t.Run("fallback to string passthrough", func(t *testing.T) { var resp struct { Fallback string } c.MustPost(`query { fallback(arg: A) }`, &resp) require.Equal(t, "A", resp.Fallback) }) } ================================================ FILE: codegen/testserver/singlefile/useptr.graphql ================================================ type A { id: ID! } type B { id: ID! } union TestUnion = A | B extend type Query { optionalUnion: TestUnion } ================================================ FILE: codegen/testserver/singlefile/useptr_test.go ================================================ package singlefile import ( "reflect" "testing" "github.com/stretchr/testify/require" ) func TestUserPtr(t *testing.T) { s := &Stub{} r := reflect.TypeOf(s.QueryResolver.OptionalUnion) require.Equal(t, reflect.Interface, r.Out(0).Kind()) } ================================================ FILE: codegen/testserver/singlefile/v-ok.go ================================================ package singlefile // VOkCaseValue model type VOkCaseValue struct{} func (v VOkCaseValue) Value() (string, bool) { return "hi", true } // VOkCaseNil model type VOkCaseNil struct{} func (v VOkCaseNil) Value() (string, bool) { return "", false } ================================================ FILE: codegen/testserver/singlefile/v-ok.graphql ================================================ extend type Query { vOkCaseValue: VOkCaseValue vOkCaseNil: VOkCaseNil } type VOkCaseValue @goModel(model:"singlefile.VOkCaseValue") { value: String } type VOkCaseNil @goModel(model:"singlefile.VOkCaseNil") { value: String } ================================================ FILE: codegen/testserver/singlefile/v-ok_test.go ================================================ package singlefile import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestOk(t *testing.T) { resolver := &Stub{} resolver.QueryResolver.VOkCaseValue = func(ctx context.Context) (*VOkCaseValue, error) { return &VOkCaseValue{}, nil } resolver.QueryResolver.VOkCaseNil = func(ctx context.Context) (*VOkCaseNil, error) { return &VOkCaseNil{}, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolver})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("v ok case value", func(t *testing.T) { var resp struct { VOkCaseValue struct { Value string } } err := c.Post(`query { vOkCaseValue { value } }`, &resp) require.NoError(t, err) require.Equal(t, "hi", resp.VOkCaseValue.Value) }) t.Run("v ok case nil", func(t *testing.T) { var resp struct { VOkCaseNil struct { Value *string } } err := c.Post(`query { vOkCaseNil { value } }`, &resp) require.NoError(t, err) require.Nil(t, resp.VOkCaseNil.Value) }) } ================================================ FILE: codegen/testserver/singlefile/validtypes.graphql ================================================ extend type Query { validType: ValidType } """ These things are all valid, but without care generate invalid go code """ type ValidType { differentCase: String! different_case: String! @goField(name:"DifferentCaseOld") validInputKeywords(input: ValidInput): Boolean! validArgs( break: String!, default: String!, func: String!, interface: String!, select: String!, case: String!, defer: String!, go: String!, map: String!, struct: String!, chan: String!, else: String!, goto: String!, package: String!, switch: String!, const: String!, fallthrough: String!, if: String!, range: String!, type: String!, continue: String!, for: String!, import: String!, return: String!, var: String!, _: String!, ): Boolean! } input ValidInput { break: String! default: String! func: String! interface: String! select: String! case: String! defer: String! go: String! map: String! struct: String! chan: String! else: String! goto: String! package: String! switch: String! const: String! fallthrough: String! if: String! range: String! type: String! continue: String! for: String! import: String! return: String! var: String! _: String! @goField(name: "Underscore") } # see https://github.com/99designs/gqlgen/issues/694 type Content_User { foo: String } type Content_Post { foo: String } union Content_Child = Content_User | Content_Post ================================================ FILE: codegen/testserver/singlefile/validtypes_test.go ================================================ package singlefile import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestValidType(t *testing.T) { resolvers := &Stub{} resolvers.QueryResolver.ValidType = func(ctx context.Context) (validType *ValidType, e error) { return &ValidType{ DifferentCase: "new", DifferentCaseOld: "old", }, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) t.Run("fields with differing cases can be distinguished", func(t *testing.T) { var resp struct { ValidType struct { New string `json:"differentCase"` Old string `json:"different_case"` } } err := c.Post(`query { validType { differentCase, different_case } }`, &resp) require.NoError(t, err) require.Equal(t, "new", resp.ValidType.New) require.Equal(t, "old", resp.ValidType.Old) }) } ================================================ FILE: codegen/testserver/singlefile/variadic.go ================================================ package singlefile import ( "context" "strconv" ) type VariadicModel struct{} type VariadicModelOption func(*VariadicModel) func (v VariadicModel) Value( ctx context.Context, rank int, opts ...VariadicModelOption, ) (string, error) { return strconv.Itoa(rank), nil } ================================================ FILE: codegen/testserver/singlefile/variadic.graphql ================================================ extend type Query { variadicModel: VariadicModel } type VariadicModel { value(rank: Int!): String } ================================================ FILE: codegen/testserver/singlefile/variadic_test.go ================================================ package singlefile import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestVariadic(t *testing.T) { resolver := &Stub{} resolver.QueryResolver.VariadicModel = func(ctx context.Context) (*VariadicModel, error) { return &VariadicModel{}, nil } srv := handler.New(NewExecutableSchema(Config{Resolvers: resolver})) srv.AddTransport(transport.POST{}) c := client.New(srv) var resp struct { VariadicModel struct { Value string } } err := c.Post(`query { variadicModel { value(rank: 1) } }`, &resp) require.NoError(t, err) require.Equal(t, "1", resp.VariadicModel.Value) err = c.Post(`query { variadicModel { value(rank: 2) } }`, &resp) require.NoError(t, err) require.Equal(t, "2", resp.VariadicModel.Value) } ================================================ FILE: codegen/testserver/singlefile/weird_type_cases.graphql ================================================ # regression test for https://github.com/99designs/gqlgen/issues/583 type asdfIt { id: ID! } type iIt { id: ID! } type AIt { id: ID! } type XXIt { id: ID! } type AbIt { id: ID! } type XxIt { id: ID! } ================================================ FILE: codegen/testserver/singlefile/wrapped_type.go ================================================ package singlefile import "github.com/99designs/gqlgen/codegen/testserver/singlefile/otherpkg" type ( WrappedScalar = otherpkg.Scalar WrappedStruct otherpkg.Struct WrappedMap otherpkg.Map WrappedSlice otherpkg.Slice ) ================================================ FILE: codegen/testserver/singlefile/wrapped_type.graphql ================================================ # regression test for https://github.com/99designs/gqlgen/issues/721 extend type Query { wrappedStruct: WrappedStruct! wrappedScalar: WrappedScalar! wrappedMap: WrappedMap! wrappedSlice: WrappedSlice! } type WrappedStruct { name: WrappedScalar!, desc: WrappedScalar } scalar WrappedScalar type WrappedMap { get(key: String!): String! } type WrappedSlice { get(idx: Int!): String! } ================================================ FILE: codegen/testserver/singlefile/wrapped_type_test.go ================================================ package singlefile import ( "context" "testing" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/codegen/testserver/singlefile/otherpkg" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestWrappedTypes(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{Resolvers: resolvers})) srv.AddTransport(transport.POST{}) c := client.New(srv) resolvers.QueryResolver.WrappedScalar = func(ctx context.Context) (scalar WrappedScalar, e error) { return "hello", nil } resolvers.QueryResolver.WrappedStruct = func(ctx context.Context) (wrappedStruct *WrappedStruct, e error) { wrapped := WrappedStruct(otherpkg.Struct{ Name: "hello", }) return &wrapped, nil } resolvers.QueryResolver.WrappedMap = func(ctx context.Context) (wrappedMap WrappedMap, e error) { wrapped := WrappedMap(map[string]string{ "name": "hello", }) return wrapped, nil } resolvers.QueryResolver.WrappedSlice = func(ctx context.Context) (slice WrappedSlice, err error) { wrapped := WrappedSlice([]string{"hello"}) return wrapped, nil } resolvers.WrappedMapResolver.Get = func(ctx context.Context, obj WrappedMap, key string) (s string, err error) { return obj[key], nil } resolvers.WrappedSliceResolver.Get = func(ctx context.Context, obj WrappedSlice, idx int) (s string, err error) { return obj[idx], nil } t.Run("wrapped struct", func(t *testing.T) { var resp struct { WrappedStruct struct { Name string } } err := c.Post(`query { wrappedStruct { name } }`, &resp) require.NoError(t, err) require.Equal(t, "hello", resp.WrappedStruct.Name) }) t.Run("wrapped scalar", func(t *testing.T) { var resp struct { WrappedScalar string } err := c.Post(`query { wrappedScalar }`, &resp) require.NoError(t, err) require.Equal(t, "hello", resp.WrappedScalar) }) t.Run("wrapped map", func(t *testing.T) { var resp struct { WrappedMap struct { Name string } } err := c.Post(`query { wrappedMap { name: get(key: "name") } }`, &resp) require.NoError(t, err) require.Equal(t, "hello", resp.WrappedMap.Name) }) t.Run("wrapped slice", func(t *testing.T) { var resp struct { WrappedSlice struct { First string } } err := c.Post(`query { wrappedSlice { first: get(idx: 0) } }`, &resp) require.NoError(t, err) require.Equal(t, "hello", resp.WrappedSlice.First) }) } ================================================ FILE: codegen/testserver/usefunctionsyntaxforexecutioncontext/directive.go ================================================ package usefunctionsyntaxforexecutioncontext import ( "context" "log" "github.com/99designs/gqlgen/graphql" ) // LogDirective implementation func LogDirective( ctx context.Context, obj any, next graphql.Resolver, message *string, ) (res any, err error) { log.Printf("Log Directive: %s", *message) // Proceed with the next resolver in the chain return next(ctx) } ================================================ FILE: codegen/testserver/usefunctionsyntaxforexecutioncontext/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package usefunctionsyntaxforexecutioncontext 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 { Mutation() MutationResolver Query() QueryResolver Subscription() SubscriptionResolver } type DirectiveRoot struct { Log func(ctx context.Context, obj any, next graphql.Resolver, message *string) (res any, err error) } type ComplexityRoot struct { Admin struct { CreatedAt func(childComplexity int) int ID func(childComplexity int) int Name func(childComplexity int) int Permissions func(childComplexity int) int } Mutation struct { CreateUser func(childComplexity int, input CreateUserInput) int DeleteUser func(childComplexity int, id string) int } MutationResponse struct { Message func(childComplexity int) int Success func(childComplexity int) int } Query struct { GetEntity func(childComplexity int, id string) int GetUser func(childComplexity int, id string) int ListUsers func(childComplexity int, filter *UserFilter) int } Subscription struct { UserCreated func(childComplexity int) int } User struct { Age func(childComplexity int) int CreatedAt func(childComplexity int) int Email func(childComplexity int) int ID func(childComplexity int) int Name func(childComplexity int) int Role func(childComplexity int) int } } type MutationResolver interface { CreateUser(ctx context.Context, input CreateUserInput) (*User, error) DeleteUser(ctx context.Context, id string) (*MutationResponse, error) } type QueryResolver interface { GetUser(ctx context.Context, id string) (*User, error) ListUsers(ctx context.Context, filter *UserFilter) ([]*User, error) GetEntity(ctx context.Context, id string) (Entity, error) } type SubscriptionResolver interface { UserCreated(ctx context.Context) (<-chan *User, 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 "Admin.createdAt": if e.ComplexityRoot.Admin.CreatedAt == nil { break } return e.ComplexityRoot.Admin.CreatedAt(childComplexity), true case "Admin.id": if e.ComplexityRoot.Admin.ID == nil { break } return e.ComplexityRoot.Admin.ID(childComplexity), true case "Admin.name": if e.ComplexityRoot.Admin.Name == nil { break } return e.ComplexityRoot.Admin.Name(childComplexity), true case "Admin.permissions": if e.ComplexityRoot.Admin.Permissions == nil { break } return e.ComplexityRoot.Admin.Permissions(childComplexity), true case "Mutation.createUser": if e.ComplexityRoot.Mutation.CreateUser == nil { break } args, err := field_Mutation_createUser_args(ctx, &ec, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Mutation.CreateUser(childComplexity, args["input"].(CreateUserInput)), true case "Mutation.deleteUser": if e.ComplexityRoot.Mutation.DeleteUser == nil { break } args, err := field_Mutation_deleteUser_args(ctx, &ec, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Mutation.DeleteUser(childComplexity, args["id"].(string)), true case "MutationResponse.message": if e.ComplexityRoot.MutationResponse.Message == nil { break } return e.ComplexityRoot.MutationResponse.Message(childComplexity), true case "MutationResponse.success": if e.ComplexityRoot.MutationResponse.Success == nil { break } return e.ComplexityRoot.MutationResponse.Success(childComplexity), true case "Query.getEntity": if e.ComplexityRoot.Query.GetEntity == nil { break } args, err := field_Query_getEntity_args(ctx, &ec, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.GetEntity(childComplexity, args["id"].(string)), true case "Query.getUser": if e.ComplexityRoot.Query.GetUser == nil { break } args, err := field_Query_getUser_args(ctx, &ec, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.GetUser(childComplexity, args["id"].(string)), true case "Query.listUsers": if e.ComplexityRoot.Query.ListUsers == nil { break } args, err := field_Query_listUsers_args(ctx, &ec, rawArgs) if err != nil { return 0, false } return e.ComplexityRoot.Query.ListUsers(childComplexity, args["filter"].(*UserFilter)), true case "Subscription.userCreated": if e.ComplexityRoot.Subscription.UserCreated == nil { break } return e.ComplexityRoot.Subscription.UserCreated(childComplexity), true case "User.age": if e.ComplexityRoot.User.Age == nil { break } return e.ComplexityRoot.User.Age(childComplexity), true case "User.createdAt": if e.ComplexityRoot.User.CreatedAt == nil { break } return e.ComplexityRoot.User.CreatedAt(childComplexity), true case "User.email": if e.ComplexityRoot.User.Email == nil { break } return e.ComplexityRoot.User.Email(childComplexity), true case "User.id": if e.ComplexityRoot.User.ID == nil { break } return e.ComplexityRoot.User.ID(childComplexity), true case "User.name": if e.ComplexityRoot.User.Name == nil { break } return e.ComplexityRoot.User.Name(childComplexity), true case "User.role": if e.ComplexityRoot.User.Role == nil { break } return e.ComplexityRoot.User.Role(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( unmarshalInputCreateUserInput, unmarshalInputUserFilter, ) 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 } case ast.Mutation: return func(ctx context.Context) *graphql.Response { if !first { return nil } first = false ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) data := _Mutation(ctx, &ec, opCtx.Operation.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) return &graphql.Response{ Data: buf.Bytes(), } } case ast.Subscription: next := _Subscription(ctx, &ec, opCtx.Operation.SelectionSet) var buf bytes.Buffer return func(ctx context.Context) *graphql.Response { buf.Reset() data := next(ctx) if data == nil { return nil } data.MarshalGQL(&buf) return &graphql.Response{ Data: buf.Bytes(), } } default: return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) } } type executionContext struct { *graphql.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 "test.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: "test.graphql", Input: sourceData("test.graphql"), BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func dir_log_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, "message", unmarshalOString2ᚖstring) if err != nil { return nil, err } args["message"] = arg0 return args, nil } func field_Mutation_createUser_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, "input", unmarshalNCreateUserInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐCreateUserInput) if err != nil { return nil, err } args["input"] = arg0 return args, nil } func field_Mutation_deleteUser_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, "id", unmarshalNID2string) if err != nil { return nil, err } args["id"] = arg0 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_getEntity_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, "id", unmarshalNID2string) if err != nil { return nil, err } args["id"] = arg0 return args, nil } func field_Query_getUser_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, "id", unmarshalNID2string) if err != nil { return nil, err } args["id"] = arg0 return args, nil } func field_Query_listUsers_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, "filter", unmarshalOUserFilter2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐUserFilter) if err != nil { return nil, err } args["filter"] = 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 _Admin_id(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *Admin) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return fieldContext_Admin_id(ctx, ec, field) }, func(ctx context.Context) (any, error) { return obj.ID, nil }, nil, func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { return marshalNID2string(ctx, ec, selections, v) }, true, true, ) } func fieldContext_Admin_id(_ context.Context, ec *executionContext, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Admin", 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 _Admin_name(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *Admin) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return fieldContext_Admin_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_Admin_name(_ context.Context, ec *executionContext, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Admin", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func _Admin_permissions(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *Admin) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return fieldContext_Admin_permissions(ctx, ec, field) }, func(ctx context.Context) (any, error) { return obj.Permissions, nil }, nil, func(ctx context.Context, selections ast.SelectionSet, v []string) graphql.Marshaler { return marshalNString2ᚕstringᚄ(ctx, ec, selections, v) }, true, true, ) } func fieldContext_Admin_permissions(_ context.Context, ec *executionContext, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Admin", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func _Admin_createdAt(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *Admin) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return fieldContext_Admin_createdAt(ctx, ec, field) }, func(ctx context.Context) (any, error) { return obj.CreatedAt, nil }, nil, func(ctx context.Context, selections ast.SelectionSet, v *string) graphql.Marshaler { return marshalODate2ᚖstring(ctx, ec, selections, v) }, true, false, ) } func fieldContext_Admin_createdAt(_ context.Context, ec *executionContext, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Admin", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Date does not have child fields") }, } return fc, nil } func _Mutation_createUser(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_Mutation_createUser(ctx, ec, field) }, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Mutation().CreateUser(ctx, fc.Args["input"].(CreateUserInput)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { message, err := unmarshalOString2ᚖstring(ctx, ec, "Creating a user") if err != nil { var zeroVal *User return zeroVal, err } if ec.Directives.Log == nil { var zeroVal *User return zeroVal, errors.New("directive log is not implemented") } return ec.Directives.Log(ctx, nil, directive0, message) } next = directive1 return next }, func(ctx context.Context, selections ast.SelectionSet, v *User) graphql.Marshaler { return marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐUser(ctx, ec, selections, v) }, true, true, ) } func fieldContext_Mutation_createUser(ctx context.Context, ec *executionContext, 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 fieldContext_User_id(ctx, ec, field) case "name": return fieldContext_User_name(ctx, ec, field) case "email": return fieldContext_User_email(ctx, ec, field) case "age": return fieldContext_User_age(ctx, ec, field) case "role": return fieldContext_User_role(ctx, ec, field) case "createdAt": return fieldContext_User_createdAt(ctx, ec, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = field_Mutation_createUser_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func _Mutation_deleteUser(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_Mutation_deleteUser(ctx, ec, field) }, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Mutation().DeleteUser(ctx, fc.Args["id"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { message, err := unmarshalOString2ᚖstring(ctx, ec, "Deleting a user") if err != nil { var zeroVal *MutationResponse return zeroVal, err } if ec.Directives.Log == nil { var zeroVal *MutationResponse return zeroVal, errors.New("directive log is not implemented") } return ec.Directives.Log(ctx, nil, directive0, message) } next = directive1 return next }, func(ctx context.Context, selections ast.SelectionSet, v *MutationResponse) graphql.Marshaler { return marshalNMutationResponse2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐMutationResponse(ctx, ec, selections, v) }, true, true, ) } func fieldContext_Mutation_deleteUser(ctx context.Context, ec *executionContext, 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 "success": return fieldContext_MutationResponse_success(ctx, ec, field) case "message": return fieldContext_MutationResponse_message(ctx, ec, field) } return nil, fmt.Errorf("no field named %q was found under type MutationResponse", field.Name) }, } defer 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_Mutation_deleteUser_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func _MutationResponse_success(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *MutationResponse) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return fieldContext_MutationResponse_success(ctx, ec, field) }, func(ctx context.Context) (any, error) { return obj.Success, nil }, nil, func(ctx context.Context, selections ast.SelectionSet, v bool) graphql.Marshaler { return marshalNBoolean2bool(ctx, ec, selections, v) }, true, true, ) } func fieldContext_MutationResponse_success(_ context.Context, ec *executionContext, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MutationResponse", 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 _MutationResponse_message(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *MutationResponse) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return fieldContext_MutationResponse_message(ctx, ec, field) }, func(ctx context.Context) (any, error) { return obj.Message, nil }, nil, func(ctx context.Context, selections ast.SelectionSet, v *string) graphql.Marshaler { return marshalOString2ᚖstring(ctx, ec, selections, v) }, true, false, ) } func fieldContext_MutationResponse_message(_ context.Context, ec *executionContext, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "MutationResponse", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } func _Query_getUser(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_getUser(ctx, ec, field) }, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().GetUser(ctx, fc.Args["id"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { message, err := unmarshalOString2ᚖstring(ctx, ec, "Fetching a user") if err != nil { var zeroVal *User return zeroVal, err } if ec.Directives.Log == nil { var zeroVal *User return zeroVal, errors.New("directive log is not implemented") } return ec.Directives.Log(ctx, nil, directive0, message) } next = directive1 return next }, func(ctx context.Context, selections ast.SelectionSet, v *User) graphql.Marshaler { return marshalOUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐUser(ctx, ec, selections, v) }, true, false, ) } func fieldContext_Query_getUser(ctx context.Context, ec *executionContext, 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 fieldContext_User_id(ctx, ec, field) case "name": return fieldContext_User_name(ctx, ec, field) case "email": return fieldContext_User_email(ctx, ec, field) case "age": return fieldContext_User_age(ctx, ec, field) case "role": return fieldContext_User_role(ctx, ec, field) case "createdAt": return fieldContext_User_createdAt(ctx, ec, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = field_Query_getUser_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func _Query_listUsers(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_listUsers(ctx, ec, field) }, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().ListUsers(ctx, fc.Args["filter"].(*UserFilter)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { message, err := unmarshalOString2ᚖstring(ctx, ec, "Listing users") if err != nil { var zeroVal []*User return zeroVal, err } if ec.Directives.Log == nil { var zeroVal []*User return zeroVal, errors.New("directive log is not implemented") } return ec.Directives.Log(ctx, nil, directive0, message) } next = directive1 return next }, func(ctx context.Context, selections ast.SelectionSet, v []*User) graphql.Marshaler { return marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐUserᚄ(ctx, ec, selections, v) }, true, true, ) } func fieldContext_Query_listUsers(ctx context.Context, ec *executionContext, 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 fieldContext_User_id(ctx, ec, field) case "name": return fieldContext_User_name(ctx, ec, field) case "email": return fieldContext_User_email(ctx, ec, field) case "age": return fieldContext_User_age(ctx, ec, field) case "role": return fieldContext_User_role(ctx, ec, field) case "createdAt": return fieldContext_User_createdAt(ctx, ec, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = field_Query_listUsers_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } func _Query_getEntity(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_getEntity(ctx, ec, field) }, func(ctx context.Context) (any, error) { fc := graphql.GetFieldContext(ctx) return ec.Resolvers.Query().GetEntity(ctx, fc.Args["id"].(string)) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { message, err := unmarshalOString2ᚖstring(ctx, ec, "Fetching an entity") if err != nil { var zeroVal Entity return zeroVal, err } if ec.Directives.Log == nil { var zeroVal Entity return zeroVal, errors.New("directive log is not implemented") } return ec.Directives.Log(ctx, nil, directive0, message) } next = directive1 return next }, func(ctx context.Context, selections ast.SelectionSet, v Entity) graphql.Marshaler { return marshalOEntity2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐEntity(ctx, ec, selections, v) }, true, false, ) } func fieldContext_Query_getEntity(ctx context.Context, ec *executionContext, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } defer func() { if r := recover(); r != nil { err = ec.Recover(ctx, r) ec.Error(ctx, err) } }() ctx = graphql.WithFieldContext(ctx, fc) if fc.Args, err = field_Query_getEntity_args(ctx, ec, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } 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 _Subscription_userCreated(ctx context.Context, ec *executionContext, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) { return graphql.ResolveFieldStream( ctx, ec.OperationContext, field, func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return fieldContext_Subscription_userCreated(ctx, ec, field) }, func(ctx context.Context) (any, error) { return ec.Resolvers.Subscription().UserCreated(ctx) }, func(ctx context.Context, next graphql.Resolver) graphql.Resolver { directive0 := next directive1 := func(ctx context.Context) (any, error) { message, err := unmarshalOString2ᚖstring(ctx, ec, "User created subscription") if err != nil { var zeroVal *User return zeroVal, err } if ec.Directives.Log == nil { var zeroVal *User return zeroVal, errors.New("directive log is not implemented") } return ec.Directives.Log(ctx, nil, directive0, message) } next = directive1 return next }, func(ctx context.Context, selections ast.SelectionSet, v *User) graphql.Marshaler { return marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐUser(ctx, ec, selections, v) }, true, true, ) } func fieldContext_Subscription_userCreated(_ context.Context, ec *executionContext, 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 fieldContext_User_id(ctx, ec, field) case "name": return fieldContext_User_name(ctx, ec, field) case "email": return fieldContext_User_email(ctx, ec, field) case "age": return fieldContext_User_age(ctx, ec, field) case "role": return fieldContext_User_role(ctx, ec, field) case "createdAt": return fieldContext_User_createdAt(ctx, ec, field) } return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } func _User_id(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return fieldContext_User_id(ctx, ec, field) }, func(ctx context.Context) (any, error) { return obj.ID, nil }, nil, func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { return marshalNID2string(ctx, ec, selections, v) }, true, true, ) } func fieldContext_User_id(_ context.Context, ec *executionContext, 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 _User_name(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return fieldContext_User_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_User_name(_ context.Context, ec *executionContext, 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 _User_email(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return fieldContext_User_email(ctx, ec, field) }, func(ctx context.Context) (any, error) { return obj.Email, nil }, nil, func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { return marshalNString2string(ctx, ec, selections, v) }, true, true, ) } func fieldContext_User_email(_ context.Context, ec *executionContext, 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 _User_age(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return fieldContext_User_age(ctx, ec, field) }, func(ctx context.Context) (any, error) { return obj.Age, nil }, nil, func(ctx context.Context, selections ast.SelectionSet, v *int) graphql.Marshaler { return marshalOInt2ᚖint(ctx, ec, selections, v) }, true, false, ) } func fieldContext_User_age(_ context.Context, ec *executionContext, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "User", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } func _User_role(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return fieldContext_User_role(ctx, ec, field) }, func(ctx context.Context) (any, error) { return obj.Role, nil }, nil, func(ctx context.Context, selections ast.SelectionSet, v RoleModel) graphql.Marshaler { return marshalNRole2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐRoleModel(ctx, ec, selections, v) }, true, true, ) } func fieldContext_User_role(_ context.Context, ec *executionContext, 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 Role does not have child fields") }, } return fc, nil } func _User_createdAt(ctx context.Context, ec *executionContext, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, ec.OperationContext, field, func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return fieldContext_User_createdAt(ctx, ec, field) }, func(ctx context.Context) (any, error) { return obj.CreatedAt, nil }, nil, func(ctx context.Context, selections ast.SelectionSet, v *string) graphql.Marshaler { return marshalODate2ᚖstring(ctx, ec, selections, v) }, true, false, ) } func fieldContext_User_createdAt(_ context.Context, ec *executionContext, 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 Date 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 unmarshalInputCreateUserInput(ctx context.Context, ec *executionContext, obj any) (CreateUserInput, error) { var it CreateUserInput if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } if _, present := asMap["role"]; !present { asMap["role"] = "USER" } fieldsInOrder := [...]string{"name", "email", "age", "role"} 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 case "email": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email")) data, err := unmarshalNString2string(ctx, ec, v) if err != nil { return it, err } it.Email = data case "age": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("age")) data, err := unmarshalOInt2ᚖint(ctx, ec, v) if err != nil { return it, err } it.Age = data case "role": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("role")) data, err := unmarshalORole2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐRoleModel(ctx, ec, v) if err != nil { return it, err } it.Role = data } } return it, nil } func unmarshalInputUserFilter(ctx context.Context, ec *executionContext, obj any) (UserFilter, error) { var it UserFilter if obj == nil { return it, nil } asMap := map[string]any{} for k, v := range obj.(map[string]any) { asMap[k] = v } if _, present := asMap["isActive"]; !present { asMap["isActive"] = true } fieldsInOrder := [...]string{"name", "email", "age", "roles", "isActive"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { case "name": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) data, err := unmarshalOString2ᚖstring(ctx, ec, v) if err != nil { return it, err } it.Name = data case "email": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email")) data, err := unmarshalOString2ᚖstring(ctx, ec, v) if err != nil { return it, err } it.Email = data case "age": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("age")) data, err := unmarshalOInt2ᚖint(ctx, ec, v) if err != nil { return it, err } it.Age = data case "roles": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("roles")) data, err := unmarshalORole2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐRoleModelᚄ(ctx, ec, v) if err != nil { return it, err } it.Roles = data case "isActive": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("isActive")) data, err := unmarshalOBoolean2ᚖbool(ctx, ec, v) if err != nil { return it, err } it.IsActive = data } } return it, nil } // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** func _Entity(ctx context.Context, ec *executionContext, sel ast.SelectionSet, obj Entity) graphql.Marshaler { switch obj := (obj).(type) { case nil: return graphql.Null case User: return _User(ctx, ec, sel, &obj) case *User: if obj == nil { return graphql.Null } return _User(ctx, ec, sel, obj) case Admin: return _Admin(ctx, ec, sel, &obj) case *Admin: if obj == nil { return graphql.Null } return _Admin(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 adminImplementors = []string{"Admin", "Entity"} func _Admin(ctx context.Context, ec *executionContext, sel ast.SelectionSet, obj *Admin) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, adminImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Admin") case "id": out.Values[i] = _Admin_id(ctx, ec, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "name": out.Values[i] = _Admin_name(ctx, ec, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "permissions": out.Values[i] = _Admin_permissions(ctx, ec, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "createdAt": out.Values[i] = _Admin_createdAt(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 mutationImplementors = []string{"Mutation"} func _Mutation(ctx context.Context, ec *executionContext, 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 "createUser": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return _Mutation_createUser(ctx, ec, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } case "deleteUser": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return _Mutation_deleteUser(ctx, ec, 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 mutationResponseImplementors = []string{"MutationResponse"} func _MutationResponse(ctx context.Context, ec *executionContext, sel ast.SelectionSet, obj *MutationResponse) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, mutationResponseImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("MutationResponse") case "success": out.Values[i] = _MutationResponse_success(ctx, ec, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "message": out.Values[i] = _MutationResponse_message(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 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 "getUser": 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 = _Query_getUser(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 "listUsers": field := field innerFunc := func(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_listUsers(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 "getEntity": 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 = _Query_getEntity(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 "__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 subscriptionImplementors = []string{"Subscription"} func _Subscription(ctx context.Context, ec *executionContext, 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 "userCreated": return _Subscription_userCreated(ctx, ec, fields[0]) default: panic("unknown field " + strconv.Quote(fields[0].Name)) } } var userImplementors = []string{"User", "Entity"} func _User(ctx context.Context, ec *executionContext, sel ast.SelectionSet, obj *User) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, userImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("User") case "id": out.Values[i] = _User_id(ctx, ec, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "name": out.Values[i] = _User_name(ctx, ec, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "email": out.Values[i] = _User_email(ctx, ec, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "age": out.Values[i] = _User_age(ctx, ec, field, obj) case "role": out.Values[i] = _User_role(ctx, ec, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } case "createdAt": out.Values[i] = _User_createdAt(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 unmarshalNCreateUserInput2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐCreateUserInput(ctx context.Context, ec *executionContext, v any) (CreateUserInput, error) { res, err := unmarshalInputCreateUserInput(ctx, ec, v) return res, graphql.ErrorOnPath(ctx, err) } func unmarshalNID2string(ctx context.Context, ec *executionContext, v any) (string, error) { res, err := graphql.UnmarshalID(v) return res, graphql.ErrorOnPath(ctx, err) } func marshalNID2string(ctx context.Context, ec *executionContext, 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 marshalNMutationResponse2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐMutationResponse(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v MutationResponse) graphql.Marshaler { return _MutationResponse(ctx, ec, sel, &v) } func marshalNMutationResponse2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐMutationResponse(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v *MutationResponse) 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 _MutationResponse(ctx, ec, sel, v) } func unmarshalNRole2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐRoleModel(ctx context.Context, ec *executionContext, v any) (RoleModel, error) { tmp, err := graphql.UnmarshalString(v) res := unmarshalNRole2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐRoleModelF[tmp] return res, graphql.ErrorOnPath(ctx, err) } func marshalNRole2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐRoleModel(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v RoleModel) graphql.Marshaler { _ = sel res := graphql.MarshalString(marshalNRole2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐRoleModelF[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 } var ( unmarshalNRole2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐRoleModelF = map[string]RoleModel{ "ADMIN": RoleModelAdmin, "USER": RoleModelUser, "GUEST": RoleModelGuest, } marshalNRole2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐRoleModelF = map[RoleModel]string{ RoleModelAdmin: "ADMIN", RoleModelUser: "USER", RoleModelGuest: "GUEST", } ) 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 unmarshalNString2ᚕ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 = unmarshalNString2string(ctx, ec, vSlice[i]) if err != nil { return nil, err } } return res, nil } func marshalNString2ᚕstringᚄ(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v []string) graphql.Marshaler { ret := make(graphql.Array, len(v)) for i := range v { ret[i] = marshalNString2string(ctx, ec, sel, v[i]) } for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func marshalNUser2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐUser(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v User) graphql.Marshaler { return _User(ctx, ec, sel, &v) } func marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐUserᚄ(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v []*User) 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 marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐUser(ctx, ec, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func marshalNUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐUser(ctx context.Context, ec *executionContext, 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 _User(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 unmarshalODate2ᚖ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 marshalODate2ᚖ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 marshalOEntity2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐEntity(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v Entity) graphql.Marshaler { if v == nil { return graphql.Null } return _Entity(ctx, ec, sel, v) } func unmarshalOInt2ᚖint(ctx context.Context, ec *executionContext, v any) (*int, error) { if v == nil { return nil, nil } res, err := graphql.UnmarshalInt(v) return &res, graphql.ErrorOnPath(ctx, err) } func marshalOInt2ᚖint(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v *int) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel _ = ctx res := graphql.MarshalInt(*v) return res } func unmarshalORole2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐRoleModelᚄ(ctx context.Context, ec *executionContext, v any) ([]RoleModel, error) { if v == nil { return nil, nil } var vSlice []any vSlice = graphql.CoerceList(v) var err error res := make([]RoleModel, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) res[i], err = unmarshalNRole2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐRoleModel(ctx, ec, vSlice[i]) if err != nil { return nil, err } } return res, nil } func marshalORole2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐRoleModelᚄ(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v []RoleModel) 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 marshalNRole2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐRoleModel(ctx, ec, sel, v[i]) }) for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } func unmarshalORole2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐRoleModel(ctx context.Context, ec *executionContext, v any) (*RoleModel, error) { if v == nil { return nil, nil } tmp, err := graphql.UnmarshalString(v) res := unmarshalORole2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐRoleModelF[tmp] return &res, graphql.ErrorOnPath(ctx, err) } func marshalORole2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐRoleModel(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v *RoleModel) graphql.Marshaler { if v == nil { return graphql.Null } _ = sel _ = ctx res := graphql.MarshalString(marshalORole2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐRoleModelF[*v]) return res } var ( unmarshalORole2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐRoleModelF = map[string]RoleModel{ "ADMIN": RoleModelAdmin, "USER": RoleModelUser, "GUEST": RoleModelGuest, } marshalORole2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐRoleModelF = map[RoleModel]string{ RoleModelAdmin: "ADMIN", RoleModelUser: "USER", RoleModelGuest: "GUEST", } ) func unmarshalOString2ᚕstringᚄ(ctx context.Context, ec *executionContext, 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 = unmarshalNString2string(ctx, ec, vSlice[i]) if err != nil { return nil, err } } return res, nil } func marshalOString2ᚕstringᚄ(ctx context.Context, ec *executionContext, 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] = marshalNString2string(ctx, ec, sel, v[i]) } for _, e := range ret { if e == graphql.Null { return graphql.Null } } return ret } 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 marshalOUser2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐUser(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v *User) graphql.Marshaler { if v == nil { return graphql.Null } return _User(ctx, ec, sel, v) } func unmarshalOUserFilter2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚋusefunctionsyntaxforexecutioncontextᚐUserFilter(ctx context.Context, ec *executionContext, v any) (*UserFilter, error) { if v == nil { return nil, nil } res, err := unmarshalInputUserFilter(ctx, ec, v) return &res, graphql.ErrorOnPath(ctx, err) } 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: codegen/testserver/usefunctionsyntaxforexecutioncontext/generated_test.go ================================================ //go:generate rm -f resolver.go //go:generate go run ../../../testdata/gqlgen.go -config gqlgen.yml -stub stub.go package usefunctionsyntaxforexecutioncontext import ( "context" "encoding/json" "testing" "time" "github.com/stretchr/testify/require" "github.com/99designs/gqlgen/client" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func TestQuery(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{ Resolvers: resolvers, Directives: DirectiveRoot{ Log: LogDirective, }, })) srv.AddTransport(transport.POST{}) c := client.New(srv) testAge := new(int) createdAt := "2021-01-01" resolvers.QueryResolver.GetUser = func(ctx context.Context, id string) (*User, error) { return &User{ ID: id, Name: "test", Email: "testEmail", Age: testAge, Role: RoleModelAdmin, CreatedAt: &createdAt, }, nil } resolvers.QueryResolver.ListUsers = func(ctx context.Context, filter *UserFilter) ([]*User, error) { return []*User{ { ID: "1", Name: "test1", Email: "testEmail", Age: testAge, Role: RoleModelAdmin, CreatedAt: &createdAt, }, { ID: "2", Name: "test2", Email: "testEmail", Age: testAge, Role: RoleModelAdmin, CreatedAt: &createdAt, }, }, nil } expectedJsonResp := ` { "getUser": { "id": "1", "name": "test", "email": "testEmail", "age": 0, "role": "ADMIN", "createdAt": "2021-01-01" }, "listUsers": [ { "id": "1", "name": "test1", "email": "testEmail", "age": 0, "role": "ADMIN", "createdAt": "2021-01-01" }, { "id": "2", "name": "test2", "email": "testEmail", "age": 0, "role": "ADMIN", "createdAt": "2021-01-01" } ] } ` t.Run("test query", func(t *testing.T) { var resp struct { GetUser struct { ID string `json:"id"` Name string `json:"name"` Email string `json:"email"` Age *int `json:"age"` Role string `json:"role"` CreatedAt string `json:"createdAt"` } `json:"getUser"` ListUsers []struct { ID string `json:"id"` Name string `json:"name"` Email string `json:"email"` Age *int `json:"age"` Role string `json:"role"` CreatedAt string `json:"createdAt"` } `json:"listUsers"` } c.MustPost(`query TestQuery { # Fetch a user by ID getUser(id: "1") { id name email age role createdAt } # List users with a filter listUsers(filter: { isActive: true, roles: [ADMIN, USER] }) { id name email age role createdAt } } `, &resp) jsonResp, err := json.Marshal(resp) require.NoError(t, err) require.JSONEq(t, expectedJsonResp, string(jsonResp)) }) } func TestMutation(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{ Resolvers: resolvers, Directives: DirectiveRoot{ Log: LogDirective, }, })) srv.AddTransport(transport.POST{}) c := client.New(srv) createdAt := "2021-01-01" resolvers.MutationResolver.CreateUser = func(ctx context.Context, input CreateUserInput) (*User, error) { return &User{ ID: "1", Name: input.Name, Email: input.Email, Age: input.Age, Role: *input.Role, CreatedAt: &createdAt, }, nil } message := "User deleted successfully" resolvers.MutationResolver.DeleteUser = func(ctx context.Context, id string) (*MutationResponse, error) { return &MutationResponse{ Success: true, Message: &message, }, nil } expectedJsonResp := ` { "createUser": { "id": "1", "name": "test", "email": "testEmail", "age": 0, "role": "ADMIN", "createdAt": "2021-01-01" }, "deleteUser": { "success": true, "message": "User deleted successfully" } } ` t.Run("test mutation", func(t *testing.T) { var resp struct { CreateUser struct { ID string `json:"id"` Name string `json:"name"` Email string `json:"email"` Age *int `json:"age"` Role string `json:"role"` CreatedAt string `json:"createdAt"` } `json:"createUser"` DeleteUser struct { Success bool `json:"success"` Message string `json:"message"` } `json:"deleteUser"` } c.MustPost(`mutation TestMutation { createUser(input: { name: "test", email: "testEmail", age: 0, role: ADMIN }) { id name email age role createdAt } deleteUser(id: "1") { success message } }`, &resp) jsonResp, err := json.Marshal(resp) require.NoError(t, err) require.JSONEq(t, expectedJsonResp, string(jsonResp)) }) } func TestSubscription(t *testing.T) { resolvers := &Stub{} srv := handler.New(NewExecutableSchema(Config{ Resolvers: resolvers, Directives: DirectiveRoot{ Log: LogDirective, }, })) srv.AddTransport(transport.Websocket{ KeepAlivePingInterval: time.Second, }) srv.AddTransport(transport.POST{}) c := client.New(srv) createdAt := "2021-01-01" resolvers.SubscriptionResolver.UserCreated = func(ctx context.Context) (<-chan *User, error) { ch := make(chan *User, 1) go func() { defer close(ch) ch <- &User{ ID: "1", Name: "testUser", Email: "testEmail", Age: nil, Role: "ADMIN", CreatedAt: &createdAt, } }() return ch, nil } t.Run("test subscription", func(t *testing.T) { var resp struct { UserCreated struct { ID string `json:"id"` Name string `json:"name"` Email string `json:"email"` Age *int `json:"age"` Role string `json:"role"` CreatedAt string `json:"createdAt"` } `json:"userCreated"` } expectedJsonResp := ` { "userCreated": { "id": "1", "name": "testUser", "email": "testEmail", "age": null, "role": "ADMIN", "createdAt": "2021-01-01" } } ` sub := c.Websocket(`subscription TestSubscription { userCreated { id name email age role createdAt } }`) defer sub.Close() err := sub.Next(&resp) require.NoError(t, err) jsonResp, err := json.Marshal(resp) require.NoError(t, err) require.JSONEq(t, expectedJsonResp, string(jsonResp)) }) } ================================================ FILE: codegen/testserver/usefunctionsyntaxforexecutioncontext/gqlgen.yml ================================================ schema: - "*.graphql" skip_validation: true use_function_syntax_for_execution_context: true exec: filename: generated.go package: usefunctionsyntaxforexecutioncontext model: filename: models-gen.go package: usefunctionsyntaxforexecutioncontext resolver: filename: resolver.go package: usefunctionsyntaxforexecutioncontext type: Resolver autobind: - "github.com/99designs/gqlgen/codegen/testserver" - "github.com/99designs/gqlgen/codegen/testserver/usefunctionsyntaxforexecutioncontext" models: Email: model: "github.com/99designs/gqlgen/codegen/testserver/singlefile.Email" StringFromContextFunction: model: "github.com/99designs/gqlgen/codegen/testserver/singlefile.StringFromContextFunction" ================================================ FILE: codegen/testserver/usefunctionsyntaxforexecutioncontext/models-gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package usefunctionsyntaxforexecutioncontext type Entity interface { IsEntity() GetID() string GetCreatedAt() *string } type Admin struct { ID string `json:"id"` Name string `json:"name"` Permissions []string `json:"permissions"` CreatedAt *string `json:"createdAt,omitempty"` } func (Admin) IsEntity() {} func (this Admin) GetID() string { return this.ID } func (this Admin) GetCreatedAt() *string { return this.CreatedAt } type CreateUserInput struct { Name string `json:"name"` Email string `json:"email"` Age *int `json:"age,omitempty"` Role *RoleModel `json:"role,omitempty"` } type Mutation struct { } type MutationResponse struct { Success bool `json:"success"` Message *string `json:"message,omitempty"` } type Query struct { } type Subscription struct { } type User struct { ID string `json:"id"` Name string `json:"name"` Email string `json:"email"` Age *int `json:"age,omitempty"` Role RoleModel `json:"role"` CreatedAt *string `json:"createdAt,omitempty"` } func (User) IsEntity() {} func (this User) GetID() string { return this.ID } func (this User) GetCreatedAt() *string { return this.CreatedAt } type UserFilter struct { Name *string `json:"name,omitempty"` Email *string `json:"email,omitempty"` Age *int `json:"age,omitempty"` Roles []RoleModel `json:"roles,omitempty"` IsActive *bool `json:"isActive,omitempty"` } ================================================ FILE: codegen/testserver/usefunctionsyntaxforexecutioncontext/models.go ================================================ package usefunctionsyntaxforexecutioncontext type RoleModel string var ( RoleModelAdmin RoleModel = "ADMIN" RoleModelUser RoleModel = "USER" RoleModelGuest RoleModel = "GUEST" ) ================================================ FILE: codegen/testserver/usefunctionsyntaxforexecutioncontext/resolver.go ================================================ package usefunctionsyntaxforexecutioncontext // 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 Resolver struct{} // CreateUser is the resolver for the createUser field. func (r *mutationResolver) CreateUser(ctx context.Context, input CreateUserInput) (*User, error) { panic("not implemented") } // DeleteUser is the resolver for the deleteUser field. func (r *mutationResolver) DeleteUser(ctx context.Context, id string) (*MutationResponse, error) { panic("not implemented") } // GetUser is the resolver for the getUser field. func (r *queryResolver) GetUser(ctx context.Context, id string) (*User, error) { panic("not implemented") } // ListUsers is the resolver for the listUsers field. func (r *queryResolver) ListUsers(ctx context.Context, filter *UserFilter) ([]*User, error) { panic("not implemented") } // GetEntity is the resolver for the getEntity field. func (r *queryResolver) GetEntity(ctx context.Context, id string) (Entity, error) { panic("not implemented") } // UserCreated is the resolver for the userCreated field. func (r *subscriptionResolver) UserCreated(ctx context.Context) (<-chan *User, error) { panic("not implemented") } // Mutation returns MutationResolver implementation. func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } // Query returns QueryResolver implementation. func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } // Subscription returns SubscriptionResolver implementation. func (r *Resolver) Subscription() SubscriptionResolver { return &subscriptionResolver{r} } type mutationResolver struct{ *Resolver } type queryResolver struct{ *Resolver } type subscriptionResolver struct{ *Resolver } ================================================ FILE: codegen/testserver/usefunctionsyntaxforexecutioncontext/stub.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package usefunctionsyntaxforexecutioncontext import ( "context" ) type Stub struct { MutationResolver struct { CreateUser func(ctx context.Context, input CreateUserInput) (*User, error) DeleteUser func(ctx context.Context, id string) (*MutationResponse, error) } QueryResolver struct { GetUser func(ctx context.Context, id string) (*User, error) ListUsers func(ctx context.Context, filter *UserFilter) ([]*User, error) GetEntity func(ctx context.Context, id string) (Entity, error) } SubscriptionResolver struct { UserCreated func(ctx context.Context) (<-chan *User, error) } } func (r *Stub) Mutation() MutationResolver { return &stubMutation{r} } func (r *Stub) Query() QueryResolver { return &stubQuery{r} } func (r *Stub) Subscription() SubscriptionResolver { return &stubSubscription{r} } type stubMutation struct{ *Stub } func (r *stubMutation) CreateUser(ctx context.Context, input CreateUserInput) (*User, error) { return r.MutationResolver.CreateUser(ctx, input) } func (r *stubMutation) DeleteUser(ctx context.Context, id string) (*MutationResponse, error) { return r.MutationResolver.DeleteUser(ctx, id) } type stubQuery struct{ *Stub } func (r *stubQuery) GetUser(ctx context.Context, id string) (*User, error) { return r.QueryResolver.GetUser(ctx, id) } func (r *stubQuery) ListUsers(ctx context.Context, filter *UserFilter) ([]*User, error) { return r.QueryResolver.ListUsers(ctx, filter) } func (r *stubQuery) GetEntity(ctx context.Context, id string) (Entity, error) { return r.QueryResolver.GetEntity(ctx, id) } type stubSubscription struct{ *Stub } func (r *stubSubscription) UserCreated(ctx context.Context) (<-chan *User, error) { return r.SubscriptionResolver.UserCreated(ctx) } ================================================ FILE: codegen/testserver/usefunctionsyntaxforexecutioncontext/test.graphql ================================================ # Custom directive to log field access (limited to fields, not input fields) directive @log(message: String) on FIELD_DEFINITION directive @goModel( model: String models: [String!] ) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION directive @goEnum(value: String) on ENUM_VALUE # Custom scalar for Date scalar Date # Enum for user roles enum Role @goModel(model: "github.com/99designs/gqlgen/codegen/testserver/usefunctionsyntaxforexecutioncontext.RoleModel") { ADMIN @goEnum(value: "github.com/99designs/gqlgen/codegen/testserver/usefunctionsyntaxforexecutioncontext.RoleModelAdmin") USER @goEnum(value: "github.com/99designs/gqlgen/codegen/testserver/usefunctionsyntaxforexecutioncontext.RoleModelUser") GUEST @goEnum(value: "github.com/99designs/gqlgen/codegen/testserver/usefunctionsyntaxforexecutioncontext.RoleModelGuest") } # Interface representing an Entity with common fields interface Entity { id: ID! createdAt: Date } # Input type for creating a user input CreateUserInput { name: String! email: String! age: Int role: Role = USER } # Input type with parameters for filtering users input UserFilter { name: String email: String age: Int roles: [Role!] isActive: Boolean = true } # Type representing a user, implementing the Entity interface type User implements Entity { id: ID! name: String! email: String! age: Int role: Role! createdAt: Date } # Type representing an admin, implementing the Entity interface type Admin implements Entity { id: ID! name: String! permissions: [String!]! createdAt: Date } # Type for mutation result type MutationResponse { success: Boolean! message: String } # Root Query type type Query { # Fetch a user by ID getUser(id: ID!): User @log(message: "Fetching a user") # List all users with optional filters listUsers(filter: UserFilter): [User!]! @log(message: "Listing users") # Fetch an entity by ID (could be User or Admin) getEntity(id: ID!): Entity @log(message: "Fetching an entity") } # Root Mutation type type Mutation { # Create a new user createUser(input: CreateUserInput!): User! @log(message: "Creating a user") # Delete a user by ID deleteUser(id: ID!): MutationResponse! @log(message: "Deleting a user") } # Root Subscription type type Subscription { # Subscription to notify when a user is created userCreated: User! @log(message: "User created subscription") } ================================================ FILE: codegen/type.go ================================================ package codegen import ( "fmt" "github.com/99designs/gqlgen/codegen/config" ) func (b *builder) buildTypes() map[string]*config.TypeReference { ret := map[string]*config.TypeReference{} for _, ref := range b.Binder.References { processType(ret, ref) } return ret } func processType(ret map[string]*config.TypeReference, ref *config.TypeReference) { key := ref.UniquenessKey() if existing, found := ret[key]; found { // Simplistic check of content which is obviously different. existingGQL := fmt.Sprintf("%v", existing.GQL) newGQL := fmt.Sprintf("%v", ref.GQL) if existingGQL != newGQL { panic( fmt.Sprintf( "non-unique key \"%s\", trying to replace %s with %s", key, existingGQL, newGQL, ), ) } } ret[key] = ref if ref.IsSlice() || ref.IsPtrToSlice() || ref.IsPtrToPtr() || ref.IsPtrToIntf() { processType(ret, ref.Elem()) } } ================================================ FILE: codegen/type.gotpl ================================================ {{ $useFunctionSyntaxForExecutionContext := .Config.UseFunctionSyntaxForExecutionContext }} {{- range $type := .ReferencedTypes }} {{ with $type.UnmarshalFunc }} {{ if $useFunctionSyntaxForExecutionContext -}} func {{ . }}(ctx context.Context, ec *executionContext, v any) ({{ $type.GO | ref }}, error) { {{- else -}} func (ec *executionContext) {{ . }}(ctx context.Context, v any) ({{ $type.GO | ref }}, error) { {{- end -}} {{- if and $type.IsNilable (not $type.GQL.NonNull) (not $type.IsPtrToPtr) }} if v == nil { return nil, nil } {{- end }} {{- if or $type.IsPtrToSlice $type.IsPtrToIntf }} {{ if $useFunctionSyntaxForExecutionContext -}} res, err := {{ $type.Elem.UnmarshalFunc }}(ctx, ec, v) {{- else -}} res, err := ec.{{ $type.Elem.UnmarshalFunc }}(ctx, v) {{- end }} return &res, graphql.ErrorOnPath(ctx, err) {{- else if $type.IsSlice }} var vSlice []any vSlice = graphql.CoerceList(v) var err error res := make([]{{$type.GO.Elem | ref}}, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) {{ if $useFunctionSyntaxForExecutionContext -}} res[i], err = {{ $type.Elem.UnmarshalFunc }}(ctx, ec, vSlice[i]) {{- else -}} res[i], err = ec.{{ $type.Elem.UnmarshalFunc }}(ctx, vSlice[i]) {{- end }} if err != nil { return nil, err } } return res, nil {{- else if and $type.IsPtrToPtr (not $type.Unmarshaler) (not $type.IsMarshaler) }} var pres {{ $type.Elem.GO | ref }} if v != nil { {{ if $useFunctionSyntaxForExecutionContext -}} res, err := {{ $type.Elem.UnmarshalFunc }}(ctx, ec, v) {{- else -}} res, err := ec.{{ $type.Elem.UnmarshalFunc }}(ctx, v) {{- end }} if err != nil { return nil, graphql.ErrorOnPath(ctx, err) } pres = res } return &pres, nil {{- else }} {{- if $type.Unmarshaler }} {{- if $type.HasEnumValues }} tmp, err := {{ $type.Unmarshaler | call }}(v) {{ if $useFunctionSyntaxForExecutionContext -}} res := {{ $type.UnmarshalFuncFunctionSyntax }}[tmp] {{- else -}} res := {{ $type.UnmarshalFunc }}[tmp] {{- end -}} {{- else if $type.CastType }} {{- if $type.IsContext }} tmp, err := {{ $type.Unmarshaler | call }}(ctx, v) {{- else }} tmp, err := {{ $type.Unmarshaler | call }}(v) {{- end }} {{- if and $type.IsNilable $type.Elem }} res := {{ $type.Elem.GO | ref }}(tmp) {{- else}} res := {{ $type.GO | ref }}(tmp) {{- end }} {{- else}} {{- if $type.IsContext }} res, err := {{ $type.Unmarshaler | call }}(ctx, v) {{- else }} res, err := {{ $type.Unmarshaler | call }}(v) {{- end }} {{- end }} {{- if and $type.IsTargetNilable (not $type.IsNilable) }} return *res, graphql.ErrorOnPath(ctx, err) {{- else if and (not $type.IsTargetNilable) $type.IsNilable }} return &res, graphql.ErrorOnPath(ctx, err) {{- else}} return res, graphql.ErrorOnPath(ctx, err) {{- end }} {{- else if $type.IsMarshaler }} {{- if and $type.IsNilable $type.Elem }} var res = new({{ $type.Elem.GO | ref }}) {{- else}} var res {{ $type.GO | ref }} {{- end }} {{- if $type.IsContext }} err := res.UnmarshalGQLContext(ctx, v) {{- else }} err := res.UnmarshalGQL(v) {{- end }} return res, graphql.ErrorOnPath(ctx, err) {{- else }} {{ if $useFunctionSyntaxForExecutionContext -}} res, err := unmarshalInput{{ $type.GQL.Name }}(ctx, ec, v) {{- else -}} res, err := ec.unmarshalInput{{ $type.GQL.Name }}(ctx, v) {{- end }} {{- if and $type.IsNilable (not $type.IsMap) (not $type.PointersInUnmarshalInput) }} return &res, graphql.ErrorOnPath(ctx, err) {{- else if and (not $type.IsNilable) $type.PointersInUnmarshalInput }} return *res, graphql.ErrorOnPath(ctx, err) {{- else }} return res, graphql.ErrorOnPath(ctx, err) {{- end }} {{- end }} {{- end }} } {{- end }} {{ with $type.MarshalFunc }} {{ if $useFunctionSyntaxForExecutionContext -}} func {{ . }}(ctx context.Context, ec *executionContext, sel ast.SelectionSet, v {{ $type.GO | ref }}) graphql.Marshaler { {{- else -}} func (ec *executionContext) {{ . }}(ctx context.Context, sel ast.SelectionSet, v {{ $type.GO | ref }}) graphql.Marshaler { {{- end -}} {{- if or $type.IsPtrToSlice $type.IsPtrToIntf }} {{ if $useFunctionSyntaxForExecutionContext -}} return {{ $type.Elem.MarshalFunc }}(ctx, ec, sel, *v) {{- else -}} return ec.{{ $type.Elem.MarshalFunc }}(ctx, sel, *v) {{- end }} {{- else if $type.IsSlice }} {{- if not $type.GQL.NonNull }} if v == nil { return graphql.Null } {{- end }} {{- if and $.HasBatchResolverFields (not $type.IsScalar) (eq $type.Elem.Definition.Kind "OBJECT") }} ctx = graphql.WithBatchParents(ctx, {{ $type.Elem.Definition.Name | quote }}, v) {{- end }} {{- if not $type.IsScalar }} ret := graphql.MarshalSliceConcurrently(ctx, len(v), {{ $.Config.Exec.WorkerLimit }}, {{ $.Config.OmitPanicHandler }}, func(ctx context.Context, i int) graphql.Marshaler { fc := graphql.GetFieldContext(ctx) fc.Result = &v[i] {{ if $useFunctionSyntaxForExecutionContext -}} return {{ $type.Elem.MarshalFunc }}(ctx, ec, sel, v[i]) {{- else -}} return ec.{{ $type.Elem.MarshalFunc }}(ctx, sel, v[i]) {{- end }} }) {{- else }} ret := make(graphql.Array, len(v)) for i := range v { {{ if $useFunctionSyntaxForExecutionContext -}} ret[i] = {{ $type.Elem.MarshalFunc }}(ctx, ec, sel, v[i]) {{- else -}} ret[i] = ec.{{ $type.Elem.MarshalFunc }}(ctx, sel, v[i]) {{- end }} } {{- end }} {{ if $type.Elem.GQL.NonNull }} for _, e := range ret { if e == graphql.Null { return graphql.Null } } {{ end }} return ret {{- else if and $type.IsPtrToPtr (not $type.Unmarshaler) (not $type.IsMarshaler) }} if v == nil { return graphql.Null } {{ if $useFunctionSyntaxForExecutionContext -}} return {{ $type.Elem.MarshalFunc }}(ctx, ec, sel, *v) {{- else -}} return ec.{{ $type.Elem.MarshalFunc }}(ctx, sel, *v) {{- end }} {{- else }} {{- if $type.IsNilable }} if v == nil { {{- if $type.GQL.NonNull }} if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") } {{- end }} return graphql.Null } {{- end }} {{- if $type.IsMarshaler }} {{- if $type.IsContext }} return graphql.WrapContextMarshaler(ctx, v) {{- else }} return v {{- end }} {{- else if $type.Marshaler }} _ = sel {{- if and (not $type.GQL.NonNull) (not $type.IsContext) }} _ = ctx {{- end }} {{- $v := "v" }} {{- if and $type.IsTargetNilable (not $type.IsNilable) }} {{- $v = "&v" }} {{- else if and (not $type.IsTargetNilable) $type.IsNilable }} {{- $v = "*v" }} {{- end }} {{- if $type.HasEnumValues }} {{- if $useFunctionSyntaxForExecutionContext -}} {{- $v = printf "%v[%v]" $type.MarshalFuncFunctionSyntax $v }} {{- else -}} {{- $v = printf "%v[%v]" $type.MarshalFunc $v }} {{- end -}} {{- else if $type.CastType }} {{- $v = printf "%v(%v)" ($type.CastType | ref) $v}} {{- end }} res := {{ $type.Marshaler | call }}({{ $v }}) {{- if $type.GQL.NonNull }} 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") } } {{- end }} {{- if $type.IsContext }} return graphql.WrapContextMarshaler(ctx, res) {{- else }} return res {{- end }} {{- else if $type.IsRoot }} {{- if eq $type.Definition.Name "Subscription" }} {{ if $useFunctionSyntaxForExecutionContext -}} res := _{{$type.Definition.Name}}(ctx, ec, sel) {{- else -}} res := ec._{{$type.Definition.Name}}(ctx, sel) {{- end }} return res(ctx) {{- else }} {{ if $useFunctionSyntaxForExecutionContext -}} return _{{$type.Definition.Name}}(ctx, ec, sel) {{- else -}} return ec._{{$type.Definition.Name}}(ctx, sel) {{- end }} {{- end }} {{- else }} {{ if $useFunctionSyntaxForExecutionContext -}} return _{{$type.Definition.Name}}(ctx, ec, sel, {{ if not $type.IsNilable}}&{{end}} v) {{- else -}} return ec._{{$type.Definition.Name}}(ctx, sel, {{ if not $type.IsNilable}}&{{end}} v) {{- end }} {{- end }} {{- end }} } {{- end }} {{- if and $type.HasEnumValues (not $type.IsSlice) }} {{- $enum := $type.GO }} {{- if $type.IsNilable }} {{- $enum = $type.GO.Elem }} {{- end }} var ( {{ if $useFunctionSyntaxForExecutionContext -}} {{ $type.UnmarshalFuncFunctionSyntax }} = map[string]{{ $enum | ref }}{ {{- else -}} {{ $type.UnmarshalFunc }} = map[string]{{ $enum | ref }}{ {{- end -}} {{- range $value := $type.EnumValues }} "{{ $value.Definition.Name }}": {{ $value.Object | obj }}, {{- end }} } {{ if $useFunctionSyntaxForExecutionContext -}} {{ $type.MarshalFuncFunctionSyntax }} = map[{{ $enum | ref }}]string{ {{- else -}} {{ $type.MarshalFunc }} = map[{{ $enum | ref }}]string{ {{- end -}} {{- range $value := $type.EnumValues }} {{ $value.Object | obj }}: "{{ $value.Definition.Name }}", {{- end }} } ) {{- end }} {{- end }} ================================================ FILE: codegen/util.go ================================================ package codegen import ( "fmt" "go/types" "strings" ) func findGoNamedType(def types.Type) (*types.Named, error) { if def == nil { return nil, nil } namedType, ok := def.(*types.Named) //nolint:staticcheck // yes, it is bad to end in newline here if !ok { return nil, fmt.Errorf( "expected %s to be a named type, instead found %T\n", def.String(), def, ) } return namedType, nil } func findGoInterface(def types.Type) (*types.Interface, error) { if def == nil { return nil, nil } namedType, err := findGoNamedType(def) if err != nil { return nil, err } if namedType == nil { return nil, nil } underlying, ok := namedType.Underlying().(*types.Interface) if !ok { return nil, fmt.Errorf( "expected %s to be a named interface, instead found %s", def.String(), namedType.String(), ) } return underlying, nil } func equalFieldName(source, target string) bool { source = strings.ReplaceAll(source, "_", "") source = strings.ReplaceAll(source, ",omitempty", "") target = strings.ReplaceAll(target, "_", "") return strings.EqualFold(source, target) } ================================================ FILE: complexity/complexity.go ================================================ package complexity import ( "context" "github.com/vektah/gqlparser/v2/ast" "github.com/99designs/gqlgen/graphql" ) func Calculate( ctx context.Context, es graphql.ExecutableSchema, op *ast.OperationDefinition, vars map[string]any, opts ...Option, ) int { os := defaultOptions for _, o := range opts { o(&os) } walker := complexityWalker{ es: es, schema: es.Schema(), vars: vars, opts: os, } return walker.selectionSetComplexity(ctx, op.SelectionSet) } type complexityWalker struct { es graphql.ExecutableSchema schema *ast.Schema vars map[string]any opts complexityOptions } func (cw complexityWalker) selectionSetComplexity( ctx context.Context, selectionSet ast.SelectionSet, ) int { var complexity int for _, selection := range selectionSet { switch s := selection.(type) { case *ast.Field: fieldDefinition := cw.schema.Types[s.Definition.Type.Name()] if fieldDefinition.Name == "__Schema" { continue } if _, ok := cw.opts.ignoreFields[s.ObjectDefinition.Name+"."+s.Name]; ok { continue } var childComplexity int switch fieldDefinition.Kind { case ast.Object, ast.Interface, ast.Union: childComplexity = cw.selectionSetComplexity(ctx, s.SelectionSet) } args := s.ArgumentMap(cw.vars) var fieldComplexity int if s.ObjectDefinition.Kind == ast.Interface { fieldComplexity = cw.interfaceFieldComplexity( ctx, s.ObjectDefinition, fieldDefinition.Kind, s.Name, childComplexity, args, ) } else { fieldComplexity = cw.fieldComplexity( ctx, s.ObjectDefinition, fieldDefinition.Kind, s.Name, childComplexity, args, ) } complexity = safeAdd(complexity, fieldComplexity) case *ast.FragmentSpread: complexity = safeAdd( complexity, cw.selectionSetComplexity(ctx, s.Definition.SelectionSet), ) case *ast.InlineFragment: complexity = safeAdd(complexity, cw.selectionSetComplexity(ctx, s.SelectionSet)) } } return complexity } func (cw complexityWalker) interfaceFieldComplexity( ctx context.Context, def *ast.Definition, fieldKind ast.DefinitionKind, field string, childComplexity int, args map[string]any, ) int { // Interfaces don't have their own separate field costs, so they have to assume the worst case. // We iterate over all implementors and choose the most expensive one. maxComplexity := 0 implementors := cw.schema.GetPossibleTypes(def) for _, t := range implementors { fieldComplexity := cw.fieldComplexity(ctx, t, fieldKind, field, childComplexity, args) if fieldComplexity > maxComplexity { maxComplexity = fieldComplexity } } return maxComplexity } func (cw complexityWalker) fieldComplexity( ctx context.Context, def *ast.Definition, fieldKind ast.DefinitionKind, field string, childComplexity int, args map[string]any, ) int { if customComplexity, ok := cw.es.Complexity(ctx, def.Name, field, childComplexity, args); ok && customComplexity >= 1 { return customComplexity } // default complexity calculation defaultComplexity := 1 switch fieldKind { case ast.Scalar, ast.Enum: defaultComplexity = cw.opts.fixedScalarValue // also defaults to 1 unless explicitly set } return safeAdd(defaultComplexity, childComplexity) } const maxInt = int(^uint(0) >> 1) // safeAdd is a saturating add of a and b that ignores negative operands. // If a + b would overflow through normal Go addition, // it returns the maximum integer value instead. // // Adding complexities with this function prevents attackers from intentionally // overflowing the complexity calculation to allow overly-complex queries. // // It also helps mitigate the impact of custom complexities that accidentally // return negative values. func safeAdd(a, b int) int { // Ignore negative operands. if a < 0 { if b < 0 { return 1 } return b } else if b < 0 { return a } c := a + b if c < a { // Set c to maximum integer instead of overflowing. c = maxInt } return c } ================================================ FILE: complexity/complexity_test.go ================================================ package complexity import ( "context" "math" "testing" "github.com/stretchr/testify/require" "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" "github.com/vektah/gqlparser/v2/validator/rules" "github.com/99designs/gqlgen/graphql" ) var schema = gqlparser.MustLoadSchema( &ast.Source{ Name: "test.graphql", Input: ` interface NameInterface { name: String } type Item implements NameInterface { scalar: String name: String list(size: Int = 10): [Item] } type ExpensiveItem implements NameInterface { name: String } type Named { name: String } union NameUnion = Item | Named type Query { scalar: String object: Item interface: NameInterface union: NameUnion customObject: Item list(size: Int = 10): [Item] } `, }, ) func requireComplexity(t *testing.T, source string, complexity int, opts ...Option) { t.Helper() query := gqlparser.MustLoadQueryWithRules(schema, source, rules.NewDefaultRules()) es := &graphql.ExecutableSchemaMock{ ComplexityFunc: func(ctx context.Context, typeName, field string, childComplexity int, args map[string]any) (int, bool) { switch typeName + "." + field { case "ExpensiveItem.name": return 5, true case "Query.list", "Item.list": return int(args["size"].(int64)) * childComplexity, true case "Query.customObject": return 1, true } return 0, false }, SchemaFunc: func() *ast.Schema { return schema }, } actualComplexity := Calculate(context.TODO(), es, query.Operations[0], nil, opts...) require.Equal(t, complexity, actualComplexity) } func TestCalculate(t *testing.T) { t.Run("uses default cost", func(t *testing.T) { const query = ` { scalar } ` requireComplexity(t, query, 1) }) t.Run("adds together fields", func(t *testing.T) { const query = ` { scalar1: scalar scalar2: scalar } ` requireComplexity(t, query, 2) }) t.Run("a level of nesting adds complexity", func(t *testing.T) { const query = ` { object { scalar } } ` requireComplexity(t, query, 2) }) t.Run("adds together children", func(t *testing.T) { const query = ` { scalar object { scalar } } ` requireComplexity(t, query, 3) }) t.Run("adds inline fragments", func(t *testing.T) { const query = ` { ... { scalar } } ` requireComplexity(t, query, 1) }) t.Run("adds fragments", func(t *testing.T) { const query = ` { ... Fragment } fragment Fragment on Query { scalar } ` requireComplexity(t, query, 1) }) t.Run("uses custom complexity", func(t *testing.T) { const query = ` { list { scalar } } ` requireComplexity(t, query, 10) }) t.Run("ignores negative custom complexity values", func(t *testing.T) { const query = ` { list(size: -100) { scalar } } ` requireComplexity(t, query, 2) }) t.Run("interfaces take max concrete cost", func(t *testing.T) { const query = ` { interface { name } } ` requireComplexity(t, query, 6) }) t.Run("guards against integer overflow", func(t *testing.T) { if maxInt == math.MaxInt32 { // this test is written assuming 64-bit ints t.Skip() } const query = ` { list1: list(size: 2147483647) { list(size: 2147483647) { list(size: 2) { scalar } } } # total cost so far: 2*0x7fffffff*0x7fffffff # = 0x7ffffffe00000002 # Adding the same again should cause overflow list2: list(size: 2147483647) { list(size: 2147483647) { list(size: 2) { scalar } } } } ` requireComplexity(t, query, math.MaxInt64) }) t.Run("fixed scalar value", func(t *testing.T) { const query = ` { scalar object { scalar name list(size: 10) { scalar } } } ` // object = 1 // list = 1 (each scalar in the list is worth 0, hence 0*10=0, // but when custom complexity is less than 1 the calculation uses the default field value, i.e. 1) requireComplexity(t, query, 2, WithFixedScalarValue(0)) // scalar = 2 // object = 1 // object.scalar = 2 // object.name = 2 // list = 2*10 requireComplexity(t, query, 27, WithFixedScalarValue(2)) }) t.Run("ignore specified", func(t *testing.T) { const query = ` { scalar object { scalar name list(size: 10) { scalar } } } ` ignore := map[string]struct{}{ "Query.scalar": {}, "Item.name": {}, } requireComplexity(t, query, 12, WithIgnoreFields(ignore)) }) } ================================================ FILE: complexity/option.go ================================================ package complexity type Option func(*complexityOptions) type complexityOptions struct { fixedScalarValue int ignoreFields map[string]struct{} } var defaultOptions = complexityOptions{ fixedScalarValue: 1, ignoreFields: nil, } // WithFixedScalarValue sets the default value attributed to scalar and enum fields. func WithFixedScalarValue(v int) Option { return func(o *complexityOptions) { o.fixedScalarValue = v } } // WithIgnoreFields specifies which fields are ignored in the complexity calculation. // It's equivalent to setting the value of these fields to zero. func WithIgnoreFields(m map[string]struct{}) Option { return func(o *complexityOptions) { o.ignoreFields = m } } ================================================ FILE: docs/build.sh ================================================ #!/bin/bash # # This was adapted from https://github.com/dgraph-io/dgraph/blob/master/wiki/scripts/build.sh # set -e GREEN='\033[32;1m' RESET='\033[0m' HOST=https://gqlgen.com IFS=$'\n' read -r -d '' -a VERSIONS_ARRAY < <(curl -s -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/99designs/gqlgen/releases?per_page=20" | jq -r '.[].tag_name' ) || true VERSIONS_ARRAY+=( "origin/master" ) joinVersions() { versions=$(printf ",%s" "${VERSIONS_ARRAY[@]}" | sed 's/origin\/master/master/') echo "${versions:1}" } function version { echo "$@" | gawk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }'; } rebuild() { VERSION_STRING=$(joinVersions) export CURRENT_VERSION=${1} if [[ $CURRENT_VERSION == 'origin/master' ]] ; then CURRENT_VERSION="master" fi export VERSIONS=${VERSION_STRING} hugo --quiet --destination="public/$CURRENT_VERSION" --baseURL="$HOST/$CURRENT_VERSION/" if [[ $1 == "${VERSIONS_ARRAY[0]}" ]]; then hugo --quiet --destination=public/ --baseURL="$HOST/" fi } currentBranch=$(git rev-parse --abbrev-ref HEAD) if ! git remote | grep -q origin ; then git remote add origin https://github.com/99designs/gqlgen fi git fetch origin --tags for version in "${VERSIONS_ARRAY[@]}" ; do echo -e "$(date) $GREEN Updating docs for $version.$RESET" rm -rf content git checkout $version -- content rebuild "$version" done rm -rf content git checkout "$currentBranch" -- content ================================================ FILE: docs/config.yml ================================================ baseurl: https://gqlgen.com/ metadataformat: yaml title: gqlgen enableGitInfo: true pygmentsCodeFences: true pygmentsUseClasses: true canonifyURLs: true params: name: gqlgen description: graphql servers the easy way menu: main: - name: Introduction url: / weight: -10 - name: Reference identifier: reference weight: 5 - name: Recipes identifier: recipes weight: 10 - name: pkg.go.dev → parent: reference url: https://pkg.go.dev/github.com/99designs/gqlgen security: funcs: getenv: - '^HUGO_' - 'VERSIONS' - 'CURRENT_VERSION' go_initialisms: replace_defaults: false initialisms: - 'CC' - 'BCC' ================================================ FILE: docs/content/config.md ================================================ --- linkTitle: Configuration title: How to configure gqlgen using gqlgen.yml description: How to configure gqlgen using gqlgen.yml menu: main weight: -5 --- gqlgen can be configured using a `gqlgen.yml` file, by default it will be loaded from the current directory, or any parent directory. As an example, here is the default configuration file generated with `gqlgen init`: ```yml # Where are all the schema files located? globs are supported eg src/**/*.graphqls schema: - graph/*.graphqls # Where should the generated server code go? exec: 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 # Comment or remove this section to skip Apollo Federation support federation: filename: graph/federation.go package: graph version: 2 options: computed_requires: true # 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: turn on use ` + "`" + `gqlgen:"fieldName"` + "`" + ` tags in your models # struct_tag: json # Optional: turn on to split imports in generated files into local modules and third-party packages # local_prefix: github.com/myrepo # Optional: turn on to use []Thing instead of []*Thing # omit_slice_element_pointers: false # Optional: turn on to omit Is() methods to interface and unions # omit_interface_checks : true # Optional: turn on to skip generation of ComplexityRoot struct content and Complexity function # omit_complexity: false # Optional: turn on to not generate any file notice comments in generated files # omit_gqlgen_file_notice: false # Optional: turn on to exclude the gqlgen version in the generated file notice. No effect if `omit_gqlgen_file_notice` is true. # omit_gqlgen_version_in_file_notice: false # Optional: turn on to exclude root models such as Query and Mutation from the generated models file. # omit_root_models: false # Optional: turn on to exclude resolver fields from the generated models file. # omit_resolver_fields: false # Optional: turn on to set a different prefix to the generated base structs used for embedding. # embedded_structs_prefix: "Base" # Optional: turn off to make struct-type struct fields not use pointers # e.g. type Thing struct { FieldA OtherThing } instead of { FieldA *OtherThing } # struct_fields_always_pointers: true # Optional: turn off to make resolvers return values instead of pointers for structs # resolvers_always_return_pointers: true # Optional: turn on to return pointers instead of values in unmarshalInput # return_pointers_in_unmarshalinput: false # Optional: wrap nullable input fields with Omittable # nullable_input_omittable: true # Optional: set to speed up generation time by not performing a final validation pass. # skip_validation: true # Optional: set to skip running `go mod tidy` when generating server code # skip_mod_tidy: true # Optional: set to use -gcflags="-N -l" during validation to disable compiler # optimizations. This makes cold cache validation ~2x faster since we only need # to check for errors, not produce optimized code. Default: false # fast_validation: false # Optional: set to use go/format.Source instead of imports.Process for formatting. # This is significantly faster (~10x) but doesn't group imports by stdlib/external/internal. # Imports will be sorted alphabetically instead. Default: false # skip_import_grouping: false # Optional: set to use light mode (NeedName|NeedFiles|NeedModule) for initial package # loading instead of full mode with NeedTypes. This avoids triggering compilation until # types are actually needed. Default: false (enable for large projects) # use_light_mode_prefetch: false # Optional: set to reuse byte buffers via sync.Pool during code formatting to reduce # GC pressure. Default: false (enable for large projects) # use_buffer_pooling: false # Optional: set to skip generation of JSON Marshalers and Unmarshalers for enums # omit_enum_json_marshalers: false # 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' # 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" # Optional: turn on to allow binding to getters and hasers (useful for editions protos) # autobind_getter_haser: true # 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 ``` Everything has defaults, so add things as you need. ## Inline config with directives gqlgen ships with some builtin directives that make it a little easier to manage wiring. To start using them you first need to define them: ```graphql directive @goModel( model: String models: [String!] forceGenerate: Boolean ) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION directive @goField( forceResolver: Boolean name: String omittable: Boolean type: String autoBindGetterHaser: Boolean forceGenerate: Boolean batch: Boolean ) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION directive @goTag( key: String! value: String ) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION directive @goExtraField( name: String type: String! overrideTags: String description: String ) repeatable on OBJECT | INPUT_OBJECT directive @inlineArguments on ARGUMENT_DEFINITION ``` > Here be dragons > > gqlgen doesnt currently support user-configurable directives for SCALAR, ENUM, INTERFACE or UNION. This only works > for internal directives. You can track the progress [here](https://github.com/99designs/gqlgen/issues/760) Now you can use these directives when defining types in your schema: ```graphql type User @goModel(model: "github.com/my/app/models.User") @goExtraField(name: "Activated", type: "bool") { id: ID! @goField(name: "todoId") name: String! @goField(forceResolver: true) @goTag(key: "xorm", value: "-") @goTag(key: "yaml") } # This make sense when autobind activated. type Person @goModel(forceGenerate: true) { id: ID! name: String! } ``` The builtin directives `goField`, `goModel`, `goTag` and `goExtraField` are automatically registered to `skip_runtime`. Any directives registered as `skip_runtime` will not exposed during introspection and are used during code generation only. If you have created a new code generation plugin using a directive which does not require runtime execution, the directive will need to be set to `skip_runtime`. e.g. a custom directive called `constraint` would be set as `skip_runtime` using the following configuration ```yml # custom directives which are not exposed during introspection. These directives are # used for code generation only directives: constraint: skip_runtime: true ``` ## Configuring for a big projects For a single gqlgen project, what gqlgen config works best really changes at a few key points during the course of that project's normal growth and evolution. For instance: 1. quick proof of concept - `single-file` layout 2. medium-sized team(s) - `follow-schema` layout 3. many teams - separate schema and resolvers into separate packages as [in this example](https://github.com/99designs/gqlgen/tree/master/_examples/large-project-structure/integration/go.mod) (see below) 4. very large type systems (more than 65,000 methods) - `use_function_syntax_for_execution_context` However, some will instead choose to adopt GraphQL Federation and split into multiple gqlgen instances before one of these growth points is even reached. Big projects usually divide into a separate domains, grouping all related files and resources under a folder such as: ``` DomainA - schema - resolver - service DomainB - schema - resolver - service ``` After first generating `resolvers` section you can comment out the entire resolver section of the `config.yaml`, so that resolvers are **not** auto-generated so you can then design any desired resolver architecture. This idea is from a discussion [https://github.com/99designs/gqlgen/issues/1253](https://github.com/99designs/gqlgen/issues/1253#issuecomment-664448226) ## Performance optimization options gqlgen provides several options to optimize code generation performance, especially useful for large schemas. ### skip_validation ```yaml skip_validation: true ``` Skips the final validation step that compiles generated code to check for errors. **When to use:** - During rapid local development when you'll compile immediately after anyway - In CI pipelines where a separate build step follows generation **When NOT to use:** - When you want immediate feedback on generation errors - When the generated code won't be compiled immediately after **Performance impact:** Saves 1-4 minutes depending on project size and cache state. --- ### fast_validation ```yaml fast_validation: true # default: false ``` Uses `-gcflags="-N -l"` during validation to disable Go compiler optimizations and inlining. Since validation only checks for compilation errors (not producing production binaries), optimizations are unnecessary. **When to use:** - Especially beneficial on cold cache (fresh checkout, CI without cache) - When you want faster validation without skipping it entirely **When NOT to use:** - If you need the validation build artifacts for debugging with optimizations - If you experience issues with the unoptimized build (very rare) **Performance impact:** ~2x faster cold cache validation (e.g., 4m 30s → 2m 15s). **Trade-off:** None for typical use. The validation binary is discarded after checking for errors. --- ### skip_import_grouping ```yaml skip_import_grouping: true # default: false ``` Uses `go/format.Source` instead of `golang.org/x/tools/imports.Process` for formatting generated code. This is significantly faster but produces different import formatting. **When to use:** - Large projects where generation time is a concern - When you don't care about import grouping style in generated files - When using automated formatters that will reformat anyway **When NOT to use:** - When you require imports grouped by category (stdlib, external, internal) - When your linter enforces specific import grouping in generated files - When generated files are frequently read by developers and style matters **Performance impact:** ~10x faster formatting (e.g., 2 minutes → 10 seconds for large projects). **Trade-off:** - With `false` (default): Imports are grouped and sorted by stdlib → external → internal - With `true`: Imports are sorted alphabetically without grouping Example difference: ```go // skip_import_grouping: false (default) - grouped imports import ( "context" "fmt" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" "myproject/internal/models" ) // skip_import_grouping: true - alphabetically sorted, no groups import ( "context" "fmt" "github.com/99designs/gqlgen/graphql" "github.com/vektah/gqlparser/v2/ast" "myproject/internal/models" ) ``` --- ### skip_mod_tidy ```yaml skip_mod_tidy: true ``` Skips running `go mod tidy` after code generation. **When to use:** - When your dependencies are already correct - In CI pipelines where mod tidy runs separately - When generating frequently during development **When NOT to use:** - After adding new external type bindings that may require new dependencies - When setting up a project for the first time **Performance impact:** Saves 1-5 seconds depending on module size. --- ### use_light_mode_prefetch ```yaml use_light_mode_prefetch: true # default: false ``` Uses `NeedName|NeedFiles|NeedModule` instead of full `NeedTypes` for initial package loading. This avoids triggering compilation until types are actually needed (e.g., for autobind). **When to use:** - Large codebases where `packages.Load` is slow - Projects with many packages that don't all need type information **When NOT to use:** - If you experience issues with type resolution - If you need full type info immediately for custom plugins **Performance impact:** ~200x faster initial package loading for large codebases. --- ### use_buffer_pooling ```yaml use_buffer_pooling: true # default: false ``` Reuses `bytes.Buffer` via `sync.Pool` during code formatting to reduce GC pressure. **When to use:** - Large projects with many generated files - When GC pauses are noticeable during generation **When NOT to use:** - If debugging memory issues and need to isolate buffer behavior **Performance impact:** Reduces GC pause times by ~25% for large projects. --- ### Recommended configurations **For maximum speed during development:** ```yaml skip_validation: true skip_mod_tidy: true skip_import_grouping: true fast_validation: true use_light_mode_prefetch: true use_buffer_pooling: true ``` **For CI with validation:** ```yaml skip_validation: false fast_validation: true skip_mod_tidy: true skip_import_grouping: true # or false if import style matters use_light_mode_prefetch: true use_buffer_pooling: true ``` **For production/release builds:** ```yaml skip_validation: false fast_validation: true skip_mod_tidy: false # skip_import_grouping: false # default - consistent import style ``` ================================================ FILE: docs/content/feature-comparison.md ================================================ --- linkTitle: Feature Comparison title: Comparing Features of Other Go GraphQL Implementations description: Comparing Features of Other Go GraphQL Implementations menu: main weight: -1 --- | | [gqlgen](https://github.com/99designs/gqlgen) | [gophers](https://github.com/graph-gophers/graphql-go) | [graphql-go](https://github.com/graphql-go/graphql) | [thunder](https://github.com/samsarahq/thunder) | | --------: | :-------- | :-------- | :-------- | :-------- | | Kind | schema first | schema first | run time types | struct first | | Boilerplate | less | more | more | some | | Docs | [docs](https://gqlgen.com) & [examples](https://github.com/99designs/gqlgen/tree/master/_examples) | [examples](https://github.com/graph-gophers/graphql-go/tree/master/example/starwars) | [examples](https://github.com/graphql-go/graphql/tree/master/examples) | [examples](https://github.com/samsarahq/thunder/tree/master/example)| | Query | 👍 | 👍 | 👍 | 👍 | | Mutation | 👍 | 🚧 [pr](https://github.com/graph-gophers/graphql-go/pull/182) | 👍 | 👍 | | Subscription | 👍 | 🚧 [pr](https://github.com/graph-gophers/graphql-go/pull/182) | 👍 | 👍 | | Type Safety | 👍 | 👍 | ⛔️ | 👍 | | Type Binding | 👍 | 👍 | ⛔️ | 👍 | | Embedding | 👍 | ⛔️ | 🚧 [pr](https://github.com/graphql-go/graphql/pull/371) | ⛔️ | | Interfaces | 👍 | 👍 | 👍 | ⛔️ [is](https://github.com/samsarahq/thunder/issues/78) | | Generated Enums | 👍 | ⛔️ | ⛔️ | ⛔️ | | Generated Inputs | 👍 | ⛔️ | ⛔️ | ⛔️ | | Federation | 👍 | ⛔️ | ⛔️ | ⛔️ | | Opentracing | 👍 | 👍 | ⛔️ | ✂️[pr](https://github.com/samsarahq/thunder/pull/77) | | Hooks for error logging | 👍 | ⛔️ | ⛔️ | ⛔️ | | Dataloading | 👍 | 👍 | 👍 | ⚠️ | | Concurrency | 👍 | 👍 | 👍 | 👍 | | Custom errors & error.path | 👍 | ⛔️ [is](https://github.com/graphql-go/graphql/issues/259) | ⛔️ | ⛔️ | | Query complexity | 👍 | ⛔️ [is](https://github.com/graphql-go/graphql/issues/231) | ⛔️ | ⛔️ | ================================================ FILE: docs/content/getting-started.md ================================================ --- linkTitle: Getting Started title: Building GraphQL servers in golang description: Get started building type-safe GraphQL servers in Golang using gqlgen menu: main weight: -7 --- This tutorial will take you through the process of building a GraphQL server with gqlgen that can: - Return a list of todos - Create new todos - Mark off todos as they are completed You can find the finished code for this tutorial [here](https://github.com/vektah/gqlgen-tutorials/tree/master/gettingstarted) ## Set up Project Create a directory for your project, and [initialise it as a Go Module](https://golang.org/doc/tutorial/create-module): ```shell mkdir gqlgen-todos cd gqlgen-todos go mod init github.com/[username]/gqlgen-todos ``` Next, 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 ``` By default you'll be using the latest version of gqlgen, but if you want to specify a particular version you can use `go get` (replacing `VERSION` with the particular version desired) ```shell go get -tool github.com/99designs/gqlgen@VERSION ``` ## Building the server ### Create the project skeleton ```shell go tool gqlgen init ``` This will create our suggested package layout. You can modify these paths in gqlgen.yml if you need to. ``` ├── go.mod ├── go.sum ├── gqlgen.yml - The gqlgen config file, knobs for controlling the generated code. ├── graph │   ├── generated - A package that only contains the generated runtime │   │   └── generated.go │   ├── model - A package for all your graph models, generated or otherwise │   │   └── models_gen.go │   ├── resolver.go - The root graph resolver type. This file wont get regenerated │   ├── schema.graphqls - Some schema. You can split the schema into as many graphql files as you like │   └── schema.resolvers.go - the resolver implementation for schema.graphql └── server.go - The entry point to your app. Customize it however you see fit ``` ### Define your schema gqlgen is a schema-first library — before writing code, you describe your API using the GraphQL [Schema Definition Language](http://graphql.org/learn/schema/). By default this goes into a file called `schema.graphqls` but you can break it up into as many different files as you want. The schema that was generated for us was: ```graphql type Todo { id: ID! text: String! done: Boolean! user: User! } type User { id: ID! name: String! } type Query { todos: [Todo!]! } input NewTodo { text: String! userId: String! } type Mutation { createTodo(input: NewTodo!): Todo! } ``` ### Implement the resolvers When executed, gqlgen's `generate` command compares the schema file (`graph/schema.graphqls`) with the models `graph/model/*`, and, wherever it can, it will bind directly to the model. That was done already when `init` was run. We'll edit the schema later in the tutorial, but for now, let's look at what was generated already. If we take a look in `graph/schema.resolvers.go` we will see all the times that gqlgen couldn't match them up. For us it was twice: ```go func (r *mutationResolver) CreateTodo(ctx context.Context, input model.NewTodo) (*model.Todo, error) { panic(fmt.Errorf("not implemented")) } func (r *queryResolver) Todos(ctx context.Context) ([]*model.Todo, error) { panic(fmt.Errorf("not implemented")) } ``` We just need to implement these two methods to get our server working: First we need somewhere to track our state, lets put it in `graph/resolver.go`. The `graph/resolver.go` file is where we declare our app's dependencies, like our database. It gets initialized once in `server.go` when we create the graph. ```go type Resolver struct{ todos []*model.Todo } ``` Returning to `graph/schema.resolvers.go`, let's implement the bodies of those automatically generated resolver functions. For `CreateTodo`, we'll use the [`crypto.rand` package](https://pkg.go.dev/crypto/rand#Int) to simply return a todo with a randomly generated ID and store that in the in-memory todos list --- in a real app, you're likely to use a database or some other backend service. ```go func (r *mutationResolver) CreateTodo(ctx context.Context, input model.NewTodo) (*model.Todo, error) { randNumber, _ := rand.Int(rand.Reader, big.NewInt(100)) todo := &model.Todo{ Text: input.Text, ID: fmt.Sprintf("T%d", randNumber), User: &model.User{ID: input.UserID, Name: "user " + input.UserID}, } r.todos = append(r.todos, todo) return todo, nil } func (r *queryResolver) Todos(ctx context.Context) ([]*model.Todo, error) { return r.todos, nil } ``` ### Run the server We now have a working server, to start it: ```bash go run server.go ``` Open http://localhost:8080 in a browser. Here are some queries to try, starting with creating a todo: ```graphql mutation createTodo { createTodo(input: { text: "todo", userId: "1" }) { user { id } text done } } ``` And then querying for it: ```graphql query findTodos { todos { text done user { name } } } ``` ### Don't eagerly fetch the user This example is great, but in the real world fetching most objects is expensive. We don't want to load the User on the todo unless the user actually asked for it. So lets replace the generated `Todo` model with something slightly more realistic. First let's enable `autobind`, allowing gqlgen to use your custom models if it can find them rather than generating them. We do this by uncommenting the `autobind` config line in `gqlgen.yml`: ```yml # gqlgen will search for any type names in the schema in these go packages # if they match it will use them, otherwise it will generate them. autobind: - "github.com/[username]/gqlgen-todos/graph/model" ``` And add `Todo` fields resolver config in `gqlgen.yml` to generate resolver for `user` field ```yml # This section declares type mapping between the GraphQL and go type systems # # The first line in each type will be used as defaults for resolver arguments and # modelgen, the others will be allowed when binding to fields. Configure them to # your liking models: ID: model: - github.com/99designs/gqlgen/graphql.ID - github.com/99designs/gqlgen/graphql.Int - github.com/99designs/gqlgen/graphql.Int64 - github.com/99designs/gqlgen/graphql.Int32 Int: model: - github.com/99designs/gqlgen/graphql.Int32 Todo: fields: user: resolver: true ``` Next, create a new file called `graph/model/todo.go` ```go package model type Todo struct { ID string `json:"id"` Text string `json:"text"` Done bool `json:"done"` UserID string `json:"userId"` User *User `json:"user"` } ``` And run `go tool gqlgen generate`. Now if we look in `graph/schema.resolvers.go` we can see a new resolver, lets implement it and fix `CreateTodo`. ```go func (r *mutationResolver) CreateTodo(ctx context.Context, input model.NewTodo) (*model.Todo, error) { randNumber, _ := rand.Int(rand.Reader, big.NewInt(100)) todo := &model.Todo{ Text: input.Text, ID: fmt.Sprintf("T%d", randNumber), UserID: input.UserID, } r.todos = append(r.todos, todo) return todo, nil } func (r *todoResolver) User(ctx context.Context, obj *model.Todo) (*model.User, error) { return &model.User{ID: obj.UserID, Name: "user " + obj.UserID}, nil } ``` ## Finishing touches At the top of our `resolver.go`, between `package` and `import`, add the following line: ```go //go:generate go tool gqlgen generate ``` This magic comment tells `go generate` what command to run when we want to regenerate our code. To run go generate recursively over your entire project, use this command: ```go go generate ./... ``` ================================================ FILE: docs/content/introduction.md ================================================ --- linkTitle: Introduction title: Type-safe GraphQL for Go type: homepage date: 2018-03-17T13:06:47+11:00 --- ================================================ FILE: docs/content/recipes/authentication.md ================================================ --- title: "Providing authentication details through context" description: How to using golang context.Context to authenticate users and pass user data to resolvers. linkTitle: Authentication menu: { main: { parent: 'recipes' } } --- We have an app where users are authenticated using a cookie in the HTTP request, and we want to check this authentication status somewhere in our graph. Because GraphQL is transport agnostic we can't assume there will even be an HTTP request, so we need to expose these authentication details to our graph using a middleware. ```go package auth import ( "database/sql" "net/http" "context" ) // A private key for context that only this package can access. This is important // to prevent collisions between different context uses var userCtxKey = &contextKey{"user"} type contextKey struct { name string } // A stand-in for our database backed user object type User struct { Name string IsAdmin bool } // Middleware decodes the share session cookie and packs the session into context func Middleware(db *sql.DB) func(http.Handler) http.Handler { return func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { c, err := r.Cookie("auth-cookie") // Allow unauthenticated users in if err != nil || c == nil { next.ServeHTTP(w, r) return } userId, err := validateAndGetUserID(c) if err != nil { http.Error(w, "Invalid cookie", http.StatusForbidden) return } // get the user from the database user := getUserByID(db, userId) // put it in context ctx := context.WithValue(r.Context(), userCtxKey, user) // and call the next with our new context r = r.WithContext(ctx) next.ServeHTTP(w, r) }) } } // ForContext finds the user from the context. REQUIRES Middleware to have run. func ForContext(ctx context.Context) *User { raw, _ := ctx.Value(userCtxKey).(*User) return raw } ``` **Note:** `getUserByID` and `validateAndGetUserID` have been left to the user to implement. Now when we create the server we should wrap it in our authentication middleware: ```go package main import ( "net/http" "github.com/99designs/gqlgen/_examples/starwars" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/playground" "github.com/go-chi/chi" ) func main() { router := chi.NewRouter() router.Use(auth.Middleware(db)) srv := handler.New(starwars.NewExecutableSchema(starwars.NewResolver())) srv.AddTransport(transport.POST{}) router.Handle("/", playground.Handler("Starwars", "/query")) router.Handle("/query", srv) err := http.ListenAndServe(":8080", router) if err != nil { panic(err) } } ``` And in our resolvers (or directives) we can call `ForContext` to retrieve the data back out: ```go func (r *queryResolver) Hero(ctx context.Context, episode Episode) (Character, error) { if user := auth.ForContext(ctx) ; user == nil || !user.IsAdmin { return Character{}, fmt.Errorf("Access denied") } if episode == EpisodeEmpire { return r.humans["1000"], nil } return r.droid["2001"], nil } ``` ### Websockets If you need access to the websocket init payload you can add your `InitFunc` in `AddTransport`. Your InitFunc implementation could then attempt to extract items from the payload: ```go package main import ( "context" "errors" "log" "net/http" "os" "time" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/extension" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/playground" "github.com/go-chi/chi" "github.com/gorilla/websocket" "github.com/gqlgen/_examples/websocket-initfunc/server/graph" "github.com/gqlgen/_examples/websocket-initfunc/server/graph/generated" "github.com/rs/cors" ) func webSocketInit(ctx context.Context, initPayload transport.InitPayload) (context.Context, error) { // Get the token from payload any := initPayload["authToken"] token, ok := any.(string) if !ok || token == "" { return nil, errors.New("authToken not found in transport payload") } // Perform token verification and authentication... userId := "john.doe" // e.g. userId, err := GetUserFromAuthentication(token) // put it in context ctxNew := context.WithValue(ctx, "username", userId) return ctxNew, nil } const defaultPort = "8080" func main() { port := os.Getenv("PORT") if port == "" { port = defaultPort } router := chi.NewRouter() // CORS setup, allow any for now // https://gqlgen.com/recipes/cors/ c := cors.New(cors.Options{ AllowedOrigins: []string{"*"}, AllowCredentials: true, Debug: false, }) srv := handler.New(generated.NewExecutableSchema(generated.Config{Resolvers: &graph.Resolver{}})) srv.AddTransport(transport.Websocket{ KeepAlivePingInterval: 10 * time.Second, Upgrader: websocket.Upgrader{ CheckOrigin: func(r *http.Request) bool { return true }, }, InitFunc: func(ctx context.Context, initPayload transport.InitPayload) (context.Context, error) { return webSocketInit(ctx, initPayload) }, }) srv.AddTransport(transport.POST{}) srv.Use(extension.Introspection{}) router.Handle("/", playground.Handler("My GraphQL App", "/app")) router.Handle("/app", c.Handler(srv)) log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) log.Fatal(http.ListenAndServe(":"+port, router)) } ``` > Note > > Subscriptions are long lived, if your tokens can timeout or need to be refreshed you should keep the token in context too and verify it is still valid in `auth.ForContext`. ================================================ FILE: docs/content/recipes/cors.md ================================================ --- title: "Setting CORS headers using rs/cors for gqlgen" description: Use the best of breed rs/cors library to set CORS headers when working with gqlgen linkTitle: CORS menu: { main: { parent: "recipes" } } --- Cross-Origin Resource Sharing (CORS) headers are required when your graphql server lives on a different domain to the one your client code is served. You can read more about CORS in the [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS). ## rs/cors gqlgen doesn't include a CORS implementation, but it is built to work with all standard http middleware. Here we are going to use the fantastic `chi` and `rs/cors` to build our server. ```go package main import ( "net/http" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/_examples/starwars" "github.com/99designs/gqlgen/graphql/handler" "github.com/go-chi/chi" "github.com/rs/cors" "github.com/gorilla/websocket" "github.com/99designs/gqlgen/graphql/playground" ) func main() { router := chi.NewRouter() // Add CORS middleware around every request // See https://github.com/rs/cors for full option listing router.Use(cors.New(cors.Options{ AllowedOrigins: []string{"http://localhost:8080"}, AllowCredentials: true, Debug: true, }).Handler) srv := handler.New(starwars.NewExecutableSchema(starwars.NewResolver())) // Handle cross-origin checks in for websocket upgrade requests: srv.AddTransport(&transport.Websocket{ Upgrader: websocket.Upgrader{ CheckOrigin: func(r *http.Request) bool { // Check against your desired domains here return r.Host == "example.org" }, ReadBufferSize: 1024, WriteBufferSize: 1024, }, }) srv.AddTransport(transport.POST{}) router.Handle("/", playground.Handler("Starwars", "/query")) router.Handle("/query", srv) err := http.ListenAndServe(":8080", router) if err != nil { panic(err) } } ``` ================================================ FILE: docs/content/recipes/enum.md ================================================ --- title: Extended enum to model binding tips linkTitle: Enum binding menu: { main: { parent: 'recipes' } } --- Using the following recipe you can bind enum values to specific const or variable. Both typed and untyped binding are supported. - For typed:\ Set model to const/var type. Set enum values to specific const/var. - For untyped:\ Set model to predefined gqlgen type (e.g. for int use `github.com/99designs/gqlgen/graphql.Int`). Set enum values to specific const/var. More examples can be found in [_examples/enum](https://github.com/99designs/gqlgen/tree/master/_examples/enum). ## Binding Targets Binding target go model enums: ```golang package model type EnumTyped int const ( EnumTypedOne EnumTyped = iota + 1 EnumTypedTwo ) const ( EnumUntypedOne = iota + 1 EnumUntypedTwo ) ``` Binding using `@goModel` and `@goEnum` directives: ```graphql directive @goModel( model: String models: [String!] ) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION directive @goEnum( value: String ) on ENUM_VALUE type Query { example(arg: EnumUntyped): EnumTyped } enum EnumTyped @goModel(model: "./model.EnumTyped") { ONE @goEnum(value: "./model.EnumTypedOne") TWO @goEnum(value: "./model.EnumTypedTwo") } enum EnumUntyped @goModel(model: "github.com/99designs/gqlgen/graphql.Int") { ONE @goEnum(value: "./model.EnumUntypedOne") TWO @goEnum(value: "./model.EnumUntypedTwo") } ``` The same result can be achieved using the config: ```yaml models: EnumTyped: model: ./model.EnumTyped enum_values: ONE: value: ./model.EnumTypedOne TWO: value: ./model.EnumTypedTwo EnumUntyped: model: github.com/99designs/gqlgen/graphql.Int enum_values: ONE: value: ./model.EnumUntypedOne TWO: value: ./model.EnumUntypedTwo ``` ## Additional Notes for int-based Enums If you want to use the generated input structs that use int-based enums to query your GraphQL server, you need an additional step to convert the int-based enum value into a JSON string representation. Otherwise, most client libraries will send an integer value, which the server will not understand, since it is expecting the string representation (e.g. `ONE` in the above example). Therefore, we must implement `MarshalJSON` and `UnmarshalJSON` on the typed enum type to convert between both. This is only possible with typed bindings. ```go func (t EnumTyped) String() string { switch t { case EnumTypedOne: return "ONE" case EnumTypedTwo: return "TWO" default: return "UNKNOWN" } } func (t EnumTyped) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, t.String())), nil } func (t *EnumTyped) UnmarshalJSON(b []byte) (err error) { var s string if err = json.Unmarshal(b, &s); err != nil { return err } switch s { case "ONE": *t = EnumTypedOne case "TWO": *t = EnumTypedTwo default: return fmt.Errorf("unexpected enum value %q", s) } return nil } ``` ================================================ FILE: docs/content/recipes/extra_fields.md ================================================ --- title: "Generation of additional extra fields for internal use" description: Pass implementation specific fields to the children resolvers without being forced to define your own types for a GraphQL model. linkTitle: Generated Model Extra Fields menu: { main: { parent: "recipes" } } --- Extra fields allows you to generate additional fields for your models. These fields can be used at runtime when implementing field resolvers. ## Extending your models Imagine you have a model named User and you want to extend a generated struct with additional data used in your service. The schema is: ```graphql type User { id: ID! name: String! } ``` Extra fields can be defined in gqlgen.yaml configuration: ```yaml models: User: extraFields: Session: description: "A Session used by this user" type: "github.com/author/mypkg.Session" overrideTags: 'xml:"session"' ``` The generated code would look like: ```go // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. type User struct { ID string Name string // A Session used by this user. Session mypkg.Session `xml:"session"` } ``` After these steps you have an extra field for your server implementation and the field is not being exposed to a caller. ### Inline config with directive To start using it you first need to define it: ```graphql directive @goExtraField( name: String type: String! overrideTags: String description: String ) repeatable on OBJECT | INPUT_OBJECT ``` Now you can use these directive when defining types in your schema: ```graphql type User @goExtraField( name: "Session" type: "github.com/author/mypkg.Session" description: "A Session used by this user" overrideTags: "xml:\"session\"" ) @goExtraField(name: "Activated", type: "bool") @goExtraField( type: "time.Time" description: "type without name will be embedded" ) { id: ID name: String } ``` The generated code would look like: ```go type User struct { ID string Name string // A Session used by this user. Session mypkg.Session `xml:"session"` Activated bool time.Time } ``` ================================================ FILE: docs/content/recipes/federation.md ================================================ --- title: "Using Apollo federation gqlgen" description: How federate many services into a single graph using Apollo linkTitle: Apollo Federation menu: { main: { parent: "recipes" } } --- In this quick guide we are going to implement the example [Apollo Federation](https://www.apollographql.com/docs/apollo-server/federation/introduction/) server in gqlgen. You can find the finished result in the [examples directory](https://github.com/99designs/gqlgen/tree/master/_examples/federation). ## Enable federation Uncomment federation configuration in your `gqlgen.yml` ```yml # Uncomment to enable federation federation: filename: graph/federation.go package: graph ``` ### Federation 2 If you are using Apollo's Federation 2 standard, your schema should automatically be upgraded so long as you include the required `@link` directive within your schema. If you want to force Federation 2 composition, the `federation` configuration supports a `version` flag to override that. For example: ```yml federation: filename: graph/federation.go package: graph version: 2 ``` ## Create the federated servers For each server to be federated we will create a new gqlgen project. ```bash go tool gqlgen generate ``` Update the schema to reflect the federated example ```graphql type Review { body: String author: User @provides(fields: "username") product: Product } extend type User @key(fields: "id") { id: ID! @external # External directive not required for key fields in federation v2 reviews: [Review] } extend type Product @key(fields: "upc") { upc: String! @external # External directive not required for key fields in federation v2 reviews: [Review] } ``` and regenerate ```bash go tool gqlgen generate ``` then implement the resolvers ```go // These two methods are required for gqlgen to resolve the internal id-only wrapper structs. // This boilerplate might be removed in a future version of gqlgen that can no-op id only nodes. func (r *entityResolver) FindProductByUpc(ctx context.Context, upc string) (*model.Product, error) { return &model.Product{ Upc: upc, }, nil } func (r *entityResolver) FindUserByID(ctx context.Context, id string) (*model.User, error) { return &model.User{ ID: id, }, nil } // Here we implement the stitched part of this service, returning reviews for a product. Of course normally you would // go back to the database, but we are just making some data up here. func (r *productResolver) Reviews(ctx context.Context, obj *model.Product) ([]*model.Review, error) { switch obj.Upc { case "top-1": return []*model.Review{{ Body: "A highly effective form of birth control.", }}, nil case "top-2": return []*model.Review{{ Body: "Fedoras are one of the most fashionable hats around and can look great with a variety of outfits.", }}, nil case "top-3": return []*model.Review{{ Body: "This is the last straw. Hat you will wear. 11/10", }}, nil } return nil, nil } func (r *userResolver) Reviews(ctx context.Context, obj *model.User) ([]*model.Review, error) { if obj.ID == "1234" { return []*model.Review{{ Body: "Has an odd fascination with hats.", }}, nil } return nil, nil } ``` > Note > > Repeat this step for each of the services in the apollo doc (accounts, products, reviews) ## Create the federation gateway ```bash npm install --save @apollo/gateway apollo-server graphql ``` ```typescript const { ApolloServer } = require("apollo-server"); const { ApolloGateway, IntrospectAndCompose } = require("@apollo/gateway"); const gateway = new ApolloGateway({ supergraphSdl: new IntrospectAndCompose({ subgraphs: [ { name: "accounts", url: "http://localhost:4001/query" }, { name: "products", url: "http://localhost:4002/query" }, { name: "reviews", url: "http://localhost:4003/query" }, ], }), }); const server = new ApolloServer({ gateway, subscriptions: false, }); server.listen().then(({ url }) => { console.log(`🚀 Server ready at ${url}`); }); ``` ## Start all the services In separate terminals: ```bash go run accounts/server.go go run products/server.go go run reviews/server.go node gateway/index.js ``` ## Query the federated gateway The examples from the apollo doc should all work, eg ```graphql query { me { username reviews { body product { name upc } } } } ``` should return ```json { "data": { "me": { "username": "Me", "reviews": [ { "body": "A highly effective form of birth control.", "product": { "name": "Trilby", "upc": "top-1" } }, { "body": "Fedoras are one of the most fashionable hats around and can look great with a variety of outfits.", "product": { "name": "Trilby", "upc": "top-1" } } ] } } } ``` ## Using @requires `@requires` enables you to [define computed fields](https://www.apollographql.com/docs/federation/federated-schemas/federated-directives/#requires). In order for this to work, you need to be able to reference the values injected by the selection set inside the `fields` property of `@requires`. In order to do this, you need to enable the `federation.options.computed_requires` flag. You also need to enable `call_argument_directives_with_null`. ```yml federation: filename: graph/federation.go package: graph version: 2 options: computed_requires: true call_argument_directives_with_null: true ``` Once you do this, if you have `@requires` declared anywhere on your schema, you'll see updates to the genrated resolver functions that include a new argument, `federationRequires`, that will contain the fields you requested in your `@requires.fields` selection set. > Note: currently it's represented as a map[string]any where the contained values are encoded with > `encoding/json`. Eventually we will generate a typesafe model that represents these models, > however that is a large lift. This typesafe support will be added in the future. ### Example Take a simple todo app schema that needs to provide a formatted status text to be used across all clients by referencing the assignee's name. ```graphql type Todo @key(fields: "id") { id: ID! text: String! statusText: String! @requires(fields: "assignee { name }") status: String! owner: User! assignee: User! @external } type User @key(fields: "id") { id: ID! name: String! @external } ``` The `statusText` resolver function is updated and can be modified accordingly to use the todo representation with the assignee name. ```golang func (r *todoResolver) StatusText(ctx context.Context, entity *model.Todo, federationRequires map[string]interface{} /* new argument generated onto your resolver function */) (string, error) { if federationRequires["assignee"] == nil { return "", nil } // federationRequires will contain the "assignee.name" field provided by the Federation router statusText := entity.Status + " by " + federationRequires["assignee"].(map[string]interface{})["name"].(string) return statusText, nil } ``` ### [DEPRECATED] Alternate API > Note: it's not recommended to use this API anymore. See the `Using @requires` section for the recommend API. If you need to support **nested** or **array** fields in the `@requires` directive, this can be enabled in the configuration by setting `federation.options.explicit_requires` to true. ```yml federation: filename: graph/federation.go package: graph version: 2 options: explicit_requires: true ``` Enabling this will generate corresponding functions with the entity representations received in the request. This allows for the entity model to be explicitly populated with the required data provided. #### Example Take a simple todo app schema that needs to provide a formatted status text to be used across all clients by referencing the assignee's name. ```graphql type Todo @key(fields: "id") { id: ID! text: String! statusText: String! @requires(fields: "assignee { name }") status: String! owner: User! assignee: User! } type User @key(fields: "id") { id: ID! name: String! @external } ``` A `PopulateTodoRequires` function is generated, and can be modified accordingly to use the todo representation with the assignee name. ```golang // PopulateTodoRequires is the requires populator for the Todo entity. func (ec *executionContext) PopulateTodoRequires(ctx context.Context, entity *model.Todo, reps map[string]interface{}) error { if reps["assignee"] != nil { entity.StatusText = entity.Status + " by " + reps["assignee"].(map[string]interface{})["name"].(string) } return nil } ``` ## Using @entityResolver The `@entityResolver` directive enables optimization for entity resolver generation in GraphQL federation. ### Configuration To use this feature, define the `@entityResolver(multi: Boolean)` directive on your OBJECT types. Federated entities must be annotated with this directive to enable the functionality. Example: ```graphql type MultiHello @key(fields: "name") @entityResolver(multi: true) ``` ### Global Configuration You can enable this feature by default by setting the `federation.options.entity_resolver_multi` flag in your configuration: ```yml federation: filename: graph/federation.go package: graph version: 2 options: entity_resolver_multi: true ``` ### Schema Example ```graphql directive @entityResolver(multi: Boolean) on OBJECT type User @key(fields: "id") @entityResolver(multi: true) { id: ID! name: String! } ``` After defining your schema, regenerate the code: ```bash go run github.com/99designs/gqlgen ``` ### Implementation Implement the generated resolver method: ```go // IMPORTANT: The output slice order is critical and must match the input slice order exactly! func (r *entityResolver) FindUserByIDs(ctx context.Context, reps []*entity.UserByIDsInput) ([]*model.User, error) { output := make([]*model.User, len(reps)) for i, user := range reps { output[i] = &model.User{ ID: user.ID, Name: "User " + user.ID, } } return output, nil } ``` When configured, the federation plugin creates an entity resolver that accepts a list of representations, improving performance by reducing the number of individual resolver calls. ================================================ FILE: docs/content/recipes/gin.md ================================================ --- title: "Using Gin to setup HTTP handlers" description: Setting up HTTP handlers using Gin, a HTTP web framework written in Go. linkTitle: Gin menu: { main: { parent: 'recipes' } } --- Gin is an excellent alternative for the `net/http` router. From their official [GitHub page](https://github.com/gin-gonic/gin): > Gin is a web framework written in Go (Golang). It features a martini-like API with much better performance, up to 40 times faster thanks to httprouter. If you need performance and good productivity, you will love Gin. Here are the steps to setup Gin and gqlgen together: Install Gin: ```bash $ go get github.com/gin-gonic/gin ``` In your router file, define the handlers for the GraphQL and Playground endpoints in two different methods and tie them together in the Gin router: ```go import ( "github.com/[username]/gqlgen-todos/graph" // Replace username with your github username "github.com/gin-gonic/gin" "github.com/vektah/gqlparser/v2/ast" "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" ) // Defining the Graphql handler func graphqlHandler() gin.HandlerFunc { // NewExecutableSchema and Config are in the generated.go file // Resolver is in the resolver.go file h := handler.New(graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}})) // Server setup: h.AddTransport(transport.Options{}) h.AddTransport(transport.GET{}) h.AddTransport(transport.POST{}) h.SetQueryCache(lru.New[*ast.QueryDocument](1000)) h.Use(extension.Introspection{}) h.Use(extension.AutomaticPersistedQuery{ Cache: lru.New[string](100), }) return func(c *gin.Context) { h.ServeHTTP(c.Writer, c.Request) } } // Defining the Playground handler func playgroundHandler() gin.HandlerFunc { h := playground.Handler("GraphQL", "/query") return func(c *gin.Context) { h.ServeHTTP(c.Writer, c.Request) } } func main() { // Setting up Gin r := gin.Default() r.POST("/query", graphqlHandler()) r.GET("/", playgroundHandler()) r.Run() } ``` ## Accessing gin.Context At the Resolver level, `gqlgen` gives you access to the `context.Context` object. One way to access the `gin.Context` is to add it to the context and retrieve it again. First, create a `gin` middleware to add its context to the `context.Context`: ```go func GinContextToContextMiddleware() gin.HandlerFunc { return func(c *gin.Context) { ctx := context.WithValue(c.Request.Context(), "GinContextKey", c) c.Request = c.Request.WithContext(ctx) c.Next() } } ``` In the router definition, use the middleware: ```go r.Use(GinContextToContextMiddleware()) ``` Define a function to recover the `gin.Context` from the `context.Context` struct: ```go func GinContextFromContext(ctx context.Context) (*gin.Context, error) { ginContext := ctx.Value("GinContextKey") if ginContext == nil { err := fmt.Errorf("could not retrieve gin.Context") return nil, err } gc, ok := ginContext.(*gin.Context) if !ok { err := fmt.Errorf("gin.Context has wrong type") return nil, err } return gc, nil } ``` Lastly, in the Resolver, retrieve the `gin.Context` with the previous defined function: ```go func (r *resolver) Todo(ctx context.Context) (*Todo, error) { gc, err := GinContextFromContext(ctx) if err != nil { return nil, err } // ... } ``` ================================================ FILE: docs/content/recipes/interfaces.md ================================================ --- title: "Embedding Interfaces" description: Embed GraphQL interfaces as Go structs using @goEmbedInterface directive linkTitle: embedded_interfaces menu: { main: { parent: "recipes" } } --- Embedding a GraphQL interface in a Go struct lets you share behavior without duplicating fields. Mark the interface with `@goEmbedInterface` and gqlgen would generate `Base{Interface}` struct and embed it to all implementors instead of copying fields. ### Core Features - **Create base struct**: Interfaces marked with `@goEmbedInterface` get `Base{Interface}` structs generated for embedding. - **Resolve chained embedding**: For annotated interfaces, modelgen walks interface implementation hierarchy and reuses already embedded types, so implementing `A & B & C` keeps a single copy of shared parents. When some intermediate interfaces are not annotated, their fields are included directly in the next implementor struct. ### Example ```graphql directive @goEmbedInterface on INTERFACE type Query { product(id: ID!): Product! } interface Node @goEmbedInterface { id: ID! } interface Ownable @goEmbedInterface { owner: String! } type Product implements Node & Ownable { id: ID! owner: String! name: String! } ``` Configuration: ```yaml # gqlgen.yml schema: - schema.graphqls model: filename: graph/model/models_gen.go ``` gqlgen generates `BaseNode` and `BaseOwnable` structs (only for interfaces with `@goEmbedInterface`), and `Product` embeds both: ```startLine:endLine:graph/model/models_gen.go type BaseNode struct { ID string `json:"id"` } func (BaseNode) IsNode() {} type BaseOwnable struct { Owner string `json:"owner"` } func (BaseOwnable) IsOwnable() {} type Product struct { BaseNode BaseOwnable Name string `json:"name"` } func (Product) IsNode() {} func (Product) IsOwnable() {} ``` In resolvers, call methods that return base implementations—no need to construct interface fields manually: ```startLine:endLine:graph/resolver.go func (r *queryResolver) Product(ctx context.Context, id string) (*model.Product, error) { node, err := r.productService.GetNode(ctx, id) if err != nil { return nil, err } owner, err := r.productService.GetOwner(ctx, id) if err != nil { return nil, err } name, err := r.productService.GetName(ctx, id) if err != nil { return nil, err } return &model.Product{ BaseNode: node, // embeds ID from service BaseOwnable: owner, // embeds Owner from service Name: name, }, nil } ``` **Limitations** - **Diamond problem**: When an interface implements multiple parent interfaces that both have `@goEmbedInterface`, both base structs are embedded. This works correctly as long as there are no field name conflicts, which prevents embedding of both parents. - **Covariant overrides**: When a type implements an interface but uses a more specific type for a field (e.g., interface declares `data: NodeData!` but implementation uses `data: ProductNodeData!`), gqlgen skips embedding the base struct for that interface and generates explicit fields instead. ================================================ FILE: docs/content/recipes/migration-0.11.md ================================================ --- title: "Migrating to 0.11" description: Changes in gqlgen 0.11 linkTitle: Migrating to 0.11 menu: { main: { parent: 'recipes' } } --- ## Updated gqlparser gqlparser had a breaking change, if you have any references to it in your project your going to need to update them from `github.com/vektah/gqlparser` to `github.com/vektah/gqlparser/v2`. ```bash sed -i 's/github.com\/vektah\/gqlparser/github.com\/vektah\/gqlparser\/v2/' $(find -name '*.go') ``` ## Handler Refactor The handler package has grown organically for a long time, 0.11 is a large cleanup of the handler package to make it more modular and easier to maintain once we get to 1.0. ### Transports Transports are the first thing that run, they handle decoding the incoming http request, and encoding the graphql response. Supported transports are: - GET - JSON POST - Multipart form - UrlEncoded form - GRAPHQL - Websockets new usage looks like this ```go srv := New(es) srv.AddTransport(transport.Websocket{ KeepAlivePingInterval: 10 * time.Second, }) srv.AddTransport(transport.Options{}) srv.AddTransport(transport.GET{}) srv.AddTransport(transport.POST{}) srv.AddTransport(transport.MultipartForm{}) srv.AddTransport(transport.UrlEncodedForm{}) srv.AddTransport(transport.GRAPHQL{}) ``` ### New handler extension API The core of this changes the handler package to be a set of composable extensions. The extensions implement a set of optional interfaces: - **OperationParameterMutator** runs before creating a OperationContext (formerly RequestContext). allows manipulating the raw query before parsing. - **OperationContextMutator** runs after creating the OperationContext, but before executing the root resolver. - **OperationInterceptor** runs for each incoming query after parsing and validation, for basic requests the writer will be invoked once, for subscriptions it will be invoked multiple times. - **ResponseInterceptor** runs around each graphql operation response. This can be called many times for a single operation the case of subscriptions. - **FieldInterceptor** runs around each field ![Anatomy of a request@2x](https://user-images.githubusercontent.com/2247982/68181515-c8a27c00-ffeb-11e9-86f6-1673e7179ecb.png) Users of an extension should not need to know which extension points are being used by a given extension, they are added to the server simply by calling `Use(extension)`. There are a few convenience methods for defining middleware inline, instead of creating an extension ```go srv := handler.New(es) srv.AroundFields(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { // this function will be called around every field. next() will evaluate the field and return // its computed value. return next(ctx) }) srv.AroundOperations(func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler { // This function will be called around every operation, next() will return a function that when // called will evaluate one response. Eventually next will return nil, signalling there are no // more results to be returned by the server. return next(ctx) }) srv.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { // This function will be called around each response in the operation. next() will evaluate // and return a single response. return next(ctx) }) ``` Some of the features supported out of the box by handler extensions: - APQ - Query Complexity - Error Presenters and Recover Func - Introspection Query support - Query AST cache - Tracing API They can be `Use`'d like this: ```go srv := handler.New(es) srv.Use(extension.Introspection{}) srv.Use(extension.AutomaticPersistedQuery{ Cache: lru.New(100), }) srv.Use(apollotracing.Tracer{}) ``` ### More consistent naming As part of cleaning up the names the RequestContext has been renamed to OperationContext, as there can be multiple created during the lifecycle of a request. A new ResponseContext has also been created and error handling has been moved here. This allows each response in a subscription to have its own errors. I'm not sure what bugs this might have been causing before... ### Removal of tracing Many of the old interfaces collapse down into just a few extension points: ![Anatomy of a request](/request_anatomy.png) The tracing interface has also been removed, tracing stats are now measured in core (eg time to parse query) and made available on the operation/response contexts. Much of the old interface was designed so that users of a tracer don't need to know which extension points it was listening to, the new handler extensions have the same goal. ### Backward compatibility There is a backwards compatibility layer that keeps most of the original interface in place. There are a few places where BC is known to be broken: - ResponseMiddleware: The signature used to be `func(ctx context.Context, next func(ctx context.Context) []byte) []byte` and is now `func(ctx context.Context) *Response`. We could maintain BC by marshalling to json before and after, but the change is pretty easy to make and is likely to cause less issues. - The Tracer interface has been removed, any tracers will need to be reimplemented against the new extension interface. ## New resolver layout 0.11 also added a new way to generate and layout resolvers on disk. We used to only generate resolver implementations whenever the file didnt exist. This behaviour is still there for those that are already used to it, However there is a new mode you can turn on in config: ```yaml resolver: layout: follow-schema dir: graph ``` This tells gqlgen to generate resolvers next to the schema file that declared the graphql field, which looks like this: ![follow-schema layout](/schema_layout.png) ================================================ FILE: docs/content/recipes/modelgen-hook.md ================================================ --- title: "Allowing mutation of generated models before rendering" description: How to use a model mutation function to insert a ORM-specific tags onto struct fields. linkTitle: "Modelgen hook" menu: { main: { parent: "recipes" } } --- ## BuildMutateHook The following recipe shows how to use a `modelgen` plugin hook to mutate generated models before they are rendered into a resulting file. This feature has many uses but the example focuses only on inserting ORM-specific tags into generated struct fields. This is a common use case since it allows for better field matching of DB queries and the generated data structure. First of all, we need to create a function that will mutate the generated model. Then we can attach the function to the plugin and use it like any other plugin. Create `generate.go` file in the same folder as `resolver.go` (usually in `graph` folder) and add the following code: ```go //go:build ignore package main import ( "fmt" "os" "github.com/99designs/gqlgen/api" "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/plugin/modelgen" ) // Defining mutation function func mutateHook(b *modelgen.ModelBuild) *modelgen.ModelBuild { for _, model := range b.Models { for _, field := range model.Fields { field.Tag += ` orm_binding:"` + model.Name + `.` + field.Name + `"` } } return b } func main() { cfg, err := config.LoadConfigFromDefaultLocations() if err != nil { fmt.Fprintln(os.Stderr, "failed to load config", err.Error()) os.Exit(2) } // Attaching the mutation function onto modelgen plugin p := modelgen.Plugin{ MutateHook: mutateHook, } err = api.Generate(cfg, api.ReplacePlugin(&p)) if err != nil { fmt.Fprintln(os.Stderr, err.Error()) os.Exit(3) } } ``` In `resolver.go`, add `//go:generate go run generate.go` (or replace `//go:generate go tool gqlgen` if you have it there). Now you can run `go generate ./...` to generate the code. Now fields from generated models will contain a additional tag `orm_binding`. This schema: ```graphql type Object { field1: String field2: Int } ``` Will gen generated into: ```go type Object struct { field1 *string `json:"field1" orm_binding:"Object.field1"` field2 *int `json:"field2" orm_binding:"Object.field2"` } ``` ## FieldMutateHook For more fine grained control over model generation, a graphql schema aware a FieldHook can be provided. This hook has access to type and field graphql definitions enabling the hook to modify the `modelgen.Field` using directives defined within the schema. The below recipe uses this feature to add validate tags to the generated model for use with `go-playground/validator` where the validate tags are defined in a constraint directive in the schema. ```go import ( "fmt" "github.com/vektah/gqlparser/v2/ast" "os" "github.com/99designs/gqlgen/api" "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/plugin/modelgen" ) // Defining mutation function func constraintFieldHook(td *ast.Definition, fd *ast.FieldDefinition, f *modelgen.Field) (*modelgen.Field, error) { // Call default hook to proceed standard directives like goField and goTag. // You can omit it, if you don't need. if f, err := modelgen.DefaultFieldMutateHook(td, fd, f); err != nil { return f, err } c := fd.Directives.ForName("constraint") if c != nil { formatConstraint := c.Arguments.ForName("format") if formatConstraint != nil{ f.Tag += " validate:"+formatConstraint.Value.String() } } return f, nil } func main() { cfg, err := config.LoadConfigFromDefaultLocations() if err != nil { fmt.Fprintln(os.Stderr, "failed to load config", err.Error()) os.Exit(2) } // Attaching the mutation function onto modelgen plugin p := modelgen.Plugin{ FieldHook: constraintFieldHook, } err = api.Generate(cfg, api.ReplacePlugin(&p)) if err != nil { fmt.Fprintln(os.Stderr, err.Error()) os.Exit(3) } } ``` This schema: ```graphql directive @constraint( format: String ) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION input ObjectInput { contactEmail: String @constraint(format: "email") website: String @constraint(format: "uri") } ``` Will generate the model: ```go type ObjectInput struct { contactEmail *string `json:"contactEmail" validate:"email"` website *string `json:"website" validate:"uri"` } ``` If a constraint being used during generation should not be published during introspection, the directive should be listed with `skip_runtime:true` in gqlgen.yml ```yaml directives: constraint: skip_runtime: true ``` The built-in directives `@goField` and `@goTag` is implemented using the FieldMutateHook. See: `plugin/modelgen/models.go` functions `GoFieldHook` and `GoTagFieldHook` ================================================ FILE: docs/content/recipes/subscriptions.md ================================================ --- title: "Subscriptions" description: Subscriptions allow for streaming real-time events to your clients. This is how to do that with gqlgen. linkTitle: "Subscriptions" menu: { main: { parent: 'recipes' } } --- GraphQL Subscriptions allow you to stream events to your clients in real-time. This is easy to do in gqlgen and this recipe will show you how to setup a quick example. ## Preparation This recipe starts with the empty project after the quick start steps were followed. Although the steps are the same in an existing, more complex projects you will need to be careful to configure routing correctly. In this recipe you will learn how to 1. add a WebSocket Transport to your server 2. add the `Subscription` type to your schema 3. implement a real-time resolver. ## Adding a WebSocket Transport To send real-time data to clients, your GraphQL server needs to have an open connection with the client. This is done using WebSockets. To add the WebSocket transport change your `main.go` by calling `AddTransport(transport.Websocket{})` on your query handler. > If you are using an external router, remember to send *ALL* requests go to your handler (at `/query`), > not just POST requests! ```go package main import ( "log" "net/http" "os" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/playground" "github.com/example/test/graph" "github.com/example/test/graph/generated" ) const defaultPort = "8080" func main() { port := os.Getenv("PORT") if port == "" { port = defaultPort } srv := handler.New(generated.NewExecutableSchema(generated.Config{Resolvers: &graph.Resolver{}})) srv.AddTransport(transport.Websocket{}) // Add WebSocket first. Here there is no config, see below for examples. srv.AddTransport(transport.Options{}) // If you are using the playground, it's smart to add Options and GET. srv.AddTransport(transport.GET{}) // ... srv.AddTransport(transport.POST{}) // ... Make sure this is after the WebSocket transport! 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)) } ``` ## Configuring WebSockets The WebSocket transport is complex, and for any non-trivial application you will need to configure it. The transport handles this configuration by setting fields on the `transport.Websocket` struct. For an in-depth look at all configuration options, [explore the implementation][code]. At it's most basic, the transport uses [`github.com/gorilla/websocket`][gorilla] to implement a WebSocket connection that sets up the subscription and then sends data to the client from the Go channel returned by the resolver. The initial handshake and the structure of the data payloads are defined by one of two protocols: `graphql-ws` or `graphql-transport-ws` Which one is used is negotiated by the client, defaulting to [`graphql-ws`][graphql-ws]. A minimal WebSocket configuration will handle two basic things: keep-alives and security checks that are normally handled by HTTP middleware that may not be available or compatible with WebSockets: ```go srv.AddTransport(transport.Websocket{ // Keep-alives are important for WebSockets to detect dead connections. This is // not unlike asking a partner who seems to have zoned out while you tell them // a story crucial to understanding the dynamics of your workplace: "Are you // listening to me?" // // Failing to set a keep-alive interval can result in the connection being held // open and the server expending resources to communicate with a client that has // long since walked to the kitchen to make a sandwich instead. KeepAlivePingInterval: 10 * time.Second, // The `github.com/gorilla/websocket.Upgrader` is used to handle the transition // from an HTTP connection to a WebSocket connection. Among other options, here // you must check the origin of the request to prevent cross-site request forgery // attacks. Upgrader: websocket.Upgrader{ CheckOrigin: func(r *http.Request) bool { // Allow exact match on host. origin := r.Header.Get("Origin") if origin == "" || origin == r.Header.Get("Host") { return true } // Match on allow-listed origins. return slices.Contains([]string{":3000", "https://ui.mysite.com"}, origin) }, }, }) ``` [code]: https://github.com/99designs/gqlgen/blob/master/graphql/handler/transport/websocket.go [gorilla]: https://pkg.go.dev/github.com/gorilla/websocket [graphql-ws]: https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md ## Adding Subscriptions to your Schema Next you'll have to define the subscriptions in your schema in the `Subscription` top-level type. ```graphql """ Make sure you have at least something in your `Query` type. If you don't have a query the playground will be unable to introspect your schema! """ type Query { placeholder: String } """ `Time` is a simple type only containing the current time as a unix epoch timestamp and a string timestamp. """ type Time { unixTime: Int! timeStamp: String! } """ `Subscription` is where all the subscriptions your clients can request. You can use Schema Directives like normal to restrict access. """ type Subscription { """ `currentTime` will return a stream of `Time` objects. """ currentTime: Time! } ``` ## Implementing your Resolver After regenerating your code with `go tool gqlgen generate` you'll find a new resolver for your subscription. It will look like any other resolver, except it expects a `<-chan *model.Time` (or whatever your type is). This is a [channel](https://go.dev/tour/concurrency/2). Channels in Go are used to send objects to a single receiver. The resolver for our example `currentTime` subscription looks as follows: ```go // CurrentTime is the resolver for the currentTime field. func (r *subscriptionResolver) CurrentTime(ctx context.Context) (<-chan *model.Time, error) { // First you'll need to `make()` your channel. Use your type here! ch := make(chan *model.Time) // You can (and probably should) handle your channels in a central place outside of `schema.resolvers.go`. // For this example we'll simply use a Goroutine with a simple loop. go func() { // Handle deregistration of the channel here. Note the `defer` defer close(ch) for { // In our example we'll send the current time every second. time.Sleep(1 * time.Second) fmt.Println("Tick") // Prepare your object. currentTime := time.Now() t := &model.Time{ UnixTime: int(currentTime.Unix()), TimeStamp: currentTime.Format(time.RFC3339), } // The subscription may have got closed due to the client disconnecting. // Hence we do send in a select block with a check for context cancellation. // This avoids goroutine getting blocked forever or panicking, select { case <-ctx.Done(): // This runs when context gets cancelled. Subscription closes. fmt.Println("Subscription Closed") // Handle deregistration of the channel here. `close(ch)` return // Remember to return to end the routine. case ch <- t: // This is the actual send. // Our message went through, do nothing } } }() // We return the channel and no error. return ch, nil } ``` ## Trying it out To try out your new subscription visit your GraphQL playground. This is exposed on `http://localhost:8080` by default. Use the following query: ```graphql subscription { currentTime { unixTime timeStamp } } ``` Run your query and you should see a response updating with the current timestamp every second. To gracefully stop the connection click the `Execute query` button again. ## Adding Server-Sent Events transport You can use instead of WebSocket (or in addition) [Server-Sent Events](https://en.wikipedia.org/wiki/Server-sent_events) as transport for subscriptions. This can have advantages and disadvantages over transport via WebSocket and requires a compatible client library, for instance [graphql-sse](https://github.com/enisdenjo/graphql-sse). The connection between server and client should be HTTP/2+. The client must send the subscription request via POST with the header `accept: text/event-stream` and `content-type: application/json` in order to be accepted by the SSE transport. The underling protocol is documented at [distinct connections mode](https://github.com/enisdenjo/graphql-sse/blob/master/PROTOCOL.md). Add the SSE transport as first of all other transports, as the order is important. ```go srv := handler.New(generated.NewExecutableSchema(generated.Config{Resolvers: &graph.Resolver{}})) srv.AddTransport(transport.SSE{}) // Add SSE first. // Continue server setup: srv.AddTransport(transport.Options{}) srv.AddTransport(transport.GET{}) srv.AddTransport(transport.POST{}) ``` Optionally add `KeepAlivePingInterval` to send a periodic heartbeat over the SSE transport. ```go srv.AddTransport(transport.SSE{ // Load balancers, proxies, or firewalls often have idle timeout // settings that specify the maximum duration a connection can // remain open without data being sent across it. If the idle // timeout is exceeded without any data being transmitted, the // connection may be closed when connecting SSE over HTTP/1. // // End-to-end HTTP/2 connections do not require a ping interval // to keep the connection open. KeepAlivePingInterval: 10 * time.Second, }) ``` The GraphQL playground does not support SSE yet. You can try out the subscription via curl: ```bash curl -N --request POST --url http://localhost:8080/query \ --data '{"query":"subscription { currentTime { unixTime timeStamp } }"}' \ -H "accept: text/event-stream" -H 'content-type: application/json' \ --verbose ``` ## Full Files Here are all files at the end of this tutorial. Only files changed from the end of the quick start are listed. ### main.go ```go package main import ( "log" "net/http" "os" "slices" "time" "github.com/gorilla/websocket" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/99designs/gqlgen/graphql/playground" "github.com/example/test/graph" "github.com/example/test/graph/generated" ) const defaultPort = "8080" func main() { port := os.Getenv("PORT") if port == "" { port = defaultPort } srv := handler.New( generated.NewExecutableSchema( generated.Config{Resolvers: &graph.Resolver{}}, ), ) srv.AddTransport(transport.SSE{}) srv.AddTransport(transport.Websocket{ KeepAlivePingInterval: 10 * time.Second, Upgrader: websocket.Upgrader{ CheckOrigin: func(r *http.Request) bool { origin := r.Header.Get("Origin") if origin == "" || origin == r.Header.Get("Host") { return true } return slices.Contains([]string{":3000", "https://ui.mysite.com"}, origin) }, }, }) srv.AddTransport(transport.Options{}) srv.AddTransport(transport.GET{}) srv.AddTransport(transport.POST{}) http.Handle("/", playground.Handler("GraphQL playground", "/query")) http.Handle("/query", srv) log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) log.Fatal(http.ListenAndServe(":"+port, nil)) } ``` ### schema.graphqls ```graphql type Query { placeholder: String } type Time { unixTime: Int! timeStamp: String! } type Subscription { currentTime: Time! } ``` ### schema.resolvers.go ```go package graph // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. import ( "context" "fmt" "time" "github.com/example/test/graph/generated" "github.com/example/test/graph/model" ) // Placeholder is the resolver for the placeholder field. func (r *queryResolver) Placeholder(ctx context.Context) (*string, error) { str := "Hello World" return &str, nil } // CurrentTime is the resolver for the currentTime field. func (r *subscriptionResolver) CurrentTime(ctx context.Context) (<-chan *model.Time, error) { ch := make(chan *model.Time) go func() { defer close(ch) for { time.Sleep(1 * time.Second) fmt.Println("Tick") currentTime := time.Now() t := &model.Time{ UnixTime: int(currentTime.Unix()), TimeStamp: currentTime.Format(time.RFC3339), } select { case <-ctx.Done(): // Exit on cancellation fmt.Println("Subscription closed.") return case ch <- t: // Our message went through, do nothing } } }() return ch, nil } // Query returns generated.QueryResolver implementation. func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } // Subscription returns generated.SubscriptionResolver implementation. func (r *Resolver) Subscription() generated.SubscriptionResolver { return &subscriptionResolver{r} } type queryResolver struct{ *Resolver } type subscriptionResolver struct{ *Resolver } ``` ================================================ FILE: docs/content/reference/apq.md ================================================ --- title: "Automatic persisted queries" description: linkTitle: "APQ" menu: { main: { parent: 'reference', weight: 10 } } --- When you work with GraphQL by default your queries are transferred with every request. That can waste significant bandwidth. To avoid that you can use Automatic Persisted Queries (APQ). With APQ you send only query hash to the server. If hash is not found on a server then client makes a second request to register query hash with original query on a server. ## Usage In order to enable Automatic Persisted Queries you need to change your client. For more information see [Automatic Persisted Queries Link](https://www.apollographql.com/docs/resources/glossary/#automatic-persisted-queries) documentation. For the server you need to implement the `graphql.Cache` interface and pass an instance to the `extension.AutomaticPersistedQuery` type. Make sure the extension is applied to your GraphQL handler. See example using [go-redis](https://github.com/go-redis/redis) package below: ```go import ( "context" "time" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/extension" "github.com/99designs/gqlgen/graphql/handler/transport" "github.com/go-redis/redis" ) type Cache struct { client redis.UniversalClient ttl time.Duration } const apqPrefix = "apq:" func NewCache(redisAddress string, ttl time.Duration) (*Cache, error) { client := redis.NewClient(&redis.Options{ Addr: redisAddress, }) err := client.Ping().Err() if err != nil { return nil, fmt.Errorf("could not create cache: %w", err) } return &Cache{client: client, ttl: ttl}, nil } func (c *Cache) Add(ctx context.Context, key string, value interface{}) { c.client.Set(apqPrefix+key, value, c.ttl) } func (c *Cache) Get(ctx context.Context, key string) (interface{}, bool) { s, err := c.client.Get(apqPrefix + key).Result() if err != nil { return struct{}{}, false } return s, true } func main() { cache, err := NewCache(cfg.RedisAddress, 24*time.Hour) if err != nil { log.Fatalf("cannot create APQ redis cache: %v", err) } c := Config{ Resolvers: &resolvers{} } gqlHandler := handler.New( generated.NewExecutableSchema(c), ) gqlHandler.AddTransport(transport.POST{}) gqlHandler.Use(extension.AutomaticPersistedQuery{Cache: cache}) http.Handle("/query", gqlHandler) } ``` ================================================ FILE: docs/content/reference/changesets.md ================================================ --- linkTitle: Changesets title: Using maps as changesets description: Falling back to map[string]interface{} to allow for presence checks. menu: { main: { parent: 'reference', weight: 10 } } --- Occasionally you need to distinguish presence from nil (undefined vs null). In gqlgen this can be done using either maps or the Omittable type. ## Maps ```graphql type Mutation { updateUser(id: ID!, changes: UserChanges!): User } input UserChanges { name: String email: String } ``` Then in config set the backing type to `map[string]interface{}` ```yaml models: UserChanges: model: "map[string]interface{}" ``` After running go generate you should end up with a resolver that looks like this: ```go func (r *mutationResolver) UpdateUser(ctx context.Context, id int, changes map[string]interface{}) (*User, error) { u := fetchFromDb(id) // Check if name was provided in the input if v, isSet := changes["name"]; isSet { // v is the value with type `interface{}` value, valid := v.(*string) // *string, could be nil if !valid { // map values are automatically coerced to the types defined in the schema, // so if this error is thrown it's most likely a type mismatch between here and your GraphQL input definition return nil, errors.New("field 'name' on UserChanges does not have type String") } if value == nil { u.Name = "" // value to use when null } else { u.Name = *value // set to the provided value } } // If !isSet, the field was omitted entirely - no change // Alternative: use reflection (see below) if err := ApplyChanges(changes, &u); err != nil { return nil, err } saveToDb(u) return u, nil } ``` Please note that map values are automatically coerced to the types defined in the schema. This means that optional, nested inputs or scalars will conform to their expected types. We often use the mapstructure library to directly apply these changesets directly to the object using reflection: ```go func ApplyChanges(changes map[string]interface{}, to interface{}) error { dec, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{ ErrorUnused: true, TagName: "json", Result: to, ZeroFields: true, // This is needed to get mapstructure to call the gqlgen unmarshaler func for custom scalars (eg Date) DecodeHook: func(a reflect.Type, b reflect.Type, v interface{}) (interface{}, error) { if reflect.PtrTo(b).Implements(reflect.TypeOf((*graphql.Unmarshaler)(nil)).Elem()) { resultType := reflect.New(b) result := resultType.MethodByName("UnmarshalGQL").Call([]reflect.Value{reflect.ValueOf(v)}) err, _ := result[0].Interface().(error) return resultType.Elem().Interface(), err } return v, nil }, }) if err != nil { return err } return dec.Decode(changes) } ``` ## Omittable The `Omittable[T]` type provides a more type-safe alternative to maps for distinguishing between unset, null, and actual values. It's a generic wrapper that tracks both the value and whether it was explicitly provided. You can enable omittable fields in two ways: **Option 1: Per-field with directive** ```graphql input UserChanges { name: String @goField(omittable: true) email: String @goField(omittable: true) } ``` **Option 2: Globally in config** ```yaml # gqlgen.yml nullable_input_omittable: true ``` This generates a Go struct using `graphql.Omittable`: ```go type UserChanges struct { Name graphql.Omittable[*string] `json:"name,omitempty"` Email graphql.Omittable[*string] `json:"email,omitempty"` } ``` Your resolver can then distinguish between three states: ```go func (r *mutationResolver) UpdateUser(ctx context.Context, id int, changes UserChanges) (*User, error) { u := fetchFromDb(id) // Check if name was provided in the input if changes.Name.IsSet() { value := changes.Name.Value() // *string, could be nil if value == nil { u.Name = "" // value to use when null } else { u.Name = *value // set to the provided value } } // If !changes.Name.IsSet(), the field was omitted entirely - no change // Alternative: use ValueOK for cleaner code if value, isSet := changes.Email.ValueOK(); isSet { u.Email = value // *string, nil if null was provided, actual value otherwise } saveToDb(u) return u, nil } ``` ### Key Methods - `IsSet()` - Returns true if the field was explicitly provided (even if null) - `Value()` - Returns the value, or zero value if not set - `ValueOK()` - Returns (value, wasSet) similar to map access - `OmittableOf(value)` - Helper to create an Omittable with a value ================================================ FILE: docs/content/reference/complexity.md ================================================ --- title: "Preventing overly complex queries" description: Avoid denial of service attacks by calculating query costs and limiting complexity. linkTitle: Query Complexity menu: { main: { parent: "reference", weight: 10 } } --- GraphQL provides a powerful way to query your data, but putting great power in the hands of your API clients also exposes you to a risk of denial of service attacks. You can mitigate that risk with gqlgen by limiting the complexity of the queries you allow. ## Expensive Queries Consider a schema that allows listing blog posts. Each blog post is also related to other posts. ```graphql type Query { posts(count: Int = 10): [Post!]! } type Post { title: String! text: String! related(count: Int = 10): [Post!]! } ``` It's not too hard to craft a query that will cause a very large response: ```graphql { posts(count: 100) { related(count: 100) { related(count: 100) { related(count: 100) { title } } } } } ``` The size of the response grows exponentially with each additional level of the `related` field. Fortunately, gqlgen's `http.Handler` includes a way to guard against this type of query. ## Limiting Query Complexity Limiting query complexity is as simple as specifying it with the provided extension package. ```go func main() { c := Config{ Resolvers: &resolvers{} } srv := handler.New(blog.NewExecutableSchema(c)) // Server setup... srv.Use(extension.FixedComplexityLimit(5)) // This line is key r.Handle("/query", srv) } ``` Now any query with complexity greater than 5 is rejected by the API. By default, each field and level of depth adds one to the overall query complexity. You can also use `extension.ComplexityLimit` to dynamically configure the complexity limit per request. To set a custom complexity value for scalars and enums, use `extension.FixedComplexityLimit` with the `WithFixedScalarValue` functional option: ```go srv.Use(extension.FixedComplexityLimit(5, complexity.WithFixedScalarValue(0))) ``` You can also specify which fields to ignore with the `WithIgnoreFields` functional option. The expected argument is a set of the field names: ```go ignore := map[string]struct{}{ "Query.foo": {}, // ignore top-level 'foo' field "Item.name": {}, // ignore the 'name' field of the 'Item' object. } srv.Use(extension.FixedComplexityLimit(5, complexity.WithIgnoreFields(ignore))) ``` This helps, but we still have a problem: the `posts` and `related` fields, which return arrays, are much more expensive to resolve than the scalar `title` and `text` fields. However, the default complexity calculation weights them equally. It would make more sense to apply a higher cost to the array fields. ## Custom Complexity Calculation To apply higher costs to certain fields, we can use custom complexity functions. ```go func main() { c := Config{ Resolvers: &resolvers{} } countComplexity := func(childComplexity, count int) int { return count * childComplexity } c.Complexity.Query.Posts = countComplexity c.Complexity.Post.Related = countComplexity srv := handler.New(blog.NewExecutableSchema(c)) srv.AddTransport(transport.POST{}) srv.Use(extension.FixedComplexityLimit(5)) http.Handle("/query", gqlHandler) } ``` When we assign a function to the appropriate `Complexity` field, that function is used in the complexity calculation. Here, the `posts` and `related` fields are weighted according to the value of their `count` parameter. This means that the more posts a client requests, the higher the query complexity. And just like the size of the response would increase exponentially in our original query, the complexity would also increase exponentially, so any client trying to abuse the API would run into the limit very quickly. By applying a query complexity limit and specifying custom complexity functions in the right places, you can easily prevent clients from using a disproportionate amount of resources and disrupting your service. ================================================ FILE: docs/content/reference/dataloaders.md ================================================ --- title: "Optimizing N+1 database queries using Dataloaders" description: Speeding up your GraphQL requests by reducing the number of round trips to the database. linkTitle: Dataloaders menu: { main: { parent: 'reference', weight: 10 } } --- Dataloaders consolidate the retrieval of information into fewer, batched calls. This example demonstrates the value of dataloaders by consolidating many SQL queries into a single bulk query. ## The Problem Imagine your graph has query that lists todos... ```graphql query { todos { user { name } } } ``` and the `todo.user` resolver reads the `User` from a database... ```go func (r *todoResolver) User(ctx context.Context, obj *model.Todo) (*model.User, error) { stmt, err := r.db.PrepareContext(ctx, "SELECT id, name FROM users WHERE id = ?") if err != nil { return nil, err } defer stmt.Close() rows, err := stmt.QueryContext(ctx, obj.UserID) if err != nil { return nil, err } defer rows.Close() if !rows.Next() { return nil, rows.Err() } var user model.User if err := rows.Scan(&user.ID, &user.Name); err != nil { return nil, err } return &user, nil } ``` The query executor will call the `Query.Todos` resolver which does a `select * from todo` and returns `N` todos. If the nested `User` is selected, the above `UserRaw` resolver will run a separate query for each user, resulting in `N+1` database queries. eg: ```sql SELECT id, todo, user_id FROM todo SELECT id, name FROM users WHERE id = ? SELECT id, name FROM users WHERE id = ? SELECT id, name FROM users WHERE id = ? SELECT id, name FROM users WHERE id = ? SELECT id, name FROM users WHERE id = ? SELECT id, name FROM users WHERE id = ? ``` Whats even worse? most of those todos are all owned by the same user! We can do better than this. ## Dataloader Dataloaders allow us to consolidate the fetching of `todo.user` across all resolvers for a given GraphQL request into a single database query and even cache the results for subsequent requests. We're going to use [vikstrous/dataloadgen](https://github.com/vikstrous/dataloadgen) to implement a dataloader for bulk-fetching users. ```bash go get github.com/vikstrous/dataloadgen ``` Next, we implement a data loader and a middleware for injecting the data loader on a request context. ```go package loaders // import vikstrous/dataloadgen with your other imports import ( "context" "database/sql" "net/http" "strings" "time" "github.com/vikstrous/dataloadgen" ) type ctxKey string const ( loadersKey = ctxKey("dataloaders") ) // userReader reads Users from a database type userReader struct { db *sql.DB } // getUsers implements a batch function that can retrieve many users by ID, // for use in a dataloader func (u *userReader) getUsers(ctx context.Context, userIDs []string) ([]*model.User, []error) { stmt, err := u.db.PrepareContext(ctx, `SELECT id, name FROM users WHERE id IN (?`+strings.Repeat(",?", len(userIDs)-1)+`)`) if err != nil { return nil, []error{err} } defer stmt.Close() rows, err := stmt.QueryContext(ctx, userIDs) if err != nil { return nil, []error{err} } defer rows.Close() users := make([]*model.User, 0, len(userIDs)) errs := make([]error, 0, len(userIDs)) for rows.Next() { var user model.User err := rows.Scan(&user.ID, &user.Name) users = append(users, &user) errs = append(errs, err) } return users, errs } // Loaders wrap your data loaders to inject via middleware type Loaders struct { UserLoader *dataloadgen.Loader[string, *model.User] } // NewLoaders instantiates data loaders for the middleware func NewLoaders(conn *sql.DB) *Loaders { // define the data loader ur := &userReader{db: conn} return &Loaders{ UserLoader: dataloadgen.NewLoader(ur.getUsers, dataloadgen.WithWait(time.Millisecond)), } } // Middleware injects data loaders into the context func Middleware(conn *sql.DB, next http.Handler) http.Handler { // return a middleware that injects the loader to the request context return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { loader := NewLoaders(conn) r = r.WithContext(context.WithValue(r.Context(), loadersKey, loader)) next.ServeHTTP(w, r) }) } // For returns the dataloader for a given context func For(ctx context.Context) *Loaders { return ctx.Value(loadersKey).(*Loaders) } // GetUser returns single user by id efficiently func GetUser(ctx context.Context, userID string) (*model.User, error) { loaders := For(ctx) return loaders.UserLoader.Load(ctx, userID) } // GetUsers returns many users by ids efficiently func GetUsers(ctx context.Context, userIDs []string) ([]*model.User, error) { loaders := For(ctx) return loaders.UserLoader.LoadAll(ctx, userIDs) } ``` Add the dataloader middleware to your server... ```go // create the query handler h := handler.New(generated.NewExecutableSchema(...)) h.AddTransport(transport.POST{}) // wrap the query handler with middleware to inject dataloader in requests. // pass in your dataloader dependencies, in this case the db connection. srv = loaders.Middleware(db, h) // register the wrapped handler http.Handle("/query", srv) ``` Now lets update our resolver to call the dataloader: ```go func (r *todoResolver) User(ctx context.Context, obj *model.Todo) (*model.User, error) { return loaders.GetUser(ctx, obj.UserID) } ``` The end result? Just 2 queries! ```sql SELECT id, todo, user_id FROM todo SELECT id, name from user WHERE id IN (?,?,?,?,?) ``` You can see an end-to-end example [here](https://github.com/vikstrous/dataloadgen-example). ================================================ FILE: docs/content/reference/directives.md ================================================ --- title: Using schema directives to implement permission checks description: Implementing graphql schema directives in golang for permission checks. linkTitle: Schema Directives menu: { main: { parent: 'reference', weight: 10 } } --- Directives act a bit like annotations, decorators, or HTTP middleware. They give you a way to specify some behaviour based on a field or argument in a generic and reusable way. This can be really useful for cross-cutting concerns like permission checks which can be applied broadly across your API. **Note**: The current directives implementation is still fairly limited, and is designed to cover the most common "field middleware" case. ## Restricting access based on user role For example, we might want to restrict which mutations or queries a client can make based on the authenticated user's role: ```graphql type Mutation { deleteUser(userID: ID!): Bool @hasRole(role: ADMIN) } ``` ### Declare it in the schema Before we can use a directive we must declare it in the schema. Here's how we would define the `@hasRole` directive: ```graphql directive @hasRole(role: Role!) on FIELD_DEFINITION enum Role { ADMIN USER } ``` Next, run `go generate` and gqlgen will add the directive to the DirectiveRoot: ```go type DirectiveRoot struct { HasRole func(ctx context.Context, obj interface{}, next graphql.Resolver, role Role) (res interface{}, err error) } ``` The arguments are: - *ctx*: the parent context - *obj*: the object containing the value this was applied to, e.g.: - for field definition directives (`FIELD_DEFINITION`), the object/input object that contains the field - for argument directives (`ARGUMENT_DEFINITION`), a map containing all arguments - *next*: the next directive in the directive chain, or the field resolver. This should be called to get the value of the field/argument/whatever. You can block access to the field by not calling `next(ctx)` after checking whether a user has a required permission, for example. - *...args*: finally, any args defined in the directive schema definition are passed in ## Implement the directive Now we must implement the directive. The directive function is assigned to the Config object before registering the GraphQL handler. ```go package main import ( "context" "log" "net/http" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/transport" ) func main() { c := Config{ Resolvers: &resolvers{} } c.Directives.HasRole = func(ctx context.Context, obj interface{}, next graphql.Resolver, role Role) (interface{}, error) { if !getCurrentUser(ctx).HasRole(role) { // block calling the next resolver return nil, fmt.Errorf("Access denied") } // or let it pass through return next(ctx) } srv := handler.New(NewExecutableSchema(c)) srv.AddTransport(transport.POST{}) http.Handle("/query", srv) log.Fatal(http.ListenAndServe(":8081", nil)) } ``` That's it! You can now apply the `@hasRole` directive to any mutation or query in your schema. ================================================ FILE: docs/content/reference/errors.md ================================================ --- linkTitle: Handling Errors title: Sending custom error data in the graphql response description: Customising graphql error types to send custom error data back to the client using gqlgen. menu: { main: { parent: 'reference', weight: 10 } } --- ## Returning errors All resolvers simply return an error to be sent to the user. The assumption is that any error message returned here is appropriate for end users. If certain messages aren't safe, customise the error presenter. ### Multiple errors To return multiple errors you can call the `graphql.Error` functions like so: ```go package foo import ( "context" "errors" "github.com/vektah/gqlparser/v2/gqlerror" "github.com/99designs/gqlgen/graphql" ) // DoThings add errors to the stack. func (r Query) DoThings(ctx context.Context) (bool, error) { // Print a formatted string graphql.AddErrorf(ctx, "Error %d", 1) // Pass an existing error out graphql.AddError(ctx, gqlerror.Errorf("zzzzzt")) // Or fully customize the error graphql.AddError(ctx, &gqlerror.Error{ Path: graphql.GetPath(ctx), Message: "A descriptive error message", Extensions: map[string]interface{}{ "code": "10-4", }, }) // And you can still return an error if you need return false, gqlerror.Errorf("BOOM! Headshot") } ``` They will be returned in the same order in the response, eg: ```json { "data": { "todo": null }, "errors": [ { "message": "Error 1", "path": [ "todo" ] }, { "message": "zzzzzt", "path": [ "todo" ] }, { "message": "A descriptive error message", "path": [ "todo" ], "extensions": { "code": "10-4" } }, { "message": "BOOM! Headshot", "path": [ "todo" ] } ] } ``` or you can simply return multiple errors ```go package foo import ( "context" "errors" "github.com/vektah/gqlparser/v2/gqlerror" "github.com/99designs/gqlgen/graphql" ) var errSomethingWrong = errors.New("some validation failed") // DoThingsReturnMultipleErrors collect errors and returns it if any. func (r Query) DoThingsReturnMultipleErrors(ctx context.Context) (bool, error) { errList := gqlerror.List{} // Add existing error errList = append(errList, gqlerror.Wrap(errSomethingWrong)) // Create new formatted and append errList = append(errList, gqlerror.Errorf("invalid value: %s", "invalid")) // Or fully customize the error and append errList = append(errList, &gqlerror.Error{ Path: graphql.GetPath(ctx), Message: "A descriptive error message", Extensions: map[string]interface{}{ "code": "10-4", }, }) return false, errList } ``` They will be returned in the same order in the response, eg: ```json { "data": { "todo": null }, "errors": [ { "message": "some validation failed", "path": [ "todo" ] }, { "message": "invalid value: invalid", "path": [ "todo" ] }, { "message": "A descriptive error message", "path": [ "todo" ], "extensions": { "code": "10-4" } }, ] } ``` ## Hooks ### The error presenter All `errors` returned by resolvers, or from validation, pass through a hook before being displayed to the user. This hook gives you the ability to customise errors however makes sense in your app. The default error presenter will capture the resolver path and use the Error() message in the response. You change this when creating the server: ```go package bar import ( "context" "errors" "github.com/vektah/gqlparser/v2/gqlerror" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" ) func main() { server := handler.New(MakeExecutableSchema(resolvers)) // Server setup... server.SetErrorPresenter(func(ctx context.Context, e error) *gqlerror.Error { err := graphql.DefaultErrorPresenter(ctx, e) var myErr *MyError if errors.As(e, &myErr) { err.Message = "Eeek!" } return err }) } ``` This function will be called with the same resolver context that generated it, so you can extract the current resolver path and whatever other state you might want to notify the client about. ### The panic handler There is also a panic handler, called whenever a panic happens to gracefully return a message to the user before stopping parsing. This is a good spot to notify your bug tracker and send a custom message to the user. Any errors returned from here will also go through the error presenter. You change this when creating the server: ```go server := handler.New(MakeExecutableSchema(resolvers)) // Server setup... server.SetRecoverFunc(func(ctx context.Context, err interface{}) error { // Notify bug tracker... return gqlerror.Errorf("Internal server error!") }) ``` While these handlers are useful in production to make sure the program does not crash, even if a user finds an issue that causes a crash-condition. During development, it can sometimes be more useful to properly crash, potentially generating a coredump to [enable further debugging](https://go.dev/wiki/CoreDumpDebugging). To allow your program to crash on a panic, add this to your config file: ```yaml omit_panic_handler: true ``` ================================================ FILE: docs/content/reference/field-collection.md ================================================ --- title: 'Determining which fields were requested by a query' description: How to determine which fields a query requested in a resolver. linkTitle: Field Collection menu: { main: { parent: 'reference', weight: 10 } } --- Often it is useful to know which fields were queried for in a resolver. Having this information can allow a resolver to only fetch the set of fields required from a data source, rather than over-fetching everything and allowing gqlgen to do the rest. This process is known as [Field Collection](https://spec.graphql.org/draft/#sec-Field-Collection) — gqlgen automatically does this in order to know which fields should be a part of the response payload. The set of collected fields does however depend on the type being resolved. Queries can contain fragments, and resolvers can return interfaces and unions, therefore the set of collected fields cannot be fully determined until the type of the resolved object is known. Within a resolver, there are several API methods available to query the selected fields. ## CollectAllFields `CollectAllFields` is the simplest way to get the set of queried fields. It will return a slice of strings of the field names from the query. This will be a unique set of fields, and will return all fragment fields, ignoring fragment Type Conditions. Given the following example query: ```graphql query { foo { fieldA ... on Bar { fieldB } ... on Baz { fieldC } } } ``` Calling `CollectAllFields` from a resolver will yield a string slice containing `fieldA`, `fieldB`, and `fieldC`. ## CollectFieldsCtx `CollectFieldsCtx` is useful in cases where more information on matches is required, or the set of collected fields should match fragment type conditions for a resolved type. `CollectFieldsCtx` takes a `satisfies` parameter, which should be a slice of strings of types that the resolved type will satisfy. For example, given the following schema: ```graphql interface Shape { area: Float } type Circle implements Shape { radius: Float area: Float } union Shapes = Circle ``` The type `Circle` would satisfy `Circle`, `Shape`, and `Shapes` — these values should be passed to `CollectFieldsCtx` to get the set of collected fields for a resolved `Circle` object. > Note > > `CollectFieldsCtx` is just a convenience wrapper around `CollectFields` that calls the later with the selection set automatically passed through from the resolver context. ## Practical example Say we have the following GraphQL query ```graphql query { flowBlocks { id block { id title type choices { id title description slug } } } } ``` We don't want to overfetch our database so we want to know which field are requested. Here is an example which get's all requested field as convenient string slice, which can be easily checked. ```golang func GetPreloads(ctx context.Context) []string { return GetNestedPreloads( graphql.GetOperationContext(ctx), graphql.CollectFieldsCtx(ctx, nil), "", ) } func GetNestedPreloads(ctx *graphql.OperationContext, fields []graphql.CollectedField, prefix string) (preloads []string) { for _, column := range fields { prefixColumn := GetPreloadString(prefix, column.Name) preloads = append(preloads, prefixColumn) preloads = append(preloads, GetNestedPreloads(ctx, graphql.CollectFields(ctx, column.Selections, nil), prefixColumn)...) } return } func GetPreloadString(prefix, name string) string { if len(prefix) > 0 { return prefix + "." + name } return name } ``` So if we call these helpers in our resolver: ```golang func (r *queryResolver) FlowBlocks(ctx context.Context) ([]*FlowBlock, error) { preloads := GetPreloads(ctx) ``` it will result in the following string slice: ``` ["id", "block", "block.id", "block.title", "block.type", "block.choices", "block.choices.id", "block.choices.title", "block.choices.description", "block.choices.slug"] ``` ================================================ FILE: docs/content/reference/file-upload.md ================================================ --- title: "File Upload" description: How to upload files. linkTitle: File Upload menu: { main: { parent: "reference", weight: 10 } } --- Graphql server has an already built-in Upload scalar to upload files using a multipart request. \ It implements the following spec [https://github.com/jaydenseric/graphql-multipart-request-spec](https://github.com/jaydenseric/graphql-multipart-request-spec), that defines an interoperable multipart form field structure for GraphQL requests, used by various file upload client implementations. To use it you need to add the Upload scalar in your schema, and it will automatically add the marshalling behaviour to Go types. # Configuration There are two specific options that can be configured for uploading files: - uploadMaxSize \ This option specifies the maximum number of bytes used to parse a request body as multipart/form-data. - uploadMaxMemory \ This option specifies the maximum number of bytes used to parse a request body as multipart/form-data in memory, with the remainder stored on disk in temporary files. # Examples ## Single file upload For this use case, the schema could look like this. ```graphql "The `UploadFile, // b.txt` scalar type represents a multipart file upload." scalar Upload "The `Query` type, represents all of the entry points into our object graph." type Query { ... } "The `Mutation` type, represents all updates we can make to our data." type Mutation { singleUpload(file: Upload!): Boolean! } ``` cURL can be used the make a query as follows: ``` curl localhost:4000/graphql \ -F operations='{ "query": "mutation ($file: Upload!) { singleUpload(file: $file) }", "variables": { "file": null } }' \ -F map='{ "0": ["variables.file"] }' \ -F 0=@a.txt ``` That invokes the following operation: ```javascript { query: ` mutation($file: Upload!) { singleUpload(file: $file) } `, variables: { file: File // a.txt } } ``` ## Multiple file upload For this use case, the schema could look like this. ```graphql "The `Upload` scalar type represents a multipart file upload." scalar Upload "The `File` type, represents the response of uploading a file." type File { id: Int! name: String! content: String! } "The `UploadFile` type, represents the request for uploading a file with a certain payload." input UploadFile { id: Int! file: Upload! } "The `Query` type, represents all of the entry points into our object graph." type Query { ... } "The `Mutation` type, represents all updates we can make to our data." type Mutation { multipleUpload(req: [UploadFile!]!): [File!]! } ``` cURL can be used the make a query as follows: ```bash curl localhost:4000/query \ -F operations='{ "query": "mutation($req: [UploadFile!]!) { multipleUpload(req: $req) { id, name, content } }", "variables": { "req": [ { "id": 1, "file": null }, { "id": 2, "file": null } ] } }' \ -F map='{ "0": ["variables.req.0.file"], "1": ["variables.req.1.file"] }' \ -F 0=@b.txt \ -F 1=@c.txt ``` That invokes the following operation: ```javascript { query: ` mutation($req: [UploadFile!]!) multipleUpload(req: $req) { id, name, content } } `, variables: { req: [ { id: 1, File, // b.txt }, { id: 2, File, // c.txt } ] } } ``` See the [_examples/fileupload](https://github.com/99designs/gqlgen/tree/master/_examples/fileupload) package for more examples. # Usage with Apollo [apollo-upload-client](https://github.com/jaydenseric/apollo-upload-client) needs to be installed in order for file uploading to work with Apollo: ```javascript import ApolloClient from "apollo-client"; import { createUploadLink } from "apollo-upload-client"; const client = new ApolloClient({ cache: new InMemoryCache(), link: createUploadLink({ uri: "/graphql" }) }); ``` A `File` object can then be passed into your mutation as a variable: ```javascript { query: ` mutation($file: Upload!) { singleUpload(file: $file) { id } } `, variables: { file: new File(...) } } ``` ================================================ FILE: docs/content/reference/introspection.md ================================================ --- title: 'Enabling introspection' description: Allow users to introspect schemas. linkTitle: Introspection menu: { main: { parent: 'reference', weight: 10 } } --- One of the best features of GraphQL is it's powerful discoverability, known as [introspection][introspection]. Introspection allows clients to query the server's schema about itself, and is the foundation of many tools like GraphiQL and Apollo Studio. ## Enabling introspection To enable introspection for the whole server, you use the bundled middleware extension `github.com/99designs/gqlgen/graphql/handler/extension.Introspection`: ```go srv := handler.New(es) // Add server setup. srv.AddTransport(transport.Options{}) srv.AddTransport(transport.POST{}) // Add the introspection middleware. srv.Use(extension.Introspection{}) ``` To opt in to introspection for certain environments, you can just guard the middleware with an environment variable: ```go srv := handler.New(es) // Server setup... if os.Getenv("ENVIRONMENT") == "development" { srv.Use(extension.Introspection{}) } ``` ## Disabling introspection based on authentication Introspection can also be guarded on a per-request context basis. For example, you can disable it in a middleware based on user authentication: ```go srv := handler.New(es) // Server setup... srv.Use(extension.Introspection{}) srv.AroundOperations(func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler { if !userForContext(ctx).IsAdmin { graphql.GetOperationContext(ctx).DisableIntrospection = true } return next(ctx) }) ``` [introspection]: https://graphql.org/learn/introspection/ ================================================ FILE: docs/content/reference/model-generation.md ================================================ --- title: Model generation description: Examples of ways to alter generated model output linkTitle: Model Generation menu: { main: {parent: 'reference', weight: 10 }} --- While we do our best to create Go models that are equivalent to their GraphQL counterparts, it can sometimes be advantageous, or even necessary, to have control over some aspects of this output depending on runtime environment. ## json ",omitempty" By default, fields that are marked as nullable in the GraphQL schema, e.g. `field: String` rather than `field: String!`, have the [json ",omitempty"](https://pkg.go.dev/encoding/json#Marshal) field tag applied to them. This is probably fine if the downstream consumers of json serialized representations of this model are all written in Go, but obviously this is not always true. To that end, you expressly disable the addition of the `,omitempty` json field tag by setting the top-level [config](https://gqlgen.com/config/) field `enable_model_json_omitempty_tag` to `false`: ### Examples ```graphql # graphql type OmitEmptyJsonTagTest { ValueNonNil: String! Value: String } ``` Without `enable_model_json_omitempty_tag` configured: ```go type OmitEmptyJSONTagTest struct { ValueNonNil string `json:"ValueNonNil" database:"OmitEmptyJsonTagTestValueNonNil"` Value *string `json:"Value,omitempty" database:"OmitEmptyJsonTagTestValue"` } ``` With `enable_model_json_omitempty_tag: true` (same as un-configured): ```go type OmitEmptyJSONTagTest struct { ValueNonNil string `json:"ValueNonNil" database:"OmitEmptyJsonTagTestValueNonNil"` Value *string `json:"Value,omitempty" database:"OmitEmptyJsonTagTestValue"` } ``` ## json ",omitzero" Fields marked as nullable in the GraphQL schema, e.g. `field: String` rather than `field: String!`, have the [json ",omitzero"](https://pkg.go.dev/encoding/json#Marshal) field tag applied to them. To that end, you expressly enable the addition of the `,omitzero` json field tag by setting the top-level [config](https://gqlgen.com/config/) field `enable_model_json_omitzero_tag` to `true`: ### Examples enable_model_json_omitempty_tag default is false. With `enable_model_json_omitempty_tag: false`: ```go type OmitEmptyJSONTagTest struct { ValueNonNil string `json:"ValueNonNil" database:"OmitEmptyJsonTagTestValueNonNil"` Value *string `json:"Value" database:"OmitEmptyJsonTagTestValue"` } ``` With `enable_model_json_omitzero_tag: true`: ```go type OmitEmptyJSONTagTest struct { ValueNonNil string `json:"ValueNonNil" database:"OmitEmptyJsonTagTestValueNonNil"` Value *string `json:"Value,omitzero" database:"OmitEmptyJsonTagTestValue"` } ``` ================================================ FILE: docs/content/reference/name-collision.md ================================================ --- title: Handling type naming collisions description: Examples of logic used to avoid type name collision linkTitle: Name Collision menu: { main: { parent: 'reference', weight: 10 }} --- While most generated Golang types must have unique names by virtue of being based on their GraphQL `type` counterpart, which themselves must be unique, there are a few edge scenarios where conflicts can occur. This document describes how those collisions are handled. ## Enum Constants Enum type generation is a prime example of where naming collisions can occur, as we build the const names per value as a composite of the Enum name and each individual value. ### Example Problem Currently, enum types are transposed as such: ```graphql # graphql enum MyEnum { value1 value2 value3 value4 } ``` Which will result in the following Golang: ```go // golang type MyEnum string const ( MyEnumValue1 MyEnum = "value1" MyEnumValue2 MyEnum = "value2" MyEnumValue3 MyEnum = "value3" MyEnumValue4 MyEnum = "value4" ) ``` However, those above enum values are just strings. What if you encounter a scenario where the following is necessary: ```graphql # graphql enum MyEnum { value1 value2 value3 value4 Value4 Value_4 } ``` The `Value4` and `Value_4` enum values cannot be directly transposed into the same "pretty" naming convention as their resulting constant names would conflict with the name for `value4`, as so: ```go // golang type MyEnum string const ( MyEnumValue1 MyEnum = "value1" MyEnumValue2 MyEnum = "value2" MyEnumValue3 MyEnum = "value3" MyEnumValue4 MyEnum = "value4" MyEnumValue4 MyEnum = "Value4" MyEnumValue4 MyEnum = "Value_4" ) ``` Which immediately leads to compilation errors as we now have three constants with the same name, but different values. ### Resolution 1. Store each name generated as part of a run for later comparison 2. Try to coerce name into `CapitalCase`. Use if no conflicts. - This process attempts to break apart identifiers into "words", identified by separating on capital letters, underscores, hyphens, and spaces. - Each "word" is capitalized and appended to previous word. 3. If non-composite name, append integer to end of name, starting at 0 and going to `math.MaxInt` 4. If composite name, in reverse order, the pieces of the name have a less opinionated converter applied 5. If all else fails, append integer to end of name, starting at 0 and going to `math.MaxInt` The first step to produce a name that does not conflict with an existing name succeeds. ## Examples ### Example A GraphQL: ```graphql # graphql enum MyEnum { Value value TitleValue title_value } ``` Go: ```go // golang type MyEnum string const ( MyEnumValue MyEnum = "Value" MyEnumvalue MyEnum = "value" MyEnumTitleValue MyEnum = "TitleValue" MyEnumtitle_value MyEnum = "title_value" ) ``` ### Example B GraphQL: ```graphql # graphql enum MyEnum { TitleValue title_value title_Value Title_Value } ``` Go: ```go // golang type MyEnum string const ( MyEnumTitleValue MyEnum = "TitleValue" MyEnumtitle_value MyEnum = "title_value" MyEnumtitle_Value MyEnum = "title_Value" MyEnumTitle_Value MyEnum = "Title_Value" ) ``` ### Example C GraphQL: ```graphql # graphql enum MyEnum { value Value } ``` Go: ```go // golang type MyEnum string const ( MyEnumValue = "value" MyEnumValue0 = "Value" ) ``` ## Warning Name collision resolution is handled per-name, as they come in. If you change the order of an enum, you could very well end up with the same constant resolving to a different value. Lets mutate [Example C](#example-c): ### Example C - State A GraphQL: ```graphql # graphql enum MyEnum { value Value } ``` Go: ```go // golang type MyEnum string const ( MyEnumValue = "value" MyEnumValue0 = "Value" ) ``` ### Example C - State B GraphQL: ```graphql # graphql enum MyEnum { Value value } ``` Go: ```go // golang type MyEnum string const ( MyEnumValue = "Value" MyEnumValue0 = "value" ) ``` Notice how the constant names are the same, but the value that each applies to has changed. ================================================ FILE: docs/content/reference/plugins.md ================================================ --- linkTitle: Plugins title: How to write plugins for gqlgen description: Use plugins to customize code generation and integrate with other libraries menu: { main: { parent: "reference", weight: 10 } } --- Plugins provide a way to hook into the gqlgen code generation lifecycle. In order to use anything other than the default plugins you will need to create your own entrypoint: ## Using a plugin To use a plugin during code generation, you need to create a new entry point. Create `generate.go` in the same folder as `resolver.go` with the following code: ```go // go:build ignore package main import ( "flag" "fmt" "io" "log" "os" "time" "github.com/99designs/gqlgen/api" "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/plugin/stubgen" ) func main() { cfg, err := config.LoadConfigFromDefaultLocations() if err != nil { fmt.Fprintln(os.Stderr, "failed to load config", err.Error()) os.Exit(2) } err = api.Generate(cfg, api.AddPlugin(yourplugin.New()), // This is the magic line ) if err != nil { fmt.Fprintln(os.Stderr, err.Error()) os.Exit(3) } } ``` In `resolver.go`, add `//go:generate go run generate.go` (or replace `//go:generate go tool gqlgen` if you have it there). Now you can run `go generate ./...` to generate code using your plugin. ## Writing a plugin There are currently only two hooks: - MutateConfig: Allows a plugin to mutate the config before codegen starts. This allows plugins to add custom directives, define types, and implement resolvers. see [modelgen](https://github.com/99designs/gqlgen/tree/master/plugin/modelgen) for an example - GenerateCode: Allows a plugin to generate a new output file, see [stubgen](https://github.com/99designs/gqlgen/tree/master/plugin/stubgen) for an example Take a look at [plugin.go](https://github.com/99designs/gqlgen/blob/master/plugin/plugin.go) for the full list of available hooks. These are likely to change with each release. ================================================ FILE: docs/content/reference/resolvers.md ================================================ --- linkTitle: Resolvers title: Resolving graphQL requests description: Different ways of binding graphQL requests to resolvers menu: { main: { parent: 'reference', weight: 10 } } --- There are multiple ways that a graphQL type can be bound to a Go struct that allows for many usecases. ## Bind directly to struct field names This is the most common use case where the names of the fields on the Go struct match the names of the fields in the graphQL type. If a Go struct field is unexported, it will not be bound to the graphQL type. ```go type Car struct { Make string Model string Color string OdometerReading int } ``` And then in your graphQL schema: ```graphql type Car { make: String! model: String! color: String! odometerReading: Int! } ``` And in the gqlgen config file: ```yaml models: Car: model: github.com/my/app/models.Car ``` In this case, each field in the graphQL type will be bound to the respective field on the go struct ignoring the case of the fields ## Bind to a method name This is also very common use case that comes up where we want to bind a graphQL field to a Go struct method ```go type Person struct { Name string } type Car struct { Make string Model string Color string OwnerID *string OdometerReading int } func (c *Car) Owner() (*Person) { // get the car owner //.... return owner } ``` And then in your graphQL schema: ```graphql type Car { make: String! model: String! color: String! odometerReading: Int! owner: Person } ``` And in the gqlgen config file: ```yaml models: Car: model: github.com/my/app/models.Car Person: model: github.com/my/app/models.Person ``` Here, we see that there is a method on car with the name ```Owner```, thus the ```Owner``` function will be called if a graphQL request includes that field to be resolved. Model methods can optionally take a context as their first argument. If a context is required, the model method will also be run in parallel. ## Bind when the field names do not match There are two ways you can bind to fields when the Go struct and the graphQL type do not match. The first way is you can bind resolvers to a struct based off of struct tags like the following: ```go type Car struct { Make string ShortState string LongState string `gqlgen:"state"` Model string Color string OdometerReading int } ``` And then in your graphQL schema: ```graphql type Car { make: String! model: String! state: String! color: String! odometerReading: Int! } ``` And in the gqlgen config file add the line: ```yaml struct_tag: gqlgen models: Car: model: github.com/my/app/models.Car ``` Here even though the graphQL type and Go struct have different field names, there is a Go struct tag field on ```longState``` that matches and thus ```state``` will be bound to ```LongState```. The second way you can bind fields is by adding a line into the config file such as: ```go type Car struct { Make string ShortState string LongState string Model string Color string OdometerReading int } ``` And then in your graphQL schema: ```graphql type Car { make: String! model: String! state: String! color: String! odometerReading: Int! } ``` And in the gqlgen config file add the line: ```yaml models: Car: model: github.com/my/app/models.Car fields: state: fieldName: LongState ``` ## Binding to Anonymous or Embedded Structs All of the rules from above apply to a struct that has an embedded struct. Here is an example ```go type Truck struct { Car Is4x4 bool } type Car struct { Make string ShortState string LongState string Model string Color string OdometerReading int } ``` And then in your graphQL schema: ```graphql type Truck { make: String! model: String! state: String! color: String! odometerReading: Int! is4x4: Bool! } ``` Here all the fields from the Go struct Car will still be bound to the respective fields in the graphQL schema that match Embedded structs are a good way to create thin wrappers around data access types an example would be: ```go type Cat struct { db.Cat //... } func (c *Cat) ID() string { // return a custom id based on the db shard and the cat's id return fmt.Sprintf("%d:%d", c.Shard, c.Id) } ``` Which would correlate with a gqlgen config file of: ```yaml models: Cat: model: github.com/my/app/models.Cat ``` ## Binding Priority If a ```struct_tags``` config exists, then struct tag binding has the highest priority over all other types of binding. In all other cases, the first Go struct field found that matches the graphQL type field will be the field that is bound. ================================================ FILE: docs/content/reference/scalars.md ================================================ --- linkTitle: Scalars title: Mapping GraphQL scalar types to Go types description: Mapping GraphQL scalar types to Go types menu: { main: { parent: "reference", weight: 10 } } --- ## Built-in helpers gqlgen ships with some built-in helpers for common custom scalar use-cases, `Int64`, `Time`, `Any`, `Upload` and `Map`. Adding any of these to a schema will automatically add the marshalling behaviour to Go types. ### Int64 Since the GraphQL spec identifies `Int` as a signed 32-bit integer, gqlgen provides an `Int64` scalar to represent 64-bit integers. Anywhere you want to use a Go `int` and not deal with overflows, use `Int64` in your schema. ```graphql scalar Int64 ``` ### Time ```graphql scalar Time ``` Maps a `Time` GraphQL scalar to a Go `time.Time` struct. This scalar adheres to the [time.RFC3339Nano](https://pkg.go.dev/time#pkg-constants) format. ### Universally Unique Identifier (UUID) ```graphql scalar UUID ``` This maps a `UUID` scalar value to a `uuid.UUID` type. If you add to gqlgen.yml: ```yaml models: UUID: model: - github.com/99designs/gqlgen/graphql.UUID ``` And then add `scalar UUID` to `schema.graphql` See the _examples/uuid package for more examples. ### Map ```graphql scalar Map ``` Maps an arbitrary GraphQL value to a `map[string]interface{}` Go type. ### Upload ```graphql scalar Upload ``` Maps a `Upload` GraphQL scalar to a `graphql.Upload` struct, defined as follows: ```go type Upload struct { File io.ReadSeeker Filename string Size int64 ContentType string } ``` ### Any ```graphql scalar Any ``` Maps an arbitrary GraphQL value to a `interface{}` Go type. ### Duration ```graphql scalar Duration ``` This maps a `Duration` scalar value conforming to the [`ISO8601`](https://en.wikipedia.org/wiki/ISO_8601#Durations) standard `PnDTnHnMn.nS` format (ex.: `P1Y2D` or `PT15M`) to a `time.Duration` type. If you add to gqlgen.yml: ```yaml models: Duration: model: - github.com/99designs/gqlgen/graphql.Duration ``` And then add `scalar Duration` to `schema.graphql` ## Custom scalars with user defined types For user defined types you can implement the [graphql.Marshaler](https://pkg.go.dev/github.com/99designs/gqlgen/graphql#Marshaler) and [graphql.Unmarshaler](https://pkg.go.dev/github.com/99designs/gqlgen/graphql#Unmarshaler) or implement the [graphql.ContextMarshaler](https://pkg.go.dev/github.com/99designs/gqlgen/graphql#ContextMarshaler) and [graphql.ContextUnmarshaler](https://pkg.go.dev/github.com/99designs/gqlgen/graphql#ContextUnmarshaler) interfaces and they will be called. ```go package mypkg import ( "context" "fmt" "io" "strconv" ) // // Most common scalars // type YesNo bool // UnmarshalGQL implements the graphql.Unmarshaler interface func (y *YesNo) UnmarshalGQL(v interface{}) error { yes, ok := v.(string) if !ok { return fmt.Errorf("YesNo must be a string") } if yes == "yes" { *y = true } else { *y = false } return nil } // MarshalGQL implements the graphql.Marshaler interface func (y YesNo) MarshalGQL(w io.Writer) { if y { w.Write([]byte(`"yes"`)) } else { w.Write([]byte(`"no"`)) } } // // Scalars that need access to the request context // type Length float64 // UnmarshalGQLContext implements the graphql.ContextUnmarshaler interface func (l *Length) UnmarshalGQLContext(ctx context.Context, v interface{}) error { s, ok := v.(string) if !ok { return fmt.Errorf("Length must be a string") } length, err := ParseLength(s) if err != nil { return err } *l = length return nil } // MarshalGQLContext implements the graphql.ContextMarshaler interface func (l Length) MarshalGQLContext(ctx context.Context, w io.Writer) error { s, err := l.FormatContext(ctx) if err != nil { return err } w.Write([]byte(strconv.Quote(s))) return nil } // ParseLength parses a length measurement string with unit on the end (eg: "12.45in") func ParseLength(string) (Length, error) // ParseLength formats the string using a value in the context to specify format func (l Length) FormatContext(ctx context.Context) (string, error) ``` and then wire up the type in `.gqlgen.yml` or via directives like normal: ```yaml models: YesNo: model: github.com/me/mypkg.YesNo ``` ## Custom scalars with third party types Sometimes you are unable to add methods to a type — perhaps you don't own the type, or it is part of the standard library (eg `string` or `time.Time`). To support this we can build an external marshaler: ```go package mypkg import ( "fmt" "io" "strings" "github.com/99designs/gqlgen/graphql" ) func MarshalMyCustomBooleanScalar(b bool) graphql.Marshaler { return graphql.WriterFunc(func(w io.Writer) { if b { w.Write([]byte("true")) } else { w.Write([]byte("false")) } }) } func UnmarshalMyCustomBooleanScalar(v interface{}) (bool, error) { switch v := v.(type) { case string: return "true" == strings.ToLower(v), nil case int: return v != 0, nil case bool: return v, nil default: return false, fmt.Errorf("%T is not a bool", v) } } ``` Then in `.gqlgen.yml` point to the name without the Marshal|Unmarshal in front: ```yaml models: MyCustomBooleanScalar: model: github.com/me/mypkg.MyCustomBooleanScalar ``` **Note:** You also can (un)marshal to pointer types via this approach, simply accept a pointer in your `Marshal...` func and return one in your `Unmarshal...` func. **Note:** You can also (un)marshal with a context by having your custom marshal function return a `graphql.ContextMarshaler` _and_ your unmarshal function take a `context.Context` as the first argument. See the [_examples/scalars](https://github.com/99designs/gqlgen/tree/master/_examples/scalars) package for more examples. ## Marshaling/Unmarshaling Errors The errors that occur as part of custom scalar marshaling/unmarshaling will return a full path to the field. For example, given the following schema: ```graphql extend type Mutation{ updateUser(userInput: UserInput!): User! } input UserInput { name: String! primaryContactDetails: ContactDetailsInput! secondaryContactDetails: ContactDetailsInput! } scalar Email input ContactDetailsInput { email: Email! } ``` ... and the following variables: ```json { "userInput": { "name": "George", "primaryContactDetails": { "email": "not-an-email" }, "secondaryContactDetails": { "email": "george@gmail.com" } } } ``` ... and an unmarshal function that returns an error if the email is invalid. The mutation will return an error containing the full path: ```json { "message": "email invalid", "path": [ "updateUser", "userInput", "primaryContactDetails", "email" ] } ``` **Note:** Marshaling errors can only be returned when using the `graphql.ContextMarshaler` style interface. ================================================ FILE: docs/layouts/404.html ================================================ {{ define "main" }}

Page not found

I'm sorry, but the requested page wasn’t found on the server. {{ end }} ================================================ FILE: docs/layouts/_default/baseof.html ================================================ {{- if .Params.description }} {{- else }} {{- end }} {{ if not .IsHome }}{{ .Title }} —{{ end }} {{ .Site.Title }} {{ partial "version-switcher" . }} {{ partial "sidebar" . }} {{ block "main" . }}{{ end }} ================================================ FILE: docs/layouts/_default/single.html ================================================ {{ define "main" }}

{{ .LinkTitle }}

{{ .Title }}
[edit]
{{partial "version-banner"}} {{ .Content }}
{{ end }} ================================================ FILE: docs/layouts/index.html ================================================ {{ define "main" }} {{ range where .Site.Pages "Type" "homepage" }}
{{ .Description }}

{{ .LinkTitle }}

{{ .Title }}
{{partial "version-banner"}} {{ .Content }} {{.Scratch.Set "intro" (readFile "content/_introduction.md")}} {{.Scratch.Set "intro" (split (.Scratch.Get "intro") "\n")}} {{.Scratch.Set "intro" (after 2 (.Scratch.Get "intro"))}} {{.Scratch.Set "intro" (delimit (.Scratch.Get "intro") "\n")}} {{.Scratch.Get "intro"|markdownify}}
{{ end }} {{ end }} ================================================ FILE: docs/layouts/partials/sidebar.html ================================================ ================================================ FILE: docs/layouts/partials/version-banner.html ================================================ {{ $currentVersion := getenv "CURRENT_VERSION" }} {{ $versionString := getenv "VERSIONS" }} {{ $versions := split $versionString "," }} {{ $latestVersion := index $versions 0 }} {{ if (eq $currentVersion "master") }}
You are looking at the docs for the unreleased master branch. The latest version is {{ $latestVersion }}.
{{ else if not (eq $latestVersion $currentVersion) }}
You are looking at the docs for an older version ({{ $currentVersion }}). The latest version is {{ $latestVersion }}.
{{ end }} ================================================ FILE: docs/layouts/partials/version-switcher.html ================================================ {{ $VersionString := getenv "VERSIONS" }} {{ $Versions := split $VersionString "," }} {{ $currentVersion := getenv "CURRENT_VERSION" }}
{{ $currentVersion }}
{{$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}}
Altair
`)) // 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,}.*`, ) // <meta> element must be in <head> and before <title> if !wantMetaCharsetElement.Match(b) { t.Errorf("no match for %s in response body", wantMetaCharsetElement.String()) } } func TestHandler_createsRelativeURLs(t *testing.T) { rec := httptest.NewRecorder() req := httptest.NewRequest(http.MethodGet, "http://localhost:8080/query", 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<Name>() methods to interface and unions # omit_interface_checks: true # Optional: turn on to skip generation of ComplexityRoot struct content and Complexity function # omit_complexity: false # Optional: turn on to not generate any file notice comments in generated files # omit_gqlgen_file_notice: false # Optional: turn on to exclude the gqlgen version in the generated file notice. No effect if `omit_gqlgen_file_notice` is true. # omit_gqlgen_version_in_file_notice: false # Optional: turn 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<ApolloLink.Result> { return new Observable((sink) => { return this.client.subscribe<ApolloLink.Result>( {...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<any, any>> = TDocumentType extends DocumentTypeDecoration< infer TType, any > ? [TType] extends [{ ' $fragmentName'?: infer TKey }] ? TKey extends string ? { ' $fragmentRefs'?: { [key in TKey]: TType } } : never : never : never; // return non-nullable if `fragmentType` is non-nullable export function useFragment<TType>( _documentNode: DocumentTypeDecoration<TType, any>, fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> ): TType; // return nullable if `fragmentType` is undefined export function useFragment<TType>( _documentNode: DocumentTypeDecoration<TType, any>, fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | undefined ): TType | undefined; // return nullable if `fragmentType` is nullable export function useFragment<TType>( _documentNode: DocumentTypeDecoration<TType, any>, fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null ): TType | null; // return nullable if `fragmentType` is nullable or undefined export function useFragment<TType>( _documentNode: DocumentTypeDecoration<TType, any>, fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null | undefined ): TType | null | undefined; // return array of non-nullable if `fragmentType` is array of non-nullable export function useFragment<TType>( _documentNode: DocumentTypeDecoration<TType, any>, fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>>> ): Array<TType>; // return array of nullable if `fragmentType` is array of nullable export function useFragment<TType>( _documentNode: DocumentTypeDecoration<TType, any>, fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined ): Array<TType> | null | undefined; // return readonly array of non-nullable if `fragmentType` is array of non-nullable export function useFragment<TType>( _documentNode: DocumentTypeDecoration<TType, any>, fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> ): ReadonlyArray<TType>; // return readonly array of nullable if `fragmentType` is array of nullable export function useFragment<TType>( _documentNode: DocumentTypeDecoration<TType, any>, fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined ): ReadonlyArray<TType> | null | undefined; export function useFragment<TType>( _documentNode: DocumentTypeDecoration<TType, any>, fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | Array<FragmentType<DocumentTypeDecoration<TType, any>>> | ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined ): TType | Array<TType> | ReadonlyArray<TType> | null | undefined { return fragmentType as any; } export function makeFragmentData< F extends DocumentTypeDecoration<any, any>, FT extends ResultOf<F> >(data: FT, _fragment: F): FragmentType<F> { return data as FragmentType<F>; } export function isFragmentReady<TQuery, TFrag>( queryNode: DocumentTypeDecoration<TQuery, any>, fragmentNode: TypedDocumentNode<TFrag>, data: FragmentType<TypedDocumentNode<Incremental<TFrag>, any>> | null | undefined ): data is FragmentType<typeof fragmentNode> { const deferredFields = (queryNode as { __meta__?: { deferredFields: Record<string, (keyof TFrag)[]> } }).__meta__ ?.deferredFields; if (!deferredFields) return true; const fragDef = fragmentNode.definitions[0] as FragmentDefinitionNode | undefined; const fragName = fragDef?.name?.value; const fields = (fragName && deferredFields[fragName]) || []; return fields.length > 0 && fields.every(field => data && field in data); } ================================================ 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<any, any>> = 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> = T | null; export type InputMaybe<T> = T | null | undefined; export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] }; export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> }; export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> }; export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never }; export type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; /** All built-in and custom scalars, mapped to their actual values */ export type Scalars = { ID: { input: string; output: string; } String: { input: string; output: string; } Boolean: { input: boolean; output: boolean; } Int: { input: number; output: number; } Float: { input: number; output: number; } Map: { input: any; output: any; } }; export enum Date_Filter_Op { Eq = 'EQ', Gt = 'GT', Gte = 'GTE', Lt = 'LT', Lte = 'LTE', Neq = 'NEQ' } export type DateFilter = { op?: InputMaybe<Date_Filter_Op>; timezone?: InputMaybe<Scalars['String']['input']>; value: Scalars['String']['input']; }; export type Element = { __typename?: 'Element'; child: Element; error: Scalars['Boolean']['output']; mismatched?: Maybe<Array<Scalars['Boolean']['output']>>; }; export enum ErrorType { Custom = 'CUSTOM', Normal = 'NORMAL' } export type ListCoercion = { enumVal?: InputMaybe<Array<InputMaybe<ErrorType>>>; intVal?: InputMaybe<Array<InputMaybe<Scalars['Int']['input']>>>; scalarVal?: InputMaybe<Array<InputMaybe<Scalars['Map']['input']>>>; strVal?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>; }; export type Query = { __typename?: 'Query'; coercion: Scalars['Boolean']['output']; complexity: Scalars['Boolean']['output']; date: Scalars['Boolean']['output']; error: Scalars['Boolean']['output']; jsonEncoding: Scalars['String']['output']; path?: Maybe<Array<Maybe<Element>>>; viewer?: Maybe<Viewer>; }; export type QueryCoercionArgs = { value?: InputMaybe<Array<ListCoercion>>; }; export type QueryComplexityArgs = { value: Scalars['Int']['input']; }; export type QueryDateArgs = { filter: DateFilter; }; export type QueryErrorArgs = { type?: InputMaybe<ErrorType>; }; export type RemoteModelWithOmitempty = { __typename?: 'RemoteModelWithOmitempty'; newDesc?: Maybe<Scalars['String']['output']>; }; export type User = { __typename?: 'User'; likes: Array<Scalars['String']['output']>; name: Scalars['String']['output']; /** @deprecated No longer supported */ phoneNumber?: Maybe<Scalars['String']['output']>; query: Query; }; export type Viewer = { __typename?: 'Viewer'; user?: Maybe<User>; }; export type CoercionQueryVariables = Exact<{ value?: InputMaybe<Array<ListCoercion> | ListCoercion>; }>; export type CoercionQuery = { __typename?: 'Query', coercion: boolean }; export type ComplexityQueryVariables = Exact<{ value: Scalars['Int']['input']; }>; export type ComplexityQuery = { __typename?: 'Query', complexity: boolean }; export type DateQueryVariables = Exact<{ filter: DateFilter; }>; export type DateQuery = { __typename?: 'Query', date: boolean }; export type ErrorQueryVariables = Exact<{ type?: InputMaybe<ErrorType>; }>; export type ErrorQuery = { __typename?: 'Query', error: boolean }; export type JsonEncodingQueryVariables = Exact<{ [key: string]: never; }>; export type JsonEncodingQuery = { __typename?: 'Query', jsonEncoding: string }; export type PathQueryVariables = Exact<{ [key: string]: never; }>; export type PathQuery = { __typename?: 'Query', path?: Array<{ __typename?: 'Element', cc: { __typename?: 'Element', error: boolean } } | null> | null }; export type ViewerQueryVariables = Exact<{ [key: string]: never; }>; export type ViewerQuery = { __typename?: 'Query', viewer?: { __typename?: 'Viewer', user?: { __typename?: 'User', name: string, phoneNumber?: string | null, query: { __typename?: 'Query', jsonEncoding: string } } & ( { __typename?: 'User' } & { ' $fragmentRefs'?: { 'UserFragmentFragment': Incremental<UserFragmentFragment> } } ) | null } | null }; export type UserFragmentFragment = { __typename?: 'User', likes: Array<string> } & { ' $fragmentName'?: 'UserFragmentFragment' }; export const UserFragmentFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"userFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"User"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"likes"}}]}}]} as unknown as DocumentNode<UserFragmentFragment, unknown>; export const CoercionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"coercion"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"value"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ListCoercion"}}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"coercion"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"value"},"value":{"kind":"Variable","name":{"kind":"Name","value":"value"}}}]}]}}]} as unknown as DocumentNode<CoercionQuery, CoercionQueryVariables>; export const ComplexityDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"complexity"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"value"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"complexity"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"value"},"value":{"kind":"Variable","name":{"kind":"Name","value":"value"}}}]}]}}]} as unknown as DocumentNode<ComplexityQuery, ComplexityQueryVariables>; export const DateDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"date"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"filter"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"DateFilter"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"date"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"filter"},"value":{"kind":"Variable","name":{"kind":"Name","value":"filter"}}}]}]}}]} as unknown as DocumentNode<DateQuery, DateQueryVariables>; export const ErrorDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"error"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"type"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"ErrorType"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"error"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"type"},"value":{"kind":"Variable","name":{"kind":"Name","value":"type"}}}]}]}}]} as unknown as DocumentNode<ErrorQuery, ErrorQueryVariables>; export const JsonEncodingDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"jsonEncoding"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"jsonEncoding"}}]}}]} as unknown as DocumentNode<JsonEncodingQuery, JsonEncodingQueryVariables>; export const PathDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"path"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"path"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"cc"},"name":{"kind":"Name","value":"child"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"error"}}]}}]}}]}}]} as unknown as DocumentNode<PathQuery, PathQueryVariables>; export const ViewerDocument = {"__meta__":{"deferredFields":{"userFragment":["likes"]}},"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"viewer"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"viewer"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"phoneNumber"}},{"kind":"Field","name":{"kind":"Name","value":"query"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"jsonEncoding"}}]}},{"kind":"FragmentSpread","name":{"kind":"Name","value":"userFragment"},"directives":[{"kind":"Directive","name":{"kind":"Name","value":"defer"}}]}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"userFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"User"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"likes"}}]}}]} as unknown as DocumentNode<ViewerQuery, ViewerQueryVariables>; ================================================ 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<capacity", func(t *testing.T) { prefix := make([]string, 0, 2) prefix = append(prefix, "prefix") fieldSet := New("foo bar{id}", prefix) require.Len(t, fieldSet, 2) t.Log(fieldSet) require.Len(t, fieldSet[0], 2) require.Equal(t, "prefix", fieldSet[0][0]) require.Equal(t, "foo", fieldSet[0][1]) require.Len(t, fieldSet[1], 3) require.Equal(t, "prefix", fieldSet[1][0]) require.Equal(t, "bar", fieldSet[1][1]) require.Equal(t, "id", fieldSet[1][2]) }) } func TestHandlesRequiresFieldWithArgument(t *testing.T) { obj := &codegen.Object{ Fields: []*codegen.Field{ { FieldDefinition: &ast.FieldDefinition{ Name: "foo(limit:4) { bar }", }, TypeReference: nil, GoFieldType: 0, GoReceiverName: "", GoFieldName: "", IsResolver: false, Args: nil, MethodHasContext: false, NoErr: false, VOkFunc: false, Object: nil, Default: nil, Stream: false, Directives: nil, }, }, Implements: nil, } require.NotNil(t, fieldByName(obj, "foo")) } func TestInvalid(t *testing.T) { require.Panics(t, func() { New("foo bar{baz", nil) }) } func TestToGo(t *testing.T) { require.Equal(t, "Foo", Field{"foo"}.ToGo()) require.Equal(t, "FooBar", Field{"foo", "bar"}.ToGo()) require.Equal(t, "BarID", Field{"bar", "id"}.ToGo()) } func TestToGoPrivate(t *testing.T) { require.Equal(t, "foo", Field{"foo"}.ToGoPrivate()) require.Equal(t, "fooBar", Field{"foo", "bar"}.ToGoPrivate()) require.Equal(t, "barID", Field{"bar", "id"}.ToGoPrivate()) } ================================================ FILE: plugin/federation/readme.md ================================================ # Federation plugin Add support for graphql federation in your graphql Go server! TODO(miguel): add details. # Tests There are several different tests. Some will process the configuration file directly. You can see those in the `federation_test.go`. There are also tests for entity resolvers, which will simulate requests from a federation server like Apollo Federation. Running entity resolver tests. 1. Go to `plugin/federation` 2. Run the command `go generate` 3. Run the tests with `go test ./...`. # Architecture TODO(miguel): add details. # Entity resolvers - GetMany entities The federation plugin implements `GetMany` semantics in which entity resolvers get the entire list of representations that need to be resolved. This functionality is currently option tho, and to enable it you need to specify the directive `@entityResolver` in the federated entity you want this feature for. E.g. ``` directive @entityResolver(multi: Boolean) on OBJECT type MultiHello @key(fields: "name") @entityResolver(multi: true) { name: String! } ``` That allows the federation plugin to generate `GetMany` resolver function that can take a list of representations to be resolved. From that entity type, the resolver function would be ``` func (r *entityResolver) FindManyMultiHellosByName(ctx context.Context, reps []*generated.ManyMultiHellosByNameInput) ([]*generated.MultiHello, error) { /// <Your code to resolve the list of items> } ``` **Note:** If you are using `omit_slice_element_pointers: true` option in your config yaml, your `GetMany` resolver will still generate in the example above the same signature `FindManyMultiHellosByName(ctx context.Context, reps []*generated.ManyMultiHellosByNameInput) ([]*generated.MultiHello, error)`. But all other instances will continue to honor `omit_slice_element_pointers: true` ================================================ 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()) }