Repository: go-park-mail-ru/lectures Branch: master Commit: ba3aaf243a75 Files: 487 Total size: 1.8 MB Directory structure: gitextract_cnldqe8r/ ├── .gitignore ├── .gitmodules ├── 1-basics/ │ ├── 1_basics/ │ │ ├── 01_vars_1/ │ │ │ └── 01_vars_1.go │ │ ├── 02_vars_2/ │ │ │ └── 02_vars_2.go │ │ ├── 03_const/ │ │ │ └── 03_const.go │ │ ├── 04_pointers/ │ │ │ └── 04_pointers.go │ │ ├── 05_array/ │ │ │ └── 05_array.go │ │ ├── 06_slice_1/ │ │ │ └── 06_slice_1.go │ │ ├── 07_slice_2/ │ │ │ └── 07_slice_2.go │ │ ├── 08_strings/ │ │ │ └── 08_strings.go │ │ ├── 09_map/ │ │ │ └── 09_map.go │ │ ├── 10_control/ │ │ │ └── 10_control.go │ │ ├── 11_loop/ │ │ │ └── 11_loop.go │ │ ├── 12_types/ │ │ │ └── 12_types.go │ │ └── 13_generic/ │ │ ├── 1_generic/ │ │ │ └── main.go │ │ └── 2_methods/ │ │ └── methods.go │ ├── 2_functions/ │ │ ├── 1_functions/ │ │ │ └── 1_functions.go │ │ ├── 2_firstclass/ │ │ │ └── 2_firstclass.go │ │ ├── 3_defer/ │ │ │ └── 3_defer.go │ │ └── 4_recover/ │ │ └── 4_recover.go │ ├── 3_structs/ │ │ ├── 1_structs/ │ │ │ └── 1_structs.go │ │ └── 2_methods/ │ │ └── 2_methods.go │ ├── 4_interfaces/ │ │ ├── 1.2_basic_sort/ │ │ │ └── 1_sort.go │ │ ├── 1_basic/ │ │ │ └── 1_basic.go │ │ ├── 2_many/ │ │ │ └── 2_many.go │ │ ├── 3_embed/ │ │ │ └── 3_embed.go │ │ ├── 4_cast/ │ │ │ └── 4_cast.go │ │ ├── 5_empty_1/ │ │ │ └── 5_empty_1.go │ │ └── 6_empty_2/ │ │ └── 6_empty_2.go │ ├── 5_visibility/ │ │ ├── dir.txt │ │ ├── main.go │ │ └── person/ │ │ ├── func.go │ │ └── person.go │ ├── 6_uniq/ │ │ ├── basic/ │ │ │ ├── data.txt │ │ │ ├── data_bad.txt │ │ │ ├── data_map.txt │ │ │ └── main.go │ │ └── with_tests/ │ │ ├── data.txt │ │ ├── data_bad.txt │ │ ├── data_map.txt │ │ ├── main.go │ │ └── main_test.go │ ├── go-intro.key │ ├── homework/ │ │ └── readme.md │ └── readme.md ├── 10-performance/ │ ├── 1_reflect/ │ │ ├── 1_print/ │ │ │ └── reflect_1.go │ │ └── 2_unpack/ │ │ └── reflect_2.go │ ├── 2_codegen/ │ │ ├── gen/ │ │ │ └── codegen.go │ │ └── pack/ │ │ ├── marshaller.go │ │ └── unpack.go │ ├── 3_perfomance_1/ │ │ ├── 1_unpack/ │ │ │ └── unpack_test.go │ │ ├── 2_prealloc/ │ │ │ └── prealloc_test.go │ │ ├── 3_pool/ │ │ │ └── pool_test.go │ │ ├── 4_string/ │ │ │ └── string_test.go │ │ └── 5_json/ │ │ ├── json_test.go │ │ ├── struct.go │ │ └── struct_easyjson.go │ ├── 4_perfomance_2/ │ │ ├── 1_optimize/ │ │ │ ├── pprof_1.go │ │ │ └── pprof_1.sh │ │ ├── 2_leak_grtn/ │ │ │ ├── pprof_2.go │ │ │ └── pprof_2.sh │ │ ├── 3_tracing/ │ │ │ └── tracing.go │ │ └── note.txt │ ├── 5_testing/ │ │ ├── cover.html │ │ ├── coverage_test.go │ │ └── main.go │ ├── 6_xml_stream/ │ │ ├── main.go │ │ └── xml_test.go │ ├── 7_inline_escape/ │ │ └── main.go │ ├── 8_cgo/ │ │ ├── 1_example/ │ │ │ └── main.go │ │ ├── 2_performance/ │ │ │ └── main.go │ │ ├── 3_usage/ │ │ │ ├── README.md │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── main.go │ │ └── README.md │ └── readme.md ├── 2-async/ │ ├── 0_basic_error_handling/ │ │ ├── 1_ignore_errors/ │ │ │ └── main.go │ │ ├── 2_panic/ │ │ │ └── main.go │ │ ├── 3_handling/ │ │ │ └── main.go │ │ └── 4_return/ │ │ └── main.go │ ├── 1_async/ │ │ ├── 10_context_cancel/ │ │ │ └── context_cancel.go │ │ ├── 10_context_timeout/ │ │ │ ├── context_parent/ │ │ │ │ └── main.go │ │ │ └── context_timeout.go │ │ ├── 11_errgroup_1/ │ │ │ └── errgroup_1.go │ │ ├── 11_errgroup_2/ │ │ │ └── errgroup_2.go │ │ ├── 12_atomic_1/ │ │ │ └── atomic_1.go │ │ ├── 12_atomic_2/ │ │ │ ├── atomic_2.go │ │ │ └── with_bench/ │ │ │ └── mutex_test.go │ │ ├── 13_ratelim/ │ │ │ └── ratelim.go │ │ ├── 14_once/ │ │ │ └── once.go │ │ ├── 1_goroutines/ │ │ │ ├── goroutines.go │ │ │ ├── i_ptr/ │ │ │ │ └── main.go │ │ │ └── mem/ │ │ │ └── main.go │ │ ├── 1_goroutines_2/ │ │ │ └── goroutines.go │ │ ├── 2_chan/ │ │ │ └── chan_1.go │ │ ├── 2_chan_2/ │ │ │ └── chan_2.go │ │ ├── 3_workerpool/ │ │ │ ├── 1_workerpool.go │ │ │ └── 2_workerpool_reusable.go │ │ ├── 4_race_1/ │ │ │ └── race_1.go │ │ ├── 4_race_2/ │ │ │ ├── race_2.go │ │ │ └── race_flag/ │ │ │ └── working_race.go │ │ ├── 4_race_3/ │ │ │ └── race_3.go │ │ ├── 4_race_3_bench/ │ │ │ └── race_test.go │ │ ├── 5_tick/ │ │ │ └── tick.go │ │ ├── 5_tick_example/ │ │ │ ├── 5_ping_pong/ │ │ │ │ └── main.go │ │ │ └── main.go │ │ ├── 6_afterfunc/ │ │ │ └── afterfunc.go │ │ ├── 7_select_1/ │ │ │ └── select_1.go │ │ ├── 7_select_2/ │ │ │ └── select_2.go │ │ ├── 7_select_2_new/ │ │ │ ├── close_buff/ │ │ │ │ └── main.go │ │ │ └── select_2_new.go │ │ ├── 7_select_3/ │ │ │ ├── close_all/ │ │ │ │ └── main.go │ │ │ ├── close_signal/ │ │ │ │ └── main.go │ │ │ └── select_3.go │ │ ├── 8_wait_1/ │ │ │ └── wait_1.go │ │ ├── 8_wait_2/ │ │ │ ├── ping_pong/ │ │ │ │ └── main.go │ │ │ └── wait_2.go │ │ ├── 8_wait_3/ │ │ │ └── wait_3.go │ │ └── 9_timeout/ │ │ └── timeout.go │ └── readings_2.md ├── 3-web/ │ ├── 0_json/ │ │ ├── 0_simple_json/ │ │ │ └── simple_json.go │ │ ├── 1_struct_tags/ │ │ │ └── struct_tags.go │ │ ├── 2_custom/ │ │ │ └── custom.go │ │ └── 3_dynamic/ │ │ └── dynamic.go │ ├── 1_net/ │ │ └── net_listen.go │ ├── 2_http/ │ │ ├── 0_http_server/ │ │ │ ├── 0_basic/ │ │ │ │ └── basic.go │ │ │ ├── 1_pages/ │ │ │ │ └── pages.go │ │ │ ├── 2_servehttp/ │ │ │ │ └── servehttp.go │ │ │ ├── 3_mux/ │ │ │ │ └── mux.go │ │ │ └── 4_servers/ │ │ │ └── servers.go │ │ ├── 1_request/ │ │ │ ├── 0_get/ │ │ │ │ └── get.go │ │ │ ├── 1_post/ │ │ │ │ └── post.go │ │ │ ├── 2_cookies/ │ │ │ │ └── cookies.go │ │ │ └── 3_headers/ │ │ │ └── headers.go │ │ ├── 2_http_client/ │ │ │ └── client.go │ │ ├── 3_files/ │ │ │ ├── 0_file_upload/ │ │ │ │ └── file_upload.go │ │ │ └── 1_static/ │ │ │ ├── static/ │ │ │ │ └── super_secret_password │ │ │ └── static.go │ │ └── 4_httptest/ │ │ ├── 0_client/ │ │ │ └── client_test.go │ │ └── 1_server/ │ │ └── server_test.go │ ├── 3_template/ │ │ ├── 0_inline/ │ │ │ └── inline.go │ │ ├── 1_file/ │ │ │ ├── file.go │ │ │ └── users.html │ │ ├── 2_func/ │ │ │ ├── func.go │ │ │ └── func.html │ │ └── 3_method/ │ │ ├── method.go │ │ └── method.html │ ├── 4_json_http/ │ │ ├── main.go │ │ └── main_test.go │ └── readings_3.md ├── 4-api/ │ ├── 1_rpc/ │ │ ├── jsonrpc/ │ │ │ ├── books.go │ │ │ └── server.go │ │ ├── main.go │ │ └── net-rpc/ │ │ ├── books.go │ │ ├── client.go │ │ └── server.go │ ├── 2_rest/ │ │ ├── books.go │ │ └── main.go │ ├── 3_graphql/ │ │ ├── gqlgen/ │ │ │ ├── generated.go │ │ │ ├── gqlgen.yml │ │ │ ├── models_gen.go │ │ │ ├── resolver.go │ │ │ ├── schema.graphql │ │ │ └── server/ │ │ │ └── server.go │ │ ├── gqlgen_full/ │ │ │ ├── gqlgen1/ │ │ │ │ ├── generated.go │ │ │ │ ├── go.mod │ │ │ │ ├── go.sum │ │ │ │ ├── gqlgen.yml │ │ │ │ ├── models_gen.go │ │ │ │ ├── resolver.go │ │ │ │ ├── schema.graphql │ │ │ │ └── server/ │ │ │ │ └── server.go │ │ │ ├── gqlgen2/ │ │ │ │ ├── generated.go │ │ │ │ ├── go.mod │ │ │ │ ├── go.sum │ │ │ │ ├── gqlgen.yml │ │ │ │ ├── models_gen.go │ │ │ │ ├── photo.go │ │ │ │ ├── resolver.go │ │ │ │ ├── schema.graphql │ │ │ │ ├── schema_alt.graphql │ │ │ │ └── server/ │ │ │ │ └── server.go │ │ │ ├── gqlgen3/ │ │ │ │ ├── generated.go │ │ │ │ ├── go.mod │ │ │ │ ├── go.sum │ │ │ │ ├── gqlgen.yml │ │ │ │ ├── models_gen.go │ │ │ │ ├── photo.go │ │ │ │ ├── resolver.go │ │ │ │ ├── schema.graphql │ │ │ │ ├── schema_alt.graphql │ │ │ │ ├── server/ │ │ │ │ │ └── server.go │ │ │ │ └── userloader_gen.go │ │ │ ├── gqlgen4/ │ │ │ │ ├── generated.go │ │ │ │ ├── go.mod │ │ │ │ ├── go.sum │ │ │ │ ├── gqlgen.yml │ │ │ │ ├── models_gen.go │ │ │ │ ├── photo.go │ │ │ │ ├── queries.txt │ │ │ │ ├── resolver.go │ │ │ │ ├── schema.graphql │ │ │ │ ├── server/ │ │ │ │ │ └── server.go │ │ │ │ └── userloader_gen.go │ │ │ ├── gqlgen5/ │ │ │ │ ├── generated.go │ │ │ │ ├── go.mod │ │ │ │ ├── go.sum │ │ │ │ ├── gqlgen.yml │ │ │ │ ├── models_gen.go │ │ │ │ ├── photo.go │ │ │ │ ├── queries.txt │ │ │ │ ├── resolver.go │ │ │ │ ├── schema.graphql │ │ │ │ ├── server/ │ │ │ │ │ └── server.go │ │ │ │ ├── test_file.txt │ │ │ │ └── userloader_gen.go │ │ │ ├── gqlgen6/ │ │ │ │ ├── generated.go │ │ │ │ ├── go.mod │ │ │ │ ├── go.sum │ │ │ │ ├── gqlgen.yml │ │ │ │ ├── models_gen.go │ │ │ │ ├── photo.go │ │ │ │ ├── queries.txt │ │ │ │ ├── resolver.go │ │ │ │ ├── schema.graphql │ │ │ │ ├── server/ │ │ │ │ │ └── server.go │ │ │ │ ├── test_file.txt │ │ │ │ └── userloader_gen.go │ │ │ └── note.txt │ │ ├── graphql-go/ │ │ │ └── main.go │ │ └── intro/ │ │ ├── instagram_gql.txt │ │ ├── instagram_sql_resp.json │ │ ├── readme.md │ │ └── schema.public.graphql │ ├── 4_swagger/ │ │ ├── docs/ │ │ │ ├── docs.go │ │ │ ├── swagger/ │ │ │ │ ├── swagger.json │ │ │ │ └── swagger.yaml │ │ │ ├── swagger.json │ │ │ └── swagger.yaml │ │ ├── main.go │ │ └── model/ │ │ └── user.go │ ├── 5_sessions/ │ │ └── main.go │ ├── 6_jwt/ │ │ └── main.go │ └── 7_oauth/ │ └── main.go ├── 5-architecture/ │ ├── 0_bad_example/ │ │ └── api.go │ ├── 10_crudapp/ │ │ ├── cmd/ │ │ │ └── crudapp/ │ │ │ └── main.go │ │ ├── file_tree.txt │ │ ├── go.mod │ │ ├── go.sum │ │ ├── internal/ │ │ │ ├── crudapp/ │ │ │ │ └── middleware/ │ │ │ │ ├── accesslog.go │ │ │ │ ├── auth.go │ │ │ │ └── panic.go │ │ │ └── pkg/ │ │ │ ├── items/ │ │ │ │ ├── delivery/ │ │ │ │ │ └── items.go │ │ │ │ ├── items.go │ │ │ │ └── repository/ │ │ │ │ └── repo.go │ │ │ ├── models/ │ │ │ │ ├── item.go │ │ │ │ ├── session.go │ │ │ │ └── user.go │ │ │ ├── session/ │ │ │ │ └── manager.go │ │ │ └── user/ │ │ │ ├── delivery/ │ │ │ │ ├── user.go │ │ │ │ └── user_test.go │ │ │ ├── mock/ │ │ │ │ └── mock_repo.go │ │ │ ├── repository/ │ │ │ │ └── user.go │ │ │ └── user.go │ │ ├── readme.md │ │ └── templates/ │ │ ├── create.html │ │ ├── edit.html │ │ ├── index.html │ │ └── login.html │ ├── 1_routers/ │ │ ├── 0_httprouter/ │ │ │ └── 0_httprouter.go │ │ ├── 1_fasthttp/ │ │ │ └── 1_fasthttp.go │ │ ├── 2_gorilla/ │ │ │ └── 2_gorilla.go │ │ └── 3_multiple/ │ │ └── 3_multiple.go │ ├── 2_middleware/ │ │ ├── 1_middleware/ │ │ │ └── 1_middleware.go │ │ └── 2_context_value/ │ │ └── 2_context_value.go │ ├── 3_errors/ │ │ ├── 1_basic_err/ │ │ │ └── 1_basic_err.go │ │ ├── 2_named_err/ │ │ │ └── 2_named_err.go │ │ ├── 3_pkg_err/ │ │ │ └── 3_pkg_err.go │ │ ├── 4_own_err/ │ │ │ └── 4_own_err.go │ │ └── 5_new_errors/ │ │ └── 5_new_errors.go │ ├── 4_validation/ │ │ └── validation.go │ ├── 5_logging/ │ │ └── main.go │ ├── 6_websockets/ │ │ ├── index.html │ │ └── main.go │ ├── 7_frameworks/ │ │ └── echo/ │ │ ├── main.go │ │ ├── middleware/ │ │ │ ├── error.go │ │ │ ├── panic.go │ │ │ ├── request_id.go │ │ │ └── session.go │ │ ├── model/ │ │ │ └── user.go │ │ └── user/ │ │ ├── delivery/ │ │ │ └── http/ │ │ │ ├── hander_test.go │ │ │ └── handler.go │ │ ├── repository/ │ │ │ └── memory.go │ │ ├── repository.go │ │ ├── usecase/ │ │ │ └── usecase.go │ │ ├── usecase.go │ │ └── usecase_mock.go │ └── readings_5.md ├── 6-databases/ │ ├── 00_databases/ │ │ ├── _kafka/ │ │ │ └── setup.sh │ │ ├── _mysql/ │ │ │ ├── injection_db.sql │ │ │ └── items.sql │ │ ├── _postgres/ │ │ │ └── items.sql │ │ └── docker-compose.yml │ ├── 01_mysql/ │ │ ├── main.go │ │ └── templates/ │ │ ├── create.html │ │ ├── edit.html │ │ └── index.html │ ├── 02_postgresql/ │ │ ├── main.go │ │ └── templates/ │ │ ├── create.html │ │ ├── edit.html │ │ └── index.html │ ├── 03_mysql_sql_injection/ │ │ └── main.go │ ├── 04_mysql_sqlmock/ │ │ ├── item_repo.go │ │ ├── item_repo_test.go │ │ ├── main.go │ │ └── templates/ │ │ ├── create.html │ │ ├── edit.html │ │ └── index.html │ ├── 05_gorm/ │ │ ├── main.go │ │ └── templates/ │ │ ├── create.html │ │ ├── edit.html │ │ └── index.html │ ├── 06_crudapp_db_tests/ │ │ ├── cmd/ │ │ │ └── crudapp/ │ │ │ └── main.go │ │ ├── pkg/ │ │ │ ├── handlers/ │ │ │ │ ├── handler.html │ │ │ │ ├── items.go │ │ │ │ ├── items_mock.go │ │ │ │ ├── items_test.go │ │ │ │ └── user.go │ │ │ ├── items/ │ │ │ │ ├── item.go │ │ │ │ ├── item_repo_test.go │ │ │ │ ├── repo_gorm.go │ │ │ │ ├── repo_mysql.go │ │ │ │ ├── repo_pgx.go │ │ │ │ └── repo_sqlx.go │ │ │ ├── middleware/ │ │ │ │ ├── accesslog.go │ │ │ │ ├── auth.go │ │ │ │ └── panic.go │ │ │ ├── session/ │ │ │ │ ├── manager.go │ │ │ │ └── session.go │ │ │ └── user/ │ │ │ └── user.go │ │ ├── readme.md │ │ └── templates/ │ │ ├── create.html │ │ ├── edit.html │ │ ├── index.html │ │ └── login.html │ ├── 07_mongodb/ │ │ ├── main.go │ │ └── templates/ │ │ ├── create.html │ │ ├── edit.html │ │ └── index.html │ ├── 08_memcache/ │ │ └── memcache.go │ ├── 09_redis_simple/ │ │ └── cmds.go │ ├── 10_redis/ │ │ ├── main.go │ │ └── session.go │ ├── 11_rabbit/ │ │ ├── form/ │ │ │ └── form.go │ │ └── resizer/ │ │ └── resize_worker.go │ ├── 12_kafka/ │ │ ├── form/ │ │ │ └── form.go │ │ └── resizer/ │ │ └── resize_worker.go │ ├── 13_tarantool_simple/ │ │ ├── Dockerfile │ │ ├── app.lua │ │ └── main.go │ ├── 14_tarantool/ │ │ ├── main.go │ │ └── session.go │ ├── crudapp_mongo/ │ │ ├── cmd/ │ │ │ └── crudapp/ │ │ │ └── main.go │ │ ├── file_tree.txt │ │ ├── pkg/ │ │ │ ├── handlers/ │ │ │ │ ├── items.go │ │ │ │ ├── items_mock.go │ │ │ │ ├── items_test.go │ │ │ │ └── user.go │ │ │ ├── items/ │ │ │ │ ├── item.go │ │ │ │ └── repo_mongo.go │ │ │ ├── middleware/ │ │ │ │ ├── accesslog.go │ │ │ │ ├── auth.go │ │ │ │ └── panic.go │ │ │ ├── session/ │ │ │ │ ├── manager.go │ │ │ │ └── session.go │ │ │ └── user/ │ │ │ └── user.go │ │ ├── readme.md │ │ └── templates/ │ │ ├── create.html │ │ ├── edit.html │ │ ├── index.html │ │ └── login.html │ ├── readings_6.md │ ├── readme.md │ └── tcache/ │ ├── cache.go │ ├── main.go │ └── posts.go ├── 7-security/ │ ├── 1_passwords/ │ │ ├── 0_password.txt │ │ ├── 1_salt.go │ │ ├── 2_pass.go │ │ └── 2_pass_bench_test.go │ ├── 2_csrf/ │ │ ├── csrf.go │ │ └── csrf.txt │ ├── 3_csrf_token/ │ │ ├── csrf.go │ │ ├── token_crypt.go │ │ ├── token_jwt.go │ │ └── tokjen_hash.go │ ├── 4_xss/ │ │ └── xss.go │ ├── 5_xss_clean/ │ │ ├── login.txt │ │ └── xss_clean.go │ ├── 6_acl/ │ │ ├── acl_rbac.txt │ │ └── casbin/ │ │ ├── basic_model.conf │ │ ├── basic_policy.csv │ │ └── rbac.go │ └── 7_docker/ │ ├── .dockerignore │ ├── Dockerfile │ ├── Dockerfile.Multistage │ ├── code/ │ │ ├── go.mod │ │ └── main.go │ ├── docker-compose.yml │ ├── nginx/ │ │ └── nginx.conf │ └── readme.md ├── 8-microservices/ │ ├── 0_service/ │ │ ├── 1_step/ │ │ │ ├── main.go │ │ │ ├── run_test.go │ │ │ └── session.go │ │ └── 2_step/ │ │ ├── main.go │ │ ├── run_test.go │ │ └── session.go │ ├── 1_net-rpc/ │ │ ├── client/ │ │ │ ├── client.go │ │ │ ├── run_test.go │ │ │ └── session.go │ │ └── server/ │ │ ├── server.go │ │ └── session.go │ ├── 2_json-rpc/ │ │ ├── client/ │ │ │ ├── client.go │ │ │ ├── run_test.go │ │ │ └── session.go │ │ └── server/ │ │ ├── server.go │ │ └── session.go │ ├── 3_protobuf/ │ │ ├── main.go │ │ ├── session.pb.go │ │ └── session.proto │ ├── 4_grpc/ │ │ ├── client/ │ │ │ ├── main.go │ │ │ └── run_test.go │ │ ├── readme.md │ │ ├── server/ │ │ │ ├── server.go │ │ │ └── session.go │ │ └── session/ │ │ ├── session.pb.go │ │ ├── session.proto │ │ └── session_grpc.pb.go │ ├── 5_grpc_features/ │ │ ├── client/ │ │ │ └── client.go │ │ └── server/ │ │ ├── server.go │ │ └── session.go │ ├── 6_grpc_stream/ │ │ ├── client/ │ │ │ ├── client.go │ │ │ └── run_test.go │ │ ├── server/ │ │ │ ├── main.go │ │ │ ├── server.go │ │ │ └── translit.go │ │ └── translit/ │ │ ├── translit.pb.go │ │ ├── translit.proto │ │ └── translit_grpc.pb.go │ └── 7_grpc_loadbalance/ │ ├── client/ │ │ └── main.go │ ├── docker-compose.yml │ ├── readme.md │ └── server/ │ ├── server.go │ └── session.go ├── 9-monitoring/ │ ├── 0_services/ │ │ ├── alertmanager/ │ │ │ └── alertmanager.yml │ │ ├── alertmanager-bot/ │ │ │ └── templates/ │ │ │ └── default.tmpl │ │ ├── docker-compose.yml │ │ └── prometheus/ │ │ ├── alerts.yml │ │ └── prometheus.yml │ ├── 1_config/ │ │ ├── 1_flag/ │ │ │ └── flag.go │ │ ├── 2_json/ │ │ │ ├── config.json │ │ │ └── json_config.go │ │ ├── 3_ldflags/ │ │ │ └── ldflags.go │ │ ├── 4_viper/ │ │ │ ├── config.yml │ │ │ └── main.go │ │ └── 5_consul/ │ │ └── consul_config.go │ ├── 2_vault/ │ │ ├── main.go │ │ └── readme.md │ ├── 3_monitoring/ │ │ ├── expvars/ │ │ │ └── expvars.go │ │ ├── metrics/ │ │ │ └── context_monitoring.go │ │ ├── prometheus/ │ │ │ ├── alertmanager/ │ │ │ │ └── alertmanager.yml │ │ │ ├── main.go │ │ │ ├── prometheus/ │ │ │ │ ├── alerts.yml │ │ │ │ └── prometheus.yml │ │ │ └── readme.md │ │ └── sentry/ │ │ ├── echo/ │ │ │ └── main.go │ │ └── simple/ │ │ └── main.go │ └── 4_tracing/ │ └── jaeger_grpc/ │ ├── client/ │ │ └── main.go │ ├── readme.md │ ├── server/ │ │ ├── server.go │ │ └── session.go │ └── session/ │ ├── session.pb.go │ └── session.proto ├── README.md ├── go.mod └── go.sum ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ .DS_Store .idea .vscode # Tarantool output files *.xlog *.snap # Test data files 6-databases/10_rabbit/images/*.jpg # Ignore binary files *.exe # Ignore tmp output files *.out ================================================ FILE: .gitmodules ================================================ [submodule "5-architecture/8_clean_arch"] path = 5-architecture/8_clean_arch url = https://github.com/bxcodec/go-clean-arch [submodule "5-architecture/9_go_project_layout"] path = 5-architecture/9_go_project_layout url = https://github.com/golang-standards/project-layout ================================================ FILE: 1-basics/1_basics/01_vars_1/01_vars_1.go ================================================ package main import "fmt" func main() { // значение по умолчанию var num0 int // значение при инициализации var num1 int = 1 // пропуск типа var num2 = 20 fmt.Println(num0, num1, num2) // короткое объявление переменной num := 30 // только для новых переменных // no new variables on left side of := // num := 31 num += 1 fmt.Println("+=", num) // ++num нету num++ fmt.Println("++", num) // camelCase - принятый стиль userIndex := 10 // under_score - не принято user_index := 10 fmt.Println(userIndex, user_index) // объявление нескольких переменных var weight, height int = 10, 20 // присваивание в существующие переменные weight, height = 11, 21 // короткое присваивание // хотя-бы одна переменная должна быть новой! weight, age := 12, 22 fmt.Println(weight, height, age) } ================================================ FILE: 1-basics/1_basics/02_vars_2/02_vars_2.go ================================================ package main import "fmt" func main() { // int - платформозависимый тип, 32/64 var i int = 10 // автоматически выбранный int var autoInt = -10 // int8, int16, int32, int64 var bigInt int64 = 1<<32 - 1 // платформозависимый тип, 32/64 var unsignedInt uint = 123 // uint8, unit16, uint32, unit64 var unsignedBigInt uint64 = 1<<64 - 1 unsignedBigInt = 0x01fe unsignedBigInt = 0b00001010101 fmt.Println(i, autoInt, bigInt, unsignedInt, unsignedBigInt) // вывод в других системах счисления fmt.Printf("в 16-ричной: %x\n", unsignedBigInt) fmt.Printf("в двоичной: %b\n", unsignedBigInt) fmt.Printf("в 8-ричной: %o\n", unsignedBigInt) // float32, float64 var pi float32 = 3.141 var e = 2.718 goldenRatio := 1.618 fmt.Println(pi, e, goldenRatio) // bool var b bool // false по-умолчанию var isOk bool = true var success = false cond := true fmt.Println(b, isOk, success, cond) // complex64, complex128 var c complex128 = -1.1 + 7.12i c2 := -1.1 + 7.12i fmt.Println(c, c2) } ================================================ FILE: 1-basics/1_basics/03_const/03_const.go ================================================ package main import "fmt" const pi = 3.141 const ( hello = "Привет" e = 2.718 ) const ( zero = iota _ // пустая переменная, пропуск iota two three // = 3 ) const ( _ = iota // пропускаем первое значение KB uint64 = 1 << (10 * iota) // 1 << (10 * 1) = 1024 MB // 1 << (10 * 2) = 1048576 ) const ( // нетипизированная константа year = 2017 // типизированная константа yearTyped int = 2017 ) func main() { var month int32 = 13 fmt.Println(month + year) // month + yearTyped (mismatched types int32 and int) // fmt.Println( month + yearTyped ) } ================================================ FILE: 1-basics/1_basics/04_pointers/04_pointers.go ================================================ package main func main() { a := 2 b := &a *b = 3 // a = 3 c := &a // новый указатель на переменную a // получение указателя на переменнут типа int // инициализировано значением по-умолчанию d := new(int) *d = 12 *c = *d // c = 12 -> a = 12 *d = 13 // c и a не изменились // nil указатель var n *int _ = n c = d // теперь с указывает туда же, куда d *c = 14 // с = 14 -> d = 14, a = 12 } ================================================ FILE: 1-basics/1_basics/05_array/05_array.go ================================================ package main import "fmt" func main() { // размер массива является частью его типа // инициализация значениями по-умолчанию var a1 [3]int // [0,0,0] fmt.Println("a1 short", a1) fmt.Printf("a1 short %v\n", a1) fmt.Printf("a1 full %#v\n", a1) const size = 2 var a2 [2 * size]bool // [false,false,false,false] fmt.Println("a2", a2) // определение размера при объявлении a3 := [...]int{1, 2, 3} fmt.Println("a2", a3) // проверка при компиляции или при выполнении // invalid array index 4 (out of bounds for 3-element array) // a3[idx] = 12 } ================================================ FILE: 1-basics/1_basics/06_slice_1/06_slice_1.go ================================================ package main import "fmt" func main() { // создание var buf0 []int // len=0, cap=0 buf1 := []int{} // len=0, cap=0 buf2 := []int{42} // len=1, cap=1 buf3 := make([]int, 0) // len=0, cap=0 buf4 := make([]int, 5) // len=5, cap=5 buf5 := make([]int, 5, 10) // len=5, cap=10 println("buffers ", buf0, buf1, buf2, buf3, buf4, buf5) // обращение к элементам someInt := buf2[0] // ошибка при выполнении // panic: runtime error: index out of range // someOtherInt := buf2[1] fmt.Println(someInt) // добавление элементов var buf []int // len=0, cap=0 buf = append(buf, 9, 10) // len=2, cap=2 buf = append(buf, 12) // len=3, cap=4 // добавление друго слайса otherBuf := make([]int, 3) // [0,0,0] buf = append(buf, otherBuf...) // len=6, cap=8 fmt.Println(buf, otherBuf) // просмотр информации о слайсе var bufLen, bufCap int = len(buf), cap(buf) fmt.Println(bufLen, bufCap) } ================================================ FILE: 1-basics/1_basics/07_slice_2/07_slice_2.go ================================================ package main import "fmt" func main() { buf := []int{1, 2, 3, 4, 5} fmt.Println(buf) /* buf: [1, 2, 3, 4, 5] ← базовый массив ↑ ↑ ↑ ↑ ↑ │ │ │ │ │ sl2[:2]: │───│ │ │ │ → len=2, cap=5 sl1[1:4]: │───┼───┤ │ → len=3, cap=4 sl3[2:]: │───┼───┼───┤ → len=3, cap=3 */ // получение среза, указывающего на ту же память sl1 := buf[1:4] // [2, 3, 4] (с 1-го до 4-го, не включая 4-й) sl2 := buf[:2] // [1, 2] (с начала до 2-го, не включая 2-й) sl3 := buf[2:] // [3, 4, 5] (со 2-го до конца) fmt.Println(sl1, sl2, sl3) fmt.Println() newBuf := buf[:] // [1, 2, 3, 4, 5] // buf = [9, 2, 3, 4, 5], т.к. та же память newBuf[0] = 9 // newBuf теперь указывает на другие данные newBuf = append(newBuf, 6) // buf = [9, 2, 3, 4, 5], не изменился // newBuf = [1, 2, 3, 4, 5, 6], изменился newBuf[0] = 1 fmt.Println("buf", buf) fmt.Println("newBuf", newBuf) fmt.Println() // копирование одного слайса в другой var emptyBuf []int // len=0, cap=0 // неправильно - скопирует меньшее (по len) из 2-х слайсов copied := copy(emptyBuf, buf) // copied = 0 fmt.Println("Invalid copy ", copied, emptyBuf) // правильно newBuf = make([]int, len(buf), len(buf)) copy(newBuf, buf) fmt.Println("Valid copy ", newBuf) // можно копировать в часть существующего слайса ints := []int{1, 2, 3, 4} copy(ints[1:3], []int{5, 6}) // ints = [1, 5, 6, 4] fmt.Println("Part copy ", ints) } ================================================ FILE: 1-basics/1_basics/08_strings/08_strings.go ================================================ package main import ( "fmt" "unicode/utf8" ) func main() { // пустая строка по-умолчанию var str string // со спец символами var hello string = "Привет\n\t" // без спец символов var world string = `Мир\n\t` fmt.Println("str", str) fmt.Println("hello", hello) fmt.Println("world", world) // UTF-8 из коробки var helloWorld = "Привет, Мир!" hi := "你好,世界" fmt.Println("helloWorld", helloWorld) fmt.Println("hi", hi) // одинарные кавычки для байт (uint8) var rawBinary byte = '\x27' // rune (uint32) для UTF-8 символов var someChinese rune = '茶' fmt.Println(rawBinary, someChinese) helloWorld = "Привет Мир" // конкатенация строк andGoodMorning := helloWorld + " и доброе утро!" fmt.Println(helloWorld, andGoodMorning) // строки неизменяемы // cannot assign to helloWorld[0] // helloWorld[0] = 72 // получение длины строки byteLen := len(helloWorld) // 19 байт symbols := utf8.RuneCountInString(helloWorld) // 10 рун fmt.Println(byteLen, symbols) // получение подстроки, в байтах, не символах! hello = helloWorld[:12] // Привет, 0-11 байты H := helloWorld[0] // byte, 72, не "П" fmt.Println(H) // конвертация в слайс байт и обратно byteString := []byte(helloWorld) helloWorld = string(byteString) fmt.Println(byteString, helloWorld) } ================================================ FILE: 1-basics/1_basics/09_map/09_map.go ================================================ package main import "fmt" func main() { // инициализация при создании var user map[string]string = map[string]string{ "name": "Anton", "lastName": "Sulaev", } // сразу с нужной ёмкостью profile := make(map[string]string, 10) // nil мапа //var profileEmpty map[string]string //fmt.Println("profileEmpty get ", profileEmpty["key"]) //profileEmpty["key"] = "1" // panic //fmt.Println("profileEmpty set ", profileEmpty["key"]) // количество элементов mapLength := len(user) fmt.Printf("%d %+v\n", mapLength, profile) /* 1. Ключ всегда comparable = != 2. sha1, crc32, crc64 Fh = func (toHash Comparable, d int) int Vasya -> Fh(Vasya) -> 10 Kolya -> Fh(Kolya) -> 10 -----------&----- 15 адресов V K O(1) Может быть не конкурентно */ // если ключа нет - вернёт значение по умолчанию для типа mName := user["middleName"] fmt.Println("mName:", mName) // проверка на существование ключа mName, mNameExist := user["middleName"] fmt.Println("mName:", mName, "mNameExist:", mNameExist) // пустая переменная - только проверяем что ключ есть _, mNameExist2 := user["middleName"] fmt.Println("mNameExist2", mNameExist2) // удаление ключа delete(user, "lastName") fmt.Printf("%#v\n", user) } ================================================ FILE: 1-basics/1_basics/10_control/10_control.go ================================================ package main import "fmt" func main() { // простое условие boolVal := true if boolVal { fmt.Println("boolVal is true") } mapVal := map[string]string{"name": "vasya"} // условие с блоком инициализации if keyValue, keyExist := mapVal["name"]; keyExist { fmt.Println("name =", keyValue) } // получаем только признак сущестования ключа if _, keyExist := mapVal["name"]; keyExist { fmt.Println("key 'name' exist") } cond := 1 // множественные if else if cond == 1 { fmt.Println("cond is 1") } else if cond == 2 { fmt.Println("cond is 2") } // switch по 1 переменной strVal := "name" switch strVal { case "name": fallthrough case "test", "lastName": // some work default: // some work } // switch как замена многим ifelse var val1, val2 = 2, 2 switch { case val1 > 1 || val2 < 11: fmt.Println("first block") case val2 > 10: fmt.Println("second block") } // выход из цикла, находясь внутри switch Loop: for key, val := range mapVal { println("switch in loop", key, val) switch { case key == "lastName": break println("dont pront this") case key == "firstName" && val == "Vasily": println("switch - break loop here") break Loop } } // конец for } ================================================ FILE: 1-basics/1_basics/11_loop/11_loop.go ================================================ package main import "fmt" func main() { // цикл без условия, while(true) OR for(;;;) for { fmt.Println("loop iteration") break } // цикл без условия, while(isRun) isRun := true for isRun { fmt.Println("loop iteration with condition") isRun = false } // цикл с условие и блоком инициализации for i := 0; i < 2; i++ { fmt.Println("loop iteration", i) if i == 1 { continue } } // операции по slice sl := []int{1, 2, 3} idx := 0 for idx < len(sl) { fmt.Println("while-stype loop, idx:", idx, "value:", sl[idx]) idx++ } for i := 0; i < len(sl); i++ { fmt.Println("c-style loop", i, sl[i]) } for idx := range sl { fmt.Println("range slice by index", sl[idx]) } for idx, val := range sl { val = idx + 1 // не поменяем sl[idx] = idx + 2 // поменяем fmt.Println("range slice by idx-value", idx, val) } fmt.Printf("slice by idx-value %v\n", sl) // операции по map profile := map[int]string{1: "Vasily", 2: "Romanov"} for key := range profile { fmt.Println("range map by key", key) } for key, val := range profile { fmt.Println("range map by key-val", key, val) } for _, val := range profile { fmt.Println("range map by val", val) } //added in go 1.22 for i := range 10 { println(i) } str := "Привет, Мир!" for pos, char := range str { fmt.Printf("%#U at pos %d\n", char, pos) } } ================================================ FILE: 1-basics/1_basics/12_types/12_types.go ================================================ package main type UserID int func main() { idx := 1 var uid UserID = 42 // даже если базовый тип одинаковый, разные типы несовместимы // cannot use uid (type UserID) as type int64 in assignment // myID := idx myID := UserID(idx) println(uid, myID) } ================================================ FILE: 1-basics/1_basics/13_generic/1_generic/main.go ================================================ package main // Зачем нужны? // ДУБЛИРОВАНИЕ КОДА! func equalInt(a, b int) bool { return a == b } func equalFloat(a, b float64) bool { return a == b } // одна функция для многих типов // [T int | float64] - объявление типа-параметра (Type parameter) func equal[T int | float64](a, b T) bool { return a == b } // Алиасы type MyType int func equalWithAlias[T ~int | ~float64](a, b T) bool { return a == b } func KeyExists[T any](m map[string]T, key string) bool { _, exists := m[key] return exists } func main() { println(equalInt(1, 2)) println(equalFloat(1.0, 2.0)) // Компилятор сам подставит нужный тип println(equal(1, 2)) // T - int println(equal(1.0, 2.0)) // T - float64 // Cannot use MyType as the type interface{ int | float64 } // Type does not implement constraint interface{ int | float64 } because type is not included in type set (int, float64) // // //println(equal(MyType(1),MyType(2))) println(equalWithAlias(MyType(1), MyType(2))) m1 := make(map[string]int) m2 := make(map[string]bool) println(KeyExists(m2, "test")) println(KeyExists(m1, "test")) } ================================================ FILE: 1-basics/1_basics/13_generic/2_methods/methods.go ================================================ package main import ( "encoding/json" "fmt" ) // 1. Базовая дженерик-структура с методами type Box[T any] struct { Value T } // Метод получает значение. T уже объявлен в структуре. func (b Box[T]) GetValue() T { return b.Value } // Метод устанавливает значение func (b *Box[T]) SetValue(v T) { b.Value = v } // 2. Структура с ограничением типов type Number interface { ~int | ~float64 } type Calculator[T Number] struct { Value T } // Методы используют то же ограничение T Number func (c Calculator[T]) Add(a T) T { return c.Value + a } func (c Calculator[T]) Multiply(a T) T { return c.Value * a } // 3. Методы с преобразованием данных type Container[T any] struct { Data T } func (c Container[T]) ToJSON() ([]byte, error) { return json.Marshal(c.Data) } func (c *Container[T]) FromJSON(data []byte) error { return json.Unmarshal(data, &c.Data) } // 4. Функция с дополнительным generic-параметром (методы не могут иметь свои параметры типов) func CompareWith[T any, U any](b Box[T], other U, compareFunc func(T, U) bool) bool { return compareFunc(b.Value, other) } // 5. Практический пример: кэш с разными типами значений type Cache[K comparable, V any] struct { data map[K]V } func NewCache[K comparable, V any]() *Cache[K, V] { return &Cache[K, V]{ data: make(map[K]V), } } func (c *Cache[K, V]) Set(key K, value V) { c.data[key] = value } func (c *Cache[K, V]) Get(key K) (V, bool) { val, exists := c.data[key] return val, exists } func (c *Cache[K, V]) Delete(key K) { delete(c.data, key) } // 6. Пример с интерфейсным ограничением type Stringer interface { String() string } type Printer[T Stringer] struct { Item T } func (p Printer[T]) Print() string { return p.Item.String() } // Реализуем интерфейс Stringer для кастомного типа type MyInt int func (m MyInt) String() string { return fmt.Sprintf("MyInt: %d", m) } func main() { // 1. Работа с Box intBox := Box[int]{Value: 42} strBox := Box[string]{Value: "hello"} fmt.Printf("intBox value: %d\n", intBox.GetValue()) fmt.Printf("strBox value: %s\n", strBox.GetValue()) intBox.SetValue(100) fmt.Printf("New intBox value: %d\n", intBox.GetValue()) // 2. Работа с Calculator intCalc := Calculator[int]{Value: 10} floatCalc := Calculator[float64]{Value: 3.14} fmt.Printf("10 * 2 = %d\n", intCalc.Multiply(2)) fmt.Printf("3.14 + 1.5 = %.2f\n", floatCalc.Add(1.5)) // 3. Работа с Cache stringCache := NewCache[string, string]() stringCache.Set("name", "Alice") stringCache.Set("city", "Moscow") if name, exists := stringCache.Get("name"); exists { fmt.Printf("Name from cache: %s\n", name) } intCache := NewCache[string, int]() intCache.Set("age", 25) intCache.Set("score", 100) if age, exists := intCache.Get("age"); exists { fmt.Printf("Age from cache: %d\n", age) } // 4. Работа с методом, имеющим дополнительный generic-параметр box := Box[int]{Value: 42} result := CompareWith(box, "42", func(a int, b string) bool { return fmt.Sprint(a) == b }) fmt.Printf("Compare 42 with '42': %t\n", result) // 5. Работа с интерфейсным ограничением myInt := MyInt(42) printer := Printer[MyInt]{Item: myInt} fmt.Println(printer.Print()) } ================================================ FILE: 1-basics/2_functions/1_functions/1_functions.go ================================================ package main import "fmt" // обычное объявление func singleIn(in int) int { return in } // много параметров func multIn(a, b int, c int) int { return a + b + c } // именованный результат func namedReturn() (out int) { out = 2 return } // несколько результатов func multipleReturn(in int) (int, error) { if in > 2 { return 0, fmt.Errorf("some error happend") } return in, nil } // несколько именованных результатов func multipleNamedReturn(ok bool) (rez int, err error) { rez = 1 if ok { err = fmt.Errorf("some error happend") // аналогично return rez, err return 3, fmt.Errorf("some error happend") } rez = 2 return } // не фиксированное количество параметров func sum(in ...int) (result int) { fmt.Printf("in := %#v \n", in) for _, val := range in { result += val } return } func main() { // fmt.Println(multipleNamedReturn(false)) // return nums := []int{1, 2, 3, 4} fmt.Println(nums, sum(nums...)) return } ================================================ FILE: 1-basics/2_functions/2_firstclass/2_firstclass.go ================================================ package main import "fmt" // обычная функция func doNothing() { fmt.Println("i'm regular function") } func main() { // анонимная функция func(in string) { fmt.Println("anon func out:", in) }("nobody") // присванивание анонимной функции в переменную printer := func(in string) { fmt.Println("printer outs:", in) } printer("as variable") // определяем тип функции type strFuncType func(string) // функция принимает коллбек worker := func(callback strFuncType) { callback("as callback") } worker(printer) // функиция возвращает замыкание prefixer := func(prefix string) strFuncType { return func(in string) { fmt.Printf("[%s] %s\n", prefix, in) } } successLogger := prefixer("SUCCESS") successLogger("expected behaviour") } ================================================ FILE: 1-basics/2_functions/3_defer/3_defer.go ================================================ package main import "fmt" func getSomeVars() string { fmt.Println("getSomeVars execution") return "getSomeVars result" } func main() { defer fmt.Println("After work") defer func() { fmt.Println(getSomeVars()) }() fmt.Println("Some userful work") } ================================================ FILE: 1-basics/2_functions/4_recover/4_recover.go ================================================ package main import ( "fmt" ) func deferTest() { defer func() { if err := recover(); err != nil { fmt.Println("panic happend FIRST:", err) } }() defer func() { if err := recover(); err != nil { fmt.Println("panic happend SECOND:", err) // panic("second panic") } }() fmt.Println("Some userful work") panic("something bad happend") return } func main() { deferTest() return } ================================================ FILE: 1-basics/3_structs/1_structs/1_structs.go ================================================ package main import "fmt" type Person struct { Id int Name string Address string } type Account struct { Id int // Name string Cleaner func(string) string Owner Person Person } func main() { // полное объявление структуры var acc Account = Account{ Id: 1, // Name: "vasya", Person: Person{ Name: "Василий", Address: "Москва", }, } fmt.Printf("%#v\n", acc) // короткое объявление структуры acc.Owner = Person{2, "Romanov Vasily", "Moscow"} fmt.Printf("%#v\n", acc) fmt.Println(acc.Name) fmt.Println(acc.Person.Name) } ================================================ FILE: 1-basics/3_structs/2_methods/2_methods.go ================================================ package main import "fmt" type Person struct { Id int Name string } // не изменит оригинальной структуры, для который вызван func (p Person) UpdateName(name string) { p.Name = name } // изменяет оригинальную структуру func (p *Person) SetName(name string) { p.Name = name } type Account struct { Id int Name string Person } func (p *Account) SetName(name string) { p.Name = name } type MySlice []int func (sl *MySlice) Add(val int) { *sl = append(*sl, val) } func (sl *MySlice) Count() int { return len(*sl) } func main() { // pers := &Person{1, "Vasily"} pers := new(Person) pers.SetName("Vasily Romanov") // (&pers).SetName("Vasily Romanov") // fmt.Printf("updated person: %#v\n", pers) var acc Account = Account{ Id: 1, Name: "vasya", Person: Person{ Id: 2, Name: "Vasily Romanov", }, } acc.SetName("romanov.vasily") acc.Person.SetName("Test") // fmt.Printf("%#v \n", acc) sl := MySlice([]int{1, 2}) sl.Add(5) fmt.Println(sl.Count(), sl) } ================================================ FILE: 1-basics/4_interfaces/1.2_basic_sort/1_sort.go ================================================ package main import ( "fmt" "sort" ) type Student struct { Age int Name string } type Students []Student func (sts Students) Len() int { return len(sts) } func (sts Students) Swap(a, b int) { sts[a], sts[b] = sts[b], sts[a] } func (sts Students) Less(a, b int) bool { return sts[a].Age < sts[b].Age } func main() { students := Students{ {Age: 18, Name: "Harry"}, {Age: 76, Name: "Benjamin"}, {Age: 20, Name: "Bob"}, {Age: 19, Name: "Alice"}, } sort.Sort(students) for _, s := range students { fmt.Printf("%d %s\n", s.Age, s.Name) } } ================================================ FILE: 1-basics/4_interfaces/1_basic/1_basic.go ================================================ package main import ( "fmt" ) type Payer interface { Pay(int) error } type Wallet struct { Cash int } func (w *Wallet) Pay(amount int) error { if w.Cash < amount { return fmt.Errorf("Не хватает денег в кошельке") } w.Cash -= amount return nil } func Buy(p Payer) { err := p.Pay(10) if err != nil { panic(err) } fmt.Printf("Спасибо за покупку через %T\n\n", p) } func main() { myWallet := &Wallet{Cash: 100} Buy(myWallet) } ================================================ FILE: 1-basics/4_interfaces/2_many/2_many.go ================================================ package main import ( "fmt" ) // -------------- type Wallet struct { Cash int } func (w *Wallet) Pay(amount int) error { if w.Cash < amount { return fmt.Errorf("Не хватает денег в кошельке") } w.Cash -= amount return nil } // -------------- type Card struct { Balance int ValidUntil string Cardholder string CVV string Number string } func (c *Card) Pay(amount int) error { if c.Balance < amount { return fmt.Errorf("Не хватает денег на карте") } c.Balance -= amount return nil } // -------------- type ApplePay struct { Money int AppleID string } func (a *ApplePay) Pay(amount int) error { if a.Money < amount { return fmt.Errorf("Не хватает денег на аккаунте") } a.Money -= amount return nil } // -------------- type Payer interface { Pay(int) error } func Buy(p Payer) { err := p.Pay(10) if err != nil { fmt.Printf("Ошибка при оплате %T: %v\n\n", p, err) return } fmt.Printf("Спасибо за покупку через %T\n\n", p) } // -------------- func main() { myWallet := &Wallet{Cash: 100} Buy(myWallet) var myMoney Payer myMoney = &Card{Balance: 100, Cardholder: "vasya"} Buy(myMoney) myMoney = &ApplePay{Money: 9} Buy(myMoney) } ================================================ FILE: 1-basics/4_interfaces/3_embed/3_embed.go ================================================ package main import ( "fmt" ) type Phone struct { Money int AppleID string } func (p *Phone) Pay(amount int) error { if p.Money < amount { return fmt.Errorf("Not enough money on account") } p.Money -= amount return nil } func (p *Phone) Ring(number string) error { if number == "" { return fmt.Errorf("PLease, enter phone") } return nil } // -------------- type Payer interface { Pay(int) error } type Ringer interface { Ring(string) error } type NFCPhone interface { Payer Ringer } // -------------- func PayForMetwiWithPhone(phone NFCPhone) { err := phone.Pay(1) if err != nil { fmt.Printf("Ошибка при оплате %v\n\n", err) return } fmt.Printf("Турникет открыт через %T\n\n", phone) } // -------------- func main() { myPhone := &Phone{Money: 9} PayForMetwiWithPhone(myPhone) } ================================================ FILE: 1-basics/4_interfaces/4_cast/4_cast.go ================================================ package main import ( "fmt" ) // -------------- type Wallet struct { Cash int } func (w *Wallet) Pay(amount int) error { if w.Cash < amount { return fmt.Errorf("Not enough cash") } w.Cash -= amount return nil } // -------------- type Card struct { Balance int ValidUntil string Cardholder string CVV string Number string } func (c *Card) Pay(amount int) error { if c.Balance < amount { return fmt.Errorf("Not enough money on balance") } c.Balance -= amount return nil } // -------------- type ApplePay struct { Money int AppleID string } func (a *ApplePay) Pay(amount int) error { if a.Money < amount { return fmt.Errorf("Not enough money on account") } a.Money -= amount return nil } // -------------- type Payer interface { Pay(int) error } // -------------- func Buy(p Payer) { switch p.(type) { case *Wallet: fmt.Println("Оплата наличными?") case *Card: plasticCard, ok := p.(*Card) if !ok { fmt.Println("Не удалось преобразовать к типу *Card") } fmt.Println("Вставляйте карту,", plasticCard.Cardholder) default: fmt.Println("Что-то новое!") } err := p.Pay(10) if err != nil { fmt.Printf("Ошибка при оплате %T: %v\n\n", p, err) return } fmt.Printf("Спасибо за покупку через %T\n\n", p) } // -------------- func main() { myWallet := &Wallet{Cash: 100} Buy(myWallet) var myMoney Payer myMoney = &Card{Balance: 100, Cardholder: "vasya"} Buy(myMoney) myMoney = &ApplePay{Money: 9} Buy(myMoney) } ================================================ FILE: 1-basics/4_interfaces/5_empty_1/5_empty_1.go ================================================ package main import ( "fmt" "strconv" ) type Wallet struct { Cash int } func (w *Wallet) Pay(amount int) error { if w.Cash < amount { return fmt.Errorf("Not enough cash") } w.Cash -= amount return nil } func (w *Wallet) String() string { return "Кошелёк в котором " + strconv.Itoa(w.Cash) + " денег" } // ----- func main() { myWallet := &Wallet{Cash: 100} fmt.Printf("Raw payment : %#v\n", myWallet) fmt.Printf("Способ оплаты: %s\n", myWallet) } ================================================ FILE: 1-basics/4_interfaces/6_empty_2/6_empty_2.go ================================================ package main import ( "fmt" "strconv" ) // -------------- type Wallet struct { Cash int } func (w *Wallet) Pay(amount int) error { if w.Cash < amount { return fmt.Errorf("Not enough cash") } w.Cash -= amount return nil } func (w *Wallet) String() string { return "Кошелёк в котором " + strconv.Itoa(w.Cash) + " денег" } // -------------- type Payer interface { Pay(int) error } // -------------- func Buy(in interface{}) { var p Payer var ok bool if p, ok = in.(Payer); !ok { fmt.Printf("%T не не является платежным средством\n\n", in) return } err := p.Pay(10) if err != nil { fmt.Printf("Ошибка при оплате %T: %v\n\n", p, err) return } fmt.Printf("Спасибо за покупку через %T\n\n", p) } // -------------- func main() { myWallet := &Wallet{Cash: 100} Buy(myWallet) Buy([]int{1, 2, 3}) Buy(3.14) } ================================================ FILE: 1-basics/5_visibility/dir.txt ================================================ C:\Users\User\go ├───bin ├───pkg └───src ├───coursera │ ├───visibility │ │ │───person │ │ │ │───person.go │ │ │ └───func.go │ │ └───main.go └───github.com └───rvasily └───examplerepo ================================================ FILE: 1-basics/5_visibility/main.go ================================================ package main import ( "fmt" prsonModule "github.com/go-park-mail-ru/lectures/1-basics/5_visibility/person" ) func init() { fmt.Println("I am init in main") } func main() { person := 1 fmt.Println("I am main", person, prsonModule.Person{}) } ================================================ FILE: 1-basics/5_visibility/person/func.go ================================================ package person import ( "fmt" ) func NewPerson(id int, name, secret string) *Person { return &Person{ ID: 1, Name: "rvasily", secret: "secret", } } func GetSecret(p *Person) string { return p.secret } func printSecret(p *Person) { fmt.Println(p.secret) } ================================================ FILE: 1-basics/5_visibility/person/person.go ================================================ package person import "fmt" var ( Public = 1 private = 1 ) func init() { fmt.Println("I am init 1") } func init() { fmt.Println("I am init 2") } type Person struct { ID int Name string secret string } func (p Person) UpdateSecret(secret string) { fmt.Println(private) p.secret = secret } ================================================ FILE: 1-basics/6_uniq/basic/data.txt ================================================ 1 2 3 3 3 3 4 5 ================================================ FILE: 1-basics/6_uniq/basic/data_bad.txt ================================================ 1 1 2 1 ================================================ FILE: 1-basics/6_uniq/basic/data_map.txt ================================================ 1 3 2 1 2 ================================================ FILE: 1-basics/6_uniq/basic/main.go ================================================ package main import ( "bufio" "fmt" "os" ) func main() { in := bufio.NewScanner(os.Stdin) var prev string for in.Scan() { txt := in.Text() if txt == prev { continue } if txt < prev { panic("file not sorted") } prev = txt fmt.Println(txt) } } ================================================ FILE: 1-basics/6_uniq/with_tests/data.txt ================================================ 1 2 3 3 3 3 4 5 ================================================ FILE: 1-basics/6_uniq/with_tests/data_bad.txt ================================================ 1 1 2 1 ================================================ FILE: 1-basics/6_uniq/with_tests/data_map.txt ================================================ 1 3 2 1 2 ================================================ FILE: 1-basics/6_uniq/with_tests/main.go ================================================ package main import ( "bufio" "fmt" "io" "os" ) func uniq(input io.Reader, output io.Writer) error { in := bufio.NewScanner(input) var prev string for in.Scan() { txt := in.Text() if txt == prev { continue } if txt < prev { return fmt.Errorf("file not sorted") } prev = txt fmt.Fprintln(output, txt) } return nil } func main() { err := uniq(os.Stdin, os.Stdout) if err != nil { fmt.Println(err) os.Exit(1) } } ================================================ FILE: 1-basics/6_uniq/with_tests/main_test.go ================================================ package main import ( "bytes" "testing" ) var testOkInput = `1 2 3 3 4 5` var testOkResult = `1 2 3 4 5 ` var testFailInput = `1 2 1` func TestOK(t *testing.T) { in := bytes.NewBufferString(testOkInput) out := bytes.NewBuffer(nil) err := uniq(in, out) if err != nil { t.Errorf("Test OK failed: %s", err) } result := out.String() if result != testOkResult { t.Errorf("Test OK failed, result not match") } } func TestFail(t *testing.T) { in := bytes.NewBufferString(testFailInput) out := bytes.NewBuffer(nil) err := uniq(in, out) if err == nil { t.Errorf("Test FAIL failed: expected error") } } ================================================ FILE: 1-basics/homework/readme.md ================================================ # Домашнее задание 1 ## Дисклеймер Это задание состоит из 2х частей, которые нужно сдавать вместе. Отдельно первая часть, как и отдельно вторая часть, не оценивается как половина задания. Задачи включают в себя как написание функциональности, так и её тестирование. Все домашние задания должны выполняться в приватных репозиториях. ## Часть 1. Uniq Нужно реализовать утилиту, с помощью которой можно вывести или отфильтровать повторяющиеся строки в файле (аналог UNIX утилиты `uniq`). Причём повторяющиеся входные строки не должны распозноваться, если они не следуют строго друг за другом. Сама утилита имеет набор параметров, которые необходимо поддержать. ### Параметры `-с` - подсчитать количество встречаний строки во входных данных. Вывести это число перед строкой отделив пробелом. `-d` - вывести только те строки, которые повторились во входных данных. `-u` - вывести только те строки, которые не повторились во входных данных. `-f num_fields` - не учитывать первые `num_fields` полей в строке. Полем в строке является непустой набор символов отделённый пробелом. `-s num_chars` - не учитывать первые `num_chars` символов в строке. При использовании вместе с параметром `-f` учитываются первые символы после `num_fields` полей (не учитывая пробел-разделитель после последнего поля). `-i` - не учитывать регистр букв. ### Использование `uniq [-c | -d | -u] [-i] [-f num] [-s chars] [input_file [output_file]]` 1. Все параметры опциональны. Поведения утилиты без параметров -- простой вывод уникальных строк из входных данных. 2. Параметры c, d, u взаимозаменяемы. Необходимо учитывать, что параллельно эти параметры не имеют никакого смысла. При передаче одного вместе с другим нужно отобразить пользователю правильное использование утилиты 3. Если не передан input_file, то входным потоком считать stdin 4. Если не передан output_file, то выходным потоком считать stdout ### Пример работы
Без параметров ```bash $cat input.txt I love music. I love music. I love music. I love music of Kartik. I love music of Kartik. Thanks. I love music of Kartik. I love music of Kartik. $cat input.txt | go run uniq.go I love music. I love music of Kartik. Thanks. I love music of Kartik. ```
С параметром input_file ```bash $cat input.txt I love music. I love music. I love music. I love music of Kartik. I love music of Kartik. Thanks. I love music of Kartik. I love music of Kartik. $go run uniq.go input.txt I love music. I love music of Kartik. Thanks. I love music of Kartik. ```
С параметрами input_file и output_file ```bash $cat input.txt I love music. I love music. I love music. I love music of Kartik. I love music of Kartik. Thanks. I love music of Kartik. I love music of Kartik. $go run uniq.go input.txt output.txt $cat output.txt I love music. I love music of Kartik. Thanks. I love music of Kartik. ```
С параметром -c ```bash $cat input.txt I love music. I love music. I love music. I love music of Kartik. I love music of Kartik. Thanks. I love music of Kartik. I love music of Kartik. $cat input.txt | go run uniq.go -c 3 I love music. 1 2 I love music of Kartik. 1 Thanks. 2 I love music of Kartik. ```
С параметром -d ```bash $cat input.txt I love music. I love music. I love music. I love music of Kartik. I love music of Kartik. Thanks. I love music of Kartik. I love music of Kartik. $cat input.txt | go run uniq.go -d I love music. I love music of Kartik. I love music of Kartik. ```
С параметром -u ```bash $cat input.txt I love music. I love music. I love music. I love music of Kartik. I love music of Kartik. Thanks. I love music of Kartik. I love music of Kartik. $cat input.txt | go run uniq.go -u Thanks. ```
С параметром -i ```bash $cat input.txt I LOVE MUSIC. I love music. I LoVe MuSiC. I love MuSIC of Kartik. I love music of kartik. Thanks. I love music of kartik. I love MuSIC of Kartik. $cat input.txt | go run uniq.go -i I LOVE MUSIC. I love MuSIC of Kartik. Thanks. I love music of kartik. ```
С параметром -f num ```bash $cat input.txt We love music. I love music. They love music. I love music of Kartik. We love music of Kartik. Thanks. $cat input.txt | go run uniq.go -f 1 We love music. I love music of Kartik. Thanks. ```
С параметром -s num ```bash $cat input.txt I love music. A love music. C love music. I love music of Kartik. We love music of Kartik. Thanks. $cat input.txt | go run uniq.go -s 1 I love music. I love music of Kartik. We love music of Kartik. Thanks. ```
### Тестирование Нужно протестировать поведение написанной функциональности с различными параметрами. Для тестирования нужно написать unit-тесты на эту функциональность. Тесты нужны как для успешных случаев, так и для неуспешных. Примеры с тестами мы будем показывать ещё на следующих лекциях, но сейчас можно посмотреть в [шестом примере первой лекции](https://github.com/go-park-mail-ru/lectures/blob/master/1-basics/6_is_sorted/sorted/sorted_test.go). ### Материалы в помощь В `1-basics/readme.md` есть список книг по го, а так же по всем частым и нужным операциям, там вы можете найти многие примеры кода, которые вам пригодятся. Материалы в помощь: * https://habrahabr.ru/post/306914/ - пакет io * https://golang.org/pkg/sort/ * https://golang.org/pkg/io/ * https://golang.org/pkg/io/ioutil/ * https://godoc.org/flag - пакет для флагов * https://godoc.org/github.com/stretchr/testify - удобный набор пакетов для тестирования * https://golang.org/pkg/bufio/#Scanner - удобный способ прочитать линии из потока данных ### Best practices 1. Уникализация строк может понадобиться не только как утилита, но и как часть более крупной логики. Для этого саму функцию уникализации можно вынести в отдельный пакет. Поскольку более крупная логика не всегда связана с чтением аргументов и данных из файла или stdin, то на вход этой функции нужно передавать слайс строк и аргументы. 2. Множество параметров, которые вдобавок и опциональны, лучше передавать структурой (например Options). Так проще расширять функциональность, а внешнему пользователю функции (не всей утилиты) будет проще передать правильные аргументы внутрь. 3. Как файл, так и stdin удовлетворяет интерфейсу io.Reader. Поэтому логику по чтению можно сделать универсальной. Аналогично и с записью -- io.Writer 4. Для написания однотипных тестовых случаев используется [табличное тестирование](https://github.com/golang/go/wiki/TableDrivenTests). Получается, что можно написать две функции тестов: успешные тестовые случаи и неуспешные тестовые случаи. 5. Для сравнения ожидаемого и действительного можно использовать пакет [require](https://godoc.org/github.com/stretchr/testify/require). Кроме простых сравнений на равенство пакет предоставляет много других ассертов. 6. Тесты не должны зависеть от внешних ресурсов. Не нужно читать файлы внутри теста. Так же не нужно тестировать передачу параметров при вызове утилиты. Никакого внешнего взаимодействия. Тестирование функции должно быть построено на том, что мы передаём некоторые входные данные в функцию и сравниваем ответ функции с ожидаемыми выходными данными. ## Часть 2. Calc Нужно написать калькулятор, умеющий вычислять выражение, подаваемое на STDIN. Достаточно реализовать сложение, вычитание, умножение, деление (поддержать дробное), поддержку скобок и унарный минус. Тут также нужны тесты 🙂 Тестами нужно покрыть все операции. ### Пример работы ```bash $ go run calc.go "(1+2)-3" 0 $ go run calc.go "(1+2)*3" 9 ``` ================================================ FILE: 1-basics/readme.md ================================================ Материалы для дополнительного чтения на английском: * https://golang.org/ref/spec - спецификация по язык * https://golang.org/ref/mem - модель памяти го. на начальном этапе не надо, но знать полезно * https://golang.org/doc/code.html - про организацию кода. GOPATH и пакеты * https://golang.org/cmd/go/ * https://blog.golang.org/strings * https://blog.golang.org/slices * https://blog.golang.org/go-slices-usage-and-internals * https://github.com/golang/go/wiki - вики го на гитхабе. очень много полезной информации * https://blog.golang.org/go-maps-in-action * https://blog.golang.org/organizing-go-code * https://golang.org/doc/effective_go.html - основной сборник тайного знания, сюда вы будуте обращатсья в первое время часто * https://github.com/golang/go/wiki/CodeReviewComments как ревьювить (и писать код). обязательно к прочтению * https://divan.github.io/posts/avoid_gotchas/ - материал аналогичный 50 оттенков го * https://research.swtch.com/interfaces * https://research.swtch.com/godata * http://jordanorelli.com/post/42369331748/function-types-in-go-golang * https://www.devdungeon.com/content/working-files-go - работа с файлами * http://www.golangprograms.com - много how-to касательно базовых вещей в go * http://yourbasic.org/golang/ - ещё большой набор how-to где можно получить углублённую информацию по всем базовым вещам. очень полезны http://yourbasic.org/golang/blueprint/ * https://github.com/Workiva/go-datastructures * https://github.com/enocom/gopher-reading-list - большая подборка статей по многим темам ( не только данной лекции ) Материалы для дополнительного чтения на русском: * https://habrahabr.ru/company/mailru/blog/314804/ - 50 оттенков го. обязательно к прочтению. многое оттуда мы ещё не проходили, но на будущее - имейте ввиду * https://habrahabr.ru/post/306914/ - Разбираемся в Go: пакет io * https://habrahabr.ru/post/272383/ - постулаты go. Маленькая статья об основными принципах языка * https://habrahabr.ru/company/mailru/blog/301036/ - лучшие практики go * https://habrahabr.ru/post/308198/ - организация кода в go * https://habrahabr.ru/post/339192/ - Зачем в Go амперсанд и звёздочка (& и *) * https://habrahabr.ru/post/325468/ - как не наступать на грабли в Go * https://habrahabr.ru/post/276981/ - Краш-курс по интерфейсам в Go * http://golang-book.ru Литература по го на русском языке: * Язык программирования Go, Алан А. А. Донован, Брайан У. Керниган * Go на практике, Matt Butcher, Мэтт Фарина Мэтт * Программирование на Go. Разработка приложений XXI века, Марк Саммерфильд Дополнительные упражнения: * https://go-tour-ru-ru.appspot.com/list - упражнения на овладение базовым синтаксисом, на случай если вам нужна небольшая практика перед первым заданием курса ================================================ FILE: 10-performance/1_reflect/1_print/reflect_1.go ================================================ package main import ( "fmt" "reflect" ) type UserID int type UserID2 UserID type User struct { ID UserID2 RealName string `unpack:"-"` Login string Flags int } func PrintReflect(u interface{}) error { val := reflect.ValueOf(u).Elem() fmt.Printf("%T have %d fields:\n", u, val.NumField()) for i := 0; i < val.NumField(); i++ { valueField := val.Field(i) typeField := val.Type().Field(i) fmt.Printf("\tname=%v, type=%v, value=%v, tag=`%v`\n", typeField.Name, typeField.Type.Kind(), valueField, typeField.Tag.Get("unpack"), ) } return nil } func main() { u := &User{ ID: 42, RealName: "unrealname", Flags: 32, } err := PrintReflect(u) if err != nil { panic(err) } } ================================================ FILE: 10-performance/1_reflect/2_unpack/reflect_2.go ================================================ package main import ( "bytes" "encoding/binary" "fmt" "reflect" ) type User struct { ID int RealName string `unpack:"-"` Login string Flags int } func UnpackReflect(u interface{}, data []byte) error { r := bytes.NewReader(data) val := reflect.ValueOf(u) if val.Kind() != reflect.Ptr { return fmt.Errorf("input is not pointer") } val = val.Elem() for i := 0; i < val.NumField(); i++ { valueField := val.Field(i) typeField := val.Type().Field(i) if typeField.Tag.Get("unpack") == "-" { continue } switch typeField.Type.Kind() { case reflect.Int: var value uint32 binary.Read(r, binary.LittleEndian, &value) valueField.SetInt(int64(value)) case reflect.String: var lenRaw uint32 binary.Read(r, binary.LittleEndian, &lenRaw) dataRaw := make([]byte, lenRaw) binary.Read(r, binary.LittleEndian, &dataRaw) valueField.SetString(string(dataRaw)) default: return fmt.Errorf("bad type: %v for field %v", typeField.Type.Kind(), typeField.Name) } } return nil } func main() { /* perl -E '$b = pack("L L/a* L", 1_123_456, "kek.kekovitch", 16); print map { ord.", " } split("", $b); ' */ data := []byte{ 128, 36, 17, 0, 13, 0, 0, 0, 107, 101, 107, 46, 107, 101, 107, 111, 118, 105, 116, 99, 104, 16, 0, 0, 0, } u := &User{} err := UnpackReflect(u, data) if err != nil { panic(err) } fmt.Printf("%#v", u) } ================================================ FILE: 10-performance/2_codegen/gen/codegen.go ================================================ // go build gen/* && ./codegen.exe pack/unpack.go pack/marshaller.go // go run pack/* package main import ( "fmt" "go/ast" "go/parser" "go/token" "log" "os" "reflect" "strings" "text/template" ) type tpl struct { FieldName string } var ( intTpl = template.Must(template.New("intTpl").Parse(` // {{.FieldName}} var {{.FieldName}}Raw uint32 binary.Read(r, binary.LittleEndian, &{{.FieldName}}Raw) in.{{.FieldName}} = int({{.FieldName}}Raw) `)) strTpl = template.Must(template.New("strTpl").Parse(` // {{.FieldName}} var {{.FieldName}}LenRaw uint32 binary.Read(r, binary.LittleEndian, &{{.FieldName}}LenRaw) {{.FieldName}}Raw := make([]byte, {{.FieldName}}LenRaw) binary.Read(r, binary.LittleEndian, &{{.FieldName}}Raw) in.{{.FieldName}} = string({{.FieldName}}Raw) `)) ) func main() { fset := token.NewFileSet() node, err := parser.ParseFile(fset, os.Args[1], nil, parser.ParseComments) if err != nil { log.Fatal(err) } out, _ := os.Create(os.Args[2]) fmt.Fprintln(out, `package `+node.Name.Name) fmt.Fprintln(out) // empty line fmt.Fprintln(out, `import "encoding/binary"`) fmt.Fprintln(out, `import "bytes"`) fmt.Fprintln(out) // empty line for _, f := range node.Decls { g, ok := f.(*ast.GenDecl) if !ok { fmt.Printf("SKIP %#T is not *ast.GenDecl\n", f) continue } SPECS_LOOP: for _, spec := range g.Specs { currType, ok := spec.(*ast.TypeSpec) if !ok { fmt.Printf("SKIP %#T is not ast.TypeSpec\n", spec) continue } currStruct, ok := currType.Type.(*ast.StructType) if !ok { fmt.Printf("SKIP %#T is not ast.StructType\n", currStruct) continue } if g.Doc == nil { fmt.Printf("SKIP struct %#v doesnt have comments\n", currType.Name.Name) continue } needCodegen := false for _, comment := range g.Doc.List { needCodegen = needCodegen || strings.HasPrefix(comment.Text, "// cgen: binpack") } if !needCodegen { fmt.Printf("SKIP struct %#v doesnt have cgen mark\n", currType.Name.Name) continue SPECS_LOOP } fmt.Printf("process struct %s\n", currType.Name.Name) fmt.Printf("\tgenerating Unpack method\n") fmt.Fprintln(out, "func (in *"+currType.Name.Name+") Unpack(data []byte) error {") fmt.Fprintln(out, " r := bytes.NewReader(data)") FIELDS_LOOP: for _, field := range currStruct.Fields.List { if field.Tag != nil { tag := reflect.StructTag(field.Tag.Value[1 : len(field.Tag.Value)-1]) if tag.Get("cgen") == "-" { continue FIELDS_LOOP } } fieldName := field.Names[0].Name fieldType := field.Type.(*ast.Ident).Name fmt.Printf("\tgenerating code for field %s.%s\n", currType.Name.Name, fieldName) switch fieldType { case "int": intTpl.Execute(out, tpl{fieldName}) case "string": strTpl.Execute(out, tpl{fieldName}) default: log.Fatalln("unsupported", fieldType) } } fmt.Fprintln(out, " return nil") fmt.Fprintln(out, "}") // end of Unpack func fmt.Fprintln(out) // empty line } } } // go build gen/* && ./codegen.exe pack/unpack.go pack/marshaller.go // go run pack/* ================================================ FILE: 10-performance/2_codegen/pack/marshaller.go ================================================ package main import "encoding/binary" import "bytes" func (in *User) Unpack(data []byte) error { r := bytes.NewReader(data) // ID var IDRaw uint32 binary.Read(r, binary.LittleEndian, &IDRaw) in.ID = int(IDRaw) // Name var NameLenRaw uint32 binary.Read(r, binary.LittleEndian, &NameLenRaw) NameRaw := make([]byte, NameLenRaw) binary.Read(r, binary.LittleEndian, &NameRaw) in.Name = string(NameRaw) // Flags var FlagsRaw uint32 binary.Read(r, binary.LittleEndian, &FlagsRaw) in.Flags = int(FlagsRaw) return nil } ================================================ FILE: 10-performance/2_codegen/pack/unpack.go ================================================ // go build -o ./codegen.exe gen/* && ./codegen.exe pack/unpack.go pack/marshaller.go package main import "fmt" // lets generate code for this struct // cgen: binpack type User struct { ID int RealName string `cgen:"-"` Name string Flags int } type Avatar struct { ID int Url string } var test = 42 func main() { /* perl -E '$b = pack("L L/a* L", 1_123_456, "kek.kekovitch", 16); print map { ord.", " } split("", $b); ' */ data := []byte{ 128, 36, 17, 0, 13, 0, 0, 0, 107, 101, 107, 46, 107, 101, 107, 111, 118, 105, 116, 99, 104, 16, 0, 0, 0, } u := User{} u.Unpack(data) fmt.Printf("Unpacked user %#v", u) } ================================================ FILE: 10-performance/3_perfomance_1/1_unpack/unpack_test.go ================================================ package unpack import ( "bytes" "encoding/binary" "fmt" "reflect" "testing" ) /* go test -bench . unpack_test.go go test -bench . -benchmem unpack_test.go */ var ( data = []byte{ 128, 36, 17, 0, 9, 0, 0, 0, 118, 46, 114, 111, 109, 97, 110, 111, 118, 16, 0, 0, 0, } ) type User struct { ID int RealName string `cgen:"-"` Login string Flags int } func BenchmarkCodegen(b *testing.B) { u := &User{} for i := 0; i < b.N; i++ { u = &User{} u.UnpackBin(data) } } func BenchmarkReflect(b *testing.B) { u := &User{} for i := 0; i < b.N; i++ { u = &User{} UnpackReflect(u, data) } } func (in *User) UnpackBin(data []byte) error { r := bytes.NewReader(data) // ID var IDRaw uint32 binary.Read(r, binary.LittleEndian, &IDRaw) in.ID = int(IDRaw) // Login var LoginLenRaw uint32 binary.Read(r, binary.LittleEndian, &LoginLenRaw) LoginRaw := make([]byte, LoginLenRaw) binary.Read(r, binary.LittleEndian, &LoginRaw) in.Login = string(LoginRaw) // Flags var FlagsRaw uint32 binary.Read(r, binary.LittleEndian, &FlagsRaw) in.Flags = int(FlagsRaw) return nil } func UnpackReflect(u interface{}, data []byte) error { r := bytes.NewReader(data) val := reflect.ValueOf(u).Elem() for i := 0; i < val.NumField(); i++ { valueField := val.Field(i) typeField := val.Type().Field(i) if typeField.Tag.Get("unpack") == "-" { continue } switch typeField.Type.Kind() { case reflect.Int: var value int binary.Read(r, binary.LittleEndian, &value) valueField.Set(reflect.ValueOf(value)) case reflect.String: var lenRaw int binary.Read(r, binary.LittleEndian, &lenRaw) dataRaw := make([]byte, lenRaw) binary.Read(r, binary.LittleEndian, &dataRaw) valueField.SetString(string(dataRaw)) default: return fmt.Errorf("bad type: %v for field %v", typeField.Type.Kind(), typeField.Name) } } return nil } /* go test -bench . unpack_test.go go test -bench . -benchmem unpack_test.go go test -bench . -benchmem -cpuprofile=cpu.out -memprofile=mem.out -memprofilerate=1 unpack_test.go go tool pprof -http=:8083 unpack.test cpu.out go tool pprof unpack.test cpu.out go tool pprof unpack.test mem.out go get github.com/uber/go-torch go-torch unpack.test cpu.out */ ================================================ FILE: 10-performance/3_perfomance_1/2_prealloc/prealloc_test.go ================================================ // go test -bench . -benchmem prealloc_test.go package prealloc import ( "testing" ) const iterNum = 1000 func BenchmarkEmptyAppend(b *testing.B) { for i := 0; i < b.N; i++ { data := make([]int, 0) for j := 0; j < iterNum; j++ { data = append(data, j) } } } func BenchmarkPreallocAppend(b *testing.B) { for i := 0; i < b.N; i++ { data := make([]int, 0, iterNum) for j := 0; j < iterNum; j++ { data = append(data, j) } } } /* go test -bench . -benchmem -cpuprofile=cpu.out -memprofile=mem.out -memprofilerate=1 prealloc/prealloc_test.go go tool pprof -http=:8083 prealloc.test cpu.out go tool pprof prealloc.test cpu.out go tool pprof prealloc.test mem.out go tool pprof -svg -inuse_space prealloc.test mem.out > mem_is.svg go tool pprof -svg -inuse_objects prealloc.test mem.out > mem_io.svg go tool pprof -svg prealloc.test cpu.out > cpu.svg go tool pprof -png prealloc.test cpu.out > cpu.png */ ================================================ FILE: 10-performance/3_perfomance_1/3_pool/pool_test.go ================================================ package pool import ( "bytes" "encoding/json" "sync" "testing" ) const iterNum = 100 type PublicPage struct { ID int Name string Url string OwnerID int ImageUrl string Tags []string Description string Rules string } var CoolGolangPublic = PublicPage{ ID: 1, Name: "CoolGolangPublic", Url: "http://example.com", OwnerID: 100500, ImageUrl: "http://example.com/img.png", Tags: []string{"programming", "go", "golang"}, Description: "Best page about golang programming", Rules: "", } var Pages = []PublicPage{ CoolGolangPublic, CoolGolangPublic, CoolGolangPublic, } func BenchmarkAllocNew(b *testing.B) { b.RunParallel(func(pb *testing.PB) { for pb.Next() { data := bytes.NewBuffer(make([]byte, 0, 64)) _ = json.NewEncoder(data).Encode(Pages) } }) } var dataPool = sync.Pool{ New: func() interface{} { return bytes.NewBuffer(make([]byte, 0, 64)) }, } func BenchmarkAllocPool(b *testing.B) { b.RunParallel(func(pb *testing.PB) { for pb.Next() { data := dataPool.Get().(*bytes.Buffer) _ = json.NewEncoder(data).Encode(Pages) data.Reset() dataPool.Put(data) } }) } /* go test -bench . -benchmem pool/pool_test.go */ ================================================ FILE: 10-performance/3_perfomance_1/4_string/string_test.go ================================================ package string import ( "regexp" "strings" "testing" ) var ( browser = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36" re = regexp.MustCompile("Android") ) // regexp.MatchString компилирует регулярку каждый раз func BenchmarkRegExp(b *testing.B) { for i := 0; i < b.N; i++ { _, _ = regexp.MatchString("Android", browser) } } // используем прекомпилированную регулярку func BenchmarkRegCompiled(b *testing.B) { for i := 0; i < b.N; i++ { re.MatchString(browser) } } // просто ищем вхождение подстроки func BenchmarkStrContains(b *testing.B) { for i := 0; i < b.N; i++ { _ = strings.Contains(browser, "Android") } } /* go test -bench . string/string_test.go go test -bench . -benchmem string/string_test.go go test -bench . -benchmem -benchtime=100000x -cpuprofile=cpu.out -memprofile=mem.out -memprofilerate=1 string/string_test.go go tool pprof -http=:8083 string.test cpu.out go tool pprof string.test cpu.out go tool pprof string.test mem.out go tool pprof -svg -inuse_space string.test mem.out > mem_is.svg go tool pprof -svg -inuse_objects string.test mem.out > mem_io.svg go tool pprof -svg string.test cpu.out > cpu.svg go tool pprof -png string.test cpu.out > cpu.png */ ================================================ FILE: 10-performance/3_perfomance_1/5_json/json_test.go ================================================ package json import ( "encoding/json" "testing" ) var ( data = []byte(`{"RealName":"Vasily", "Login":"v.romanov", "Status":1, "Flags": 1}`) u = User{} c = Client{} ) // go test -v -bench=. -benchmem json/*.go // go test -v -bench=. json/*.go func BenchmarkDecodeStandart(b *testing.B) { for i := 0; i < b.N; i++ { _ = json.Unmarshal(data, &c) } } func BenchmarkDecodeEasyjson(b *testing.B) { for i := 0; i < b.N; i++ { _ = u.UnmarshalJSON(data) } } func BenchmarkEncodeStandart(b *testing.B) { for i := 0; i < b.N; i++ { _, _ = json.Marshal(&c) } } func BenchmarkEncodeEasyjson(b *testing.B) { for i := 0; i < b.N; i++ { _, _ = u.MarshalJSON() } } ================================================ FILE: 10-performance/3_perfomance_1/5_json/struct.go ================================================ package json //easyjson:json type User struct { Id int RealName string Login string Flags int Status int } type Client struct { Id int RealName string Login string Flags int Status int } ================================================ FILE: 10-performance/3_perfomance_1/5_json/struct_easyjson.go ================================================ // Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT. package json import ( json "encoding/json" easyjson "github.com/mailru/easyjson" jlexer "github.com/mailru/easyjson/jlexer" jwriter "github.com/mailru/easyjson/jwriter" ) // suppress unused package warning var ( _ *json.RawMessage _ *jlexer.Lexer _ *jwriter.Writer _ easyjson.Marshaler ) func easyjson9f2eff5fDecodeSt(in *jlexer.Lexer, out *User) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { in.Consumed() } in.Skip() return } in.Delim('{') for !in.IsDelim('}') { key := in.UnsafeString() in.WantColon() if in.IsNull() { in.Skip() in.WantComma() continue } switch key { case "Id": out.Id = int(in.Int()) case "RealName": out.RealName = string(in.String()) case "Login": out.Login = string(in.String()) case "Flags": out.Flags = int(in.Int()) case "Status": out.Status = int(in.Int()) default: in.SkipRecursive() } in.WantComma() } in.Delim('}') if isTopLevel { in.Consumed() } } func easyjson9f2eff5fEncodeSt(out *jwriter.Writer, in User) { out.RawByte('{') first := true _ = first if !first { out.RawByte(',') } first = false out.RawString("\"Id\":") out.Int(int(in.Id)) if !first { out.RawByte(',') } first = false out.RawString("\"RealName\":") out.String(string(in.RealName)) if !first { out.RawByte(',') } first = false out.RawString("\"Login\":") out.String(string(in.Login)) if !first { out.RawByte(',') } first = false out.RawString("\"Flags\":") out.Int(int(in.Flags)) if !first { out.RawByte(',') } first = false out.RawString("\"Status\":") out.Int(int(in.Status)) out.RawByte('}') } // MarshalJSON supports json.Marshaler interface func (v User) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjson9f2eff5fEncodeSt(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v User) MarshalEasyJSON(w *jwriter.Writer) { easyjson9f2eff5fEncodeSt(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *User) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjson9f2eff5fDecodeSt(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *User) UnmarshalEasyJSON(l *jlexer.Lexer) { easyjson9f2eff5fDecodeSt(l, v) } ================================================ FILE: 10-performance/4_perfomance_2/1_optimize/pprof_1.go ================================================ package main import ( "bytes" "fmt" "net/http" _ "net/http/pprof" "sync" "time" ) type Post struct { ID int Text string Author string Comments int Time time.Time } func handleSlow(w http.ResponseWriter, req *http.Request) { s := "" for i := 0; i < 1000; i++ { p := &Post{ID: i, Text: "new post"} s += fmt.Sprintf("%#v", p) } w.Write([]byte(s)) } func main() { http.HandleFunc("/", handleSlow) http.HandleFunc("/fast", handleFast) fmt.Println("starting server at :8080") fmt.Println(http.ListenAndServe(":8080", nil)) } /* go build -o pprof_1.exe pprof_1.go && ./pprof_1.exe hey -z 20s http://127.0.0.1:8080 hey -z 20s http://127.0.0.1:8080/fast curl http://127.0.0.1:8080/debug/pprof/heap -o mem_out.txt curl http://127.0.0.1:8080/debug/pprof/profile?seconds=5 -o cpu_out.txt go tool pprof -svg -inuse_space pprof_1.exe mem_out.txt > mem_is.svg go tool pprof -svg -inuse_objects pprof_1.exe mem_out.txt > mem_oo.svg go tool pprof -svg -alloc_space pprof_1.exe mem_out.txt > mem_as.svg go tool pprof -svg -alloc_objects pprof_1.exe mem_out.txt > mem_ao.svg go tool pprof -svg pprof_1.exe cpu_out.txt > cpu.svg */ var dataPool = sync.Pool{ New: func() interface{} { return &Post{} }, } var bufPool = sync.Pool{ New: func() interface{} { return bytes.NewBuffer(make([]byte, 0, 50000)) }, } func handleFast(w http.ResponseWriter, req *http.Request) { buf := bufPool.Get().(*bytes.Buffer) for i := 0; i < 1000; i++ { p := dataPool.Get().(*Post) p.ID = i p.Text = "new post" fmt.Fprintf(buf, "%#v", p) *p = Post{} dataPool.Put(p) } buf.Reset() bufPool.Put(buf) w.Write(buf.Bytes()) } ================================================ FILE: 10-performance/4_perfomance_2/1_optimize/pprof_1.sh ================================================ curl http://127.0.0.1:8080/debug/pprof/profile?seconds=5 -o cpu_out.txt curl http://127.0.0.1:8080/debug/pprof/heap -o mem_out.txt # go tool pprof -svg -alloc_objects pprof_1.exe mem_out.txt > mem_ao.svg # go tool pprof -svg -alloc_space pprof_1.exe mem_out.txt > mem_as.svg # go tool pprof -svg -inuse_objects pprof_1.exe mem_out.txt > mem_io.svg # go tool pprof -svg -inuse_space pprof_1.exe mem_out.txt > mem_is.svg # go tool pprof -svg pprof_1.exe cpu_out.txt > cpu.svg # go tool pprof pprof_1.exe mem_out.txt # go tool pprof pprof_1.exe cpu_out.txt # go tool pprof -http=:8081 -alloc_objects pprof_1.exe mem_out.txt # go tool pprof -http=:8081 pprof_1.exe cpu_out.txt ================================================ FILE: 10-performance/4_perfomance_2/2_leak_grtn/pprof_2.go ================================================ package main import ( "fmt" "net/http" _ "net/http/pprof" "time" ) type Post struct { ID int Text string Author string Comments int Time time.Time } func getPost(out chan []Post) { posts := []Post{} for i := 1; i < 10; i++ { post := Post{ID: 1, Text: "text"} posts = append(posts, post) } out <- posts } func longHeavyWork(ch chan bool) { time.Sleep(1 * time.Minute) ch <- true } func handleLeak(w http.ResponseWriter, req *http.Request) { res := make(chan []Post) go getPost(res) return <-res } func main() { http.HandleFunc("/", handleLeak) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } /* go build -o pprof_2.exe pprof_2.go && ./pprof_2.exe hey -z 30s -q 100 http://127.0.0.1:8080/ ./pprof_2.sh */ ================================================ FILE: 10-performance/4_perfomance_2/2_leak_grtn/pprof_2.sh ================================================ curl http://localhost:8080/debug/pprof/goroutine?debug=2 -o goroutines.txt curl http://127.0.0.1:8080/debug/pprof/heap -o mem_out.txt # go tool pprof -svg -inuse_objects pprof_2.exe mem_out.txt > mem_io.svg # go tool pprof -svg -inuse_space pprof_2.exe mem_out.txt > mem_is.svg ================================================ FILE: 10-performance/4_perfomance_2/3_tracing/tracing.go ================================================ package main import ( "encoding/json" "fmt" "net/http" _ "net/http/pprof" "runtime" "time" ) type Post struct { ID int Text string Author string Comments int Time time.Time } func handle(w http.ResponseWriter, req *http.Request) { result := "" for i := 0; i < 100; i++ { currPost := &Post{ID: i, Text: "new post", Time: time.Now()} jsonRaw, _ := json.Marshal(currPost) result += string(jsonRaw) } time.Sleep(3 * time.Millisecond) w.Write([]byte(result)) } func main() { runtime.GOMAXPROCS(4) http.HandleFunc("/", handle) fmt.Println("starting server at :8080") fmt.Println(http.ListenAndServe(":8080", nil)) } /* go build -o tracing.exe tracing.go && ./tracing.exe ab -t 300 -n 10000000 -c 10 http://127.0.0.1:8080/ curl http://localhost:8080/debug/pprof/trace?seconds=10 -o trace.out go tool trace -http "0.0.0.0:8081" tracing.exe trace.out */ ================================================ FILE: 10-performance/4_perfomance_2/note.txt ================================================ go tool pprof -http=:8080 pprof_2.exe cpu_out.txt ================================================ FILE: 10-performance/5_testing/cover.html ================================================
not tracked not covered covered
================================================ FILE: 10-performance/5_testing/coverage_test.go ================================================ package main import ( "testing" "reflect" ) type TestCase struct{ Key string User *User IsError bool } func TestGetUser(t *testing.T) { cases := []TestCase{ TestCase{"ok", &User{ID: 27}, false}, // TestCase{"fail", nil, true}, TestCase{"not_exist", nil, true}, } for caseNum, item := range cases { u, err := GetUser(item.Key) if item.IsError && err == nil { t.Errorf("[%d] expected error, got nil", caseNum) } if !item.IsError && err != nil { t.Errorf("[%d] unexpected error", caseNum, err) } if !reflect.DeepEqual(u, item.User) { t.Errorf("[%d] wrong results: got %+v, expected %+v", caseNum, u, item.User) } } } /* go test -coverprofile=cover.out go tool cover -html=cover.out -o cover.html */ ================================================ FILE: 10-performance/5_testing/main.go ================================================ package main import ( "encoding/json" "fmt" ) type User struct { ID int } var data = map[string][]byte{ "ok": []byte(`{"ID": 27}`), "fail": []byte(`{"ID": 27`), } func GetUser(key string) (*User, error) { if jsonStr, ok := data[key]; ok { user := &User{} err := json.Unmarshal(jsonStr, user) if err != nil { return nil, fmt.Errorf("Cant decode json") } return user, nil } return nil, fmt.Errorf("User doesnt exist") } ================================================ FILE: 10-performance/6_xml_stream/main.go ================================================ package main import ( "encoding/xml" "fmt" "bytes" "io" ) type User struct { ID int `xml:"id,attr"` Login string `xml:"login"` Name string `xml:"name"` Browser string `xml:"browser"` } type Users struct { Version string `xml:"version,attr"` List []User `xml:"user"` } var xmlData = []byte(` user1 Василий Романов Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36 user2 Иван Иванов Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36 user3 Иван Петров Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; Trident/5.0) user1 Василий Романов Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36 user2 Иван Иванов Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36 user3 Иван Петров Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; Trident/5.0) `) func CountStruct() { logins := make([]string, 0) v := new(Users) err := xml.Unmarshal(xmlData, &v) if err != nil { fmt.Printf("error: %v", err) return } for _, u := range v.List { logins = append(logins, u.Login) } } func CountDecoder() { input := bytes.NewReader(xmlData) decoder := xml.NewDecoder(input) logins := make([]string, 0) var login string for { tok, tokenErr := decoder.Token() if tokenErr != nil && tokenErr != io.EOF { fmt.Println("error happend", tokenErr) break } else if tokenErr == io.EOF { break } if tok == nil { fmt.Println("t is nil break") } switch tok := tok.(type) { case xml.StartElement: if tok.Name.Local == "login" { if err := decoder.DecodeElement(&login, &tok); err != nil { fmt.Println("error happend", err) } logins = append(logins, login) } } } } /* go test -bench . -benchmem xml_test.go */ func main() { CountStruct() CountDecoder() } ================================================ FILE: 10-performance/6_xml_stream/xml_test.go ================================================ package main import ( "testing" ) func BenchmarkCountStruct(b *testing.B) { for i := 0; i < b.N; i++ { CountStruct() } } func BenchmarkCountDecoder(b *testing.B) { for i := 0; i < b.N; i++ { CountDecoder() } } ================================================ FILE: 10-performance/7_inline_escape/main.go ================================================ package main import ( "fmt" ) /* go run -gcflags -m main.go go run -gcflags '-m -m' main.go */ type User struct { ID int Login string } func (u *User) GetID() int { return u.ID } func newUser(login string) *User { return &User{123, login} } func setToZero(in *int) { // for i := 0; i<3; i++ { // *in = 1 // } *in = 0 } func main() { u := newUser("test") u.ID = 1 data := make([]string, 20) data = append(data, "test") i := 1 setToZero(&i) // _ = fmt.Sprint(data) // _ = fmt.Sprint(u) fmt.Println("test") } ================================================ FILE: 10-performance/8_cgo/1_example/main.go ================================================ package main /* #include */ import "C" import "fmt" func main() { num := C.double(16) result := C.sqrt(num) fmt.Printf("Квадратный корень из %.2f равен %.2f\n", num, result) } ================================================ FILE: 10-performance/8_cgo/2_performance/main.go ================================================ package main /* #include long long factorialC(long long n) { long long result = 1; for (long long i = 2; i <= n; i++) { result *= i; } return result; } */ import "C" import ( "fmt" "math/big" ) func factorialCGo(n int64) int64 { return int64(C.factorialC(C.longlong(n))) } func factorialGo(n int64) *big.Int { result := big.NewInt(1) for i := int64(2); i <= n; i++ { result.Mul(result, big.NewInt(i)) } return result } func main() { n := int64(20) fmt.Println("Факториал на C через CGO:", factorialCGo(n)) } ================================================ FILE: 10-performance/8_cgo/3_usage/README.md ================================================ ``` brew install pkg-config ``` https://github.com/klippa-app/go-pdfium ================================================ FILE: 10-performance/8_cgo/3_usage/go.mod ================================================ module pdfium go 1.23.3 require github.com/klippa-app/go-pdfium v1.13.0 require ( github.com/fatih/color v1.13.0 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-hclog v1.6.3 // indirect github.com/hashicorp/go-plugin v1.6.1 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/mattn/go-colorable v0.1.12 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 // indirect github.com/oklog/run v1.0.0 // indirect golang.org/x/net v0.29.0 // indirect golang.org/x/sys v0.25.0 // indirect golang.org/x/text v0.18.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect google.golang.org/grpc v1.58.3 // indirect google.golang.org/protobuf v1.34.1 // indirect ) ================================================ FILE: 10-performance/8_cgo/3_usage/go.sum ================================================ github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= 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/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 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-20240727154555-813a5fbdbec8 h1:FKHo8hFI3A+7w0aUQuYXQ+6EN5stWmeY/AZqtM8xk9k= github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= 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/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-plugin v1.6.1 h1:P7MR2UP6gNKGPp+y7EZw2kOiq4IR9WiqLvp0XOsVdwI= github.com/hashicorp/go-plugin v1.6.1/go.mod h1:XPHFku2tFo3o3QKFgSYo+cghcUhw1NA1hZyMK0PWAw0= github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo= github.com/klippa-app/go-pdfium v1.13.0 h1:Ow9+cPhhcmKdxp3GCwds79zWyOZHyJIJGGt70R/nUWc= github.com/klippa-app/go-pdfium v1.13.0/go.mod h1:eVVeeXJkk+W6KLaJy4fizsERYUaMqJulSXD9JQjx+8s= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 h1:7GoSOOW2jpsfkntVKaS2rAr1TJqfcxotyaUcuxoZSzg= github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/onsi/ginkgo/v2 v2.20.0 h1:PE84V2mHqoT1sglvHc8ZdQtPcwmvvt29WLEEO3xmdZw= github.com/onsi/ginkgo/v2 v2.20.0/go.mod h1:lG9ey2Z29hR41WMVthyJBGUBcBhGOtoPF2VFMvBXFCI= github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= 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/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tetratelabs/wazero v1.8.1 h1:NrcgVbWfkWvVc4UtT4LRLDf91PsOzDzefMdwhLfA550= github.com/tetratelabs/wazero v1.8.1/go.mod h1:yAI0XTsMBhREkM/YDAK/zNou3GoiAce1P6+rp/wQhjs= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U= google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ= google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= 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.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= 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: 10-performance/8_cgo/3_usage/main.go ================================================ package main import ( "image/png" "io/ioutil" "log" "os" "time" "github.com/klippa-app/go-pdfium" "github.com/klippa-app/go-pdfium/requests" "github.com/klippa-app/go-pdfium/single_threaded" ) // Be sure to close pools/instances when you're done with them. var pool pdfium.Pool var instance pdfium.Pdfium func init() { // Init the PDFium library and return the instance to open documents. pool = single_threaded.Init(single_threaded.Config{}) var err error instance, err = pool.GetInstance(time.Second * 30) if err != nil { log.Fatal(err) } } func main() { filePath := "example.pdf" output := "example.pdf.png" err := renderPage(filePath, 1, output) if err != nil { log.Fatal(err) } } func renderPage(filePath string, page int, output string) error { // Load the PDF file into a byte array. pdfBytes, err := ioutil.ReadFile(filePath) if err != nil { return err } // Open the PDF using PDFium (and claim a worker) doc, err := instance.OpenDocument(&requests.OpenDocument{ File: &pdfBytes, }) if err != nil { return err } // Always close the document, this will release its resources. defer instance.FPDF_CloseDocument(&requests.FPDF_CloseDocument{ Document: doc.Document, }) // Render the page in DPI 200. pageRender, err := instance.RenderPageInDPI(&requests.RenderPageInDPI{ DPI: 200, // The DPI to render the page in. Page: requests.Page{ ByIndex: &requests.PageByIndex{ Document: doc, Index: 0, }, }, // The page to render, 0-indexed. }) if err != nil { return err } // Write the output to a file. f, err := os.Create(output) if err != nil { return err } defer f.Close() err = png.Encode(f, pageRender.Image) if err != nil { return err } return nil } ================================================ FILE: 10-performance/8_cgo/README.md ================================================ # CGO - Wiki: https://go.dev/wiki/cgo CGO мощный инструмент, используемый в основном для использования логики библиотек, которые изначально написаны на C и включают сложную логику. ================================================ FILE: 10-performance/readme.md ================================================ go test -bench . -benchmem -cpuprofile=cpu.out -memprofile=mem.out -memprofilerate=1 -benchtime=50000x unpack_test.go go tool pprof -http=:8083 main.test cpu.out go tool pprof -http=:8083 main.test mem.out ================================================ FILE: 2-async/0_basic_error_handling/1_ignore_errors/main.go ================================================ package main import ( "fmt" ) var idToUsername = map[int]string{ 0: "romanov", 1: "sulaev", 2: "dorofeev", } func main() { var id int for { _, err := fmt.Scanf("%d", &id) if err != nil { fmt.Printf("err scanf %v\n", err) continue } fmt.Printf("username for id %d: %s\n", id, idToUsername[id]) } } ================================================ FILE: 2-async/0_basic_error_handling/2_panic/main.go ================================================ package main import ( "fmt" ) var idToUsername = map[int]string{ 0: "romanov", 1: "sulaev", 2: "dorofeev", } func main() { var id int for { _, err := fmt.Scanf("%d", &id) if err != nil { panic(err) } username, ok := idToUsername[id] if !ok { panic(fmt.Sprintf("no user with id %d", id)) } fmt.Printf("username for id %d: %s\n", id, username) } } ================================================ FILE: 2-async/0_basic_error_handling/3_handling/main.go ================================================ package main import ( "fmt" ) var idToUsername = map[int]string{ 0: "romanov", 1: "sulaev", 2: "dorofeev", } func handling() error { var id int _, err := fmt.Scanf("%d", &id) // ask, why so many errors? if err != nil { return fmt.Errorf("failed to get username: %w", err) } username, ok := idToUsername[id] if !ok { return fmt.Errorf("no user with id %d", id) } fmt.Printf("username for id %d: %s\n", id, username) return nil } func main() { for { err := handling() if err != nil { fmt.Printf("error happened: %v\n", err) } } } ================================================ FILE: 2-async/0_basic_error_handling/4_return/main.go ================================================ package main import ( "errors" "fmt" ) type MyError struct { Code int } func (e MyError) Error() string { return fmt.Sprintf("my error, code=%d", e.Code) } func bad() error { var err *MyError = nil fmt.Println("in bad", err == nil) return nil // явно указываем nil } func main() { err := bad() var me MyError fmt.Println("errors as: ", errors.As(err, &me)) fmt.Println("in main", err == nil) fmt.Printf("err: %#v\n", err) } ================================================ FILE: 2-async/1_async/10_context_cancel/context_cancel.go ================================================ package main import ( "context" "fmt" "math/rand" "time" ) func student(ctx context.Context, workerNum int, out chan<- int) { waitTime := time.Duration(rand.Intn(100)+10) * time.Millisecond fmt.Println(workerNum, "студент думает", waitTime) select { case <-ctx.Done(): fmt.Println("студент", workerNum, "не успел придумать вопрос") return case <-time.After(waitTime): fmt.Println("студент", workerNum, "придумал") out <- workerNum } } func main() { ctx, cancel := context.WithCancel(context.Background()) result := make(chan int, 1) for i := 0; i <= 10; i++ { go student(ctx, i, result) } foundBy := <-result fmt.Println("вопрос был задан студентом", foundBy) cancel() time.Sleep(time.Second) } ================================================ FILE: 2-async/1_async/10_context_timeout/context_parent/main.go ================================================ package main import ( "context" "fmt" "time" ) func worker(ctx context.Context, name string) { fmt.Println(name, "стартовал") select { case <-ctx.Done(): fmt.Println(name, "остановлен:", ctx.Err()) case <-time.After(3 * time.Second): fmt.Println(name, "успел закончить работу", ctx.Err()) } } func main() { parentCtx, cancelParent := context.WithCancel(context.Background()) // parentCtx, cancelParent := context.WithTimeout(context.Background(), 500*time.Millisecond) childCtx1, _ := context.WithCancel(parentCtx) //childCtx2, _ := context.WithTimeout(parentCtx, 3*time.Second) go worker(childCtx1, "child-1") go worker(childCtx1, "child-2") time.Sleep(4 * time.Second) fmt.Println("main: отменяем родительский контекст") cancelParent() time.Sleep(1 * time.Second) } ================================================ FILE: 2-async/1_async/10_context_timeout/context_timeout.go ================================================ package main import ( "context" "fmt" "math/rand" "time" ) func worker(ctx context.Context, workerNum int, out chan<- int) { waitTime := time.Duration(rand.Intn(100)+10) * time.Millisecond fmt.Println(workerNum, "студент ", waitTime) select { case <-ctx.Done(): fmt.Println("студент", workerNum, "не успел придумать вопрос") return case <-time.After(waitTime): fmt.Println("студент", workerNum, "придумал вопрос") out <- workerNum } } func main() { workTime := 50 * time.Millisecond ctx, _ := context.WithTimeout(context.Background(), workTime) result := make(chan int, 1) for i := 0; i <= 10; i++ { go worker(ctx, i, result) } totalFound := 0 LOOP: for { select { case <-ctx.Done(): break LOOP case foundBy := <-result: totalFound++ fmt.Println("студент", foundBy, "задал вопрос") } } fmt.Println("всего вопросов", totalFound) time.Sleep(time.Second) } ================================================ FILE: 2-async/1_async/11_errgroup_1/errgroup_1.go ================================================ package main import ( "fmt" "time" "golang.org/x/sync/errgroup" ) const ( goroutinesNum = 3 badGorutineNum = 2 ) func printGorutineNum(num int) error { fmt.Println(num, "gorutine will work after") if num == badGorutineNum { fmt.Println("error found in gorutine", num) return fmt.Errorf("bad gorutine number %d", num) } fmt.Println("goroutine number", num) return nil } func main() { eg := errgroup.Group{} // Инициализируем группу for i := 0; i < goroutinesNum; i++ { eg.Go(func() error { return printGorutineNum(i + 1) }) } time.Sleep(time.Millisecond) err := eg.Wait() if err != nil { fmt.Println(err) } else { fmt.Println("done") } } ================================================ FILE: 2-async/1_async/11_errgroup_2/errgroup_2.go ================================================ package main import ( "context" "fmt" "golang.org/x/sync/errgroup" "time" ) const ( goroutinesNum = 3 badGorutineNum = 2 ) func printGorutineNum(ctx context.Context, num int) error { waitTime := time.Duration(10*(num+1)) * time.Millisecond fmt.Println(num, "gorutine wil work after", waitTime) select { case <-ctx.Done(): fmt.Printf("gorutine %d cancelled\n", num) return nil case <-time.After(waitTime): if num == badGorutineNum { fmt.Println("error found in gorutine", num) return fmt.Errorf("bad gorutine number %d", num) } fmt.Println("goroutine number", num) } return nil } func main() { eg, ctx := errgroup.WithContext(context.Background()) // Инициализируем группу с контекстом for i := 0; i < goroutinesNum; i++ { eg.Go(func() error { return printGorutineNum(ctx, i+1) }) } time.Sleep(time.Millisecond) err := eg.Wait() if err != nil { fmt.Println(err) } else { fmt.Println("done") } } ================================================ FILE: 2-async/1_async/12_atomic_1/atomic_1.go ================================================ package main import ( "fmt" "sync" "time" ) var totalOperations int32 = 0 var mu = &sync.Mutex{} func inc() { //mu.Lock() //defer mu.Unlock() // Не атомарная операция totalOperations++ } func main() { //runtime.GOMAXPROCS(1) for i := 0; i < 1000; i++ { go inc() } time.Sleep(100 * time.Millisecond) // Ожидается 1000 //mu.Lock() fmt.Println("total operation = ", totalOperations) //mu.Unlock() } ================================================ FILE: 2-async/1_async/12_atomic_2/atomic_2.go ================================================ package main import ( "fmt" "sync/atomic" // atomic_2.go "time" ) var totalOperations int32 func inc() { atomic.AddInt32(&totalOperations, 1) // атомарно } func main() { for i := 0; i < 1000; i++ { go inc() } time.Sleep(2 * time.Millisecond) fmt.Println("total operation = ", totalOperations) } ================================================ FILE: 2-async/1_async/12_atomic_2/with_bench/mutex_test.go ================================================ package main import ( "sync" "sync/atomic" "testing" ) var ( totalMutex int32 totalAtomic int32 mutex = &sync.Mutex{} ) func BenchmarkMutexParallel(b *testing.B) { b.RunParallel(func(pb *testing.PB) { for pb.Next() { mutex.Lock() totalMutex++ mutex.Unlock() } }) } func BenchmarkAtomicParallel(b *testing.B) { b.RunParallel(func(pb *testing.PB) { for pb.Next() { atomic.AddInt32(&totalAtomic, 1) } }) } func BenchmarkLocalCounter(b *testing.B) { var localCounter int64 for i := 0; i < b.N; i++ { localCounter++ } _ = localCounter } ================================================ FILE: 2-async/1_async/13_ratelim/ratelim.go ================================================ package main import ( "fmt" "runtime" "strings" "sync" "time" ) const ( iterationsNum = 6 goroutinesNum = 5 quotaLimit = 2 ) func startWorker(in int, wg *sync.WaitGroup, quotaCh chan struct{}) { defer wg.Done() fmt.Printf("start %d\n", in) time.Sleep(time.Millisecond) quotaCh <- struct{}{} defer func() { <-quotaCh }() for j := 0; j < iterationsNum; j++ { fmt.Println(formatWork(in, j)) // if j%2 == 0 { // <-quotaCh // ratelim.go, возвращаем слот // quotaCh <- struct{}{} // ratelim.go, берём слот // } runtime.Gosched() // даём поработать другим горутинам } } func main() { wg := &sync.WaitGroup{} quotaCh := make(chan struct{}, quotaLimit) for i := 0; i < goroutinesNum; i++ { wg.Add(1) go startWorker(i, wg, quotaCh) } time.Sleep(time.Millisecond) wg.Wait() } func formatWork(in, j int) string { return fmt.Sprintln(strings.Repeat(" ", in), "█", strings.Repeat(" ", goroutinesNum-in), "th", in, "iter", j, strings.Repeat("■", j)) } ================================================ FILE: 2-async/1_async/14_once/once.go ================================================ package main import ( "fmt" "sync" ) func Init() { fmt.Println("Init once") } func init() { fmt.Println("Init at start of program") } func main() { const routinesNum = 10 once := &sync.Once{} wg := &sync.WaitGroup{} wg.Add(routinesNum) for i := 0; i < routinesNum; i++ { go func() { defer wg.Done() once.Do(Init) }() } wg.Wait() } ================================================ FILE: 2-async/1_async/1_goroutines/goroutines.go ================================================ package main import ( "fmt" "time" ) const goroutinesNum = 7 func main() { for i := 0; i < goroutinesNum; i++ { //i := i go func() { // А если go < 1.22? fmt.Println(i) }() } time.Sleep(time.Second) } ================================================ FILE: 2-async/1_async/1_goroutines/i_ptr/main.go ================================================ package main import ( "fmt" ) const goroutinesNum = 7 func main() { var ptrs []*int for i := 0; i < goroutinesNum; i++ { //i := i fmt.Println("адрес i:", &i) ptrs = append(ptrs, &i) } for i, pt := range ptrs { fmt.Println("адрес в range i:", &i) ptrs = append(ptrs, &i) fmt.Println(*pt) } } ================================================ FILE: 2-async/1_async/1_goroutines/mem/main.go ================================================ package main import ( "fmt" "runtime" "time" ) func main() { var m1, m2 runtime.MemStats runtime.ReadMemStats(&m1) for i := 0; i < 10; i++ { go func() { //var b [2048]byte //_ = b //fmt.Println(b) //fmt.Println(i) }() } time.Sleep(time.Second) runtime.ReadMemStats(&m2) fmt.Printf("Allocated before: %d KB\n", m1.Alloc/1024) fmt.Printf("Allocated after : %d KB\n", m2.Alloc/1024) fmt.Printf("Per goroutine : ~%d bytes\n", (m2.Alloc-m1.Alloc)/10) } ================================================ FILE: 2-async/1_async/1_goroutines_2/goroutines.go ================================================ package main import ( "fmt" "strings" "time" ) const ( iterationsNum = 6 goroutinesNum = 6 ) func doWork(th int) { for j := 0; j < iterationsNum; j++ { /*if j%2 != 0 { time.Sleep(1 * time.Millisecond) }*/ fmt.Printf(formatWork(th, j)) //runtime.Gosched() } } func main() { //runtime.GOMAXPROCS(1) for i := 0; i < goroutinesNum; i++ { go doWork(i) } time.Sleep(time.Second) } func formatWork(in, j int) string { return fmt.Sprintln(strings.Repeat(" ", in), "█", strings.Repeat(" ", goroutinesNum-in), "th", in, "iter", j, strings.Repeat("■", j)) } ================================================ FILE: 2-async/1_async/2_chan/chan_1.go ================================================ package main import ( "fmt" ) func main() { ch1 := make(chan int) go func(in chan int) { fmt.Println("GO: before read from chan") // time.Sleep(1000 * time.Millisecond) val := <-in fmt.Println("GO: get from chan", val) fmt.Println("GO: after read from chan") }(ch1) fmt.Println("MAIN: before put to chan") // time.Sleep(1000 * time.Millisecond) ch1 <- 42 //ch1 <- 100500 fmt.Println("MAIN: after put to chan") fmt.Scanln() } ================================================ FILE: 2-async/1_async/2_chan_2/chan_2.go ================================================ package main import ( "fmt" "time" ) func main() { in := make(chan int) go func(out chan<- int) { for i := 0; i <= 10; i++ { fmt.Println("before", i) out <- i fmt.Println("after", i) } close(out) fmt.Println("generator finish") }(in) time.Sleep(2 * time.Second) for i := range in { fmt.Println("\tget", i) } /* for { v, ok := <-in if !ok { break } fmt.Println("\tget", v) }*/ fmt.Scanln() } ================================================ FILE: 2-async/1_async/3_workerpool/1_workerpool.go ================================================ package main import ( "fmt" "runtime" "strings" "time" ) const goroutinesNum = 3 func startWorker(workerNum int, in <-chan string) { for input := range in { fmt.Println(formatWork(workerNum, input)) time.Sleep(10 * time.Millisecond) } printFinishWork(workerNum) } func formatWork(in int, input string) string { return fmt.Sprintln(strings.Repeat(" ", in), "█", strings.Repeat(" ", goroutinesNum-in), "th", in, "recieved", input) } func printFinishWork(in int) { fmt.Println(strings.Repeat("==", in), "█", strings.Repeat("==", goroutinesNum-in), "===", in, "finished") } func main() { runtime.GOMAXPROCS(0) workerInput := make(chan string) for i := 0; i < goroutinesNum; i++ { go startWorker(i, workerInput) } months := []string{"Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь", "123", } for _, monthName := range months { workerInput <- monthName } close(workerInput) // попробуйте закомментировать time.Sleep(time.Second) } ================================================ FILE: 2-async/1_async/3_workerpool/2_workerpool_reusable.go ================================================ package main type workerPool struct { locker chan struct{} queue chan func() } func NewWorkerPool(maxWorkers int) workerPool { wp := workerPool{ locker: make(chan struct{}, maxWorkers), queue: make(chan func(), maxWorkers), } go wp.work() return wp } func (wp workerPool) work() { for { task := <-wp.queue wp.locker <- struct{}{} go func() { defer func() { <-wp.locker }() task() }() } } func (wp workerPool) PutTask(task func()) { wp.queue <- task } ================================================ FILE: 2-async/1_async/4_race_1/race_1.go ================================================ package main import "fmt" func main() { var counters = map[int]int{} for i := 0; i < 5; i++ { go func(counters map[int]int, th int) { for j := 0; j < 5; j++ { counters[th*10+j]++ } }(counters, i) } fmt.Scanln() fmt.Println("counters result", counters) } ================================================ FILE: 2-async/1_async/4_race_2/race_2.go ================================================ package main import ( "fmt" "sync" ) func main() { var counters = map[int]int{} mu := &sync.Mutex{} for i := 0; i < 5; i++ { go func(counters map[int]int, th int, mu *sync.Mutex) { for j := 0; j < 5; j++ { mu.Lock() counters[th*10+j]++ mu.Unlock() } }(counters, i, mu) } fmt.Scanln() mu.Lock() fmt.Println("counters result", counters) mu.Unlock() } // -race ================================================ FILE: 2-async/1_async/4_race_2/race_flag/working_race.go ================================================ package main import ( "fmt" "time" ) // add race flag func main() { var counter int for i := 0; i < 4; i++ { go func() { for j := 0; j < 1000; j++ { counter++ } }() } time.Sleep(2 * time.Second) fmt.Println("counter =", counter) } ================================================ FILE: 2-async/1_async/4_race_3/race_3.go ================================================ package main import ( "fmt" "sync" "time" ) // look sync.Map func main() { var counters = map[int]int{} mu := &sync.RWMutex{} for i := 0; i < 5; i++ { go func(counters map[int]int, th int, mu *sync.RWMutex) { for j := 0; j < 5; j++ { if (th*10+j)%7 == 0 { mu.Lock() counters[th*10+j]++ mu.Unlock() } else { mu.RLock() fmt.Printf("[%d,%d] result %v\n", th, j, counters) mu.RUnlock() } } }(counters, i, mu) } time.Sleep(100 * time.Millisecond) mu.RLock() fmt.Println("counters result", counters) mu.RUnlock() } ================================================ FILE: 2-async/1_async/4_race_3_bench/race_test.go ================================================ package main import ( "sync" "testing" ) func BenchmarkMapWithRWMutex(b *testing.B) { counters := make(map[int]int) var mu sync.RWMutex b.ResetTimer() b.RunParallel(func(pb *testing.PB) { i := 0 for pb.Next() { key := i % 1000 if key%7 == 0 { mu.Lock() counters[key]++ mu.Unlock() } else { mu.RLock() _ = counters[key] mu.RUnlock() } i++ } }) } func BenchmarkMapWithMutex(b *testing.B) { counters := make(map[int]int) var mu sync.Mutex b.ResetTimer() b.RunParallel(func(pb *testing.PB) { i := 0 for pb.Next() { key := i % 1000 if key%7 == 0 { mu.Lock() counters[key]++ mu.Unlock() } else { mu.Lock() _ = counters[key] mu.Unlock() } i++ } }) } ================================================ FILE: 2-async/1_async/5_tick/tick.go ================================================ package main import ( "fmt" "time" ) func main() { ticker := time.NewTicker(time.Second) i := 0 for tickTime := range ticker.C { i++ fmt.Println("step", i, "time", tickTime) if i >= 5 { // Надо останавливать, иначе потечет (но с Go 1.23 не надо 🙂) ticker.Stop() //os.Exit(3) break } } fmt.Println("total", i) return // Не может быть остановлен и собран сборщиком мусора // Используйте, если должен работать вечно c := time.Tick(time.Second) i = 0 for tickTime := range c { i++ fmt.Println("step", i, "time", tickTime) if i >= 5 { break } } } //while true; do echo "Starting program..."; go run tick.go; echo "Program exited with code $?"; sleep 1; done; ================================================ FILE: 2-async/1_async/5_tick_example/5_ping_pong/main.go ================================================ package main import ( "fmt" ) func main() { ch := make(chan string) go func() { for pong := range ch { fmt.Println(pong) ch <- "ping" } }() go func() { for ping := range ch { fmt.Println(ping) ch <- "pong" } }() ch <- "ping" var blockNil chan int <-blockNil } ================================================ FILE: 2-async/1_async/5_tick_example/main.go ================================================ package main import ( "fmt" "time" ) func main() { tick1s := time.Tick(1 * time.Second) tick3s := time.Tick(3 * time.Second) tick4s := time.Tick(4 * time.Second) //var blockNil chan int //done := make(chan struct{}) go func() { for t := range tick1s { fmt.Println("worker-1s tick at", t.Format("15:04:05")) } }() go func() { for t := range tick3s { fmt.Println("worker-3s tick at", t.Format("15:04:05")) } }() go func() { for t := range tick4s { fmt.Println("worker-4s start", t.Format("15:04:05")) //close(blockNil) //panic //close(done) // "сигнал" для завершения //done <- struct{}{} //var blockInGo chan int //blockInGo <- 1 fmt.Println("worker-4s finish", t.Format("15:04:05")) } }() //select {} //var blockNil chan int //<-blockNil /* var ch chan string if ch == nil { }*/ //blockNil <- 1 //<-done //valCh := <-done //fmt.Println("valCh", valCh) //fmt.Println(<-done) } ================================================ FILE: 2-async/1_async/6_afterfunc/afterfunc.go ================================================ package main import ( "fmt" "time" ) func sayHello() { fmt.Println("Hello World") } func main() { timer := time.AfterFunc(1*time.Second, sayHello) fmt.Scanln() timer.Stop() fmt.Scanln() } ================================================ FILE: 2-async/1_async/7_select_1/select_1.go ================================================ package main import ( "fmt" ) func main() { ch1 := make(chan int, 1) ch2 := make(chan int, 1) ch1 <- 1 //ch2 <- 1 select { case val := <-ch1: fmt.Println("ch1 val", val) case ch2 <- 1: fmt.Println("put val to ch2") default: fmt.Println("default case") } fmt.Println("finish") } ================================================ FILE: 2-async/1_async/7_select_2/select_2.go ================================================ package main import ( "fmt" ) func main() { ch1 := make(chan int, 2) ch1 <- 1 ch1 <- 2 ch2 := make(chan int, 2) ch2 <- 3 LOOP: for { select { case v1 := <-ch1: fmt.Println("chan1 val", v1) case v2 := <-ch2: fmt.Println("chan2 val", v2) default: break LOOP } } } ================================================ FILE: 2-async/1_async/7_select_2_new/close_buff/main.go ================================================ package main import ( "fmt" ) func main() { ch := make(chan int, 3) ch <- 1 ch <- 2 ch <- 3 close(ch) fmt.Println("channel closed") /* for v := range ch { fmt.Println("read:", v) }*/ for { select { case v, ok := <-ch: if !ok { fmt.Println("select: channel empty and closed — exit") return } fmt.Println("select: read value", v) } } } ================================================ FILE: 2-async/1_async/7_select_2_new/select_2_new.go ================================================ package main import ( "fmt" ) // Read 2 channels till they are closed func main() { ch1 := make(chan int) ch2 := make(chan int) go func() { ch2 <- 0 close(ch2) ch1 <- 1 ch1 <- 2 ch1 <- 3 ch1 <- 4 ch1 <- 5 ch1 <- 6 close(ch1) }() for { select { case v1, ok := <-ch1: if !ok { fmt.Println("ch1 closed") ch1 = nil } fmt.Println("chan1 val", v1) case v2, ok := <-ch2: if !ok { fmt.Println("ch2 closed") ch2 = nil } fmt.Println("chan2 val", v2) } if ch1 == nil && ch2 == nil { fmt.Print("Two channels closed") break } } } ================================================ FILE: 2-async/1_async/7_select_3/close_all/main.go ================================================ package main import ( "fmt" "time" ) func worker(id int, cancelCh chan struct{}) { fmt.Println("worker", id, "started") for { select { case <-cancelCh: fmt.Println("worker", id, "stopped") return default: time.Sleep(300 * time.Millisecond) } } } func main() { cancelCh := make(chan struct{}) for i := 1; i <= 3; i++ { go worker(i, cancelCh) } time.Sleep(1 * time.Second) fmt.Println("sending cancel signal") //cancelCh <- struct{}{} close(cancelCh) time.Sleep(1 * time.Second) } ================================================ FILE: 2-async/1_async/7_select_3/close_signal/main.go ================================================ package main import ( "fmt" "os" "os/signal" "syscall" "time" ) func worker(id int, done <-chan struct{}) { for { select { case <-done: fmt.Println("worker", id, "stopped") return default: fmt.Println("worker", id, "working") time.Sleep(1 * time.Second) } } } func main() { done := make(chan struct{}) go worker(1, done) go worker(2, done) // канал для сигналов ОС sigCh := make(chan os.Signal) signal.Notify(sigCh, os.Interrupt, syscall.SIGTERM) // ждём Ctrl+C <-sigCh fmt.Println("\nCtrl+C pressed") // оповещаем все горутины // можем обновить конфиг и т.д. close(done) time.Sleep(1 * time.Second) //подождем вывод fmt.Println("main exit") } ================================================ FILE: 2-async/1_async/7_select_3/select_3.go ================================================ package main import ( "fmt" ) func main() { cancelCh := make(chan bool) dataCh := make(chan int) go func(cancelCh chan bool, dataCh chan int) { val := 0 for { select { case <-cancelCh: // Закрываем канал там, где пишем // А что если много генераторов? close(dataCh) return case dataCh <- val: val++ } } }(cancelCh, dataCh) for curVal := range dataCh { fmt.Println("read", curVal) if curVal > 3 { fmt.Println("send cancel") cancelCh <- true // Что если этот канал должен остановить множество генераторов? // close(cancelCh) } } } ================================================ FILE: 2-async/1_async/8_wait_1/wait_1.go ================================================ package main import ( "log" "time" ) func main() { result := make(chan string) go func(out chan<- string) { time.Sleep(1 * time.Second) log.Println("async operation ready, return result") out <- "success" }(result) time.Sleep(2 * time.Second) log.Println("some useful work done") opStatus := <-result log.Println("main goroutine:", opStatus) } ================================================ FILE: 2-async/1_async/8_wait_2/ping_pong/main.go ================================================ package main import ( "fmt" "sync" "time" ) func main() { ballCh := make(chan string) wg := &sync.WaitGroup{} wg.Add(1) // Ping go func() { defer wg.Done() for { select { case ball := <-ballCh: fmt.Println(ball) time.Sleep(500 * time.Millisecond) ballCh <- "ping" } } }() wg.Add(1) // Pong go func() { defer wg.Done() for { select { case ball := <-ballCh: fmt.Println(ball) time.Sleep(500 * time.Millisecond) ballCh <- "pong" } } }() // Стартовый удар ballCh <- "ping" //select {} wg.Wait() } ================================================ FILE: 2-async/1_async/8_wait_2/wait_2.go ================================================ package main import ( "fmt" "strings" "sync" "time" ) const ( iterationsNum = 7 goroutinesNum = 5 ) func doWork(in int, wg *sync.WaitGroup) { defer wg.Done() // Уменьшаем счетчик на 1 for j := 0; j < iterationsNum; j++ { fmt.Printf(formatWork(in, j)) time.Sleep(time.Millisecond) } } func main() { wg := &sync.WaitGroup{} // Инициализируем группу for i := 0; i < goroutinesNum; i++ { // wg.Add надо вызывать в той горутине, которая порождает воркеров // В ином случае другая горутина может не успеть запуститься и выполнится Wait wg.Add(1) // Добавляем 1 к счетчику go doWork(i, wg) } time.Sleep(time.Millisecond) wg.Wait() // Ожидаем, пока wg.Done() не приведёт счетчик к 0 } func formatWork(in, j int) string { return fmt.Sprintln(strings.Repeat(" ", in), "█", strings.Repeat(" ", goroutinesNum-in), "th", in, "iter", j, strings.Repeat("■", j)) } ================================================ FILE: 2-async/1_async/8_wait_3/wait_3.go ================================================ package main import ( "fmt" "strings" "sync" "time" //github.com/neonxp/rutina ) const ( iterationsNum = 7 goroutinesNum = 5 ) func doWork(in int) { for j := 0; j < iterationsNum; j++ { fmt.Printf(formatWork(in, j)) time.Sleep(time.Millisecond) } } func main() { wg := &sync.WaitGroup{} // Инициализируем группу for i := 0; i < goroutinesNum; i++ { wg.Go(func() { // С go 1.25 doWork(i) }) } time.Sleep(time.Millisecond) wg.Wait() // Ожидаем, пока wg.Done() не приведёт счетчик к 0 } func formatWork(in, j int) string { return fmt.Sprintln(strings.Repeat(" ", in), "█", strings.Repeat(" ", goroutinesNum-in), "th", in, "iter", j, strings.Repeat("■", j)) } ================================================ FILE: 2-async/1_async/9_timeout/timeout.go ================================================ package main import ( "fmt" "time" ) func longSQLQuery() chan bool { ch := make(chan bool, 1) go func() { time.Sleep(2 * time.Second) ch <- true }() return ch } func main() { // При 1 выполнится таймаут, при 3 - выполнится операция timer := time.NewTimer(3 * time.Second) select { case <-timer.C: fmt.Println("timer.C timeout happend") case result := <-longSQLQuery(): // Освобождаем ресурс if !timer.Stop() { <-timer.C } fmt.Println("operation result:", result) } } ================================================ FILE: 2-async/readings_2.md ================================================ На русском: * https://habrahabr.ru/post/141853/ - как работают горутины * https://habrahabr.ru/post/308070/ - как работают каналы * https://habrahabr.ru/post/333654/ - как работает планировщик ( https://rakyll.org/scheduler/ ) * https://habrahabr.ru/post/271789/ - танцы с мютексами На английском: * https://blog.golang.org/race-detector * https://blog.golang.org/pipelines * https://blog.golang.org/advanced-go-concurrency-patterns * https://blog.golang.org/go-concurrency-patterns-timing-out-and * https://talks.golang.org/2012/concurrency.slide#1 * https://www.goinggo.net/2017/10/the-behavior-of-channels.html * http://marcio.io/2015/07/handling-1-million-requests-per-minute-with-golang/ - рассказ про оптимизацию воркер пула * http://www.tapirgames.com/blog/golang-channel * http://www.tapirgames.com/blog/golang-channel-closing * https://github.com/golang/go/wiki/CommonMistakes Видео: * https://www.youtube.com/watch?v=5buaPyJ0XeQ - классное выступление Dave Cheney про функции первого класса и использование их с горутинами, очень рекомендую, оно небольшое * https://www.youtube.com/watch?v=f6kdp27TYZs - Google I/O 2012 - Go Concurrency Patterns - очень рекомендую * https://www.youtube.com/watch?v=rDRa23k70CU&list=PLDWZ5uzn69eyM81omhIZLzvRhTOXvpeX9&index=15 - ещё одно хорошее видео про паттерны конкуренции в го * https://www.youtube.com/watch?v=KAWeC9evbGM - видео Андрея Смирнова с конференции Highload - в нём вы можете получить более детальную информацию по теме вводного видео (методы обработки запросов и плюсы неблокирующего подхода), о том, что там творится на системном уровне. На русском, не про go Книги: * Язык программирования Go, Алан А. А. Донован, Брайан У. Керниган - глава 8 * Concurrency in Go: Tools and Techniques for Developers, by Katherine Cox-Buday ================================================ FILE: 3-web/0_json/0_simple_json/simple_json.go ================================================ package main import ( "encoding/json" "fmt" ) type User struct { ID int Username string phone string } var jsonStr = `{"id": 42, "username": "rvasily", "phone": "123"}` func main() { data := []byte(jsonStr) u := &User{} json.Unmarshal(data, u) fmt.Printf("struct:\n\t%#v\n\n", u) u.phone = "987654321" result, err := json.Marshal(u) if err != nil { panic(err) } fmt.Printf("json string:\n\t%s\n", string(result)) } ================================================ FILE: 3-web/0_json/1_struct_tags/struct_tags.go ================================================ package main import ( "encoding/json" "fmt" ) type User struct { ID int `json:"user_id,string"` Username string Address string `json:",omitempty"` Company string `json:"-"` } func main() { u := &User{ ID: 42, Username: "rvasily", Address: "test", Company: "Mail.Ru Group", } result, _ := json.Marshal(u) fmt.Printf("json string: %s\n", string(result)) } ================================================ FILE: 3-web/0_json/2_custom/custom.go ================================================ package main import ( "encoding/json" "fmt" "strconv" "strings" ) type Company string // MarshalJSON удовлетворяет интерфейсу json.Marshaler func (c Company) MarshalJSON() ([]byte, error) { return json.Marshal(fmt.Sprintf("ООО «%s»", c)) } // UnmarshalJSON удовлетворяет интерфейсу json.Unmarshaler func (c *Company) UnmarshalJSON(data []byte) error { var company string if err := json.Unmarshal(data, &company); err != nil { return err } *c = Company(strings.TrimSuffix(strings.TrimPrefix(company, "ООО «"), "»")) return nil } type User struct { ID int PassportSeries int PassportNumber int Company Company } // MarshalJSON удовлетворяет интерфейсу json.Marshaler func (u *User) MarshalJSON() ([]byte, error) { return json.Marshal(struct { ID int `json:"user_id"` Passport string `json:"passport"` Company Company `json:"company"` }{ ID: u.ID, Passport: fmt.Sprintf("%d %d", u.PassportSeries, u.PassportNumber), Company: u.Company, }) } // UnmarshalJSON удовлетворяет интерфейсу json.Unmarshaler func (u *User) UnmarshalJSON(data []byte) error { var temp struct { ID int `json:"user_id"` Passport string `json:"passport"` Company Company `json:"company"` } if err := json.Unmarshal(data, &temp); err != nil { return err } u.ID = temp.ID u.Company = temp.Company passportParts := strings.SplitN(temp.Passport, " ", 2) u.PassportSeries, _ = strconv.Atoi(passportParts[0]) u.PassportNumber, _ = strconv.Atoi(passportParts[1]) return nil } func main() { u := &User{ ID: 42, PassportSeries: 4512, PassportNumber: 123456, Company: "VK", } result, err := json.Marshal(u) if err != nil { panic(err) } fmt.Printf("json string: %s\n", string(result)) var unmarshalledUser User err = json.Unmarshal(result, &unmarshalledUser) if err != nil { panic(err) } fmt.Printf("unmarshalledUser: %+v\n", unmarshalledUser) } ================================================ FILE: 3-web/0_json/3_dynamic/dynamic.go ================================================ package main import ( "encoding/json" "fmt" ) var jsonStr = `[ {"id": 17, "username": "iivan", "phone": 0}, {"id": "17", "address": "none", "company": "Mail.ru"}, 5, [] ]` func main() { data := []byte(jsonStr) var users interface{} json.Unmarshal(data, &users) fmt.Printf("unpacked in empty interface:\n%#v\n\n", users) user2 := map[string]interface{}{ "id": 42, "username": "rvasily", } var user2i interface{} = user2 result, _ := json.Marshal(user2i) fmt.Printf("json string from map:\n %s\n", string(result)) } ================================================ FILE: 3-web/1_net/net_listen.go ================================================ package main import ( "bufio" "fmt" "net" ) func handleConnection(conn net.Conn) { name := conn.RemoteAddr().String() fmt.Printf("%+v connected\n", name) conn.Write([]byte("Hello, " + name + "\n\r")) defer conn.Close() scanner := bufio.NewScanner(conn) for scanner.Scan() { text := scanner.Text() if text == "Exit" { conn.Write([]byte("Bye\n\r")) fmt.Println(name, "disconnected") break } else if text != "" { fmt.Println(name, "enters", text) conn.Write([]byte("You enter " + text + "\n\r")) } } } func main() { listener, err := net.Listen("tcp", ":8080") if err != nil { panic(err) } for { conn, err := listener.Accept() if err != nil { panic(err) } go handleConnection(conn) } } ================================================ FILE: 3-web/2_http/0_http_server/0_basic/basic.go ================================================ package main import ( "fmt" "net/http" ) func handler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") // fmt.Fprintln(w, "

Привет, мир!

") w.Write([]byte("{}")) } func main() { http.HandleFunc("/", handler) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } ================================================ FILE: 3-web/2_http/0_http_server/1_pages/pages.go ================================================ package main import ( "fmt" "net/http" ) func handler(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, "Main page") } func main() { http.HandleFunc("/page", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, "Single page:", r.URL.String()) }) http.HandleFunc("/pages/", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, "Multiple pages:", r.URL.String()) }) http.HandleFunc("/", handler) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } ================================================ FILE: 3-web/2_http/0_http_server/2_servehttp/servehttp.go ================================================ package main import ( "fmt" "net/http" ) type Handler struct { Name string } func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, "Name:", h.Name, "URL:", r.URL.String()) } func main() { testHandler := &Handler{Name: "test"} http.Handle("/test/", testHandler) rootHandler := &Handler{Name: "root"} http.Handle("/", rootHandler) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } ================================================ FILE: 3-web/2_http/0_http_server/3_mux/mux.go ================================================ package main import ( "fmt" "net/http" "time" ) func handler(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, "URL:", r.URL.String()) } func main() { mux := http.NewServeMux() mux.HandleFunc("/", handler) server := http.Server{ Addr: ":8080", Handler: mux, ReadTimeout: 10 * time.Second, WriteTimeout: 10 * time.Second, } fmt.Println("starting server at :8080") server.ListenAndServe() } ================================================ FILE: 3-web/2_http/0_http_server/4_servers/servers.go ================================================ package main import ( "fmt" "net/http" ) func runServer(addr string) { mux := http.NewServeMux() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, "Addr:", addr, "URL:", r.URL.String()) }) server := http.Server{ Addr: addr, Handler: mux, } fmt.Println("starting server at", addr) server.ListenAndServe() } func main() { go runServer(":8081") runServer(":8080") } ================================================ FILE: 3-web/2_http/1_request/0_get/get.go ================================================ package main import ( "fmt" "net/http" ) func handler(w http.ResponseWriter, r *http.Request) { for key, value := range r.URL.Query() { fmt.Println(key, value) } } func main() { http.HandleFunc("/", handler) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } ================================================ FILE: 3-web/2_http/1_request/1_post/post.go ================================================ package main import ( "fmt" "net/http" ) var loginFormTmpl = []byte(`
Login: Password:
`) func mainPage(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodPost { w.Write(loginFormTmpl) return } r.ParseForm() inputLogin := r.Form["login"][0] //inputLogin := r.FormValue("login") fmt.Fprintln(w, "you enter: ", inputLogin) } func main() { http.HandleFunc("/", mainPage) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } ================================================ FILE: 3-web/2_http/1_request/2_cookies/cookies.go ================================================ package main import ( "fmt" "net/http" "time" ) func mainPage(w http.ResponseWriter, r *http.Request) { session, err := r.Cookie("session_id") loggedIn := (err != http.ErrNoCookie) if loggedIn { fmt.Fprintln(w, `logout`) fmt.Fprintln(w, "Welcome, "+session.Value) } else { fmt.Fprintln(w, `login`) fmt.Fprintln(w, "You need to login") } } func loginPage(w http.ResponseWriter, r *http.Request) { expiration := time.Now().Add(10 * time.Hour) cookie := http.Cookie{ Name: "session_id", Value: "Dmitry", Expires: expiration, HttpOnly: true, } http.SetCookie(w, &cookie) http.Redirect(w, r, "/", http.StatusFound) } func logoutPage(w http.ResponseWriter, r *http.Request) { session, err := r.Cookie("session_id") if err == http.ErrNoCookie { http.Redirect(w, r, "/", http.StatusFound) return } session.Expires = time.Now().AddDate(0, 0, -1) http.SetCookie(w, session) http.Redirect(w, r, "/", http.StatusFound) } func main() { http.HandleFunc("/login", loginPage) http.HandleFunc("/logout", logoutPage) http.HandleFunc("/", mainPage) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } ================================================ FILE: 3-web/2_http/1_request/3_headers/headers.go ================================================ package main import ( "fmt" "net/http" ) func handler(w http.ResponseWriter, r *http.Request) { w.Header().Set("RequestID", "d41d8cd98f00b204") fmt.Fprintln(w, "You browser is", r.UserAgent()) fmt.Fprintln(w, "You accept", r.Header.Get("Accept")) } func main() { http.HandleFunc("/", handler) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } ================================================ FILE: 3-web/2_http/2_http_client/client.go ================================================ package main import ( "bytes" "fmt" "io" "net" "net/http" "net/url" "strconv" "time" ) func startServer() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "getHandler: incoming request %#v\n", r) fmt.Fprintf(w, "getHandler: r.Url %#v\n", r.URL) }) http.HandleFunc("/raw_body", func(w http.ResponseWriter, r *http.Request) { body, err := io.ReadAll(r.Body) defer r.Body.Close() // важный пункт! if err != nil { http.Error(w, err.Error(), 500) return } fmt.Fprintf(w, "postHandler: raw body %s\n", string(body)) }) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } func runGet() { url := "http://127.0.0.1:8080/?param=123¶m2=test" resp, err := http.Get(url) if err != nil { fmt.Println("error happend", err) return } defer resp.Body.Close() // важный пункт! respBody, err := io.ReadAll(resp.Body) fmt.Printf("http.Get body %#v\n\n\n", string(respBody)) } func runGetFullReq() { req := &http.Request{ Method: http.MethodGet, Header: http.Header{ "User-Agent": {"coursera/golang"}, }, } req.URL, _ = url.Parse("http://127.0.0.1:8080/?id=42") req.URL.Query().Set("user", "rvasily") resp, err := http.DefaultClient.Do(req) if err != nil { fmt.Println("error happend", err) return } defer resp.Body.Close() // важный пункт! respBody, err := io.ReadAll(resp.Body) fmt.Printf("testGetFullReq resp %#v\n\n\n", string(respBody)) } func runTransportAndPost() { transport := &http.Transport{ DialContext: (&net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 30 * time.Second, DualStack: true, }).DialContext, MaxIdleConns: 100, IdleConnTimeout: 90 * time.Second, TLSHandshakeTimeout: 10 * time.Second, ExpectContinueTimeout: 1 * time.Second, } client := &http.Client{ Timeout: time.Second * 10, Transport: transport, } data := `{"id": 42, "user": "rvasily"}` body := bytes.NewBufferString(data) url := "http://127.0.0.1:8080/raw_body" req, _ := http.NewRequest(http.MethodPost, url, body) req.Header.Add("Content-Type", "application/json") req.Header.Add("Content-Length", strconv.Itoa(len(data))) resp, err := client.Do(req) if err != nil { fmt.Println("error happend", err) return } defer resp.Body.Close() // важный пункт! respBody, err := io.ReadAll(resp.Body) fmt.Printf("runTransport %#v\n\n\n", string(respBody)) } func main() { go startServer() time.Sleep(100 * time.Millisecond) runGet() runGetFullReq() runTransportAndPost() } ================================================ FILE: 3-web/2_http/3_files/0_file_upload/file_upload.go ================================================ package main import ( "crypto/md5" "encoding/json" "fmt" "io" "net/http" ) var uploadFormTmpl = []byte(`
Image:
`) func mainPage(w http.ResponseWriter, r *http.Request) { w.Write(uploadFormTmpl) } func uploadPage(w http.ResponseWriter, r *http.Request) { r.ParseMultipartForm(5 * 1024 * 1025) file, header, err := r.FormFile("my_file") if err != nil { fmt.Println(err) return } defer file.Close() fmt.Fprintf(w, "header.Filename %v\n", header.Filename) fmt.Fprintf(w, "header.Header %#v\n", header.Header) hasher := md5.New() io.Copy(hasher, file) fmt.Fprintf(w, "md5 %x\n", hasher.Sum(nil)) } type Params struct { ID int User string } /* curl -v -X POST -H "Content-Type: application/json" -d '{"id": 2, "user": "rvasily"}' http://localhost:8080/raw_body */ func uploadRawBody(w http.ResponseWriter, r *http.Request) { body, err := io.ReadAll(r.Body) defer r.Body.Close() p := &Params{} err = json.Unmarshal(body, p) if err != nil { http.Error(w, err.Error(), 500) return } fmt.Fprintf(w, "content-type %#v\n", r.Header.Get("Content-Type")) fmt.Fprintf(w, "params %#v\n", p) } func main() { http.HandleFunc("/", mainPage) http.HandleFunc("/upload", uploadPage) http.HandleFunc("/raw_body", uploadRawBody) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } ================================================ FILE: 3-web/2_http/3_files/1_static/static/super_secret_password ================================================ BestPassword! qwerty1234567890 ================================================ FILE: 3-web/2_http/3_files/1_static/static.go ================================================ package main import ( "fmt" "net/http" ) func handler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/html") w.Write([]byte(` Hello World!
`)) } func main() { http.HandleFunc("/", handler) staticHandler := http.StripPrefix( "/data/", http.FileServer(http.Dir("./static")), ) http.Handle("/data/", staticHandler) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } ================================================ FILE: 3-web/2_http/4_httptest/0_client/client_test.go ================================================ package client import ( "io" "net/http" "net/http/httptest" "testing" ) type TestCase struct { ID string Response string StatusCode int } func GetUser(w http.ResponseWriter, r *http.Request) { key := r.FormValue("id") if key == "42" { w.WriteHeader(http.StatusOK) io.WriteString(w, `{"status": 200, "resp": {"user": 42}}`) } else { w.WriteHeader(http.StatusInternalServerError) io.WriteString(w, `{"status": 500, "err": "db_error"}`) } } func TestGetUser(t *testing.T) { cases := []TestCase{ TestCase{ ID: "42", Response: `{"status": 200, "resp": {"user": 42}}`, StatusCode: http.StatusOK, }, TestCase{ ID: "500", Response: `{"status": 500, "err": "db_error"}`, StatusCode: http.StatusInternalServerError, }, } for caseNum, item := range cases { url := "http://example.com/api/user?id=" + item.ID req := httptest.NewRequest("GET", url, nil) w := httptest.NewRecorder() GetUser(w, req) if w.Code != item.StatusCode { t.Errorf("[%d] wrong StatusCode: got %d, expected %d", caseNum, w.Code, item.StatusCode) } resp := w.Result() body, _ := io.ReadAll(resp.Body) bodyStr := string(body) if bodyStr != item.Response { t.Errorf("[%d] wrong Response: got %+v, expected %+v", caseNum, bodyStr, item.Response) } } } ================================================ FILE: 3-web/2_http/4_httptest/1_server/server_test.go ================================================ package server import ( "encoding/json" "io" "net/http" "net/http/httptest" "reflect" "testing" ) type TestCase struct { ID string Result *CheckoutResult IsError bool } type CheckoutResult struct { Status int Balance int Err string } func CheckoutDummy(w http.ResponseWriter, r *http.Request) { key := r.FormValue("id") switch key { case "42": w.WriteHeader(http.StatusOK) io.WriteString(w, `{"status": 200, "balance": 100500}`) case "100500": w.WriteHeader(http.StatusOK) io.WriteString(w, `{"status": 400, "err": "bad_balance"}`) case "__broken_json": w.WriteHeader(http.StatusOK) io.WriteString(w, `{"status": 400`) //broken json case "__internal_error": fallthrough default: w.WriteHeader(http.StatusInternalServerError) } } type Cart struct { PaymentApiURL string } func (c *Cart) Checkout(id string) (*CheckoutResult, error) { url := c.PaymentApiURL + "?id=" + id resp, err := http.Get(url) if err != nil { return nil, err } defer resp.Body.Close() data, err := io.ReadAll(resp.Body) if err != nil { return nil, err } result := &CheckoutResult{} err = json.Unmarshal(data, result) if err != nil { return nil, err } return result, nil } func TestCartCheckout(t *testing.T) { cases := []TestCase{ TestCase{ ID: "42", Result: &CheckoutResult{ Status: 200, Balance: 100500, Err: "", }, IsError: false, }, TestCase{ ID: "100500", Result: &CheckoutResult{ Status: 400, Balance: 0, Err: "bad_balance", }, IsError: false, }, TestCase{ ID: "__broken_json", Result: nil, IsError: true, }, TestCase{ ID: "__internal_error", Result: nil, IsError: true, }, } ts := httptest.NewServer(http.HandlerFunc(CheckoutDummy)) for caseNum, item := range cases { c := &Cart{ PaymentApiURL: ts.URL, } result, err := c.Checkout(item.ID) if err != nil && !item.IsError { t.Errorf("[%d] unexpected error: %#v", caseNum, err) } if err == nil && item.IsError { t.Errorf("[%d] expected error, got nil", caseNum) } if !reflect.DeepEqual(item.Result, result) { t.Errorf("[%d] wrong result, expected %#v, got %#v", caseNum, item.Result, result) } } ts.Close() } ================================================ FILE: 3-web/3_template/0_inline/inline.go ================================================ package main import ( "fmt" "net/http" "text/template" ) type tplParams struct { URL string Browser string } const EXAMPLE = ` Browser {{.Browser}} you at {{.URL}} ` func handle(w http.ResponseWriter, r *http.Request) { tmpl := template.New(`example`) tmpl, _ = tmpl.Parse(EXAMPLE) params := tplParams{ URL: r.URL.String(), Browser: r.UserAgent(), } tmpl.Execute(w, params) } func main() { http.HandleFunc("/", handle) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } ================================================ FILE: 3-web/3_template/1_file/file.go ================================================ package main import ( "fmt" "html/template" "net/http" ) type User struct { ID int Name string Active bool } func main() { tmpl := template.Must(template.ParseFiles("users.html")) users := []User{ User{1, "Vasily", true}, User{2, "Ivan", false}, User{3, "Dmitry", true}, } http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { tmpl.Execute(w, struct { Users []User }{ users, }) }) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } ================================================ FILE: 3-web/3_template/1_file/users.html ================================================

Users

{{range .Users}} {{.Name}} {{if .Active}}active{{end}}
{{end}} ================================================ FILE: 3-web/3_template/2_func/func.go ================================================ package main import ( "fmt" "html/template" "net/http" ) type User struct { ID int Name string Active bool } func IsUserOdd(u *User) bool { return u.ID%2 != 0 } func main() { tmplFuncs := template.FuncMap{ "OddUser": IsUserOdd, } tmpl, err := template. New(""). Funcs(tmplFuncs). ParseFiles("func.html") if err != nil { panic(err) } users := []User{ User{1, "Vasily", true}, User{2, "Ivan", false}, User{3, "Dmitry", true}, } http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { err := tmpl.ExecuteTemplate(w, "func.html", struct { Users []User }{ users, }) if err != nil { panic(err) } }) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } ================================================ FILE: 3-web/3_template/2_func/func.html ================================================

Users

{{range .Users}} {{.Name}}, {{if OddUser .}} id {{.ID}} is odd {{end}}
{{end}} ================================================ FILE: 3-web/3_template/3_method/method.go ================================================ package main import ( "fmt" "html/template" "net/http" ) type User struct { ID int Name string Active bool } func (u *User) PrintActive() string { if !u.Active { return "" } return "method says user " + u.Name + " active" } func main() { tmpl, err := template. New(""). ParseFiles("method.html") if err != nil { panic(err) } users := []User{ User{1, "Vasily", true}, User{2, "Ivan", false}, User{3, "Dmitry", true}, } http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { err := tmpl.ExecuteTemplate(w, "method.html", struct { Users []User }{ users, }) if err != nil { panic(err) } }) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } ================================================ FILE: 3-web/3_template/3_method/method.html ================================================

Users

{{range .Users}} {{.Name}} {{.PrintActive}}
{{end}} ================================================ FILE: 3-web/4_json_http/main.go ================================================ package main import ( "encoding/json" "fmt" "log" "net/http" "sync" ) type UserInput struct { Name string `json:"name"` Password string `json:"password"` } type User struct { ID uint64 `json:"id"` Name string `json:"name"` Password string `json:"-"` } type Handlers struct { users []User mu *sync.Mutex } func (h *Handlers) HandleCreateUser(w http.ResponseWriter, r *http.Request) { defer r.Body.Close() decoder := json.NewDecoder(r.Body) newUserInput := new(UserInput) err := decoder.Decode(newUserInput) if err != nil { log.Printf("error while unmarshalling JSON: %s", err) w.Write([]byte("{}")) return } fmt.Println(newUserInput) h.mu.Lock() var id uint64 = 0 if len(h.users) > 0 { id = h.users[len(h.users)-1].ID + 1 } h.users = append(h.users, User{ ID: id, Name: newUserInput.Name, Password: newUserInput.Password, }) h.mu.Unlock() } func (h *Handlers) HandleListUsers(w http.ResponseWriter, r *http.Request) { encoder := json.NewEncoder(w) h.mu.Lock() err := encoder.Encode(h.users) h.mu.Unlock() if err != nil { log.Printf("error while marshalling JSON: %s", err) w.Write([]byte("{}")) return } } func main() { handlers := Handlers{ users: make([]User, 0), mu: &sync.Mutex{}, } http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") w.Write([]byte("{}")) }) http.HandleFunc("/users/", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") log.Println(r.URL.Path) if r.Method == http.MethodPost { handlers.HandleCreateUser(w, r) return } handlers.HandleListUsers(w, r) }) http.ListenAndServe(":8080", nil) } ================================================ FILE: 3-web/4_json_http/main_test.go ================================================ package main import ( "bytes" "io" "net/http" "net/http/httptest" "reflect" "strings" "sync" "testing" ) func TestCreateUsers(t *testing.T) { t.Parallel() h := Handlers{ users: []User{}, mu: &sync.Mutex{}, } body := bytes.NewReader([]byte(`{"name": "Vasily", "password": "qwerty"}`)) expectedUsers := []User{ { ID: 3, Name: "Vasily", Password: "qwerty", }, } r := httptest.NewRequest("POST", "/users/", body) w := httptest.NewRecorder() h.HandleCreateUser(w, r) if w.Code != http.StatusOK { t.Error("status is not ok") } reflect.DeepEqual(h.users, expectedUsers) } var expectedJSON = `[{"id":1,"name":"Afanasiy"},{"id":2,"name":"Ka"}]` func TestGetUsers(t *testing.T) { h := Handlers{ users: []User{ { ID: 1, Name: "Afanasiy", Password: "1234", }, { ID: 2, Name: "Ka", Password: "jdjfaljhfljehfs;l3345354", }, }, mu: &sync.Mutex{}, } t.Parallel() r := httptest.NewRequest("GET", "/users/", nil) w := httptest.NewRecorder() h.HandleListUsers(w, r) if w.Code != http.StatusOK { t.Error("status is not ok") } bytes, _ := io.ReadAll(w.Body) if strings.Trim(string(bytes), "\n") != expectedJSON { t.Errorf("expected: [%s], got: [%s]", expectedJSON, string(bytes)) } } ================================================ FILE: 3-web/readings_3.md ================================================ Конечно же документация: * https://golang.org/pkg/net/http/ Дополнительные материалы * https://gowebexamples.github.io/ - примеры касательно разработки веба * https://golang.org/doc/articles/wiki/ * https://astaxie.gitbooks.io/build-web-application-with-golang/ * https://github.com/thewhitetulip/web-dev-golang-anti-textbook/ * https://codegangsta.gitbooks.io/building-web-apps-with-go/content/ * http://www.golangprograms.com/ * http://marcio.io/2015/07/cheap-mapreduce-in-go/ * https://www.rzaluska.com/blog/important-go-interfaces/ * https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/ - про таймауты * http://polyglot.ninja/golang-making-http-requests/ * http://tumregels.github.io/Network-Programming-with-Go/ На русском: * https://habrahabr.ru/post/330512/ - Многопользовательская игра на Go через telnet - чисто сеть ================================================ FILE: 4-api/1_rpc/jsonrpc/books.go ================================================ package main import ( "log" "sync" ) type Book struct { ID uint `json:"id"` Title string `json:"title"` Price uint `json:"price"` } type BookStore struct { books []*Book mu sync.RWMutex } func NewBookStore() *BookStore { return &BookStore{ mu: sync.RWMutex{}, books: []*Book{}, } } func (bs *BookStore) AddBook(in *Book, out *Book) error { log.Println("AddBook called") bs.mu.Lock() bs.books = append(bs.books, in) bs.mu.Unlock() *out = *in return nil } func (bs *BookStore) GetBooks(in int, out *[]*Book) error { log.Println("GetBooks called") bs.mu.Lock() defer bs.mu.Unlock() *out = bs.books return nil } ================================================ FILE: 4-api/1_rpc/jsonrpc/server.go ================================================ package main import ( "fmt" "io" "log" "net/http" "net/rpc" "net/rpc/jsonrpc" ) type HttpConn struct { in io.Reader out io.Writer } func (c *HttpConn) Read(p []byte) (n int, err error) { return c.in.Read(p) } func (c *HttpConn) Write(d []byte) (n int, err error) { return c.out.Write(d) } func (c *HttpConn) Close() error { return nil } /* { "jsonrpc":"2.0", "id":1, "method":"BookStore.AddBook", "params":[ { "title": "The Moon is a harsh mistress", "price": 200 } ] } */ /* curl -v -X POST -H "Content-Type: application/json" -H "X-Auth: 123" -d '{"jsonrpc":"2.0", "id": 1, "method": "BookStore.AddBook", "params": [{"title":"The Moon is a harsh mistress", "price": 200}]}' http://localhost:8081/rpc curl -v -X POST -H "Content-Type: application/json" -H "X-Auth: 123" -d '{"jsonrpc":"2.0", "id": 2, "method": "BookStore.GetBooks", "params": []}' http://localhost:8081/rpc */ type Handler struct { rpcServer *rpc.Server } func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { fmt.Println("rpc auth: ", r.Header.Get("X-Auth")) serverCodec := jsonrpc.NewServerCodec(&HttpConn{ in: r.Body, out: w, }) w.Header().Set("Content-Type", "application/json") err := h.rpcServer.ServeRequest(serverCodec) if err != nil { log.Printf("Error while serving JSON request: %v", err) http.Error(w, `{"error":"cant serve request"}`, 500) } else { w.WriteHeader(200) } } func main() { bookStore := NewBookStore() server := rpc.NewServer() server.Register(bookStore) sessionHandler := &Handler{ rpcServer: server, } http.Handle("/rpc", sessionHandler) fmt.Println("starting server at :8081") http.ListenAndServe(":8081", nil) } ================================================ FILE: 4-api/1_rpc/main.go ================================================ package main import ( "fmt" "net/http" ) func login(w http.ResponseWriter, r *http.Request) { fmt.Println("login") w.Write([]byte("login")) } func signup(w http.ResponseWriter, r *http.Request) { fmt.Println("signup") w.Write([]byte("signup")) } func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { method := r.FormValue("method") switch method { case "login": login(w, r) case "signup": signup(w, r) } }) http.ListenAndServe(":9090", nil) } ================================================ FILE: 4-api/1_rpc/net-rpc/books.go ================================================ package main import ( "log" "sync" ) type Book struct { ID uint Title string Price uint } type BookStore struct { books []*Book mu sync.RWMutex } func NewBookStore() *BookStore { return &BookStore{ mu: sync.RWMutex{}, books: []*Book{}, } } func (bs *BookStore) AddBook(in *Book, out *Book) error { log.Println("AddBook called") bs.mu.Lock() bs.books = append(bs.books, in) bs.mu.Unlock() *out = *in return nil } func (bs *BookStore) GetBooks(in int, out *[]*Book) error { log.Println("GetBooks called") bs.mu.Lock() defer bs.mu.Unlock() *out = bs.books return nil } ================================================ FILE: 4-api/1_rpc/net-rpc/client.go ================================================ package main import ( "log" "net/rpc" ) func main() { client, err := rpc.DialHTTP("tcp", "localhost:8081") if err != nil { log.Fatal("dialing:", err) } res := new(Book) client.Call("BookStore.AddBook", &Book{Title: "The Moon is a harsh mistress"}, res) if err != nil { log.Printf("AddBook error: %s\n", err) } log.Printf("AddBook: %#v", res) books := &[]*Book{} err = client.Call("BookStore.GetBooks", 0, books) if err != nil { log.Printf("GetBooks error: %s\n", err) } log.Printf("GetBooks: %#v", *books) } ================================================ FILE: 4-api/1_rpc/net-rpc/server.go ================================================ package main import ( "fmt" "log" "net" "net/http" "net/rpc" ) func main() { bookStore := NewBookStore() rpc.Register(bookStore) rpc.HandleHTTP() l, e := net.Listen("tcp", ":8081") if e != nil { log.Fatal("listen error:", e) } fmt.Println("starting server at :8081") http.Serve(l, nil) } ================================================ FILE: 4-api/2_rest/books.go ================================================ package main import ( "log" "sync" ) type Book struct { ID uint `json:"id"` Title string `json:"title"` Price uint `json:"price"` } type BookStore struct { books []*Book mu sync.RWMutex nextID uint } func NewBookStore() *BookStore { return &BookStore{ mu: sync.RWMutex{}, books: []*Book{}, } } func (bs *BookStore) AddBook(in *Book) (uint, error) { log.Println("AddBook called") bs.mu.Lock() bs.nextID++ in.ID = bs.nextID log.Println("nextID", bs.nextID) bs.books = append(bs.books, in) bs.mu.Unlock() return in.ID, nil } func (bs *BookStore) GetBooks() ([]*Book, error) { log.Println("GetBooks called") bs.mu.RLock() defer bs.mu.RUnlock() return bs.books, nil } ================================================ FILE: 4-api/2_rest/main.go ================================================ package main import ( "encoding/json" "log" "net/http" "strconv" "github.com/gorilla/mux" ) type Result struct { Body interface{} `json:"body,omitempty"` Err string `json:"err,omitempty"` } type BooksHandler struct { store *BookStore } func (api *BooksHandler) List(w http.ResponseWriter, r *http.Request) { books, err := api.store.GetBooks() if err != nil { http.Error(w, `{"error":"db"}`, 500) return } body := map[string]interface{}{ "books": books, } json.NewEncoder(w).Encode(&Result{Body: body}) } // http://127.0.0.1:8080/add?title=test&price=123 func (api *BooksHandler) Add(w http.ResponseWriter, r *http.Request) { title := r.FormValue("title") price, _ := strconv.Atoi(r.FormValue("price")) in := &Book{ Title: title, Price: uint(price), } id, err := api.store.AddBook(in) if err != nil { http.Error(w, `{"error":"db"}`, 500) return } body := map[string]interface{}{ "id": id, } json.NewEncoder(w).Encode(&Result{Body: body}) } func (api *BooksHandler) BookByID(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) id, err := strconv.Atoi(vars["id"]) if err != nil { http.Error(w, `{"error":"bad id"}`, 400) return } books, err := api.store.GetBooks() if err != nil { http.Error(w, `{"error":"db"}`, 500) return } var book *Book for _, b := range books { if b.ID == uint(id) { book = b break } } if book == nil { http.Error(w, `{"body":{"book":null}}`, 404) return } body := map[string]interface{}{ "book": book, } json.NewEncoder(w).Encode(&Result{Body: body}) } func main() { r := mux.NewRouter() api := &BooksHandler{ store: NewBookStore(), } r.HandleFunc("/", api.List) r.HandleFunc("/add", api.Add) r.HandleFunc("/book/{id:[0-9]+}", api.BookByID) log.Println("start serving :8080") http.ListenAndServe(":8080", r) } ================================================ FILE: 4-api/3_graphql/gqlgen/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package gqlgen import ( "bytes" "context" "errors" "strconv" "sync" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" "github.com/vektah/gqlparser" "github.com/vektah/gqlparser/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 { Author struct { Name func(childComplexity int) int } Book struct { Author func(childComplexity int) int ID func(childComplexity int) int Price func(childComplexity int) int Title func(childComplexity int) int } Query struct { Books func(childComplexity int) int } } type QueryResolver interface { Books(ctx context.Context) ([]*Book, error) } type executableSchema struct { resolvers ResolverRoot directives DirectiveRoot complexity ComplexityRoot } func (e *executableSchema) Schema() *ast.Schema { return parsedSchema } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { ec := executionContext{nil, e} _ = ec switch typeName + "." + field { case "Author.name": if e.complexity.Author.Name == nil { break } return e.complexity.Author.Name(childComplexity), true case "Book.author": if e.complexity.Book.Author == nil { break } return e.complexity.Book.Author(childComplexity), true case "Book.id": if e.complexity.Book.ID == nil { break } return e.complexity.Book.ID(childComplexity), true case "Book.price": if e.complexity.Book.Price == nil { break } return e.complexity.Book.Price(childComplexity), true case "Book.title": if e.complexity.Book.Title == nil { break } return e.complexity.Book.Title(childComplexity), true case "Query.books": if e.complexity.Query.Books == nil { break } return e.complexity.Query.Books(childComplexity), true } return 0, false } func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { ec := executionContext{graphql.GetRequestContext(ctx), e} buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { data := ec._Query(ctx, op.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) return buf.Bytes() }) return &graphql.Response{ Data: buf, Errors: ec.Errors, Extensions: ec.Extensions, } } func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { return graphql.ErrorResponse(ctx, "mutations are not supported") } func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) } type executionContext struct { *graphql.RequestContext *executableSchema } func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } return introspection.WrapSchema(parsedSchema), nil } func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil } var parsedSchema = gqlparser.MustLoadSchema( &ast.Source{Name: "schema.graphql", Input: `type Author { name: String! } type Book { id: ID! title: String! price: Float! author: Author } type Query { books: [Book!]! } `}, ) // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { arg0, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } } args["name"] = arg0 return args, nil } func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { 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) _Author_name(ctx context.Context, field graphql.CollectedField, obj *Author) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Author", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Book_id(ctx context.Context, field graphql.CollectedField, obj *Book) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Book", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _Book_title(ctx context.Context, field graphql.CollectedField, obj *Book) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Book", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Title, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Book_price(ctx context.Context, field graphql.CollectedField, obj *Book) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Book", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Price, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(float64) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNFloat2float64(ctx, field.Selections, res) } func (ec *executionContext) _Book_author(ctx context.Context, field graphql.CollectedField, obj *Book) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Book", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Author, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*Author) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalOAuthor2ᚖgithubᚗcomᚋgoᚑparkᚑmailᚑruᚋlecturesᚋ4ᚋ3_graphqlᚋgqlgenᚐAuthor(ctx, field.Selections, res) } func (ec *executionContext) _Query_books(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Books(rctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]*Book) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNBook2ᚕᚖgithubᚗcomᚋgoᚑparkᚑmailᚑruᚋlecturesᚋ4ᚋ3_graphqlᚋgqlgenᚐBook(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query___type_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectType(args["name"].(string)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectSchema() }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Locations, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalN__DirectiveLocation2ᚕstring(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DefaultValue, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Types(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.QueryType(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.MutationType(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.SubscriptionType(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Directives(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, field.Selections, res) } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Kind(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_fields_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Fields(args["includeDeprecated"].(bool)), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, field.Selections, res) } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Interfaces(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.PossibleTypes(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_enumValues_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, field.Selections, res) } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.InputFields(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, field.Selections, res) } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.OfType(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var authorImplementors = []string{"Author"} func (ec *executionContext) _Author(ctx context.Context, sel ast.SelectionSet, obj *Author) graphql.Marshaler { fields := graphql.CollectFields(ec.RequestContext, sel, authorImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Author") case "name": out.Values[i] = ec._Author_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 bookImplementors = []string{"Book"} func (ec *executionContext) _Book(ctx context.Context, sel ast.SelectionSet, obj *Book) graphql.Marshaler { fields := graphql.CollectFields(ec.RequestContext, sel, bookImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Book") case "id": out.Values[i] = ec._Book_id(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "title": out.Values[i] = ec._Book_title(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "price": out.Values[i] = ec._Book_price(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "author": out.Values[i] = ec._Book_author(ctx, field, obj) 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.RequestContext, sel, queryImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "Query", }) out := graphql.NewFieldSet(fields) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "books": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_books(ctx, field) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": out.Values[i] = ec._Query___schema(ctx, field) 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.RequestContext, 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++ } 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.RequestContext, 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.RequestContext, 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.RequestContext, 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.RequestContext, sel, __SchemaImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Schema") case "types": 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.RequestContext, 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) 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) marshalNBook2githubᚗcomᚋgoᚑparkᚑmailᚑruᚋlecturesᚋ4ᚋ3_graphqlᚋgqlgenᚐBook(ctx context.Context, sel ast.SelectionSet, v Book) graphql.Marshaler { return ec._Book(ctx, sel, &v) } func (ec *executionContext) marshalNBook2ᚕᚖgithubᚗcomᚋgoᚑparkᚑmailᚑruᚋlecturesᚋ4ᚋ3_graphqlᚋgqlgenᚐBook(ctx context.Context, sel ast.SelectionSet, v []*Book) 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 rctx := &graphql.ResolverContext{ Index: &i, Result: &v[i], } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = nil } }() if !isLen1 { defer wg.Done() } ret[i] = ec.marshalNBook2ᚖgithubᚗcomᚋgoᚑparkᚑmailᚑruᚋlecturesᚋ4ᚋ3_graphqlᚋgqlgenᚐBook(ctx, sel, v[i]) } if isLen1 { f(i) } else { go f(i) } } wg.Wait() return ret } func (ec *executionContext) marshalNBook2ᚖgithubᚗcomᚋgoᚑparkᚑmailᚑruᚋlecturesᚋ4ᚋ3_graphqlᚋgqlgenᚐBook(ctx context.Context, sel ast.SelectionSet, v *Book) graphql.Marshaler { if v == nil { if !ec.HasError(graphql.GetResolverContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null } return ec._Book(ctx, sel, v) } func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { res := graphql.MarshalBoolean(v) if res == graphql.Null { if !ec.HasError(graphql.GetResolverContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalNFloat2float64(ctx context.Context, v interface{}) (float64, error) { return graphql.UnmarshalFloat(v) } func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { res := graphql.MarshalFloat(v) if res == graphql.Null { if !ec.HasError(graphql.GetResolverContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalID(v) } func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalID(v) if res == graphql.Null { if !ec.HasError(graphql.GetResolverContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { if !ec.HasError(graphql.GetResolverContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { return ec.___Directive(ctx, sel, &v) } func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup isLen1 := len(v) == 1 if !isLen1 { wg.Add(len(v)) } for i := range v { i := i rctx := &graphql.ResolverContext{ Index: &i, Result: &v[i], } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { defer 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() return ret } func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { if !ec.HasError(graphql.GetResolverContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstring(ctx context.Context, v interface{}) ([]string, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { vSlice = tmp1 } else { vSlice = []interface{}{v} } } var err error res := make([]string, len(vSlice)) for i := range vSlice { 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 rctx := &graphql.ResolverContext{ Index: &i, Result: &v[i], } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { defer 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() 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 rctx := &graphql.ResolverContext{ Index: &i, Result: &v[i], } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { defer 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() 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 rctx := &graphql.ResolverContext{ Index: &i, Result: &v[i], } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { defer 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() 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 !ec.HasError(graphql.GetResolverContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null } return ec.___Type(ctx, sel, v) } func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { if !ec.HasError(graphql.GetResolverContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) marshalOAuthor2githubᚗcomᚋgoᚑparkᚑmailᚑruᚋlecturesᚋ4ᚋ3_graphqlᚋgqlgenᚐAuthor(ctx context.Context, sel ast.SelectionSet, v Author) graphql.Marshaler { return ec._Author(ctx, sel, &v) } func (ec *executionContext) marshalOAuthor2ᚖgithubᚗcomᚋgoᚑparkᚑmailᚑruᚋlecturesᚋ4ᚋ3_graphqlᚋgqlgenᚐAuthor(ctx context.Context, sel ast.SelectionSet, v *Author) graphql.Marshaler { if v == nil { return graphql.Null } return ec._Author(ctx, sel, v) } func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { return graphql.MarshalBoolean(v) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } res, err := ec.unmarshalOBoolean2bool(ctx, v) return &res, err } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOBoolean2bool(ctx, sel, *v) } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { return graphql.MarshalString(v) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } res, err := ec.unmarshalOString2string(ctx, v) return &res, err } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOString2string(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 rctx := &graphql.ResolverContext{ Index: &i, Result: &v[i], } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { defer 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() 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 rctx := &graphql.ResolverContext{ Index: &i, Result: &v[i], } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { defer 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() 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 rctx := &graphql.ResolverContext{ Index: &i, Result: &v[i], } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { defer 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() return ret } func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { return ec.___Schema(ctx, sel, &v) } 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__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) 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 rctx := &graphql.ResolverContext{ Index: &i, Result: &v[i], } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { defer 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() 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: 4-api/3_graphql/gqlgen/gqlgen.yml ================================================ # .gqlgen.yml example # # Refer to https://gqlgen.com/config/ # for detailed .gqlgen.yml documentation. schema: - schema.graphql exec: filename: generated.go model: filename: models_gen.go resolver: filename: resolver.go type: Resolver autobind: [] ================================================ FILE: 4-api/3_graphql/gqlgen/models_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package gqlgen type Author struct { Name string `json:"name"` } type Book struct { ID string `json:"id"` Title string `json:"title"` Price float64 `json:"price"` Author *Author `json:"author"` } ================================================ FILE: 4-api/3_graphql/gqlgen/resolver.go ================================================ package gqlgen import ( "context" ) // THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES. type Resolver struct{} func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } type queryResolver struct{ *Resolver } func (r *queryResolver) Books(ctx context.Context) ([]*Book, error) { return []*Book{ { ID: "1", Title: "The Moon is a harsh mistress", Price: 200, Author: &Author{Name: "John"}, }, }, nil } ================================================ FILE: 4-api/3_graphql/gqlgen/schema.graphql ================================================ type Author { name: String! } type Book { id: ID! title: String! price: Float! author: Author } type Query { books: [Book!]! } ================================================ FILE: 4-api/3_graphql/gqlgen/server/server.go ================================================ package main import ( "log" "net/http" "os" gql "github.com/go-park-mail-ru/lectures/4-api/3_graphql/gqlgen" "github.com/99designs/gqlgen/handler" ) const defaultPort = "8080" func main() { port := os.Getenv("PORT") if port == "" { port = defaultPort } http.Handle("/", handler.Playground("GraphQL playground", "/query")) http.Handle("/query", handler.GraphQL(gql.NewExecutableSchema(gql.Config{Resolvers: &gql.Resolver{}}))) log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) log.Fatal(http.ListenAndServe(":"+port, nil)) } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen1/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package gqlgen1 import ( "bytes" "context" "errors" "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 { Mutation() MutationResolver Query() QueryResolver } type DirectiveRoot struct { } type ComplexityRoot struct { Mutation struct { RatePhoto func(childComplexity int, photoID string, direction string) int } Photo struct { Comment func(childComplexity int) int Followed func(childComplexity int) int ID func(childComplexity int) int Liked func(childComplexity int) int Rating func(childComplexity int) int URL func(childComplexity int) int User func(childComplexity int) int } Query struct { Photos func(childComplexity int, userID string) int Timeline func(childComplexity int) int User func(childComplexity int, userID string) int } User struct { Avatar func(childComplexity int) int ID func(childComplexity int) int Name func(childComplexity int) int } } type MutationResolver interface { RatePhoto(ctx context.Context, photoID string, direction string) (*Photo, error) } type QueryResolver interface { Timeline(ctx context.Context) ([]*Photo, error) User(ctx context.Context, userID string) (*User, error) Photos(ctx context.Context, userID string) ([]*Photo, error) } type executableSchema struct { resolvers ResolverRoot directives DirectiveRoot complexity ComplexityRoot } func (e *executableSchema) Schema() *ast.Schema { return parsedSchema } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { ec := executionContext{nil, e} _ = ec switch typeName + "." + field { case "Mutation.ratePhoto": if e.complexity.Mutation.RatePhoto == nil { break } args, err := ec.field_Mutation_ratePhoto_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Mutation.RatePhoto(childComplexity, args["photoID"].(string), args["direction"].(string)), true case "Photo.comment": if e.complexity.Photo.Comment == nil { break } return e.complexity.Photo.Comment(childComplexity), true case "Photo.followed": if e.complexity.Photo.Followed == nil { break } return e.complexity.Photo.Followed(childComplexity), true case "Photo.id": if e.complexity.Photo.ID == nil { break } return e.complexity.Photo.ID(childComplexity), true case "Photo.liked": if e.complexity.Photo.Liked == nil { break } return e.complexity.Photo.Liked(childComplexity), true case "Photo.rating": if e.complexity.Photo.Rating == nil { break } return e.complexity.Photo.Rating(childComplexity), true case "Photo.url": if e.complexity.Photo.URL == nil { break } return e.complexity.Photo.URL(childComplexity), true case "Photo.user": if e.complexity.Photo.User == nil { break } return e.complexity.Photo.User(childComplexity), true case "Query.photos": if e.complexity.Query.Photos == nil { break } args, err := ec.field_Query_photos_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Query.Photos(childComplexity, args["userID"].(string)), true case "Query.timeline": if e.complexity.Query.Timeline == nil { break } return e.complexity.Query.Timeline(childComplexity), true case "Query.user": if e.complexity.Query.User == nil { break } args, err := ec.field_Query_user_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Query.User(childComplexity, args["userID"].(string)), true case "User.avatar": if e.complexity.User.Avatar == nil { break } return e.complexity.User.Avatar(childComplexity), true case "User.id": if e.complexity.User.ID == nil { break } return e.complexity.User.ID(childComplexity), true case "User.name": if e.complexity.User.Name == nil { break } return e.complexity.User.Name(childComplexity), true } return 0, false } func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { rc := graphql.GetOperationContext(ctx) ec := executionContext{rc, e} first := true switch rc.Operation.Operation { case ast.Query: return func(ctx context.Context) *graphql.Response { if !first { return nil } first = false data := ec._Query(ctx, rc.Operation.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) return &graphql.Response{ Data: buf.Bytes(), } } case ast.Mutation: return func(ctx context.Context) *graphql.Response { if !first { return nil } first = false data := ec._Mutation(ctx, rc.Operation.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) return &graphql.Response{ Data: buf.Bytes(), } } default: return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) } } type executionContext struct { *graphql.OperationContext *executableSchema } func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } return introspection.WrapSchema(parsedSchema), nil } func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil } var sources = []*ast.Source{ &ast.Source{Name: "schema.graphql", Input: `type User { id: ID! name: String! avatar: String! } type Photo { id: ID! user: User! url: String! comment: String! rating: Int! liked: Boolean! followed: Boolean! } type Query { # query{timeline{id,url,user{id,name}}} timeline: [Photo!]! # query{user(userID:"1"){id,avatar,name}} user(userID: ID!): User! # query{photos(userID:"1"){id,url,user{id,name}}} photos(userID: ID!): [Photo!]! } type Mutation { # mutation _{ratePhoto(photoID:"1", direction:"up"){id,url,rating,user{id,name}}} ratePhoto(photoID: ID!, direction: String!): Photo! } # go run github.com/99designs/gqlgen init # go run github.com/99designs/gqlgen -v # rm -rf generated.go models_generated gqlgen.yml models_gen.go resolver.go server.go`, BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) field_Mutation_ratePhoto_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["photoID"]; ok { arg0, err = ec.unmarshalNID2string(ctx, tmp) if err != nil { return nil, err } } args["photoID"] = arg0 var arg1 string if tmp, ok := rawArgs["direction"]; ok { arg1, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } } args["direction"] = arg1 return args, nil } func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { arg0, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } } args["name"] = arg0 return args, nil } func (ec *executionContext) field_Query_photos_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["userID"]; ok { arg0, err = ec.unmarshalNID2string(ctx, tmp) if err != nil { return nil, err } } args["userID"] = arg0 return args, nil } func (ec *executionContext) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["userID"]; ok { arg0, err = ec.unmarshalNID2string(ctx, tmp) if err != nil { return nil, err } } args["userID"] = arg0 return args, nil } func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 return args, nil } // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _Mutation_ratePhoto(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Mutation", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Mutation_ratePhoto_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Mutation().RatePhoto(rctx, args["photoID"].(string), args["direction"].(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.(*Photo) fc.Result = res return ec.marshalNPhoto2ᚖgqlgen1ᚐPhoto(ctx, field.Selections, res) } func (ec *executionContext) _Photo_id(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _Photo_user(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.User, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*User) fc.Result = res return ec.marshalNUser2ᚖgqlgen1ᚐUser(ctx, field.Selections, res) } func (ec *executionContext) _Photo_url(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.URL, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Photo_comment(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Comment, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Photo_rating(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Rating, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) fc.Result = res return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _Photo_liked(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Liked, nil }) if err != nil { ec.Error(ctx, 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) _Photo_followed(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Followed, nil }) if err != nil { ec.Error(ctx, 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) _Query_timeline(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Timeline(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.([]*Photo) fc.Result = res return ec.marshalNPhoto2ᚕᚖgqlgen1ᚐPhotoᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_user_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().User(rctx, args["userID"].(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.(*User) fc.Result = res return ec.marshalNUser2ᚖgqlgen1ᚐUser(ctx, field.Selections, res) } func (ec *executionContext) _Query_photos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_photos_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Photos(rctx, args["userID"].(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.([]*Photo) fc.Result = res return ec.marshalNPhoto2ᚕᚖgqlgen1ᚐPhotoᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query___type_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectType(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) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.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) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _User_avatar(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Avatar, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*string) fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_fields_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Fields(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) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_enumValues_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.EnumValues(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) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // 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) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Mutation") case "ratePhoto": out.Values[i] = ec._Mutation_ratePhoto(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 photoImplementors = []string{"Photo"} func (ec *executionContext) _Photo(ctx context.Context, sel ast.SelectionSet, obj *Photo) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, photoImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Photo") case "id": out.Values[i] = ec._Photo_id(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "user": out.Values[i] = ec._Photo_user(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "url": out.Values[i] = ec._Photo_url(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "comment": out.Values[i] = ec._Photo_comment(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "rating": out.Values[i] = ec._Photo_rating(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "liked": out.Values[i] = ec._Photo_liked(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "followed": out.Values[i] = ec._Photo_followed(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 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 { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "timeline": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_timeline(ctx, field) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "user": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_user(ctx, field) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "photos": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_photos(ctx, field) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": out.Values[i] = 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++ } case "avatar": out.Values[i] = ec._User_avatar(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++ } 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 "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) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch() if invalids > 0 { return graphql.Null } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { res := graphql.MarshalBoolean(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalID(v) } func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalID(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{}) (int, error) { return graphql.UnmarshalInt(v) } func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { res := graphql.MarshalInt(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) marshalNPhoto2gqlgen1ᚐPhoto(ctx context.Context, sel ast.SelectionSet, v Photo) graphql.Marshaler { return ec._Photo(ctx, sel, &v) } func (ec *executionContext) marshalNPhoto2ᚕᚖgqlgen1ᚐPhotoᚄ(ctx context.Context, sel ast.SelectionSet, v []*Photo) 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.marshalNPhoto2ᚖgqlgen1ᚐPhoto(ctx, sel, v[i]) } if isLen1 { f(i) } else { go f(i) } } wg.Wait() return ret } func (ec *executionContext) marshalNPhoto2ᚖgqlgen1ᚐPhoto(ctx context.Context, sel ast.SelectionSet, v *Photo) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null } return ec._Photo(ctx, sel, v) } func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) marshalNUser2gqlgen1ᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler { return ec._User(ctx, sel, &v) } func (ec *executionContext) marshalNUser2ᚖgqlgen1ᚐUser(ctx context.Context, sel ast.SelectionSet, v *User) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null } return ec._User(ctx, sel, v) } func (ec *executionContext) 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() return ret } func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { vSlice = tmp1 } else { vSlice = []interface{}{v} } } var err error res := make([]string, len(vSlice)) for i := range vSlice { 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() 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() 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() return ret } func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null } return ec.___Type(ctx, sel, v) } func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { return graphql.MarshalBoolean(v) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } res, err := ec.unmarshalOBoolean2bool(ctx, v) return &res, err } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOBoolean2bool(ctx, sel, *v) } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { return graphql.MarshalString(v) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } res, err := ec.unmarshalOString2string(ctx, v) return &res, err } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOString2string(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() 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() 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() return ret } func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { return ec.___Schema(ctx, sel, &v) } 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__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) 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() 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: 4-api/3_graphql/gqlgen_full/gqlgen1/go.mod ================================================ module gqlgen1 go 1.13 require ( github.com/99designs/gqlgen v0.11.1 github.com/vektah/gqlparser v1.3.1 github.com/vektah/gqlparser/v2 v2.0.1 ) ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen1/go.sum ================================================ github.com/99designs/gqlgen v0.11.1 h1:QoSL8/AAJ2T3UOeQbdnBR32JcG4pO08+P/g5jdbFkUg= github.com/99designs/gqlgen v0.11.1/go.mod h1:vjFOyBZ7NwDl+GdSD4PFn7BQn5Fy7ohJwXn7Vk8zz+c= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/agnivade/levenshtein v1.0.3 h1:M5ZnqLOoZR8ygVq0FfkXsNOKzMCk0xRiow0R5+5VkQ0= github.com/agnivade/levenshtein v1.0.3/go.mod h1:4SFRZbbXWLF4MU1T9Qg0pGgH3Pjs+t6ie5efyrwRJXs= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= 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/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/trifles v0.0.0-20190318185328-a8d75aae118c/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= github.com/go-chi/chi v3.3.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/mux v1.6.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/websocket v1.2.0 h1:VJtLvh6VQym50czpZzx07z/kw9EgAxI3x1ZB8taTMQQ= github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= github.com/matryer/moq v0.0.0-20200106131100-75d0ddfc0007/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047 h1:zCoDWFD5nrJJVjbXiDZcVhOBSzKn3o9LgRLLMRNuru8= github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e/go.mod h1:/HUdMve7rvxZma+2ZELQeNh88+003LL7Pf/CZ089j8U= github.com/vektah/gqlparser v1.3.1 h1:8b0IcD3qZKWJQHSzynbDlrtP3IxVydZ2DZepCGofqfU= github.com/vektah/gqlparser v1.3.1/go.mod h1:bkVf0FX+Stjg/MHnm8mEyubuaArhNEqfQhF+OTiAL74= github.com/vektah/gqlparser/v2 v2.0.1 h1:xgl5abVnsd4hkN9rk65OJID9bfcLSMuTaTcZj777q1o= github.com/vektah/gqlparser/v2 v2.0.1/go.mod h1:SyUiHgLATUR8BiYURfTirrTcGpcE+4XkV2se04Px1Ms= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589 h1:rjUrONFu4kLchcZTfp3/96bR8bW8dIa8uz3cR5n0cgM= golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:L5q+DGLGOQFpo1snNEkLOJT2d1YTW66rWNzatr3He1k= ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen1/gqlgen.yml ================================================ # .gqlgen.yml example # # Refer to https://gqlgen.com/config/ # for detailed .gqlgen.yml documentation. schema: - schema.graphql exec: filename: generated.go model: filename: models_gen.go resolver: filename: resolver.go type: Resolver autobind: [] ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen1/models_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package gqlgen1 type Photo struct { ID string `json:"id"` User *User `json:"user"` URL string `json:"url"` Comment string `json:"comment"` Rating int `json:"rating"` Liked bool `json:"liked"` Followed bool `json:"followed"` } type User struct { ID string `json:"id"` Name string `json:"name"` Avatar string `json:"avatar"` } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen1/resolver.go ================================================ package gqlgen1 import ( "context" ) // THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES. type Resolver struct{} func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } type mutationResolver struct{ *Resolver } func (r *mutationResolver) RatePhoto(ctx context.Context, photoID string, direction string) (*Photo, error) { panic("not implemented") } type queryResolver struct{ *Resolver } func (r *queryResolver) Timeline(ctx context.Context) ([]*Photo, error) { panic("not implemented") } func (r *queryResolver) User(ctx context.Context, userID string) (*User, error) { panic("not implemented") } func (r *queryResolver) Photos(ctx context.Context, userID string) ([]*Photo, error) { panic("not implemented") } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen1/schema.graphql ================================================ type User { id: ID! name: String! avatar: String! } type Photo { id: ID! user: User! url: String! comment: String! rating: Int! liked: Boolean! followed: Boolean! } type Query { # query{timeline{id,url,user{id,name}}} timeline: [Photo!]! # query{user(userID:"1"){id,avatar,name}} user(userID: ID!): User! # query{photos(userID:"1"){id,url,user{id,name}}} photos(userID: ID!): [Photo!]! } type Mutation { # mutation _{ratePhoto(photoID:"1", direction:"up"){id,url,rating,user{id,name}}} ratePhoto(photoID: ID!, direction: String!): Photo! } # go run github.com/99designs/gqlgen init # go run github.com/99designs/gqlgen -v # rm -rf generated.go models_generated gqlgen.yml models_gen.go resolver.go server.go ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen1/server/server.go ================================================ package main import ( gqlgen "gqlgen1" "log" "net/http" "os" "github.com/99designs/gqlgen/handler" ) const defaultPort = "8080" func main() { port := os.Getenv("PORT") if port == "" { port = defaultPort } http.Handle("/", handler.Playground("GraphQL playground", "/query")) http.Handle("/query", handler.GraphQL(gqlgen.NewExecutableSchema(gqlgen.Config{Resolvers: &gqlgen.Resolver{}}))) log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) log.Fatal(http.ListenAndServe(":"+port, nil)) } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen2/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package gqlgen2 import ( "bytes" "context" "errors" "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 { Mutation() MutationResolver Photo() PhotoResolver Query() QueryResolver } type DirectiveRoot struct { } type ComplexityRoot struct { Mutation struct { RatePhoto func(childComplexity int, photoID string, direction string) int } Photo struct { Comment func(childComplexity int) int Followed func(childComplexity int) int ID func(childComplexity int) int Liked func(childComplexity int) int Rating func(childComplexity int) int URL func(childComplexity int) int User func(childComplexity int) int } Query struct { Photos func(childComplexity int, userID string) int Timeline func(childComplexity int) int User func(childComplexity int, userID string) int } User struct { Avatar func(childComplexity int) int ID func(childComplexity int) int Name func(childComplexity int) int } } type MutationResolver interface { RatePhoto(ctx context.Context, photoID string, direction string) (*Photo, error) } type PhotoResolver interface { ID(ctx context.Context, obj *Photo) (string, error) User(ctx context.Context, obj *Photo) (*User, error) } type QueryResolver interface { Timeline(ctx context.Context) ([]*Photo, error) User(ctx context.Context, userID string) (*User, error) Photos(ctx context.Context, userID string) ([]*Photo, error) } type executableSchema struct { resolvers ResolverRoot directives DirectiveRoot complexity ComplexityRoot } func (e *executableSchema) Schema() *ast.Schema { return parsedSchema } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { ec := executionContext{nil, e} _ = ec switch typeName + "." + field { case "Mutation.ratePhoto": if e.complexity.Mutation.RatePhoto == nil { break } args, err := ec.field_Mutation_ratePhoto_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Mutation.RatePhoto(childComplexity, args["photoID"].(string), args["direction"].(string)), true case "Photo.comment": if e.complexity.Photo.Comment == nil { break } return e.complexity.Photo.Comment(childComplexity), true case "Photo.followed": if e.complexity.Photo.Followed == nil { break } return e.complexity.Photo.Followed(childComplexity), true case "Photo.id": if e.complexity.Photo.ID == nil { break } return e.complexity.Photo.ID(childComplexity), true case "Photo.liked": if e.complexity.Photo.Liked == nil { break } return e.complexity.Photo.Liked(childComplexity), true case "Photo.rating": if e.complexity.Photo.Rating == nil { break } return e.complexity.Photo.Rating(childComplexity), true case "Photo.url": if e.complexity.Photo.URL == nil { break } return e.complexity.Photo.URL(childComplexity), true case "Photo.user": if e.complexity.Photo.User == nil { break } return e.complexity.Photo.User(childComplexity), true case "Query.photos": if e.complexity.Query.Photos == nil { break } args, err := ec.field_Query_photos_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Query.Photos(childComplexity, args["userID"].(string)), true case "Query.timeline": if e.complexity.Query.Timeline == nil { break } return e.complexity.Query.Timeline(childComplexity), true case "Query.user": if e.complexity.Query.User == nil { break } args, err := ec.field_Query_user_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Query.User(childComplexity, args["userID"].(string)), true case "User.avatar": if e.complexity.User.Avatar == nil { break } return e.complexity.User.Avatar(childComplexity), true case "User.id": if e.complexity.User.ID == nil { break } return e.complexity.User.ID(childComplexity), true case "User.name": if e.complexity.User.Name == nil { break } return e.complexity.User.Name(childComplexity), true } return 0, false } func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { rc := graphql.GetOperationContext(ctx) ec := executionContext{rc, e} first := true switch rc.Operation.Operation { case ast.Query: return func(ctx context.Context) *graphql.Response { if !first { return nil } first = false data := ec._Query(ctx, rc.Operation.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) return &graphql.Response{ Data: buf.Bytes(), } } case ast.Mutation: return func(ctx context.Context) *graphql.Response { if !first { return nil } first = false data := ec._Mutation(ctx, rc.Operation.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) return &graphql.Response{ Data: buf.Bytes(), } } default: return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) } } type executionContext struct { *graphql.OperationContext *executableSchema } func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } return introspection.WrapSchema(parsedSchema), nil } func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil } var sources = []*ast.Source{ &ast.Source{Name: "schema.graphql", Input: `type User { id: ID! name: String! avatar: String! } type Photo { id: ID! user: User! url: String! comment: String! rating: Int! liked: Boolean! followed: Boolean! } type Query { # query{timeline{id,url,user{id,name}}} timeline: [Photo!]! # query{user(userID:"1"){id,url,user{id,name}}} user(userID: ID!): User! # query{user(userID:"1"){id,avatar,name}} photos(userID: ID!): [Photo!]! } type Mutation { # mutation _{ratePhoto(photoID:"1", direction:"up"){id,url,rating,user{id,name}}} ratePhoto(photoID: ID!, direction: String!): Photo! } # go run github.com/99designs/gqlgen init # go run github.com/99designs/gqlgen -v `, BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) field_Mutation_ratePhoto_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["photoID"]; ok { arg0, err = ec.unmarshalNID2string(ctx, tmp) if err != nil { return nil, err } } args["photoID"] = arg0 var arg1 string if tmp, ok := rawArgs["direction"]; ok { arg1, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } } args["direction"] = arg1 return args, nil } func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { arg0, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } } args["name"] = arg0 return args, nil } func (ec *executionContext) field_Query_photos_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["userID"]; ok { arg0, err = ec.unmarshalNID2string(ctx, tmp) if err != nil { return nil, err } } args["userID"] = arg0 return args, nil } func (ec *executionContext) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["userID"]; ok { arg0, err = ec.unmarshalNID2string(ctx, tmp) if err != nil { return nil, err } } args["userID"] = arg0 return args, nil } func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 return args, nil } // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _Mutation_ratePhoto(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Mutation", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Mutation_ratePhoto_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Mutation().RatePhoto(rctx, args["photoID"].(string), args["direction"].(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.(*Photo) fc.Result = res return ec.marshalNPhoto2ᚖgqlgen2ᚐPhoto(ctx, field.Selections, res) } func (ec *executionContext) _Photo_id(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Photo().ID(rctx, obj) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _Photo_user(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Photo().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ᚖgqlgen2ᚐUser(ctx, field.Selections, res) } func (ec *executionContext) _Photo_url(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.URL, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Photo_comment(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Comment, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Photo_rating(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Rating, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) fc.Result = res return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _Photo_liked(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Liked, nil }) if err != nil { ec.Error(ctx, 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) _Photo_followed(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Followed, nil }) if err != nil { ec.Error(ctx, 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) _Query_timeline(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Timeline(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.([]*Photo) fc.Result = res return ec.marshalNPhoto2ᚕᚖgqlgen2ᚐPhotoᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_user_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().User(rctx, args["userID"].(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.(*User) fc.Result = res return ec.marshalNUser2ᚖgqlgen2ᚐUser(ctx, field.Selections, res) } func (ec *executionContext) _Query_photos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_photos_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Photos(rctx, args["userID"].(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.([]*Photo) fc.Result = res return ec.marshalNPhoto2ᚕᚖgqlgen2ᚐPhotoᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query___type_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectType(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) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.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) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _User_avatar(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Avatar, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*string) fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_fields_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Fields(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) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_enumValues_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.EnumValues(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) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // 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) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Mutation") case "ratePhoto": out.Values[i] = ec._Mutation_ratePhoto(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 photoImplementors = []string{"Photo"} func (ec *executionContext) _Photo(ctx context.Context, sel ast.SelectionSet, obj *Photo) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, photoImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Photo") case "id": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Photo_id(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "user": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Photo_user(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "url": out.Values[i] = ec._Photo_url(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "comment": out.Values[i] = ec._Photo_comment(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "rating": out.Values[i] = ec._Photo_rating(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "liked": out.Values[i] = ec._Photo_liked(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "followed": out.Values[i] = ec._Photo_followed(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch() if invalids > 0 { return graphql.Null } return out } var 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 { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "timeline": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_timeline(ctx, field) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "user": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_user(ctx, field) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "photos": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_photos(ctx, field) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": out.Values[i] = 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++ } case "avatar": out.Values[i] = ec._User_avatar(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++ } 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 "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) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch() if invalids > 0 { return graphql.Null } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { res := graphql.MarshalBoolean(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalID(v) } func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalID(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{}) (int, error) { return graphql.UnmarshalInt(v) } func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { res := graphql.MarshalInt(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) marshalNPhoto2gqlgen2ᚐPhoto(ctx context.Context, sel ast.SelectionSet, v Photo) graphql.Marshaler { return ec._Photo(ctx, sel, &v) } func (ec *executionContext) marshalNPhoto2ᚕᚖgqlgen2ᚐPhotoᚄ(ctx context.Context, sel ast.SelectionSet, v []*Photo) 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.marshalNPhoto2ᚖgqlgen2ᚐPhoto(ctx, sel, v[i]) } if isLen1 { f(i) } else { go f(i) } } wg.Wait() return ret } func (ec *executionContext) marshalNPhoto2ᚖgqlgen2ᚐPhoto(ctx context.Context, sel ast.SelectionSet, v *Photo) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null } return ec._Photo(ctx, sel, v) } func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) marshalNUser2gqlgen2ᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler { return ec._User(ctx, sel, &v) } func (ec *executionContext) marshalNUser2ᚖgqlgen2ᚐUser(ctx context.Context, sel ast.SelectionSet, v *User) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null } return ec._User(ctx, sel, v) } func (ec *executionContext) 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() return ret } func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { vSlice = tmp1 } else { vSlice = []interface{}{v} } } var err error res := make([]string, len(vSlice)) for i := range vSlice { 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() 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() 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() return ret } func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null } return ec.___Type(ctx, sel, v) } func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { return graphql.MarshalBoolean(v) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } res, err := ec.unmarshalOBoolean2bool(ctx, v) return &res, err } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOBoolean2bool(ctx, sel, *v) } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { return graphql.MarshalString(v) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } res, err := ec.unmarshalOString2string(ctx, v) return &res, err } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOString2string(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() 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() 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() return ret } func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { return ec.___Schema(ctx, sel, &v) } 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__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) 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() 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: 4-api/3_graphql/gqlgen_full/gqlgen2/go.mod ================================================ module gqlgen2 go 1.13 require ( github.com/99designs/gqlgen v0.11.1 github.com/vektah/gqlparser/v2 v2.0.1 ) ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen2/go.sum ================================================ github.com/99designs/gqlgen v0.11.1 h1:QoSL8/AAJ2T3UOeQbdnBR32JcG4pO08+P/g5jdbFkUg= github.com/99designs/gqlgen v0.11.1/go.mod h1:vjFOyBZ7NwDl+GdSD4PFn7BQn5Fy7ohJwXn7Vk8zz+c= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/agnivade/levenshtein v1.0.3 h1:M5ZnqLOoZR8ygVq0FfkXsNOKzMCk0xRiow0R5+5VkQ0= github.com/agnivade/levenshtein v1.0.3/go.mod h1:4SFRZbbXWLF4MU1T9Qg0pGgH3Pjs+t6ie5efyrwRJXs= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= 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/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/trifles v0.0.0-20190318185328-a8d75aae118c/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= github.com/go-chi/chi v3.3.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/mux v1.6.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/websocket v1.2.0 h1:VJtLvh6VQym50czpZzx07z/kw9EgAxI3x1ZB8taTMQQ= github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= github.com/matryer/moq v0.0.0-20200106131100-75d0ddfc0007/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047 h1:zCoDWFD5nrJJVjbXiDZcVhOBSzKn3o9LgRLLMRNuru8= github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e/go.mod h1:/HUdMve7rvxZma+2ZELQeNh88+003LL7Pf/CZ089j8U= github.com/vektah/gqlparser/v2 v2.0.1 h1:xgl5abVnsd4hkN9rk65OJID9bfcLSMuTaTcZj777q1o= github.com/vektah/gqlparser/v2 v2.0.1/go.mod h1:SyUiHgLATUR8BiYURfTirrTcGpcE+4XkV2se04Px1Ms= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589 h1:rjUrONFu4kLchcZTfp3/96bR8bW8dIa8uz3cR5n0cgM= golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:L5q+DGLGOQFpo1snNEkLOJT2d1YTW66rWNzatr3He1k= ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen2/gqlgen.yml ================================================ # .gqlgen.yml example # # Refer to https://gqlgen.com/config/ # for detailed .gqlgen.yml documentation. schema: - schema.graphql exec: filename: generated.go model: filename: models_gen.go resolver: filename: resolver.go type: Resolver models: Photo: model: gqlgen2.Photo fields: user: resolver: true autobind: [] ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen2/models_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package gqlgen2 type User struct { ID string `json:"id"` Name string `json:"name"` Avatar string `json:"avatar"` } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen2/photo.go ================================================ package gqlgen2 import ( "log" "strconv" ) type Photo struct { ID uint `json:"id"` UserID uint `json:"-"` // User *User `json:"user"` URL string `json:"url"` Comment string `json:"comment"` Rating int `json:"rating"` Liked bool `json:"liked"` Followed bool `json:"followed"` } func (ph *Photo) Id() string { log.Println("call Photo.Id method", ph.ID) return strconv.Itoa(int(ph.ID)) } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen2/resolver.go ================================================ package gqlgen2 //go:generate go run github.com/99designs/gqlgen import ( "context" "fmt" "log" "strconv" ) // THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES. type Resolver struct { PhotosData map[string]*Photo Users map[uint]*User } func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } func (r *Resolver) Photo() PhotoResolver { return &photoResolver{r} } func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } type mutationResolver struct{ *Resolver } func (r *mutationResolver) RatePhoto(ctx context.Context, id string, direction string) (*Photo, error) { log.Println("call mutationResolver.RatePhoto method with id", id, direction) rate := 1 if direction != "up" { rate = -1 } ph, ok := r.PhotosData[id] if !ok { return nil, fmt.Errorf("no photo %v found", id) } ph.Rating += rate return ph, nil } type photoResolver struct{ *Resolver } func (r *photoResolver) ID(ctx context.Context, obj *Photo) (string, error) { return obj.Id(), nil } func (r *photoResolver) User(ctx context.Context, obj *Photo) (*User, error) { // log.Println("call photoResolver.User", obj.UserID) log.Printf("photoResolver.User: SELECT id, name FROM user WHERE ID = %d\n", obj.UserID) return r.Users[obj.UserID], nil } type queryResolver struct{ *Resolver } func (r *queryResolver) Timeline(ctx context.Context) ([]*Photo, error) { log.Println("call queryResolver.Timeline with ctx.userID", ctx.Value("userID")) items := []*Photo{} for _, ph := range r.PhotosData { items = append(items, ph) } return items, nil } func (r *queryResolver) User(ctx context.Context, userID string) (*User, error) { log.Println("call queryResolver.User for", userID) id, _ := strconv.Atoi(userID) return r.Users[uint(id)], nil } func (r *queryResolver) Photos(ctx context.Context, userID string) ([]*Photo, error) { log.Println("call queryResolver.Photos") id, _ := strconv.Atoi(userID) items := []*Photo{} for _, ph := range r.PhotosData { if ph.UserID != uint(id) { continue } items = append(items, ph) } return items, nil } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen2/schema.graphql ================================================ type User { id: ID! name: String! avatar: String! } type Photo { id: ID! user: User! url: String! comment: String! rating: Int! liked: Boolean! followed: Boolean! } type Query { # query{timeline{id,url,user{id,name}}} timeline: [Photo!]! # query{user(userID:"1"){id,url,user{id,name}}} user(userID: ID!): User! # query{user(userID:"1"){id,avatar,name}} photos(userID: ID!): [Photo!]! } type Mutation { # mutation _{ratePhoto(photoID:"1", direction:"up"){id,url,rating,user{id,name}}} ratePhoto(photoID: ID!, direction: String!): Photo! } # go run github.com/99designs/gqlgen init # go run github.com/99designs/gqlgen -v ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen2/schema_alt.graphql ================================================ directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION directive @goField(forceResolver: Boolean, name: String) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION type User { id: ID! name: String! avatar: String } type Photo @goModel(model:"coursera/3p/graphql/gqlgen2.Photo") { id: ID! user: User! @goField(forceResolver: true) url: String! comment: String! rating: Int! liked: Boolean! followed: Boolean! } type Query { # query{timeline{id,url,user{id,name}}} timeline: [Photo!]! # query{user(userID:"1"){id,url,user{id,name}}} user(userID: ID!): User! # query{user(userID:"1"){id,avatar,name}} photos(userID: ID!): [Photo!]! } type Mutation { # mutation _{ratePhoto(photoID:"1", direction:"up"){id,url,rating,user{id,name}}} ratePhoto(photoID: ID!, direction: String!): Photo! } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen2/server/server.go ================================================ package main import ( "context" gqlgen "gqlgen2" "log" "net/http" "github.com/99designs/gqlgen/handler" ) /* query{timeline{id,url,user{id,name}}} query{user(userID:"1"){id,avatar, name}} mutation _{ratePhoto(photoID:"1", direction:"up"){id,url,rating,user{id,name}}} */ var users = map[uint]*gqlgen.User{ 1: { ID: "1", Name: "rvasily", Avatar: "https://via.placeholder.com/150", }, 2: { ID: "2", Name: "v.romanov", Avatar: "https://via.placeholder.com/150", }, } var photos = map[string]*gqlgen.Photo{ "1": { ID: 1, UserID: 1, URL: "https://via.placeholder.com/300", Comment: "fromn studio", Rating: 1, Liked: true, Followed: false, }, "2": { ID: 2, UserID: 1, URL: "https://via.placeholder.com/300", Comment: "cool view", Rating: 0, Liked: false, Followed: false, }, "3": { ID: 3, UserID: 2, URL: "https://via.placeholder.com/300", Comment: "at work", Rating: 0, Liked: false, Followed: false, }, } func AuthMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { log.Println("new request") ctx := context.WithValue(r.Context(), "userID", 1) r = r.WithContext(ctx) next.ServeHTTP(w, r) }) } func main() { http.Handle("/", handler.Playground("GraphQL playground", "/query")) cfg := gqlgen.Config{ Resolvers: &gqlgen.Resolver{ Users: users, PhotosData: photos, }, } gqlHandler := handler.GraphQL(gqlgen.NewExecutableSchema(cfg)) handler := AuthMiddleware(gqlHandler) http.Handle("/query", handler) port := "8080" log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) log.Fatal(http.ListenAndServe(":"+port, nil)) } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen3/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package gqlgen3 import ( "bytes" "context" "errors" "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 { Mutation() MutationResolver Photo() PhotoResolver Query() QueryResolver } type DirectiveRoot struct { } type ComplexityRoot struct { Mutation struct { RatePhoto func(childComplexity int, photoID string, direction string) int } Photo struct { Comment func(childComplexity int) int ID func(childComplexity int) int Liked func(childComplexity int) int Rating func(childComplexity int) int URL func(childComplexity int) int User func(childComplexity int) int } Query struct { Photos func(childComplexity int, userID string) int Timeline func(childComplexity int) int User func(childComplexity int, userID string) int } User struct { Avatar func(childComplexity int) int Followed func(childComplexity int) int ID func(childComplexity int) int Name func(childComplexity int) int } } type MutationResolver interface { RatePhoto(ctx context.Context, photoID string, direction string) (*Photo, error) } type PhotoResolver interface { ID(ctx context.Context, obj *Photo) (string, error) User(ctx context.Context, obj *Photo) (*User, error) } type QueryResolver interface { Timeline(ctx context.Context) ([]*Photo, error) User(ctx context.Context, userID string) (*User, error) Photos(ctx context.Context, userID string) ([]*Photo, error) } type executableSchema struct { resolvers ResolverRoot directives DirectiveRoot complexity ComplexityRoot } func (e *executableSchema) Schema() *ast.Schema { return parsedSchema } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { ec := executionContext{nil, e} _ = ec switch typeName + "." + field { case "Mutation.ratePhoto": if e.complexity.Mutation.RatePhoto == nil { break } args, err := ec.field_Mutation_ratePhoto_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Mutation.RatePhoto(childComplexity, args["photoID"].(string), args["direction"].(string)), true case "Photo.comment": if e.complexity.Photo.Comment == nil { break } return e.complexity.Photo.Comment(childComplexity), true case "Photo.id": if e.complexity.Photo.ID == nil { break } return e.complexity.Photo.ID(childComplexity), true case "Photo.liked": if e.complexity.Photo.Liked == nil { break } return e.complexity.Photo.Liked(childComplexity), true case "Photo.rating": if e.complexity.Photo.Rating == nil { break } return e.complexity.Photo.Rating(childComplexity), true case "Photo.url": if e.complexity.Photo.URL == nil { break } return e.complexity.Photo.URL(childComplexity), true case "Photo.user": if e.complexity.Photo.User == nil { break } return e.complexity.Photo.User(childComplexity), true case "Query.photos": if e.complexity.Query.Photos == nil { break } args, err := ec.field_Query_photos_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Query.Photos(childComplexity, args["userID"].(string)), true case "Query.timeline": if e.complexity.Query.Timeline == nil { break } return e.complexity.Query.Timeline(childComplexity), true case "Query.user": if e.complexity.Query.User == nil { break } args, err := ec.field_Query_user_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Query.User(childComplexity, args["userID"].(string)), true case "User.avatar": if e.complexity.User.Avatar == nil { break } return e.complexity.User.Avatar(childComplexity), true case "User.followed": if e.complexity.User.Followed == nil { break } return e.complexity.User.Followed(childComplexity), true case "User.id": if e.complexity.User.ID == nil { break } return e.complexity.User.ID(childComplexity), true case "User.name": if e.complexity.User.Name == nil { break } return e.complexity.User.Name(childComplexity), true } return 0, false } func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { rc := graphql.GetOperationContext(ctx) ec := executionContext{rc, e} first := true switch rc.Operation.Operation { case ast.Query: return func(ctx context.Context) *graphql.Response { if !first { return nil } first = false data := ec._Query(ctx, rc.Operation.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) return &graphql.Response{ Data: buf.Bytes(), } } case ast.Mutation: return func(ctx context.Context) *graphql.Response { if !first { return nil } first = false data := ec._Mutation(ctx, rc.Operation.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) return &graphql.Response{ Data: buf.Bytes(), } } default: return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) } } type executionContext struct { *graphql.OperationContext *executableSchema } func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } return introspection.WrapSchema(parsedSchema), nil } func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil } var sources = []*ast.Source{ &ast.Source{Name: "schema.graphql", Input: `type User { id: ID! name: String! avatar: String! followed: Boolean! } type Photo { id: ID! user: User! url: String! comment: String! rating: Int! liked: Boolean! } type Query { # query{timeline{id,url,user{id,name}}} timeline: [Photo!]! # query{user(userID:"1"){id,url,user{id,name}}} user(userID: ID!): User! # query{user(userID:"1"){id,avatar,name}} photos(userID: ID!): [Photo!]! } type Mutation { # mutation _{ratePhoto(photoID:"1", direction:"up"){id,url,rating,user{id,name}}} ratePhoto(photoID: ID!, direction: String!): Photo! } # go run github.com/99designs/gqlgen init # go run github.com/99designs/gqlgen -v `, BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) field_Mutation_ratePhoto_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["photoID"]; ok { arg0, err = ec.unmarshalNID2string(ctx, tmp) if err != nil { return nil, err } } args["photoID"] = arg0 var arg1 string if tmp, ok := rawArgs["direction"]; ok { arg1, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } } args["direction"] = arg1 return args, nil } func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { arg0, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } } args["name"] = arg0 return args, nil } func (ec *executionContext) field_Query_photos_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["userID"]; ok { arg0, err = ec.unmarshalNID2string(ctx, tmp) if err != nil { return nil, err } } args["userID"] = arg0 return args, nil } func (ec *executionContext) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["userID"]; ok { arg0, err = ec.unmarshalNID2string(ctx, tmp) if err != nil { return nil, err } } args["userID"] = arg0 return args, nil } func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 return args, nil } // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _Mutation_ratePhoto(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Mutation", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Mutation_ratePhoto_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Mutation().RatePhoto(rctx, args["photoID"].(string), args["direction"].(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.(*Photo) fc.Result = res return ec.marshalNPhoto2ᚖgqlgen3ᚐPhoto(ctx, field.Selections, res) } func (ec *executionContext) _Photo_id(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Photo().ID(rctx, obj) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _Photo_user(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Photo().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ᚖgqlgen3ᚐUser(ctx, field.Selections, res) } func (ec *executionContext) _Photo_url(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.URL, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Photo_comment(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Comment, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Photo_rating(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Rating, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) fc.Result = res return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _Photo_liked(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Liked, nil }) if err != nil { ec.Error(ctx, 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) _Query_timeline(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Timeline(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.([]*Photo) fc.Result = res return ec.marshalNPhoto2ᚕᚖgqlgen3ᚐPhotoᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_user_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().User(rctx, args["userID"].(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.(*User) fc.Result = res return ec.marshalNUser2ᚖgqlgen3ᚐUser(ctx, field.Selections, res) } func (ec *executionContext) _Query_photos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_photos_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Photos(rctx, args["userID"].(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.([]*Photo) fc.Result = res return ec.marshalNPhoto2ᚕᚖgqlgen3ᚐPhotoᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query___type_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectType(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) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.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) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _User_avatar(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Avatar, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _User_followed(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Followed, nil }) if err != nil { ec.Error(ctx, 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) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*string) fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_fields_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Fields(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) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_enumValues_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.EnumValues(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) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // 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) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Mutation") case "ratePhoto": out.Values[i] = ec._Mutation_ratePhoto(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 photoImplementors = []string{"Photo"} func (ec *executionContext) _Photo(ctx context.Context, sel ast.SelectionSet, obj *Photo) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, photoImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Photo") case "id": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Photo_id(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "user": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Photo_user(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "url": out.Values[i] = ec._Photo_url(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "comment": out.Values[i] = ec._Photo_comment(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "rating": out.Values[i] = ec._Photo_rating(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "liked": out.Values[i] = ec._Photo_liked(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch() if invalids > 0 { return graphql.Null } return out } var 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 { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "timeline": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_timeline(ctx, field) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "user": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_user(ctx, field) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "photos": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_photos(ctx, field) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": out.Values[i] = 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++ } case "avatar": out.Values[i] = ec._User_avatar(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } case "followed": out.Values[i] = ec._User_followed(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++ } 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 "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) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch() if invalids > 0 { return graphql.Null } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { res := graphql.MarshalBoolean(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalID(v) } func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalID(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{}) (int, error) { return graphql.UnmarshalInt(v) } func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { res := graphql.MarshalInt(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) marshalNPhoto2gqlgen3ᚐPhoto(ctx context.Context, sel ast.SelectionSet, v Photo) graphql.Marshaler { return ec._Photo(ctx, sel, &v) } func (ec *executionContext) marshalNPhoto2ᚕᚖgqlgen3ᚐPhotoᚄ(ctx context.Context, sel ast.SelectionSet, v []*Photo) 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.marshalNPhoto2ᚖgqlgen3ᚐPhoto(ctx, sel, v[i]) } if isLen1 { f(i) } else { go f(i) } } wg.Wait() return ret } func (ec *executionContext) marshalNPhoto2ᚖgqlgen3ᚐPhoto(ctx context.Context, sel ast.SelectionSet, v *Photo) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null } return ec._Photo(ctx, sel, v) } func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) marshalNUser2gqlgen3ᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler { return ec._User(ctx, sel, &v) } func (ec *executionContext) marshalNUser2ᚖgqlgen3ᚐUser(ctx context.Context, sel ast.SelectionSet, v *User) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null } return ec._User(ctx, sel, v) } func (ec *executionContext) 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() return ret } func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { vSlice = tmp1 } else { vSlice = []interface{}{v} } } var err error res := make([]string, len(vSlice)) for i := range vSlice { 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() 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() 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() return ret } func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null } return ec.___Type(ctx, sel, v) } func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { return graphql.MarshalBoolean(v) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } res, err := ec.unmarshalOBoolean2bool(ctx, v) return &res, err } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOBoolean2bool(ctx, sel, *v) } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { return graphql.MarshalString(v) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } res, err := ec.unmarshalOString2string(ctx, v) return &res, err } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOString2string(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() 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() 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() return ret } func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { return ec.___Schema(ctx, sel, &v) } 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__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) 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() 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: 4-api/3_graphql/gqlgen_full/gqlgen3/go.mod ================================================ module gqlgen3 go 1.13 require ( github.com/99designs/gqlgen v0.11.1 github.com/vektah/gqlparser/v2 v2.0.1 ) ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen3/go.sum ================================================ github.com/99designs/gqlgen v0.11.1 h1:QoSL8/AAJ2T3UOeQbdnBR32JcG4pO08+P/g5jdbFkUg= github.com/99designs/gqlgen v0.11.1/go.mod h1:vjFOyBZ7NwDl+GdSD4PFn7BQn5Fy7ohJwXn7Vk8zz+c= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/agnivade/levenshtein v1.0.3 h1:M5ZnqLOoZR8ygVq0FfkXsNOKzMCk0xRiow0R5+5VkQ0= github.com/agnivade/levenshtein v1.0.3/go.mod h1:4SFRZbbXWLF4MU1T9Qg0pGgH3Pjs+t6ie5efyrwRJXs= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= 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/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/trifles v0.0.0-20190318185328-a8d75aae118c/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= github.com/go-chi/chi v3.3.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/mux v1.6.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/websocket v1.2.0 h1:VJtLvh6VQym50czpZzx07z/kw9EgAxI3x1ZB8taTMQQ= github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= github.com/matryer/moq v0.0.0-20200106131100-75d0ddfc0007/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047 h1:zCoDWFD5nrJJVjbXiDZcVhOBSzKn3o9LgRLLMRNuru8= github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e/go.mod h1:/HUdMve7rvxZma+2ZELQeNh88+003LL7Pf/CZ089j8U= github.com/vektah/gqlparser/v2 v2.0.1 h1:xgl5abVnsd4hkN9rk65OJID9bfcLSMuTaTcZj777q1o= github.com/vektah/gqlparser/v2 v2.0.1/go.mod h1:SyUiHgLATUR8BiYURfTirrTcGpcE+4XkV2se04Px1Ms= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589 h1:rjUrONFu4kLchcZTfp3/96bR8bW8dIa8uz3cR5n0cgM= golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:L5q+DGLGOQFpo1snNEkLOJT2d1YTW66rWNzatr3He1k= ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen3/gqlgen.yml ================================================ # .gqlgen.yml example # # Refer to https://gqlgen.com/config/ # for detailed .gqlgen.yml documentation. schema: - schema.graphql exec: filename: generated.go model: filename: models_gen.go resolver: filename: resolver.go type: Resolver models: Photo: model: gqlgen3.Photo fields: user: resolver: true autobind: [] ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen3/models_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package gqlgen3 type User struct { ID string `json:"id"` Name string `json:"name"` Avatar string `json:"avatar"` Followed bool `json:"followed"` } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen3/photo.go ================================================ package gqlgen3 import ( // "log" "strconv" ) type Photo struct { ID uint `json:"id"` UserID uint `json:"-"` // User *User `json:"user"` URL string `json:"url"` Comment string `json:"comment"` Rating int `json:"rating"` Liked bool `json:"liked"` } func (ph *Photo) Id() string { // log.Println("call Photo.Id method", ph.ID) return strconv.Itoa(int(ph.ID)) } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen3/resolver.go ================================================ package gqlgen3 //go:generate go run github.com/99designs/gqlgen import ( "context" "fmt" "log" "strconv" "time" ) // THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES. type Resolver struct { PhotosData map[string]*Photo Users map[uint]*User } func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } func (r *Resolver) Photo() PhotoResolver { return &photoResolver{r} } func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } type mutationResolver struct{ *Resolver } func (r *mutationResolver) RatePhoto(ctx context.Context, id string, direction string) (*Photo, error) { log.Println("call mutationResolver.RatePhoto method with id", id, direction) rate := 1 if direction != "up" { rate = -1 } ph, ok := r.PhotosData[id] if !ok { return nil, fmt.Errorf("no photo %v found", id) } ph.Rating += rate return ph, nil } type photoResolver struct{ *Resolver } func (r *photoResolver) ID(ctx context.Context, obj *Photo) (string, error) { return obj.Id(), nil } func (r *photoResolver) User(ctx context.Context, obj *Photo) (*User, error) { // return r.Users[obj.UserID], nil log.Println("call photoResolver.User", obj.UserID) start := time.Now() user, err := ctx.Value("userLoaderKey").(*UserLoader).Load(obj.UserID) log.Println("get photoResolver.User", obj.UserID, "from UserLoader, time ", time.Since(start)) return user, err } type queryResolver struct{ *Resolver } func (r *queryResolver) Timeline(ctx context.Context) ([]*Photo, error) { log.Println("call queryResolver.Timeline with ctx.userID", ctx.Value("userID")) items := []*Photo{} for _, ph := range r.PhotosData { items = append(items, ph) } return items, nil } func (r *queryResolver) User(ctx context.Context, userID string) (*User, error) { log.Println("call queryResolver.User for", userID) id, _ := strconv.Atoi(userID) return r.Users[uint(id)], nil } func (r *queryResolver) Photos(ctx context.Context, userID string) ([]*Photo, error) { log.Println("call queryResolver.Photos") id, _ := strconv.Atoi(userID) items := []*Photo{} for _, ph := range r.PhotosData { if ph.UserID != uint(id) { continue } items = append(items, ph) } return items, nil } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen3/schema.graphql ================================================ type User { id: ID! name: String! avatar: String! followed: Boolean! } type Photo { id: ID! user: User! url: String! comment: String! rating: Int! liked: Boolean! } type Query { # query{timeline{id,url,user{id,name}}} timeline: [Photo!]! # query{user(userID:"1"){id,url,user{id,name}}} user(userID: ID!): User! # query{user(userID:"1"){id,avatar,name}} photos(userID: ID!): [Photo!]! } type Mutation { # mutation _{ratePhoto(photoID:"1", direction:"up"){id,url,rating,user{id,name}}} ratePhoto(photoID: ID!, direction: String!): Photo! } # go run github.com/99designs/gqlgen init # go run github.com/99designs/gqlgen -v ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen3/schema_alt.graphql ================================================ directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION directive @goField(forceResolver: Boolean, name: String) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION type User { id: ID! name: String! avatar: String followed: Boolean! } type Photo @goModel(model:"coursera/3p/graphql/gqlgen3.Photo") { id: ID! user: User! @goField(forceResolver: true) url: String! comment: String! rating: Int! liked: Boolean! } type Query { # query{timeline{id,url,user{id,name}}} timeline: [Photo!]! # query{user(userID:"1"){id,url,user{id,name}}} user(userID: ID!): User! # query{user(userID:"1"){id,avatar,name}} photos(userID: ID!): [Photo!]! } type Mutation { # mutation _{ratePhoto(photoID:"1", direction:"up"){id,url,rating,user{id,name}}} ratePhoto(photoID: ID!, direction: String!): Photo! } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen3/server/server.go ================================================ package main import ( "context" gqlgen "gqlgen3" "log" "net/http" "time" "github.com/99designs/gqlgen/handler" ) /* query{timeline{id,url,user{id,name}}} query{user(userID:"1"){id,avatar, name}} mutation _{ratePhoto(photoID:"1", direction:"up"){id,url,rating,user{id,name}}} */ var users = map[uint]*gqlgen.User{ 1: { ID: "1", Name: "rvasily", Avatar: "https://via.placeholder.com/150", }, 2: { ID: "2", Name: "v.romanov", Avatar: "https://via.placeholder.com/150", }, } var photos = map[string]*gqlgen.Photo{ "1": { ID: 1, UserID: 1, URL: "https://via.placeholder.com/300", Comment: "fromn studio", Rating: 1, Liked: true, }, "2": { ID: 2, UserID: 1, URL: "https://via.placeholder.com/300", Comment: "cool view", Rating: 0, Liked: false, }, "3": { ID: 3, UserID: 2, URL: "https://via.placeholder.com/300", Comment: "at work", Rating: 0, Liked: false, }, } // go run github.com/vektah/dataloaden UserLoader uint *coursera/3p/graphql/gqlgen3.User func UserLoaderMiddleware(resolver *gqlgen.Resolver, next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { cfg := gqlgen.UserLoaderConfig{ MaxBatch: 100, Wait: 1 * time.Millisecond, Fetch: func(ids []uint) ([]*gqlgen.User, []error) { // имеем доступ до r *http.Request - там context с сессией пользователя sessionUserID := r.Context().Value("userID").(uint) log.Printf("UserLoader Request - ids %v for user %v\n", ids, sessionUserID) log.Println("\n\tSELECT id, name FROM user WHERE id IN (1,2)") log.Println(` SELECT id, name, user_follows.follow_id FROM users LEFT JOIN user_follows ON user_follows.follow_id=photos.user_id AND user_follows.user_id = ? WHERE users.id IN (1,2)`) users := make([]*gqlgen.User, len(ids)) for i, id := range ids { // имеем доступ до resolver *gqlgen.Resolver - там коннет к базе users[i] = resolver.Users[id] } return users, nil }, } userLoader := gqlgen.NewUserLoader(cfg) ctx := context.WithValue(r.Context(), "userLoaderKey", userLoader) r = r.WithContext(ctx) next.ServeHTTP(w, r) }) } func AuthMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // log.Println("new request") ctx := context.WithValue(r.Context(), "userID", uint(1)) r = r.WithContext(ctx) next.ServeHTTP(w, r) }) } func main() { http.Handle("/", handler.Playground("GraphQL playground", "/query")) resolver := &gqlgen.Resolver{ Users: users, PhotosData: photos, } cfg := gqlgen.Config{ Resolvers: resolver, } gqlHandler := handler.GraphQL(gqlgen.NewExecutableSchema(cfg)) handler := UserLoaderMiddleware(resolver, gqlHandler) handler = AuthMiddleware(handler) http.Handle("/query", handler) port := "8080" log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) log.Fatal(http.ListenAndServe(":"+port, nil)) } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen3/userloader_gen.go ================================================ // Code generated by github.com/vektah/dataloaden, DO NOT EDIT. package gqlgen3 import ( "sync" "time" ) // UserLoaderConfig captures the config to create a new UserLoader type UserLoaderConfig struct { // Fetch is a method that provides the data for the loader Fetch func(keys []uint) ([]*User, []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 } // NewUserLoader creates a new UserLoader given a fetch, wait, and maxBatch func NewUserLoader(config UserLoaderConfig) *UserLoader { return &UserLoader{ fetch: config.Fetch, wait: config.Wait, maxBatch: config.MaxBatch, } } // UserLoader batches and caches requests type UserLoader struct { // this method provides the data for the loader fetch func(keys []uint) ([]*User, []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[uint]*User // 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 *userLoaderBatch // mutex to prevent races mu sync.Mutex } type userLoaderBatch struct { keys []uint data []*User error []error closing bool done chan struct{} } // Load a User by key, batching and caching will be applied automatically func (l *UserLoader) Load(key uint) (*User, error) { return l.LoadThunk(key)() } // LoadThunk returns a function that when called will block waiting for a User. // 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 *UserLoader) LoadThunk(key uint) func() (*User, error) { l.mu.Lock() if it, ok := l.cache[key]; ok { l.mu.Unlock() return func() (*User, error) { return it, nil } } if l.batch == nil { l.batch = &userLoaderBatch{done: make(chan struct{})} } batch := l.batch pos := batch.keyIndex(l, key) l.mu.Unlock() return func() (*User, error) { <-batch.done var data *User 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 *UserLoader) LoadAll(keys []uint) ([]*User, []error) { results := make([]func() (*User, error), len(keys)) for i, key := range keys { results[i] = l.LoadThunk(key) } users := make([]*User, len(keys)) errors := make([]error, len(keys)) for i, thunk := range results { users[i], errors[i] = thunk() } return users, errors } // LoadAllThunk returns a function that when called will block waiting for a Users. // 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 *UserLoader) LoadAllThunk(keys []uint) func() ([]*User, []error) { results := make([]func() (*User, error), len(keys)) for i, key := range keys { results[i] = l.LoadThunk(key) } return func() ([]*User, []error) { users := make([]*User, len(keys)) errors := make([]error, len(keys)) for i, thunk := range results { users[i], errors[i] = thunk() } return users, 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 *UserLoader) Prime(key uint, value *User) 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 *UserLoader) Clear(key uint) { l.mu.Lock() delete(l.cache, key) l.mu.Unlock() } func (l *UserLoader) unsafeSet(key uint, value *User) { if l.cache == nil { l.cache = map[uint]*User{} } 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 *userLoaderBatch) keyIndex(l *UserLoader, key uint) 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 *userLoaderBatch) startTimer(l *UserLoader) { 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 *userLoaderBatch) end(l *UserLoader) { b.data, b.error = l.fetch(b.keys) close(b.done) } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen4/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package gqlgen4 import ( "bytes" "context" "errors" "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 { Mutation() MutationResolver Photo() PhotoResolver Query() QueryResolver User() UserResolver } type DirectiveRoot struct { } type ComplexityRoot struct { Mutation struct { RatePhoto func(childComplexity int, photoID string, direction string) int } Photo struct { Comment func(childComplexity int) int ID func(childComplexity int) int Liked func(childComplexity int) int Rating func(childComplexity int) int URL func(childComplexity int) int User func(childComplexity int) int } Query struct { Photos func(childComplexity int, userID string) int Timeline func(childComplexity int) int User func(childComplexity int, userID string) int } User struct { Avatar func(childComplexity int) int Followed func(childComplexity int) int ID func(childComplexity int) int Name func(childComplexity int) int Photos func(childComplexity int, count int) int } } type MutationResolver interface { RatePhoto(ctx context.Context, photoID string, direction string) (*Photo, error) } type PhotoResolver interface { ID(ctx context.Context, obj *Photo) (string, error) User(ctx context.Context, obj *Photo) (*User, error) } type QueryResolver interface { Timeline(ctx context.Context) ([]*Photo, error) User(ctx context.Context, userID string) (*User, error) Photos(ctx context.Context, userID string) ([]*Photo, error) } type UserResolver interface { Photos(ctx context.Context, obj *User, count int) ([]*Photo, error) } type executableSchema struct { resolvers ResolverRoot directives DirectiveRoot complexity ComplexityRoot } func (e *executableSchema) Schema() *ast.Schema { return parsedSchema } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { ec := executionContext{nil, e} _ = ec switch typeName + "." + field { case "Mutation.ratePhoto": if e.complexity.Mutation.RatePhoto == nil { break } args, err := ec.field_Mutation_ratePhoto_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Mutation.RatePhoto(childComplexity, args["photoID"].(string), args["direction"].(string)), true case "Photo.comment": if e.complexity.Photo.Comment == nil { break } return e.complexity.Photo.Comment(childComplexity), true case "Photo.id": if e.complexity.Photo.ID == nil { break } return e.complexity.Photo.ID(childComplexity), true case "Photo.liked": if e.complexity.Photo.Liked == nil { break } return e.complexity.Photo.Liked(childComplexity), true case "Photo.rating": if e.complexity.Photo.Rating == nil { break } return e.complexity.Photo.Rating(childComplexity), true case "Photo.url": if e.complexity.Photo.URL == nil { break } return e.complexity.Photo.URL(childComplexity), true case "Photo.user": if e.complexity.Photo.User == nil { break } return e.complexity.Photo.User(childComplexity), true case "Query.photos": if e.complexity.Query.Photos == nil { break } args, err := ec.field_Query_photos_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Query.Photos(childComplexity, args["userID"].(string)), true case "Query.timeline": if e.complexity.Query.Timeline == nil { break } return e.complexity.Query.Timeline(childComplexity), true case "Query.user": if e.complexity.Query.User == nil { break } args, err := ec.field_Query_user_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Query.User(childComplexity, args["userID"].(string)), true case "User.avatar": if e.complexity.User.Avatar == nil { break } return e.complexity.User.Avatar(childComplexity), true case "User.followed": if e.complexity.User.Followed == nil { break } return e.complexity.User.Followed(childComplexity), true case "User.id": if e.complexity.User.ID == nil { break } return e.complexity.User.ID(childComplexity), true case "User.name": if e.complexity.User.Name == nil { break } return e.complexity.User.Name(childComplexity), true case "User.photos": if e.complexity.User.Photos == nil { break } args, err := ec.field_User_photos_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.User.Photos(childComplexity, args["count"].(int)), true } return 0, false } func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { rc := graphql.GetOperationContext(ctx) ec := executionContext{rc, e} first := true switch rc.Operation.Operation { case ast.Query: return func(ctx context.Context) *graphql.Response { if !first { return nil } first = false data := ec._Query(ctx, rc.Operation.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) return &graphql.Response{ Data: buf.Bytes(), } } case ast.Mutation: return func(ctx context.Context) *graphql.Response { if !first { return nil } first = false data := ec._Mutation(ctx, rc.Operation.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) return &graphql.Response{ Data: buf.Bytes(), } } default: return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) } } type executionContext struct { *graphql.OperationContext *executableSchema } func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } return introspection.WrapSchema(parsedSchema), nil } func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil } var sources = []*ast.Source{ &ast.Source{Name: "schema.graphql", Input: `type User { id: ID! name: String! avatar: String! followed: Boolean! # subscriptions(count: Int! = 10): [User!]! # subscribers(count: Int! = 10): [User!]! """возвращает фотограции данного пользователя""" photos(count: Int! = 10): [Photo!]! } type Photo { id: ID! user: User! url: String! comment: String! rating: Int! liked: Boolean! } type Query { # query{timeline{id,url,user{id,name}}} """возвращает ленту текущего пользователя - фото тех, на кого он подписан""" timeline: [Photo!]! # query{user(userID:"1"){id,name,avatar}} """возвращает выбранного пользователя""" user(userID: ID!): User! # query{user(userID:"1"){id,avatar,name}} """возвращает фотограции выбранного пользователя""" photos(userID: ID!): [Photo!]! } type Mutation { # mutation _{ratePhoto(photoID:"1", direction:"up"){id,url,rating,user{id,name}}} ratePhoto(photoID: ID!, direction: String!): Photo! } # go run github.com/99designs/gqlgen init # go run github.com/99designs/gqlgen -v `, BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) field_Mutation_ratePhoto_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["photoID"]; ok { arg0, err = ec.unmarshalNID2string(ctx, tmp) if err != nil { return nil, err } } args["photoID"] = arg0 var arg1 string if tmp, ok := rawArgs["direction"]; ok { arg1, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } } args["direction"] = arg1 return args, nil } func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { arg0, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } } args["name"] = arg0 return args, nil } func (ec *executionContext) field_Query_photos_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["userID"]; ok { arg0, err = ec.unmarshalNID2string(ctx, tmp) if err != nil { return nil, err } } args["userID"] = arg0 return args, nil } func (ec *executionContext) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["userID"]; ok { arg0, err = ec.unmarshalNID2string(ctx, tmp) if err != nil { return nil, err } } args["userID"] = arg0 return args, nil } func (ec *executionContext) field_User_photos_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 int if tmp, ok := rawArgs["count"]; ok { arg0, err = ec.unmarshalNInt2int(ctx, tmp) if err != nil { return nil, err } } args["count"] = arg0 return args, nil } func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 return args, nil } // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _Mutation_ratePhoto(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Mutation", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Mutation_ratePhoto_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Mutation().RatePhoto(rctx, args["photoID"].(string), args["direction"].(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.(*Photo) fc.Result = res return ec.marshalNPhoto2ᚖgqlgen4ᚐPhoto(ctx, field.Selections, res) } func (ec *executionContext) _Photo_id(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Photo().ID(rctx, obj) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _Photo_user(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Photo().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ᚖgqlgen4ᚐUser(ctx, field.Selections, res) } func (ec *executionContext) _Photo_url(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.URL, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Photo_comment(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Comment, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Photo_rating(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Rating, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) fc.Result = res return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _Photo_liked(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Liked, nil }) if err != nil { ec.Error(ctx, 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) _Query_timeline(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Timeline(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.([]*Photo) fc.Result = res return ec.marshalNPhoto2ᚕᚖgqlgen4ᚐPhotoᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_user_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().User(rctx, args["userID"].(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.(*User) fc.Result = res return ec.marshalNUser2ᚖgqlgen4ᚐUser(ctx, field.Selections, res) } func (ec *executionContext) _Query_photos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_photos_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Photos(rctx, args["userID"].(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.([]*Photo) fc.Result = res return ec.marshalNPhoto2ᚕᚖgqlgen4ᚐPhotoᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query___type_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectType(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) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.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) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _User_avatar(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Avatar, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _User_followed(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Followed, nil }) if err != nil { ec.Error(ctx, 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) _User_photos(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_User_photos_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.User().Photos(rctx, obj, args["count"].(int)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]*Photo) fc.Result = res return ec.marshalNPhoto2ᚕᚖgqlgen4ᚐPhotoᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*string) fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_fields_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Fields(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) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_enumValues_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.EnumValues(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) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // 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) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Mutation") case "ratePhoto": out.Values[i] = ec._Mutation_ratePhoto(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 photoImplementors = []string{"Photo"} func (ec *executionContext) _Photo(ctx context.Context, sel ast.SelectionSet, obj *Photo) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, photoImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Photo") case "id": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Photo_id(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "user": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Photo_user(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "url": out.Values[i] = ec._Photo_url(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "comment": out.Values[i] = ec._Photo_comment(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "rating": out.Values[i] = ec._Photo_rating(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "liked": out.Values[i] = ec._Photo_liked(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch() if invalids > 0 { return graphql.Null } return out } var 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 { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "timeline": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_timeline(ctx, field) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "user": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_user(ctx, field) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "photos": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_photos(ctx, field) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": out.Values[i] = 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 { atomic.AddUint32(&invalids, 1) } case "name": out.Values[i] = ec._User_name(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "avatar": out.Values[i] = ec._User_avatar(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "followed": out.Values[i] = ec._User_followed(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "photos": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._User_photos(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) 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++ } 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 "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) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch() if invalids > 0 { return graphql.Null } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { res := graphql.MarshalBoolean(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalID(v) } func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalID(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{}) (int, error) { return graphql.UnmarshalInt(v) } func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { res := graphql.MarshalInt(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) marshalNPhoto2gqlgen4ᚐPhoto(ctx context.Context, sel ast.SelectionSet, v Photo) graphql.Marshaler { return ec._Photo(ctx, sel, &v) } func (ec *executionContext) marshalNPhoto2ᚕᚖgqlgen4ᚐPhotoᚄ(ctx context.Context, sel ast.SelectionSet, v []*Photo) 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.marshalNPhoto2ᚖgqlgen4ᚐPhoto(ctx, sel, v[i]) } if isLen1 { f(i) } else { go f(i) } } wg.Wait() return ret } func (ec *executionContext) marshalNPhoto2ᚖgqlgen4ᚐPhoto(ctx context.Context, sel ast.SelectionSet, v *Photo) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null } return ec._Photo(ctx, sel, v) } func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) marshalNUser2gqlgen4ᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler { return ec._User(ctx, sel, &v) } func (ec *executionContext) marshalNUser2ᚖgqlgen4ᚐUser(ctx context.Context, sel ast.SelectionSet, v *User) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null } return ec._User(ctx, sel, v) } func (ec *executionContext) 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() return ret } func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { vSlice = tmp1 } else { vSlice = []interface{}{v} } } var err error res := make([]string, len(vSlice)) for i := range vSlice { 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() 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() 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() return ret } func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null } return ec.___Type(ctx, sel, v) } func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { return graphql.MarshalBoolean(v) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } res, err := ec.unmarshalOBoolean2bool(ctx, v) return &res, err } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOBoolean2bool(ctx, sel, *v) } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { return graphql.MarshalString(v) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } res, err := ec.unmarshalOString2string(ctx, v) return &res, err } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOString2string(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() 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() 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() return ret } func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { return ec.___Schema(ctx, sel, &v) } 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__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) 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() 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: 4-api/3_graphql/gqlgen_full/gqlgen4/go.mod ================================================ module gqlgen4 go 1.13 require ( github.com/99designs/gqlgen v0.11.1 github.com/vektah/gqlparser/v2 v2.0.1 ) ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen4/go.sum ================================================ github.com/99designs/gqlgen v0.11.1 h1:QoSL8/AAJ2T3UOeQbdnBR32JcG4pO08+P/g5jdbFkUg= github.com/99designs/gqlgen v0.11.1/go.mod h1:vjFOyBZ7NwDl+GdSD4PFn7BQn5Fy7ohJwXn7Vk8zz+c= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/agnivade/levenshtein v1.0.3 h1:M5ZnqLOoZR8ygVq0FfkXsNOKzMCk0xRiow0R5+5VkQ0= github.com/agnivade/levenshtein v1.0.3/go.mod h1:4SFRZbbXWLF4MU1T9Qg0pGgH3Pjs+t6ie5efyrwRJXs= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= 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/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/trifles v0.0.0-20190318185328-a8d75aae118c/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= github.com/go-chi/chi v3.3.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/mux v1.6.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/websocket v1.2.0 h1:VJtLvh6VQym50czpZzx07z/kw9EgAxI3x1ZB8taTMQQ= github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= github.com/matryer/moq v0.0.0-20200106131100-75d0ddfc0007/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047 h1:zCoDWFD5nrJJVjbXiDZcVhOBSzKn3o9LgRLLMRNuru8= github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e/go.mod h1:/HUdMve7rvxZma+2ZELQeNh88+003LL7Pf/CZ089j8U= github.com/vektah/gqlparser/v2 v2.0.1 h1:xgl5abVnsd4hkN9rk65OJID9bfcLSMuTaTcZj777q1o= github.com/vektah/gqlparser/v2 v2.0.1/go.mod h1:SyUiHgLATUR8BiYURfTirrTcGpcE+4XkV2se04Px1Ms= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589 h1:rjUrONFu4kLchcZTfp3/96bR8bW8dIa8uz3cR5n0cgM= golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:L5q+DGLGOQFpo1snNEkLOJT2d1YTW66rWNzatr3He1k= ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen4/gqlgen.yml ================================================ schema: - schema.graphql exec: filename: generated.go model: filename: models_gen.go resolver: filename: resolver.go type: Resolver models: Photo: model: gqlgen4.Photo fields: user: resolver: true User: fields: photos: resolver: true autobind: [] ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen4/models_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package gqlgen4 type User struct { ID string `json:"id"` Name string `json:"name"` Avatar string `json:"avatar"` Followed bool `json:"followed"` // возвращает фотограции данного пользователя Photos []*Photo `json:"photos"` } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen4/photo.go ================================================ package gqlgen4 import ( // "log" "strconv" ) type Photo struct { ID uint `json:"id"` UserID uint `json:"-"` // User *User `json:"user"` URL string `json:"url"` Comment string `json:"comment"` Rating int `json:"rating"` Liked bool `json:"liked"` } func (ph *Photo) Id() string { // log.Println("call Photo.Id method", ph.ID) return strconv.Itoa(int(ph.ID)) } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen4/queries.txt ================================================ query { user(userID: "1") { id name avatar } } # ----- query { user(userID: "1") { id name avatar photos { id url user { id name photos { id url } } } } } # ----- query { user(userID: "1") { id name avatar photos(count:20) { id url user { id name photos(count:100) { id url } } } } } # ---- query getFullUser($userID: ID!, $cnt1:Int!, $cnt2:Int! ) { user(userID: $userID) { id name avatar photos(count:$cnt1) { id url user { id name photos(count:$cnt2) { id url } } } } photos(userID:$userID) {id, url} } { "userID":"1", "cnt1":10, "cnt2":20 } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen4/resolver.go ================================================ package gqlgen4 //go:generate go run github.com/99designs/gqlgen import ( "context" "fmt" "log" "strconv" "time" ) // THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES. type Resolver struct { PhotosData map[string]*Photo Users map[uint]*User } func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } func (r *Resolver) Photo() PhotoResolver { return &photoResolver{r} } func (r *Resolver) User() UserResolver { return &userResolver{r} } func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } type mutationResolver struct{ *Resolver } func (r *mutationResolver) RatePhoto(ctx context.Context, id string, direction string) (*Photo, error) { log.Println("call mutationResolver.RatePhoto method with id", id, direction) rate := 1 if direction != "up" { rate = -1 } ph, ok := r.PhotosData[id] if !ok { return nil, fmt.Errorf("no photo %v found", id) } ph.Rating += rate return ph, nil } type userResolver struct{ *Resolver } func (r *userResolver) Photos(ctx context.Context, obj *User, count int) ([]*Photo, error) { log.Println("call userResolver.Photos with count", count) id, _ := strconv.Atoi(obj.ID) items := []*Photo{} for _, ph := range r.PhotosData { if ph.UserID != uint(id) { continue } items = append(items, ph) } return items, nil } type photoResolver struct{ *Resolver } func (r *photoResolver) ID(ctx context.Context, obj *Photo) (string, error) { return obj.Id(), nil } func (r *photoResolver) User(ctx context.Context, obj *Photo) (*User, error) { // return r.Users[obj.UserID], nil log.Println("call photoResolver.User", obj.UserID) start := time.Now() user, err := ctx.Value("userLoaderKey").(*UserLoader).Load(obj.UserID) log.Println("get photoResolver.User", obj.UserID, "from UserLoader, time ", time.Since(start)) return user, err } type queryResolver struct{ *Resolver } func (r *queryResolver) Timeline(ctx context.Context) ([]*Photo, error) { log.Println("call queryResolver.Timeline with ctx.userID", ctx.Value("userID")) items := []*Photo{} for _, ph := range r.PhotosData { items = append(items, ph) } return items, nil } func (r *queryResolver) User(ctx context.Context, userID string) (*User, error) { log.Println("call queryResolver.User for", userID) id, _ := strconv.Atoi(userID) return r.Users[uint(id)], nil } func (r *queryResolver) Photos(ctx context.Context, userID string) ([]*Photo, error) { log.Println("call queryResolver.Photos") id, _ := strconv.Atoi(userID) items := []*Photo{} for _, ph := range r.PhotosData { if ph.UserID != uint(id) { continue } items = append(items, ph) } return items, nil } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen4/schema.graphql ================================================ type User { id: ID! name: String! avatar: String! followed: Boolean! # subscriptions(count: Int! = 10): [User!]! # subscribers(count: Int! = 10): [User!]! """возвращает фотограции данного пользователя""" photos(count: Int! = 10): [Photo!]! } type Photo { id: ID! user: User! url: String! comment: String! rating: Int! liked: Boolean! } type Query { # query{timeline{id,url,user{id,name}}} """возвращает ленту текущего пользователя - фото тех, на кого он подписан""" timeline: [Photo!]! # query{user(userID:"1"){id,name,avatar}} """возвращает выбранного пользователя""" user(userID: ID!): User! # query{user(userID:"1"){id,avatar,name}} """возвращает фотограции выбранного пользователя""" photos(userID: ID!): [Photo!]! } type Mutation { # mutation _{ratePhoto(photoID:"1", direction:"up"){id,url,rating,user{id,name}}} ratePhoto(photoID: ID!, direction: String!): Photo! } # go run github.com/99designs/gqlgen init # go run github.com/99designs/gqlgen -v ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen4/server/server.go ================================================ package main import ( "context" gqlgen "gqlgen4" "log" "net/http" "time" "github.com/99designs/gqlgen/handler" ) /* query{timeline{id,url,user{id,name}}} query{user(userID:"1"){id,avatar, name}} mutation _{ratePhoto(photoID:"1", direction:"up"){id,url,rating,user{id,name}}} */ var users = map[uint]*gqlgen.User{ 1: { ID: "1", Name: "rvasily", Avatar: "https://via.placeholder.com/150", }, 2: { ID: "2", Name: "v.romanov", Avatar: "https://via.placeholder.com/150", }, } var photos = map[string]*gqlgen.Photo{ "1": { ID: 1, UserID: 1, URL: "https://via.placeholder.com/300", Comment: "fromn studio", Rating: 1, Liked: true, }, "2": { ID: 2, UserID: 1, URL: "https://via.placeholder.com/300", Comment: "cool view", Rating: 0, Liked: false, }, "3": { ID: 3, UserID: 2, URL: "https://via.placeholder.com/300", Comment: "at work", Rating: 0, Liked: false, }, } // go run github.com/vektah/dataloaden UserLoader uint *coursera/3p/graphql/gqlgen3.User func UserLoaderMiddleware(resolver *gqlgen.Resolver, next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { cfg := gqlgen.UserLoaderConfig{ MaxBatch: 100, Wait: 1 * time.Millisecond, Fetch: func(ids []uint) ([]*gqlgen.User, []error) { // имеем доступ до r *http.Request - там context с сессией пользователя sessionUserID := r.Context().Value("userID").(uint) log.Printf("UserLoader Request - ids %v for user %v\n", ids, sessionUserID) users := make([]*gqlgen.User, len(ids)) for i, id := range ids { // имеем доступ до resolver *gqlgen.Resolver - там коннет к базе users[i] = resolver.Users[id] } return users, nil }, } userLoader := gqlgen.NewUserLoader(cfg) ctx := context.WithValue(r.Context(), "userLoaderKey", userLoader) r = r.WithContext(ctx) next.ServeHTTP(w, r) }) } func AuthMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // log.Println("new request") ctx := context.WithValue(r.Context(), "userID", uint(1)) r = r.WithContext(ctx) next.ServeHTTP(w, r) }) } func main() { http.Handle("/", handler.Playground("GraphQL playground", "/query")) resolver := &gqlgen.Resolver{ Users: users, PhotosData: photos, } cfg := gqlgen.Config{ Resolvers: resolver, } cfg.Complexity.User.Photos = func(childComplexity, count int) int { return count * childComplexity } gqlHandler := handler.GraphQL( gqlgen.NewExecutableSchema(cfg), handler.ComplexityLimit(500), ) handler := UserLoaderMiddleware(resolver, gqlHandler) handler = AuthMiddleware(handler) http.Handle("/query", handler) port := "8080" log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) log.Fatal(http.ListenAndServe(":"+port, nil)) } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen4/userloader_gen.go ================================================ // Code generated by github.com/vektah/dataloaden, DO NOT EDIT. package gqlgen4 import ( "sync" "time" ) // UserLoaderConfig captures the config to create a new UserLoader type UserLoaderConfig struct { // Fetch is a method that provides the data for the loader Fetch func(keys []uint) ([]*User, []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 } // NewUserLoader creates a new UserLoader given a fetch, wait, and maxBatch func NewUserLoader(config UserLoaderConfig) *UserLoader { return &UserLoader{ fetch: config.Fetch, wait: config.Wait, maxBatch: config.MaxBatch, } } // UserLoader batches and caches requests type UserLoader struct { // this method provides the data for the loader fetch func(keys []uint) ([]*User, []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[uint]*User // 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 *userLoaderBatch // mutex to prevent races mu sync.Mutex } type userLoaderBatch struct { keys []uint data []*User error []error closing bool done chan struct{} } // Load a User by key, batching and caching will be applied automatically func (l *UserLoader) Load(key uint) (*User, error) { return l.LoadThunk(key)() } // LoadThunk returns a function that when called will block waiting for a User. // 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 *UserLoader) LoadThunk(key uint) func() (*User, error) { l.mu.Lock() if it, ok := l.cache[key]; ok { l.mu.Unlock() return func() (*User, error) { return it, nil } } if l.batch == nil { l.batch = &userLoaderBatch{done: make(chan struct{})} } batch := l.batch pos := batch.keyIndex(l, key) l.mu.Unlock() return func() (*User, error) { <-batch.done var data *User 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 *UserLoader) LoadAll(keys []uint) ([]*User, []error) { results := make([]func() (*User, error), len(keys)) for i, key := range keys { results[i] = l.LoadThunk(key) } users := make([]*User, len(keys)) errors := make([]error, len(keys)) for i, thunk := range results { users[i], errors[i] = thunk() } return users, errors } // LoadAllThunk returns a function that when called will block waiting for a Users. // 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 *UserLoader) LoadAllThunk(keys []uint) func() ([]*User, []error) { results := make([]func() (*User, error), len(keys)) for i, key := range keys { results[i] = l.LoadThunk(key) } return func() ([]*User, []error) { users := make([]*User, len(keys)) errors := make([]error, len(keys)) for i, thunk := range results { users[i], errors[i] = thunk() } return users, 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 *UserLoader) Prime(key uint, value *User) 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 *UserLoader) Clear(key uint) { l.mu.Lock() delete(l.cache, key) l.mu.Unlock() } func (l *UserLoader) unsafeSet(key uint, value *User) { if l.cache == nil { l.cache = map[uint]*User{} } 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 *userLoaderBatch) keyIndex(l *UserLoader, key uint) 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 *userLoaderBatch) startTimer(l *UserLoader) { 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 *userLoaderBatch) end(l *UserLoader) { b.data, b.error = l.fetch(b.keys) close(b.done) } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen5/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package gqlgen5 import ( "bytes" "context" "errors" "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 { Mutation() MutationResolver Photo() PhotoResolver Query() QueryResolver User() UserResolver } type DirectiveRoot struct { } type ComplexityRoot struct { Mutation struct { RatePhoto func(childComplexity int, photoID string, direction string) int UploadPhoto func(childComplexity int, comment string, file graphql.Upload) int } Photo struct { Comment func(childComplexity int) int ID func(childComplexity int) int Liked func(childComplexity int) int Rating func(childComplexity int) int URL func(childComplexity int) int User func(childComplexity int) int } Query struct { Photos func(childComplexity int, userID string) int Timeline func(childComplexity int) int User func(childComplexity int, userID string) int } User struct { Avatar func(childComplexity int) int Followed func(childComplexity int) int ID func(childComplexity int) int Name func(childComplexity int) int Photos func(childComplexity int, count int) int } } type MutationResolver interface { RatePhoto(ctx context.Context, photoID string, direction string) (*Photo, error) UploadPhoto(ctx context.Context, comment string, file graphql.Upload) (*Photo, error) } type PhotoResolver interface { ID(ctx context.Context, obj *Photo) (string, error) User(ctx context.Context, obj *Photo) (*User, error) } type QueryResolver interface { Timeline(ctx context.Context) ([]*Photo, error) User(ctx context.Context, userID string) (*User, error) Photos(ctx context.Context, userID string) ([]*Photo, error) } type UserResolver interface { Photos(ctx context.Context, obj *User, count int) ([]*Photo, error) } type executableSchema struct { resolvers ResolverRoot directives DirectiveRoot complexity ComplexityRoot } func (e *executableSchema) Schema() *ast.Schema { return parsedSchema } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { ec := executionContext{nil, e} _ = ec switch typeName + "." + field { case "Mutation.ratePhoto": if e.complexity.Mutation.RatePhoto == nil { break } args, err := ec.field_Mutation_ratePhoto_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Mutation.RatePhoto(childComplexity, args["photoID"].(string), args["direction"].(string)), true case "Mutation.uploadPhoto": if e.complexity.Mutation.UploadPhoto == nil { break } args, err := ec.field_Mutation_uploadPhoto_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Mutation.UploadPhoto(childComplexity, args["comment"].(string), args["file"].(graphql.Upload)), true case "Photo.comment": if e.complexity.Photo.Comment == nil { break } return e.complexity.Photo.Comment(childComplexity), true case "Photo.id": if e.complexity.Photo.ID == nil { break } return e.complexity.Photo.ID(childComplexity), true case "Photo.liked": if e.complexity.Photo.Liked == nil { break } return e.complexity.Photo.Liked(childComplexity), true case "Photo.rating": if e.complexity.Photo.Rating == nil { break } return e.complexity.Photo.Rating(childComplexity), true case "Photo.url": if e.complexity.Photo.URL == nil { break } return e.complexity.Photo.URL(childComplexity), true case "Photo.user": if e.complexity.Photo.User == nil { break } return e.complexity.Photo.User(childComplexity), true case "Query.photos": if e.complexity.Query.Photos == nil { break } args, err := ec.field_Query_photos_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Query.Photos(childComplexity, args["userID"].(string)), true case "Query.timeline": if e.complexity.Query.Timeline == nil { break } return e.complexity.Query.Timeline(childComplexity), true case "Query.user": if e.complexity.Query.User == nil { break } args, err := ec.field_Query_user_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Query.User(childComplexity, args["userID"].(string)), true case "User.avatar": if e.complexity.User.Avatar == nil { break } return e.complexity.User.Avatar(childComplexity), true case "User.followed": if e.complexity.User.Followed == nil { break } return e.complexity.User.Followed(childComplexity), true case "User.id": if e.complexity.User.ID == nil { break } return e.complexity.User.ID(childComplexity), true case "User.name": if e.complexity.User.Name == nil { break } return e.complexity.User.Name(childComplexity), true case "User.photos": if e.complexity.User.Photos == nil { break } args, err := ec.field_User_photos_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.User.Photos(childComplexity, args["count"].(int)), true } return 0, false } func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { rc := graphql.GetOperationContext(ctx) ec := executionContext{rc, e} first := true switch rc.Operation.Operation { case ast.Query: return func(ctx context.Context) *graphql.Response { if !first { return nil } first = false data := ec._Query(ctx, rc.Operation.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) return &graphql.Response{ Data: buf.Bytes(), } } case ast.Mutation: return func(ctx context.Context) *graphql.Response { if !first { return nil } first = false data := ec._Mutation(ctx, rc.Operation.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) return &graphql.Response{ Data: buf.Bytes(), } } default: return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) } } type executionContext struct { *graphql.OperationContext *executableSchema } func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } return introspection.WrapSchema(parsedSchema), nil } func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil } var sources = []*ast.Source{ &ast.Source{Name: "schema.graphql", Input: `# gqlgen знает как с этим работать и что парсить это надо через multipart-form scalar Upload type User { id: ID! name: String! avatar: String! followed: Boolean! # subscriptions(count: Int! = 10): [User!]! # subscribers(count: Int! = 10): [User!]! """возвращает фотограции данного пользователя""" photos(count: Int! = 10): [Photo!]! } type Photo { id: ID! user: User! url: String! comment: String! rating: Int! liked: Boolean! } type Query { # query{timeline{id,url,user{id,name}}} """возвращает ленту текущего пользователя - фото тех, на кого он подписан""" timeline: [Photo!]! # query{user(userID:"1"){id,name,avatar}} """возвращает выбранного пользователя""" user(userID: ID!): User! # query{user(userID:"1"){id,avatar,name}} """возвращает фотограции выбранного пользователя""" photos(userID: ID!): [Photo!]! } type Mutation { # mutation _{ratePhoto(photoID:"1", direction:"up"){id,url,rating,user{id,name}}} ratePhoto(photoID: ID!, direction: String!): Photo! uploadPhoto(comment: String!, file: Upload!): Photo! } # go run github.com/99designs/gqlgen init # go run github.com/99designs/gqlgen -v `, BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) field_Mutation_ratePhoto_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["photoID"]; ok { arg0, err = ec.unmarshalNID2string(ctx, tmp) if err != nil { return nil, err } } args["photoID"] = arg0 var arg1 string if tmp, ok := rawArgs["direction"]; ok { arg1, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } } args["direction"] = arg1 return args, nil } func (ec *executionContext) field_Mutation_uploadPhoto_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["comment"]; ok { arg0, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } } args["comment"] = arg0 var arg1 graphql.Upload if tmp, ok := rawArgs["file"]; ok { arg1, err = ec.unmarshalNUpload2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx, tmp) if err != nil { return nil, err } } args["file"] = arg1 return args, nil } func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { arg0, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } } args["name"] = arg0 return args, nil } func (ec *executionContext) field_Query_photos_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["userID"]; ok { arg0, err = ec.unmarshalNID2string(ctx, tmp) if err != nil { return nil, err } } args["userID"] = arg0 return args, nil } func (ec *executionContext) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["userID"]; ok { arg0, err = ec.unmarshalNID2string(ctx, tmp) if err != nil { return nil, err } } args["userID"] = arg0 return args, nil } func (ec *executionContext) field_User_photos_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 int if tmp, ok := rawArgs["count"]; ok { arg0, err = ec.unmarshalNInt2int(ctx, tmp) if err != nil { return nil, err } } args["count"] = arg0 return args, nil } func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 return args, nil } // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _Mutation_ratePhoto(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Mutation", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Mutation_ratePhoto_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Mutation().RatePhoto(rctx, args["photoID"].(string), args["direction"].(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.(*Photo) fc.Result = res return ec.marshalNPhoto2ᚖgqlgen5ᚐPhoto(ctx, field.Selections, res) } func (ec *executionContext) _Mutation_uploadPhoto(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Mutation", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Mutation_uploadPhoto_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Mutation().UploadPhoto(rctx, args["comment"].(string), args["file"].(graphql.Upload)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*Photo) fc.Result = res return ec.marshalNPhoto2ᚖgqlgen5ᚐPhoto(ctx, field.Selections, res) } func (ec *executionContext) _Photo_id(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Photo().ID(rctx, obj) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _Photo_user(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Photo().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ᚖgqlgen5ᚐUser(ctx, field.Selections, res) } func (ec *executionContext) _Photo_url(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.URL, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Photo_comment(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Comment, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Photo_rating(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Rating, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) fc.Result = res return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _Photo_liked(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Liked, nil }) if err != nil { ec.Error(ctx, 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) _Query_timeline(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Timeline(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.([]*Photo) fc.Result = res return ec.marshalNPhoto2ᚕᚖgqlgen5ᚐPhotoᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_user_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().User(rctx, args["userID"].(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.(*User) fc.Result = res return ec.marshalNUser2ᚖgqlgen5ᚐUser(ctx, field.Selections, res) } func (ec *executionContext) _Query_photos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_photos_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Photos(rctx, args["userID"].(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.([]*Photo) fc.Result = res return ec.marshalNPhoto2ᚕᚖgqlgen5ᚐPhotoᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query___type_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectType(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) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.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) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _User_avatar(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Avatar, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _User_followed(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Followed, nil }) if err != nil { ec.Error(ctx, 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) _User_photos(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "User", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_User_photos_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.User().Photos(rctx, obj, args["count"].(int)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]*Photo) fc.Result = res return ec.marshalNPhoto2ᚕᚖgqlgen5ᚐPhotoᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*string) fc.Result = res return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) fc.Result = res return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_fields_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Fields(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) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_enumValues_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.EnumValues(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) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } }() fc := &graphql.FieldContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.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) } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // 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) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Mutation") case "ratePhoto": out.Values[i] = ec._Mutation_ratePhoto(ctx, field) if out.Values[i] == graphql.Null { invalids++ } case "uploadPhoto": out.Values[i] = ec._Mutation_uploadPhoto(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 photoImplementors = []string{"Photo"} func (ec *executionContext) _Photo(ctx context.Context, sel ast.SelectionSet, obj *Photo) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, photoImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Photo") case "id": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Photo_id(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "user": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Photo_user(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "url": out.Values[i] = ec._Photo_url(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "comment": out.Values[i] = ec._Photo_comment(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "rating": out.Values[i] = ec._Photo_rating(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "liked": out.Values[i] = ec._Photo_liked(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch() if invalids > 0 { return graphql.Null } return out } var 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 { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "timeline": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_timeline(ctx, field) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "user": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_user(ctx, field) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "photos": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_photos(ctx, field) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": out.Values[i] = 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 { atomic.AddUint32(&invalids, 1) } case "name": out.Values[i] = ec._User_name(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "avatar": out.Values[i] = ec._User_avatar(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "followed": out.Values[i] = ec._User_followed(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "photos": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._User_photos(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) 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++ } 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 "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) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch() if invalids > 0 { return graphql.Null } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { res := graphql.MarshalBoolean(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalID(v) } func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalID(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{}) (int, error) { return graphql.UnmarshalInt(v) } func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { res := graphql.MarshalInt(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) marshalNPhoto2gqlgen5ᚐPhoto(ctx context.Context, sel ast.SelectionSet, v Photo) graphql.Marshaler { return ec._Photo(ctx, sel, &v) } func (ec *executionContext) marshalNPhoto2ᚕᚖgqlgen5ᚐPhotoᚄ(ctx context.Context, sel ast.SelectionSet, v []*Photo) 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.marshalNPhoto2ᚖgqlgen5ᚐPhoto(ctx, sel, v[i]) } if isLen1 { f(i) } else { go f(i) } } wg.Wait() return ret } func (ec *executionContext) marshalNPhoto2ᚖgqlgen5ᚐPhoto(ctx context.Context, sel ast.SelectionSet, v *Photo) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null } return ec._Photo(ctx, sel, v) } func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalNUpload2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, v interface{}) (graphql.Upload, error) { return graphql.UnmarshalUpload(v) } func (ec *executionContext) marshalNUpload2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, sel ast.SelectionSet, v graphql.Upload) graphql.Marshaler { res := graphql.MarshalUpload(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) marshalNUser2gqlgen5ᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler { return ec._User(ctx, sel, &v) } func (ec *executionContext) marshalNUser2ᚖgqlgen5ᚐUser(ctx context.Context, sel ast.SelectionSet, v *User) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null } return ec._User(ctx, sel, v) } func (ec *executionContext) 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() return ret } func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { vSlice = tmp1 } else { vSlice = []interface{}{v} } } var err error res := make([]string, len(vSlice)) for i := range vSlice { 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() 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() 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() return ret } func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null } return ec.___Type(ctx, sel, v) } func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { return graphql.MarshalBoolean(v) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } res, err := ec.unmarshalOBoolean2bool(ctx, v) return &res, err } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOBoolean2bool(ctx, sel, *v) } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { return graphql.MarshalString(v) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } res, err := ec.unmarshalOString2string(ctx, v) return &res, err } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOString2string(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() 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() 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() return ret } func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { return ec.___Schema(ctx, sel, &v) } 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__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) 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() 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: 4-api/3_graphql/gqlgen_full/gqlgen5/go.mod ================================================ module gqlgen5 go 1.13 require ( github.com/99designs/gqlgen v0.11.1 github.com/vektah/gqlparser/v2 v2.0.1 ) ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen5/go.sum ================================================ github.com/99designs/gqlgen v0.11.1 h1:QoSL8/AAJ2T3UOeQbdnBR32JcG4pO08+P/g5jdbFkUg= github.com/99designs/gqlgen v0.11.1/go.mod h1:vjFOyBZ7NwDl+GdSD4PFn7BQn5Fy7ohJwXn7Vk8zz+c= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/agnivade/levenshtein v1.0.3 h1:M5ZnqLOoZR8ygVq0FfkXsNOKzMCk0xRiow0R5+5VkQ0= github.com/agnivade/levenshtein v1.0.3/go.mod h1:4SFRZbbXWLF4MU1T9Qg0pGgH3Pjs+t6ie5efyrwRJXs= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= 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/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/trifles v0.0.0-20190318185328-a8d75aae118c/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= github.com/go-chi/chi v3.3.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/mux v1.6.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/websocket v1.2.0 h1:VJtLvh6VQym50czpZzx07z/kw9EgAxI3x1ZB8taTMQQ= github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= github.com/matryer/moq v0.0.0-20200106131100-75d0ddfc0007/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047 h1:zCoDWFD5nrJJVjbXiDZcVhOBSzKn3o9LgRLLMRNuru8= github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e/go.mod h1:/HUdMve7rvxZma+2ZELQeNh88+003LL7Pf/CZ089j8U= github.com/vektah/gqlparser/v2 v2.0.1 h1:xgl5abVnsd4hkN9rk65OJID9bfcLSMuTaTcZj777q1o= github.com/vektah/gqlparser/v2 v2.0.1/go.mod h1:SyUiHgLATUR8BiYURfTirrTcGpcE+4XkV2se04Px1Ms= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589 h1:rjUrONFu4kLchcZTfp3/96bR8bW8dIa8uz3cR5n0cgM= golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:L5q+DGLGOQFpo1snNEkLOJT2d1YTW66rWNzatr3He1k= ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen5/gqlgen.yml ================================================ schema: - schema.graphql exec: filename: generated.go model: filename: models_gen.go resolver: filename: resolver.go type: Resolver models: Photo: model: gqlgen5.Photo fields: user: resolver: true User: fields: photos: resolver: true autobind: [] ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen5/models_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package gqlgen5 type User struct { ID string `json:"id"` Name string `json:"name"` Avatar string `json:"avatar"` Followed bool `json:"followed"` // возвращает фотограции данного пользователя Photos []*Photo `json:"photos"` } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen5/photo.go ================================================ package gqlgen5 import ( // "log" "strconv" ) type Photo struct { ID uint `json:"id"` UserID uint `json:"-"` // User *User `json:"user"` URL string `json:"url"` Comment string `json:"comment"` Rating int `json:"rating"` Liked bool `json:"liked"` } func (ph *Photo) Id() string { // log.Println("call Photo.Id method", ph.ID) return strconv.Itoa(int(ph.ID)) } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen5/queries.txt ================================================ query { user(userID: "1") { id name avatar } } query { user(userID: "1") { id name avatar photos {id, url, user{ id name photos { id, url } }} } } # ----- query { user(userID: "1") { id name avatar photos(count:20) { id url user { id name photos(count:100) { id url } } } } } # ---- query($userID: ID!, $cnt1:Int!, $cnt2:Int! ) { user(userID: $userID) { id name avatar photos(count:$cnt1) { id url user { id name photos(count:$cnt2) { id url } } } } photos(userID:$userID) {id, url} } { "userID":"1", "cnt1":10, "cnt2":20 } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen5/resolver.go ================================================ package gqlgen5 //go:generate go run github.com/99designs/gqlgen -v import ( "context" "crypto/md5" "fmt" "io/ioutil" "log" "strconv" "time" "github.com/99designs/gqlgen/graphql" ) type Resolver struct { PhotosData map[string]*Photo Users map[uint]*User } func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } func (r *Resolver) Photo() PhotoResolver { return &photoResolver{r} } func (r *Resolver) User() UserResolver { return &userResolver{r} } func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } type mutationResolver struct{ *Resolver } func (r *mutationResolver) RatePhoto(ctx context.Context, id string, direction string) (*Photo, error) { log.Println("call mutationResolver.RatePhoto method with id", id, direction) rate := 1 if direction != "up" { rate = -1 } ph, ok := r.PhotosData[id] if !ok { return nil, fmt.Errorf("no photo %v found", id) } ph.Rating += rate return ph, nil } func (r *mutationResolver) UploadPhoto(ctx context.Context, comment string, file graphql.Upload) (*Photo, error) { sessionUserID := ctx.Value("userID").(uint) content, err := ioutil.ReadAll(file.File) if err != nil { return nil, err } hasher := md5.New() hasher.Write(content) log.Printf("incoming file %v, %v bytes, md5 %x", file.Filename, file.Size, hasher.Sum(nil)) ph := &Photo{ ID: 42, UserID: sessionUserID, Comment: comment, URL: "/photos/" + file.Filename, } r.PhotosData[strconv.Itoa(int(ph.ID))] = ph return ph, nil } type userResolver struct{ *Resolver } func (r *userResolver) Photos(ctx context.Context, obj *User, count int) ([]*Photo, error) { log.Println("call userResolver.Photos with count", count) id, _ := strconv.Atoi(obj.ID) items := []*Photo{} for _, ph := range r.PhotosData { if ph.UserID != uint(id) { continue } items = append(items, ph) } return items, nil } type photoResolver struct{ *Resolver } func (r *photoResolver) ID(ctx context.Context, obj *Photo) (string, error) { return obj.Id(), nil } func (r *photoResolver) User(ctx context.Context, obj *Photo) (*User, error) { // return r.Users[obj.UserID], nil log.Println("call photoResolver.User", obj.UserID) start := time.Now() user, err := ctx.Value("userLoaderKey").(*UserLoader).Load(obj.UserID) log.Println("get photoResolver.User", obj.UserID, "from UserLoader, time ", time.Since(start)) return user, err } type queryResolver struct{ *Resolver } func (r *queryResolver) Timeline(ctx context.Context) ([]*Photo, error) { log.Println("call queryResolver.Timeline with ctx.userID", ctx.Value("userID")) items := []*Photo{} for _, ph := range r.PhotosData { items = append(items, ph) } return items, nil } func (r *queryResolver) User(ctx context.Context, userID string) (*User, error) { log.Println("call queryResolver.User for", userID) id, _ := strconv.Atoi(userID) return r.Users[uint(id)], nil } func (r *queryResolver) Photos(ctx context.Context, userID string) ([]*Photo, error) { log.Println("call queryResolver.Photos") id, _ := strconv.Atoi(userID) items := []*Photo{} for _, ph := range r.PhotosData { if ph.UserID != uint(id) { continue } items = append(items, ph) } return items, nil } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen5/schema.graphql ================================================ # gqlgen знает как с этим работать и что парсить это надо через multipart-form scalar Upload type User { id: ID! name: String! avatar: String! followed: Boolean! # subscriptions(count: Int! = 10): [User!]! # subscribers(count: Int! = 10): [User!]! """возвращает фотограции данного пользователя""" photos(count: Int! = 10): [Photo!]! } type Photo { id: ID! user: User! url: String! comment: String! rating: Int! liked: Boolean! } type Query { # query{timeline{id,url,user{id,name}}} """возвращает ленту текущего пользователя - фото тех, на кого он подписан""" timeline: [Photo!]! # query{user(userID:"1"){id,name,avatar}} """возвращает выбранного пользователя""" user(userID: ID!): User! # query{user(userID:"1"){id,avatar,name}} """возвращает фотограции выбранного пользователя""" photos(userID: ID!): [Photo!]! } type Mutation { # mutation _{ratePhoto(photoID:"1", direction:"up"){id,url,rating,user{id,name}}} ratePhoto(photoID: ID!, direction: String!): Photo! uploadPhoto(comment: String!, file: Upload!): Photo! } # go run github.com/99designs/gqlgen init # go run github.com/99designs/gqlgen -v ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen5/server/server.go ================================================ package main import ( "context" gqlgen "gqlgen5" "log" "net/http" "time" "github.com/99designs/gqlgen/handler" ) /* curl localhost:8080/query \ -F operations='{ "query": "mutation($comment: String!, $file: Upload!) { uploadPhoto(comment: $comment, file: $file) { id } }", "variables": { "comment": "building 5 comment", "file": null } }' \ -F map='{ "0": ["variables.file"] }' \ -F 0=@./test_file.txt \ --trace-ascii - { query: ` mutation($comment: String!, $file: Upload!) { uploadPhoto(comment: $comment, file: $file) { id } } `, variables: { comment: "building 5 comment", file: File // test_file.txt } } */ var users = map[uint]*gqlgen.User{ 1: { ID: "1", Name: "rvasily", Avatar: "https://via.placeholder.com/150", }, 2: { ID: "2", Name: "v.romanov", Avatar: "https://via.placeholder.com/150", }, } var photos = map[string]*gqlgen.Photo{ "1": { ID: 1, UserID: 1, URL: "https://via.placeholder.com/300", Comment: "from studio", Rating: 1, Liked: true, }, // "2": { // ID: 2, // UserID: 1, // URL: "https://via.placeholder.com/300", // Comment: "cool view", // Rating: 0, // Liked: false, // }, "3": { ID: 3, UserID: 2, URL: "https://via.placeholder.com/300", Comment: "at work", Rating: 0, Liked: false, }, } // go run github.com/vektah/dataloaden UserLoader uint *coursera/3p/graphql/gqlgen3.User func UserLoaderMiddleware(resolver *gqlgen.Resolver, next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { cfg := gqlgen.UserLoaderConfig{ MaxBatch: 100, Wait: 1 * time.Millisecond, Fetch: func(ids []uint) ([]*gqlgen.User, []error) { // имеем доступ до r *http.Request - там context с сессией пользователя sessionUserID := r.Context().Value("userID").(uint) log.Printf("UserLoader Request - ids %v for user %v\n", ids, sessionUserID) log.Printf("request %v\n", r) log.Printf("ctx %v\n", r.Context()) users := make([]*gqlgen.User, len(ids)) for i, id := range ids { // имеем доступ до resolver *gqlgen.Resolver - там коннет к базе users[i] = resolver.Users[id] } return users, nil }, } userLoader := gqlgen.NewUserLoader(cfg) ctx := context.WithValue(r.Context(), "userLoaderKey", userLoader) r = r.WithContext(ctx) next.ServeHTTP(w, r) }) } func AuthMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // log.Println("new request") ctx := context.WithValue(r.Context(), "userID", uint(1)) r = r.WithContext(ctx) next.ServeHTTP(w, r) }) } func main() { http.Handle("/", handler.Playground("GraphQL playground", "/query")) resolver := &gqlgen.Resolver{ Users: users, PhotosData: photos, } cfg := gqlgen.Config{ Resolvers: resolver, } cfg.Complexity.User.Photos = func(childComplexity, count int) int { return count * childComplexity } gqlHandler := handler.GraphQL( gqlgen.NewExecutableSchema(cfg), handler.ComplexityLimit(500), ) handler := UserLoaderMiddleware(resolver, gqlHandler) handler = AuthMiddleware(handler) http.Handle("/query", handler) port := "8080" log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) log.Fatal(http.ListenAndServe(":"+port, nil)) } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen5/test_file.txt ================================================ TEST_FILE_XXXXXXXXXXXXXXXXXX ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen5/userloader_gen.go ================================================ // Code generated by github.com/vektah/dataloaden, DO NOT EDIT. package gqlgen5 import ( "sync" "time" ) // UserLoaderConfig captures the config to create a new UserLoader type UserLoaderConfig struct { // Fetch is a method that provides the data for the loader Fetch func(keys []uint) ([]*User, []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 } // NewUserLoader creates a new UserLoader given a fetch, wait, and maxBatch func NewUserLoader(config UserLoaderConfig) *UserLoader { return &UserLoader{ fetch: config.Fetch, wait: config.Wait, maxBatch: config.MaxBatch, } } // UserLoader batches and caches requests type UserLoader struct { // this method provides the data for the loader fetch func(keys []uint) ([]*User, []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[uint]*User // 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 *userLoaderBatch // mutex to prevent races mu sync.Mutex } type userLoaderBatch struct { keys []uint data []*User error []error closing bool done chan struct{} } // Load a User by key, batching and caching will be applied automatically func (l *UserLoader) Load(key uint) (*User, error) { return l.LoadThunk(key)() } // LoadThunk returns a function that when called will block waiting for a User. // 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 *UserLoader) LoadThunk(key uint) func() (*User, error) { l.mu.Lock() if it, ok := l.cache[key]; ok { l.mu.Unlock() return func() (*User, error) { return it, nil } } if l.batch == nil { l.batch = &userLoaderBatch{done: make(chan struct{})} } batch := l.batch pos := batch.keyIndex(l, key) l.mu.Unlock() return func() (*User, error) { <-batch.done var data *User 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 *UserLoader) LoadAll(keys []uint) ([]*User, []error) { results := make([]func() (*User, error), len(keys)) for i, key := range keys { results[i] = l.LoadThunk(key) } users := make([]*User, len(keys)) errors := make([]error, len(keys)) for i, thunk := range results { users[i], errors[i] = thunk() } return users, errors } // LoadAllThunk returns a function that when called will block waiting for a Users. // 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 *UserLoader) LoadAllThunk(keys []uint) func() ([]*User, []error) { results := make([]func() (*User, error), len(keys)) for i, key := range keys { results[i] = l.LoadThunk(key) } return func() ([]*User, []error) { users := make([]*User, len(keys)) errors := make([]error, len(keys)) for i, thunk := range results { users[i], errors[i] = thunk() } return users, 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 *UserLoader) Prime(key uint, value *User) 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 *UserLoader) Clear(key uint) { l.mu.Lock() delete(l.cache, key) l.mu.Unlock() } func (l *UserLoader) unsafeSet(key uint, value *User) { if l.cache == nil { l.cache = map[uint]*User{} } 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 *userLoaderBatch) keyIndex(l *UserLoader, key uint) 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 *userLoaderBatch) startTimer(l *UserLoader) { 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 *userLoaderBatch) end(l *UserLoader) { b.data, b.error = l.fetch(b.keys) close(b.done) } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen6/generated.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package gqlgen6 import ( "bytes" "context" "errors" "fmt" "strconv" "sync" "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" "github.com/vektah/gqlparser" "github.com/vektah/gqlparser/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 Photo() PhotoResolver Query() QueryResolver User() UserResolver } type DirectiveRoot struct { IsSubscribed func(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) Validation func(ctx context.Context, obj interface{}, next graphql.Resolver, funcs []string) (res interface{}, err error) } type ComplexityRoot struct { Mutation struct { RatePhoto func(childComplexity int, photoID string, direction string) int UploadPhoto func(childComplexity int, comment string, file graphql.Upload) int } Photo struct { Comment func(childComplexity int) int ID func(childComplexity int) int Liked func(childComplexity int) int Rating func(childComplexity int) int URL func(childComplexity int) int User func(childComplexity int) int } Query struct { Photos func(childComplexity int, userID string) int Timeline func(childComplexity int) int User func(childComplexity int, userID string) int } User struct { Avatar func(childComplexity int) int Followed func(childComplexity int) int ID func(childComplexity int) int Name func(childComplexity int) int Photos func(childComplexity int, count int) int } } type MutationResolver interface { RatePhoto(ctx context.Context, photoID string, direction string) (*Photo, error) UploadPhoto(ctx context.Context, comment string, file graphql.Upload) (*Photo, error) } type PhotoResolver interface { ID(ctx context.Context, obj *Photo) (string, error) User(ctx context.Context, obj *Photo) (*User, error) } type QueryResolver interface { Timeline(ctx context.Context) ([]*Photo, error) User(ctx context.Context, userID string) (*User, error) Photos(ctx context.Context, userID string) ([]*Photo, error) } type UserResolver interface { Photos(ctx context.Context, obj *User, count int) ([]*Photo, error) } type executableSchema struct { resolvers ResolverRoot directives DirectiveRoot complexity ComplexityRoot } func (e *executableSchema) Schema() *ast.Schema { return parsedSchema } func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { ec := executionContext{nil, e} _ = ec switch typeName + "." + field { case "Mutation.ratePhoto": if e.complexity.Mutation.RatePhoto == nil { break } args, err := ec.field_Mutation_ratePhoto_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Mutation.RatePhoto(childComplexity, args["photoID"].(string), args["direction"].(string)), true case "Mutation.uploadPhoto": if e.complexity.Mutation.UploadPhoto == nil { break } args, err := ec.field_Mutation_uploadPhoto_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Mutation.UploadPhoto(childComplexity, args["comment"].(string), args["file"].(graphql.Upload)), true case "Photo.comment": if e.complexity.Photo.Comment == nil { break } return e.complexity.Photo.Comment(childComplexity), true case "Photo.id": if e.complexity.Photo.ID == nil { break } return e.complexity.Photo.ID(childComplexity), true case "Photo.liked": if e.complexity.Photo.Liked == nil { break } return e.complexity.Photo.Liked(childComplexity), true case "Photo.rating": if e.complexity.Photo.Rating == nil { break } return e.complexity.Photo.Rating(childComplexity), true case "Photo.url": if e.complexity.Photo.URL == nil { break } return e.complexity.Photo.URL(childComplexity), true case "Photo.user": if e.complexity.Photo.User == nil { break } return e.complexity.Photo.User(childComplexity), true case "Query.photos": if e.complexity.Query.Photos == nil { break } args, err := ec.field_Query_photos_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Query.Photos(childComplexity, args["userID"].(string)), true case "Query.timeline": if e.complexity.Query.Timeline == nil { break } return e.complexity.Query.Timeline(childComplexity), true case "Query.user": if e.complexity.Query.User == nil { break } args, err := ec.field_Query_user_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Query.User(childComplexity, args["userID"].(string)), true case "User.avatar": if e.complexity.User.Avatar == nil { break } return e.complexity.User.Avatar(childComplexity), true case "User.followed": if e.complexity.User.Followed == nil { break } return e.complexity.User.Followed(childComplexity), true case "User.id": if e.complexity.User.ID == nil { break } return e.complexity.User.ID(childComplexity), true case "User.name": if e.complexity.User.Name == nil { break } return e.complexity.User.Name(childComplexity), true case "User.photos": if e.complexity.User.Photos == nil { break } args, err := ec.field_User_photos_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.User.Photos(childComplexity, args["count"].(int)), true } return 0, false } func (e *executableSchema) Query(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { ec := executionContext{graphql.GetRequestContext(ctx), e} buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { data := ec._Query(ctx, op.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) return buf.Bytes() }) return &graphql.Response{ Data: buf, Errors: ec.Errors, Extensions: ec.Extensions, } } func (e *executableSchema) Mutation(ctx context.Context, op *ast.OperationDefinition) *graphql.Response { ec := executionContext{graphql.GetRequestContext(ctx), e} buf := ec.RequestMiddleware(ctx, func(ctx context.Context) []byte { data := ec._Mutation(ctx, op.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) return buf.Bytes() }) return &graphql.Response{ Data: buf, Errors: ec.Errors, Extensions: ec.Extensions, } } func (e *executableSchema) Subscription(ctx context.Context, op *ast.OperationDefinition) func() *graphql.Response { return graphql.OneShot(graphql.ErrorResponse(ctx, "subscriptions are not supported")) } type executionContext struct { *graphql.RequestContext *executableSchema } func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } return introspection.WrapSchema(parsedSchema), nil } func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { if ec.DisableIntrospection { return nil, errors.New("introspection disabled") } return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil } var parsedSchema = gqlparser.MustLoadSchema( &ast.Source{Name: "schema.graphql", Input: `# gqlgen знает как с этим работать и что парсить это надо через multipart-form scalar Upload directive @isSubscribed on FIELD_DEFINITION directive @validation(funcs: [String!]!) on ARGUMENT_DEFINITION type User { id: ID! name: String! avatar: String! followed: Boolean! # subscriptions(count: Int! = 10): [User!]! # subscribers(count: Int! = 10): [User!]! """возвращает фотограции данного пользователя""" photos(count: Int! = 10): [Photo!]! @isSubscribed } type Photo { id: ID! user: User! url: String! comment: String! rating: Int! liked: Boolean! } type Query { # query{timeline{id,url,user{id,name}}} """возвращает ленту текущего пользователя - фото тех, на кого он подписан""" timeline: [Photo!]! # query{user(userID:"1"){id,name,avatar}} """возвращает выбранного пользователя""" user(userID: ID!): User! # query{user(userID:"1"){id,avatar,name}} """возвращает фотограции выбранного пользователя""" photos(userID: ID!): [Photo!]! } type Mutation { # mutation _{ratePhoto(photoID:"1", direction:"up"){id,url,rating,user{id,name}}} ratePhoto(photoID: ID!, direction: String!): Photo! uploadPhoto( comment: String! @validation(funcs: ["noBadUrls", "noMatureLanguage"]) file: Upload! ): Photo! } # go run github.com/99designs/gqlgen init # go run github.com/99designs/gqlgen -v `}, ) // endregion ************************** generated!.gotpl ************************** // region ***************************** args.gotpl ***************************** func (ec *executionContext) dir_validation_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 []string if tmp, ok := rawArgs["funcs"]; ok { arg0, err = ec.unmarshalNString2ᚕstringᚄ(ctx, tmp) if err != nil { return nil, err } } args["funcs"] = arg0 return args, nil } func (ec *executionContext) field_Mutation_ratePhoto_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["photoID"]; ok { arg0, err = ec.unmarshalNID2string(ctx, tmp) if err != nil { return nil, err } } args["photoID"] = arg0 var arg1 string if tmp, ok := rawArgs["direction"]; ok { arg1, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } } args["direction"] = arg1 return args, nil } func (ec *executionContext) field_Mutation_uploadPhoto_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["comment"]; ok { directive0 := func(ctx context.Context) (interface{}, error) { return ec.unmarshalNString2string(ctx, tmp) } directive1 := func(ctx context.Context) (interface{}, error) { funcs, err := ec.unmarshalNString2ᚕstringᚄ(ctx, []interface{}{"noBadUrls", "noMatureLanguage"}) if err != nil { return nil, err } if ec.directives.Validation == nil { return nil, errors.New("directive validation is not implemented") } return ec.directives.Validation(ctx, rawArgs, directive0, funcs) } tmp, err = directive1(ctx) if err != nil { return nil, err } if data, ok := tmp.(string); ok { arg0 = data } else { return nil, fmt.Errorf(`unexpected type %T from directive, should be string`, tmp) } } args["comment"] = arg0 var arg1 graphql.Upload if tmp, ok := rawArgs["file"]; ok { arg1, err = ec.unmarshalNUpload2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx, tmp) if err != nil { return nil, err } } args["file"] = arg1 return args, nil } func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["name"]; ok { arg0, err = ec.unmarshalNString2string(ctx, tmp) if err != nil { return nil, err } } args["name"] = arg0 return args, nil } func (ec *executionContext) field_Query_photos_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["userID"]; ok { arg0, err = ec.unmarshalNID2string(ctx, tmp) if err != nil { return nil, err } } args["userID"] = arg0 return args, nil } func (ec *executionContext) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string if tmp, ok := rawArgs["userID"]; ok { arg0, err = ec.unmarshalNID2string(ctx, tmp) if err != nil { return nil, err } } args["userID"] = arg0 return args, nil } func (ec *executionContext) field_User_photos_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 int if tmp, ok := rawArgs["count"]; ok { arg0, err = ec.unmarshalNInt2int(ctx, tmp) if err != nil { return nil, err } } args["count"] = arg0 return args, nil } func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 return args, nil } func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["includeDeprecated"]; ok { arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) if err != nil { return nil, err } } args["includeDeprecated"] = arg0 return args, nil } // endregion ***************************** args.gotpl ***************************** // region ************************** directives.gotpl ************************** // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** func (ec *executionContext) _Mutation_ratePhoto(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Mutation", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Mutation_ratePhoto_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Mutation().RatePhoto(rctx, args["photoID"].(string), args["direction"].(string)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*Photo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNPhoto2ᚖgqlgen6ᚐPhoto(ctx, field.Selections, res) } func (ec *executionContext) _Mutation_uploadPhoto(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Mutation", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Mutation_uploadPhoto_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Mutation().UploadPhoto(rctx, args["comment"].(string), args["file"].(graphql.Upload)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*Photo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNPhoto2ᚖgqlgen6ᚐPhoto(ctx, field.Selections, res) } func (ec *executionContext) _Photo_id(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Photo", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Photo().ID(rctx, obj) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _Photo_user(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Photo", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Photo().User(rctx, obj) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*User) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNUser2ᚖgqlgen6ᚐUser(ctx, field.Selections, res) } func (ec *executionContext) _Photo_url(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.URL, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Photo_comment(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Comment, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _Photo_rating(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Rating, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(int) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNInt2int(ctx, field.Selections, res) } func (ec *executionContext) _Photo_liked(ctx context.Context, field graphql.CollectedField, obj *Photo) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Photo", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Liked, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) _Query_timeline(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Timeline(rctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]*Photo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNPhoto2ᚕᚖgqlgen6ᚐPhotoᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_user_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().User(rctx, args["userID"].(string)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*User) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNUser2ᚖgqlgen6ᚐUser(ctx, field.Selections, res) } func (ec *executionContext) _Query_photos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query_photos_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Photos(rctx, args["userID"].(string)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]*Photo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNPhoto2ᚕᚖgqlgen6ᚐPhotoᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_Query___type_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectType(args["name"].(string)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "Query", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectSchema() }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*introspection.Schema) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNID2string(ctx, field.Selections, res) } func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _User_avatar(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Avatar, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) _User_followed(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "User", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Followed, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) _User_photos(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "User", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field_User_photos_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.User().Photos(rctx, obj, args["count"].(int)) } directive1 := func(ctx context.Context) (interface{}, error) { if ec.directives.IsSubscribed == nil { return nil, errors.New("directive isSubscribed is not implemented") } return ec.directives.IsSubscribed(ctx, obj, directive0) } tmp, err := directive1(rctx) if err != nil { return nil, err } if tmp == nil { return nil, nil } if data, ok := tmp.([]*Photo); ok { return data, nil } return nil, fmt.Errorf(`unexpected type %T from directive, should be []*gqlgen6.Photo`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]*Photo) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNPhoto2ᚕᚖgqlgen6ᚐPhotoᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Locations, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Directive", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__EnumValue", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(bool) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Field", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalNString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__InputValue", Field: field, Args: nil, IsMethod: false, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DefaultValue, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Types(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.QueryType(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.MutationType(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.SubscriptionType(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Schema", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Directives(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.([]introspection.Directive) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Kind(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") } return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalN__TypeKind2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(string) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalOString2string(ctx, field.Selections, res) } func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_fields_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Fields(args["includeDeprecated"].(bool)), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.([]introspection.Field) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Interfaces(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.PossibleTypes(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.([]introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) rawArgs := field.ArgumentMap(ec.Variables) args, err := ec.field___Type_enumValues_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.([]introspection.EnumValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.InputFields(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.([]introspection.InputValue) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { ctx = ec.Tracer.StartFieldExecution(ctx, field) defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = graphql.Null } ec.Tracer.EndFieldExecution(ctx) }() rctx := &graphql.ResolverContext{ Object: "__Type", Field: field, Args: nil, IsMethod: true, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.OfType(), nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { return graphql.Null } res := resTmp.(*introspection.Type) rctx.Result = res ctx = ec.Tracer.StartFieldChildExecution(ctx) return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** // endregion **************************** input.gotpl ***************************** // region ************************** interface.gotpl *************************** // endregion ************************** interface.gotpl *************************** // region **************************** object.gotpl **************************** var mutationImplementors = []string{"Mutation"} func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.RequestContext, sel, mutationImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "Mutation", }) out := graphql.NewFieldSet(fields) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Mutation") case "ratePhoto": out.Values[i] = ec._Mutation_ratePhoto(ctx, field) if out.Values[i] == graphql.Null { invalids++ } case "uploadPhoto": out.Values[i] = ec._Mutation_uploadPhoto(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 photoImplementors = []string{"Photo"} func (ec *executionContext) _Photo(ctx context.Context, sel ast.SelectionSet, obj *Photo) graphql.Marshaler { fields := graphql.CollectFields(ec.RequestContext, sel, photoImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Photo") case "id": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Photo_id(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "user": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Photo_user(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "url": out.Values[i] = ec._Photo_url(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "comment": out.Values[i] = ec._Photo_comment(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "rating": out.Values[i] = ec._Photo_rating(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "liked": out.Values[i] = ec._Photo_liked(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch() if invalids > 0 { return graphql.Null } return out } var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { fields := graphql.CollectFields(ec.RequestContext, sel, queryImplementors) ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ Object: "Query", }) out := graphql.NewFieldSet(fields) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Query") case "timeline": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_timeline(ctx, field) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "user": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_user(ctx, field) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "photos": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._Query_photos(ctx, field) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": out.Values[i] = 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.RequestContext, 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 { atomic.AddUint32(&invalids, 1) } case "name": out.Values[i] = ec._User_name(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "avatar": out.Values[i] = ec._User_avatar(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "followed": out.Values[i] = ec._User_followed(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } case "photos": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) } }() res = ec._User_photos(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) 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.RequestContext, 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++ } 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.RequestContext, 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.RequestContext, 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.RequestContext, 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.RequestContext, sel, __SchemaImplementors) out := graphql.NewFieldSet(fields) var invalids uint32 for i, field := range fields { switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("__Schema") case "types": 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.RequestContext, 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) default: panic("unknown field " + strconv.Quote(field.Name)) } } out.Dispatch() if invalids > 0 { return graphql.Null } return out } // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { res := graphql.MarshalBoolean(v) if res == graphql.Null { if !ec.HasError(graphql.GetResolverContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalID(v) } func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalID(v) if res == graphql.Null { if !ec.HasError(graphql.GetResolverContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{}) (int, error) { return graphql.UnmarshalInt(v) } func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { res := graphql.MarshalInt(v) if res == graphql.Null { if !ec.HasError(graphql.GetResolverContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) marshalNPhoto2gqlgen6ᚐPhoto(ctx context.Context, sel ast.SelectionSet, v Photo) graphql.Marshaler { return ec._Photo(ctx, sel, &v) } func (ec *executionContext) marshalNPhoto2ᚕᚖgqlgen6ᚐPhotoᚄ(ctx context.Context, sel ast.SelectionSet, v []*Photo) 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 rctx := &graphql.ResolverContext{ Index: &i, Result: &v[i], } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) ret = nil } }() if !isLen1 { defer wg.Done() } ret[i] = ec.marshalNPhoto2ᚖgqlgen6ᚐPhoto(ctx, sel, v[i]) } if isLen1 { f(i) } else { go f(i) } } wg.Wait() return ret } func (ec *executionContext) marshalNPhoto2ᚖgqlgen6ᚐPhoto(ctx context.Context, sel ast.SelectionSet, v *Photo) graphql.Marshaler { if v == nil { if !ec.HasError(graphql.GetResolverContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null } return ec._Photo(ctx, sel, v) } func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { if !ec.HasError(graphql.GetResolverContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalNString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { vSlice = tmp1 } else { vSlice = []interface{}{v} } } var err error res := make([]string, len(vSlice)) for i := range vSlice { 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]) } return ret } func (ec *executionContext) unmarshalNUpload2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, v interface{}) (graphql.Upload, error) { return graphql.UnmarshalUpload(v) } func (ec *executionContext) marshalNUpload2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx context.Context, sel ast.SelectionSet, v graphql.Upload) graphql.Marshaler { res := graphql.MarshalUpload(v) if res == graphql.Null { if !ec.HasError(graphql.GetResolverContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) marshalNUser2gqlgen6ᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler { return ec._User(ctx, sel, &v) } func (ec *executionContext) marshalNUser2ᚖgqlgen6ᚐUser(ctx context.Context, sel ast.SelectionSet, v *User) graphql.Marshaler { if v == nil { if !ec.HasError(graphql.GetResolverContext(ctx)) { ec.Errorf(ctx, "must not be null") } 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 rctx := &graphql.ResolverContext{ Index: &i, Result: &v[i], } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { defer 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() return ret } func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { if !ec.HasError(graphql.GetResolverContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { var vSlice []interface{} if v != nil { if tmp1, ok := v.([]interface{}); ok { vSlice = tmp1 } else { vSlice = []interface{}{v} } } var err error res := make([]string, len(vSlice)) for i := range vSlice { 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 rctx := &graphql.ResolverContext{ Index: &i, Result: &v[i], } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { defer 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() 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 rctx := &graphql.ResolverContext{ Index: &i, Result: &v[i], } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { defer 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() 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 rctx := &graphql.ResolverContext{ Index: &i, Result: &v[i], } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { defer 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() 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 !ec.HasError(graphql.GetResolverContext(ctx)) { ec.Errorf(ctx, "must not be null") } return graphql.Null } return ec.___Type(ctx, sel, v) } func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { res := graphql.MarshalString(v) if res == graphql.Null { if !ec.HasError(graphql.GetResolverContext(ctx)) { ec.Errorf(ctx, "must not be null") } } return res } func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { return graphql.UnmarshalBoolean(v) } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { return graphql.MarshalBoolean(v) } func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { if v == nil { return nil, nil } res, err := ec.unmarshalOBoolean2bool(ctx, v) return &res, err } func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOBoolean2bool(ctx, sel, *v) } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { return graphql.UnmarshalString(v) } func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { return graphql.MarshalString(v) } func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil } res, err := ec.unmarshalOString2string(ctx, v) return &res, err } func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { if v == nil { return graphql.Null } return ec.marshalOString2string(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 rctx := &graphql.ResolverContext{ Index: &i, Result: &v[i], } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { defer 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() 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 rctx := &graphql.ResolverContext{ Index: &i, Result: &v[i], } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { defer 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() 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 rctx := &graphql.ResolverContext{ Index: &i, Result: &v[i], } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { defer 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() return ret } func (ec *executionContext) marshalO__Schema2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v introspection.Schema) graphql.Marshaler { return ec.___Schema(ctx, sel, &v) } 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__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) 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 rctx := &graphql.ResolverContext{ Index: &i, Result: &v[i], } ctx := graphql.WithResolverContext(ctx, rctx) f := func(i int) { defer 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() 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: 4-api/3_graphql/gqlgen_full/gqlgen6/go.mod ================================================ module gqlgen6 go 1.13 require ( github.com/99designs/gqlgen v0.10.2 github.com/vektah/gqlparser v1.2.0 ) ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen6/go.sum ================================================ github.com/99designs/gqlgen v0.10.2 h1:FfjCqIWejHDJeLpQTI0neoZo5vDO3sdo5oNCucet3A0= github.com/99designs/gqlgen v0.10.2/go.mod h1:aDB7oabSAyZ4kUHLEySsLxnWrBy3lA0A2gWKU+qoHwI= github.com/agnivade/levenshtein v1.0.1 h1:3oJU7J3FGFmyhn8KHjmVaZCN5hxTr7GxgRue+sxIXdQ= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-chi/chi v3.3.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/mux v1.6.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/websocket v1.2.0 h1:VJtLvh6VQym50czpZzx07z/kw9EgAxI3x1ZB8taTMQQ= github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e/go.mod h1:/HUdMve7rvxZma+2ZELQeNh88+003LL7Pf/CZ089j8U= github.com/vektah/gqlparser v1.2.0 h1:ntkSCX7F5ZJKl+HIVnmLaO269MruasVpNiMOjX9kgo0= github.com/vektah/gqlparser v1.2.0/go.mod h1:bkVf0FX+Stjg/MHnm8mEyubuaArhNEqfQhF+OTiAL74= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd h1:oMEQDWVXVNpceQoVd1JN3CQ7LYJJzs5qWqZIUcxXHHw= golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 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/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:L5q+DGLGOQFpo1snNEkLOJT2d1YTW66rWNzatr3He1k= ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen6/gqlgen.yml ================================================ schema: - schema.graphql exec: filename: generated.go model: filename: models_gen.go resolver: filename: resolver.go type: Resolver models: Photo: model: gqlgen6.Photo fields: user: resolver: true User: fields: photos: resolver: true autobind: [] ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen6/models_gen.go ================================================ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. package gqlgen6 type User struct { ID string `json:"id"` Name string `json:"name"` Avatar string `json:"avatar"` Followed bool `json:"followed"` // возвращает фотограции данного пользователя Photos []*Photo `json:"photos"` } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen6/photo.go ================================================ package gqlgen6 import ( // "log" "strconv" ) type Photo struct { ID uint `json:"id"` UserID uint `json:"-"` // User *User `json:"user"` URL string `json:"url"` Comment string `json:"comment"` Rating int `json:"rating"` Liked bool `json:"liked"` } func (ph *Photo) Id() string { // log.Println("call Photo.Id method", ph.ID) return strconv.Itoa(int(ph.ID)) } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen6/queries.txt ================================================ query { user(userID: "1") { id name avatar } } query { user(userID: "1") { id name avatar photos {id, url, user{ id name photos { id, url } }} } } # ----- query { user(userID: "1") { id name avatar photos(count:20) { id url user { id name photos(count:100) { id url } } } } } # ---- query($userID: ID!, $cnt1:Int!, $cnt2:Int! ) { user(userID: $userID) { id name avatar photos(count:$cnt1) { id url user { id name photos(count:$cnt2) { id url } } } } photos(userID:$userID) {id, url} } { "userID":"1", "cnt1":10, "cnt2":20 } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen6/resolver.go ================================================ package gqlgen6 //go:generate go run github.com/99designs/gqlgen -v import ( "context" "crypto/md5" "fmt" "io/ioutil" "log" "strconv" "time" "github.com/99designs/gqlgen/graphql" ) type Resolver struct { PhotosData map[string]*Photo Users map[uint]*User } func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } func (r *Resolver) Photo() PhotoResolver { return &photoResolver{r} } func (r *Resolver) User() UserResolver { return &userResolver{r} } func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } type mutationResolver struct{ *Resolver } func (r *mutationResolver) RatePhoto(ctx context.Context, id string, direction string) (*Photo, error) { log.Println("call mutationResolver.RatePhoto method with id", id, direction) rate := 1 if direction != "up" { rate = -1 } ph, ok := r.PhotosData[id] if !ok { return nil, fmt.Errorf("no photo %v found", id) } ph.Rating += rate return ph, nil } func (r *mutationResolver) UploadPhoto(ctx context.Context, comment string, file graphql.Upload) (*Photo, error) { sessionUserID := ctx.Value("userID").(uint) content, err := ioutil.ReadAll(file.File) if err != nil { return nil, err } hasher := md5.New() hasher.Write(content) log.Printf("incoming file %v, %v bytes, md5 %x", file.Filename, file.Size, hasher.Sum(nil)) ph := &Photo{ ID: 42, UserID: sessionUserID, Comment: comment, URL: "/photos/" + file.Filename, } r.PhotosData[strconv.Itoa(int(ph.ID))] = ph return ph, nil } type userResolver struct{ *Resolver } func (r *userResolver) Photos(ctx context.Context, obj *User, count int) ([]*Photo, error) { log.Println("call userResolver.Photos with count", count) id, _ := strconv.Atoi(obj.ID) items := []*Photo{} for _, ph := range r.PhotosData { if ph.UserID != uint(id) { continue } items = append(items, ph) } return items, nil } type photoResolver struct{ *Resolver } func (r *photoResolver) ID(ctx context.Context, obj *Photo) (string, error) { return obj.Id(), nil } func (r *photoResolver) User(ctx context.Context, obj *Photo) (*User, error) { // return r.Users[obj.UserID], nil log.Println("call photoResolver.User", obj.UserID) start := time.Now() user, err := ctx.Value("userLoaderKey").(*UserLoader).Load(obj.UserID) log.Println("get photoResolver.User", obj.UserID, "from UserLoader, time ", time.Since(start)) return user, err } type queryResolver struct{ *Resolver } func (r *queryResolver) Timeline(ctx context.Context) ([]*Photo, error) { log.Println("call queryResolver.Timeline with ctx.userID", ctx.Value("userID")) items := []*Photo{} for _, ph := range r.PhotosData { items = append(items, ph) } return items, nil } func (r *queryResolver) User(ctx context.Context, userID string) (*User, error) { log.Println("call queryResolver.User for", userID) id, _ := strconv.Atoi(userID) return r.Users[uint(id)], nil } func (r *queryResolver) Photos(ctx context.Context, userID string) ([]*Photo, error) { log.Println("call queryResolver.Photos") id, _ := strconv.Atoi(userID) items := []*Photo{} for _, ph := range r.PhotosData { if ph.UserID != uint(id) { continue } items = append(items, ph) } return items, nil } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen6/schema.graphql ================================================ # gqlgen знает как с этим работать и что парсить это надо через multipart-form scalar Upload directive @isSubscribed on FIELD_DEFINITION directive @validation(funcs: [String!]!) on ARGUMENT_DEFINITION type User { id: ID! name: String! avatar: String! followed: Boolean! # subscriptions(count: Int! = 10): [User!]! # subscribers(count: Int! = 10): [User!]! """возвращает фотограции данного пользователя""" photos(count: Int! = 10): [Photo!]! @isSubscribed } type Photo { id: ID! user: User! url: String! comment: String! rating: Int! liked: Boolean! } type Query { # query{timeline{id,url,user{id,name}}} """возвращает ленту текущего пользователя - фото тех, на кого он подписан""" timeline: [Photo!]! # query{user(userID:"1"){id,name,avatar}} """возвращает выбранного пользователя""" user(userID: ID!): User! # query{user(userID:"1"){id,avatar,name}} """возвращает фотограции выбранного пользователя""" photos(userID: ID!): [Photo!]! } type Mutation { # mutation _{ratePhoto(photoID:"1", direction:"up"){id,url,rating,user{id,name}}} ratePhoto(photoID: ID!, direction: String!): Photo! uploadPhoto( comment: String! @validation(funcs: ["noBadUrls", "noMatureLanguage"]) file: Upload! ): Photo! } # go run github.com/99designs/gqlgen init # go run github.com/99designs/gqlgen -v ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen6/server/server.go ================================================ package main import ( "context" "fmt" gqlgen "gqlgen6" "log" "net/http" "strconv" "strings" "time" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/handler" ) /* # ok curl localhost:8080/query \ -F operations='{ "query": "mutation($comment: String!, $file: Upload!) { uploadPhoto(comment: $comment, file: $file) { id } }", "variables": { "comment": "cool photo", "file": null } }' \ -F map='{ "0": ["variables.file"] }' \ -F 0=@./test_file.txt \ --trace-ascii - # mature language curl localhost:8080/query \ -F operations='{ "query": "mutation($comment: String!, $file: Upload!) { uploadPhoto(comment: $comment, file: $file) { id } }", "variables": { "comment": "блин!", "file": null } }' \ -F map='{ "0": ["variables.file"] }' \ -F 0=@./test_file.txt # bad url curl localhost:8080/query \ -F operations='{ "query": "mutation($comment: String!, $file: Upload!) { uploadPhoto(comment: $comment, file: $file) { id } }", "variables": { "comment": "https://evil.com", "file": null } }' \ -F map='{ "0": ["variables.file"] }' \ -F 0=@./test_file.txt query($userID: ID!){ user(userID: $userID) { id avatar name photos { id } } } */ var users = map[uint]*gqlgen.User{ 1: { ID: "1", Name: "rvasily", Avatar: "https://via.placeholder.com/150", }, 2: { ID: "2", Name: "v.romanov", Avatar: "https://via.placeholder.com/150", }, 3: { ID: "3", Name: "romanov.vasily", Avatar: "https://via.placeholder.com/150", }, } var photos = map[string]*gqlgen.Photo{ "1": { ID: 1, UserID: 1, URL: "https://via.placeholder.com/300", Comment: "from studio", Rating: 1, Liked: true, }, "2": { ID: 2, UserID: 1, URL: "https://via.placeholder.com/300", Comment: "cool view", Rating: 0, Liked: false, }, "3": { ID: 3, UserID: 2, URL: "https://via.placeholder.com/300", Comment: "at work", Rating: 0, Liked: false, }, "4": { ID: 3, UserID: 3, URL: "https://via.placeholder.com/300", Comment: "at work", Rating: 0, Liked: false, }, } // go run github.com/vektah/dataloaden UserLoader uint *coursera/3p/graphql/gqlgen3.User func UserLoaderMiddleware(resolver *gqlgen.Resolver, next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { cfg := gqlgen.UserLoaderConfig{ MaxBatch: 100, Wait: 1 * time.Millisecond, Fetch: func(ids []uint) ([]*gqlgen.User, []error) { // имеем доступ до r *http.Request - там context с сессией пользователя sessionUserID := r.Context().Value("userID").(uint) log.Printf("UserLoader Request - ids %v for user %v\n", ids, sessionUserID) log.Printf("request %v\n", r) log.Printf("ctx %v\n", r.Context()) users := make([]*gqlgen.User, len(ids)) for i, id := range ids { // имеем доступ до resolver *gqlgen.Resolver - там коннет к базе users[i] = resolver.Users[id] } return users, nil }, } userLoader := gqlgen.NewUserLoader(cfg) ctx := context.WithValue(r.Context(), "userLoaderKey", userLoader) r = r.WithContext(ctx) next.ServeHTTP(w, r) }) } func AuthMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // log.Println("new request") ctx := context.WithValue(r.Context(), "userID", uint(1)) r = r.WithContext(ctx) next.ServeHTTP(w, r) }) } // 1-й подписан на 2-го var followedData = map[uint]map[uint]struct{}{ 1: map[uint]struct{}{ 2: struct{}{}, }, } func IsFollowed(userID, currUserID uint) bool { currSubs, ok := followedData[currUserID] if !ok { return false } _, isFollowed := currSubs[userID] return isFollowed } func CheckIsSubscribed(ctx context.Context, obj interface{}, next graphql.Resolver) (interface{}, error) { log.Printf("CheckIsSubscribed %T %#V", obj, obj) sessionUserID := ctx.Value("userID").(uint) switch obj.(type) { case *gqlgen.User: u := obj.(*gqlgen.User) userID, _ := strconv.Atoi(u.ID) if uint(userID) == sessionUserID { break } if !IsFollowed(uint(userID), sessionUserID) { return nil, fmt.Errorf("availible only for followers") } } return next(ctx) } func noBadUrls(vars map[string]interface{}) bool { val, ok := vars["comment"].(string) if !ok { return false } return !strings.Contains(val, "evil.com") } func noMatureLanguage(vars map[string]interface{}) bool { val, ok := vars["comment"].(string) if !ok { return false } return !strings.Contains(val, "блин") } var validators = map[string]func(map[string]interface{}) bool{ "noBadUrls": noBadUrls, "noMatureLanguage": noMatureLanguage, } func CheckValidation(ctx context.Context, obj interface{}, next graphql.Resolver, callbacks []string) (interface{}, error) { log.Printf("CheckValidation %T %#V %#v", obj, obj, callbacks) for _, cbName := range callbacks { cb, ok := validators[cbName] if !ok { return nil, fmt.Errorf("cant find callback %s", cbName) } vars, ok := obj.(map[string]interface{}) if !ok { return nil, fmt.Errorf("unexpected args type: %T", obj) } if !cb(vars) { return nil, fmt.Errorf("check %s failed", cbName) } } return next(ctx) } func main() { http.Handle("/", handler.Playground("GraphQL playground", "/query")) resolver := &gqlgen.Resolver{ Users: users, PhotosData: photos, } cfg := gqlgen.Config{ Resolvers: resolver, } cfg.Complexity.User.Photos = func(childComplexity, count int) int { return count * childComplexity } cfg.Directives.IsSubscribed = CheckIsSubscribed cfg.Directives.Validation = CheckValidation gqlHandler := handler.GraphQL( gqlgen.NewExecutableSchema(cfg), handler.ComplexityLimit(500), ) handler := UserLoaderMiddleware(resolver, gqlHandler) handler = AuthMiddleware(handler) http.Handle("/query", handler) port := "8080" log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) log.Fatal(http.ListenAndServe(":"+port, nil)) } ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen6/test_file.txt ================================================ TEST_FILE_XXXXXXXXXXXXXXXXXX ================================================ FILE: 4-api/3_graphql/gqlgen_full/gqlgen6/userloader_gen.go ================================================ // Code generated by github.com/vektah/dataloaden, DO NOT EDIT. package gqlgen6 import ( "sync" "time" ) // UserLoaderConfig captures the config to create a new UserLoader type UserLoaderConfig struct { // Fetch is a method that provides the data for the loader Fetch func(keys []uint) ([]*User, []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 } // NewUserLoader creates a new UserLoader given a fetch, wait, and maxBatch func NewUserLoader(config UserLoaderConfig) *UserLoader { return &UserLoader{ fetch: config.Fetch, wait: config.Wait, maxBatch: config.MaxBatch, } } // UserLoader batches and caches requests type UserLoader struct { // this method provides the data for the loader fetch func(keys []uint) ([]*User, []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[uint]*User // 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 *userLoaderBatch // mutex to prevent races mu sync.Mutex } type userLoaderBatch struct { keys []uint data []*User error []error closing bool done chan struct{} } // Load a User by key, batching and caching will be applied automatically func (l *UserLoader) Load(key uint) (*User, error) { return l.LoadThunk(key)() } // LoadThunk returns a function that when called will block waiting for a User. // 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 *UserLoader) LoadThunk(key uint) func() (*User, error) { l.mu.Lock() if it, ok := l.cache[key]; ok { l.mu.Unlock() return func() (*User, error) { return it, nil } } if l.batch == nil { l.batch = &userLoaderBatch{done: make(chan struct{})} } batch := l.batch pos := batch.keyIndex(l, key) l.mu.Unlock() return func() (*User, error) { <-batch.done var data *User 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 *UserLoader) LoadAll(keys []uint) ([]*User, []error) { results := make([]func() (*User, error), len(keys)) for i, key := range keys { results[i] = l.LoadThunk(key) } users := make([]*User, len(keys)) errors := make([]error, len(keys)) for i, thunk := range results { users[i], errors[i] = thunk() } return users, errors } // LoadAllThunk returns a function that when called will block waiting for a Users. // 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 *UserLoader) LoadAllThunk(keys []uint) func() ([]*User, []error) { results := make([]func() (*User, error), len(keys)) for i, key := range keys { results[i] = l.LoadThunk(key) } return func() ([]*User, []error) { users := make([]*User, len(keys)) errors := make([]error, len(keys)) for i, thunk := range results { users[i], errors[i] = thunk() } return users, 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 *UserLoader) Prime(key uint, value *User) 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 *UserLoader) Clear(key uint) { l.mu.Lock() delete(l.cache, key) l.mu.Unlock() } func (l *UserLoader) unsafeSet(key uint, value *User) { if l.cache == nil { l.cache = map[uint]*User{} } 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 *userLoaderBatch) keyIndex(l *UserLoader, key uint) 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 *userLoaderBatch) startTimer(l *UserLoader) { 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 *userLoaderBatch) end(l *UserLoader) { b.data, b.error = l.fetch(b.keys) close(b.done) } ================================================ FILE: 4-api/3_graphql/gqlgen_full/note.txt ================================================ go run github.com/99designs/gqlgen init go run github.com/99designs/gqlgen -v go generate ./... dataloaden coursera/3p/graphql/gqlgen3.User https://github.com/99designs/gqlgen/blob/master/example/dataloader/dataloaders.go go run github.com/vektah/dataloaden UserLoader uint *coursera/3p/graphql/gqlgen3.User uploadPhoto(comment: String!, file: Upload!) Photo! curl localhost:8080/graphql \ -F operations='{ "query": "mutation ($file: Upload!) { singleUpload(file: $file) { id } }", "variables": { "file": null } }' \ -F map='{ "0": ["variables.file"] }' \ -F 0=@../photo_samples/building_1.jpg { query: ` mutation($file: Upload!) { singleUpload(file: $file) { id } } `, variables: { file: File // a.txt } } https://99designs.com/blog/engineering/gqlgen-a-graphql-server-generator-for-go/ https://github.com/99designs/gqlgen query{timeline{id,url,user{id,name}}} query{user(userID:"1"){id,avatar, name}} mutation _{ratePhoto(photoID:"1", direction:"up"){id,url,rating,user{id,name}}} ================================================ FILE: 4-api/3_graphql/graphql-go/main.go ================================================ package main import ( "encoding/json" "fmt" "log" "math/rand" "net/http" "time" "github.com/graphql-go/graphql" ) /* Create http://127.0.0.1:8080/graphql?query=mutation+_{create(title:%22taocp%22,price:2500,author:1){id,title,price}} Read http://127.0.0.1:8080/graphql?query={books{id,title,author{name}}} http://127.0.0.1:8080/graphql?query={book(id:1){id,title,author{name}}} Update http://127.0.0.1:8080/graphql?query=mutation+_{update(id:1,price:42.0,title:"test"){id,title,price}} Delete http://127.0.0.1:8080/graphql?query=mutation+_{delete(id:1){id,title,price}} */ type Author struct { Name string `json:"string"` } type Book struct { ID int64 `json:"id"` Title string `json:"title"` Author uint `json:"author"` Price float64 `json:"price"` } var authors = map[uint]Author{ 1: Author{ Name: "Robert Heinlein", }, } var books = []Book{ Book{ ID: 1, Title: "The Moon is a harsh mistress", Author: 1, Price: 200, }, } var authorType = graphql.NewObject( graphql.ObjectConfig{ Name: "Author", Fields: graphql.Fields{ "name": &graphql.Field{ Type: graphql.String, }, }, }, ) var bookType = graphql.NewObject( graphql.ObjectConfig{ Name: "Book", Fields: graphql.Fields{ "id": &graphql.Field{ Type: graphql.Int, }, "title": &graphql.Field{ Type: graphql.String, }, "author": &graphql.Field{ Type: authorType, Resolve: func(params graphql.ResolveParams) (interface{}, error) { book, ok := params.Source.(Book) if !ok { return nil, fmt.Errorf("cannot convert source to Book") } return authors[book.Author], nil }, }, "price": &graphql.Field{ Type: graphql.Float, }, }, }, ) var mutationType = graphql.NewObject(graphql.ObjectConfig{ Name: "Mutation", Fields: graphql.Fields{ "create": &graphql.Field{ Type: bookType, Description: "Create new book", Args: graphql.FieldConfigArgument{ "title": &graphql.ArgumentConfig{ Type: graphql.NewNonNull(graphql.String), }, "author": &graphql.ArgumentConfig{ Type: graphql.NewNonNull(graphql.Int), }, "price": &graphql.ArgumentConfig{ Type: graphql.NewNonNull(graphql.Float), }, }, Resolve: func(params graphql.ResolveParams) (interface{}, error) { rand.Seed(time.Now().UnixNano()) log.Println(params.Args) book := Book{ ID: int64(rand.Intn(100000)), // генерируем случайный ID Title: params.Args["title"].(string), Author: uint(params.Args["author"].(int)), Price: params.Args["price"].(float64), } books = append(books, book) return book, nil }, }, "update": &graphql.Field{ Type: bookType, Description: "Update book by id", Args: graphql.FieldConfigArgument{ "id": &graphql.ArgumentConfig{ Type: graphql.NewNonNull(graphql.Int), }, "title": &graphql.ArgumentConfig{ Type: graphql.String, }, "author": &graphql.ArgumentConfig{ Type: graphql.Int, }, "price": &graphql.ArgumentConfig{ Type: graphql.Float, }, }, Resolve: func(params graphql.ResolveParams) (interface{}, error) { id, _ := params.Args["id"].(int) title, titleOk := params.Args["title"].(string) author, authorOk := params.Args["author"].(int) price, priceOk := params.Args["price"].(float64) book := Book{} for i, p := range books { if int64(id) != p.ID { continue } if titleOk { books[i].Title = title } if authorOk { books[i].Author = uint(author) } if priceOk { books[i].Price = price } book = books[i] } return book, nil }, }, "delete": &graphql.Field{ Type: bookType, Description: "Delete book by id", Args: graphql.FieldConfigArgument{ "id": &graphql.ArgumentConfig{ Type: graphql.NewNonNull(graphql.Int), }, }, Resolve: func(params graphql.ResolveParams) (interface{}, error) { id, _ := params.Args["id"].(int) book := Book{} for i, p := range books { if int64(id) == p.ID { book = books[i] books = append(books[:i], books[i+1:]...) } } return book, nil }, }, }, }) var queryType = graphql.NewObject( graphql.ObjectConfig{ Name: "Query", Fields: graphql.Fields{ "book": &graphql.Field{ Type: bookType, Description: "Get book by id", Args: graphql.FieldConfigArgument{ "id": &graphql.ArgumentConfig{ Type: graphql.Int, }, }, Resolve: func(p graphql.ResolveParams) (interface{}, error) { id, ok := p.Args["id"].(int) if ok { for _, book := range books { if int(book.ID) == id { return book, nil } } } return nil, nil }, }, "books": &graphql.Field{ Type: graphql.NewList(bookType), Description: "Get books list", Resolve: func(params graphql.ResolveParams) (interface{}, error) { return books, nil }, }, }, }) var schema, _ = graphql.NewSchema( graphql.SchemaConfig{ Query: queryType, Mutation: mutationType, }, ) func executeQuery(query string, schema graphql.Schema) *graphql.Result { result := graphql.Do(graphql.Params{ Schema: schema, RequestString: query, }) if len(result.Errors) > 0 { fmt.Printf("errors: %v", result.Errors) } return result } func main() { http.HandleFunc("/graphql", func(w http.ResponseWriter, r *http.Request) { result := executeQuery(r.URL.Query().Get("query"), schema) json.NewEncoder(w).Encode(result) }) http.ListenAndServe(":8080", nil) } ================================================ FILE: 4-api/3_graphql/intro/instagram_gql.txt ================================================ {"5095":"viewer() { eligible_promotions.ig_parameters().surface_nux_id().external_gating_permitted_qps() { edges { priority, time_range { start, end }, node { id, promotion_id, max_impressions, triggers, template { name, parameters { name, string_value } }, creatives { title { text }, content { text }, footer { text }, social_context { text }, primary_action{ title { text }, url, limit, dismiss_promotion }, secondary_action{ title { text }, url, limit, dismiss_promotion }, dismiss_action{ title { text }, url, limit, dismiss_promotion }, image { uri } } } } } }","5780":"viewer() { eligible_promotions.ig_parameters().surface_nux_id().external_gating_permitted_qps() { edges { priority, time_range { start, end }, node { id, promotion_id, max_impressions, triggers, template { name, parameters { name, string_value } }, creatives { title { text }, content { text }, footer { text }, social_context { text }, primary_action{ title { text }, url, limit, dismiss_promotion }, secondary_action{ title { text }, url, limit, dismiss_promotion }, dismiss_action{ title { text }, url, limit, dismiss_promotion }, image { uri } } } } } }"} ================================================ FILE: 4-api/3_graphql/intro/instagram_sql_resp.json ================================================ { "data":{ "user":{ "id":"8783838119", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/62df74739256182ff0c6e649b92af2e1/5DF8D1FD/t51.2885-19/s150x150/47581251_1143495042491718_7332190549358673920_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"rvasily.msk", "edge_web_feed_timeline":{ "page_info":{ "has_next_page":true, "end_cursor":"KKkBARAAAAIoABgAEAAQAAgACAAIAP____9_______-______5___9f____3______v6f__9___-__v_7__7_____5_________9___7_______f9_-vS-94VU4v6MKqzsf8f__2-_____nfr___79v_7f_-f__7v_P___1_f_v7v__9vf__79___-_7__7_3__7___-b8___-173_____3_5_d7vfKyMEsCABb8tfaXmVsA" }, "edges":[ { "node":{ "__typename":"GraphImage", "id":"2118287177818397102", "dimensions":{ "height":1080, "width":1080 }, "display_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/0e72e01774b67986c7956914c964d537/5E05EFA3/t51.2885-15/e35/67194079_764206027315731_4716759996914198074_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "display_resources":[ { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/e8d3c843e8d18da582ad809e6fc33339/5DFF9846/t51.2885-15/sh0.08/e35/s640x640/67194079_764206027315731_4716759996914198074_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":640, "config_height":640 }, { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/eff3cb4a484f7c4116778a638e004441/5E0A8746/t51.2885-15/sh0.08/e35/s750x750/67194079_764206027315731_4716759996914198074_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":750, "config_height":750 }, { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/0e72e01774b67986c7956914c964d537/5E05EFA3/t51.2885-15/e35/67194079_764206027315731_4716759996914198074_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":1080, "config_height":1080 } ], "follow_hashtag_info":null, "is_video":false, "should_log_client_event":false, "tracking_token":"eyJ2ZXJzaW9uIjo1LCJwYXlsb2FkIjp7ImlzX2FuYWx5dGljc190cmFja2VkIjp0cnVlLCJ1dWlkIjoiZDNkNWVkZTkzNjg3NDM0MmI5MzdmMGMzNDA1NWVlMTIyMTE4Mjg3MTc3ODE4Mzk3MTAyIiwic2VydmVyX3Rva2VuIjoiMTU2Njc0ODY2MTIyMXwyMTE4Mjg3MTc3ODE4Mzk3MTAyfDg3ODM4MzgxMTl8YzliZjQyYTcxMjU2OTQ5YzRjNWI4ZGYyNzVjYmQ4YmU4NmM4NDQzZGZmNzQ0OTE1Y2M5YjM2NTczOThkZmQ5OSJ9LCJzaWduYXR1cmUiOiIifQ==", "edge_media_to_tagged_user":{ "edges":[ ] }, "accessibility_caption":"\u041d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f: \u0432 \u043f\u043e\u043c\u0435\u0449\u0435\u043d\u0438\u0438", "attribution":null, "shortcode":"B1lqvcOIVmu", "edge_media_to_caption":{ "edges":[ { "node":{ "text":"@_nguan_\n#dreamermagazine" } } ] }, "edge_media_preview_comment":{ "count":5, "page_info":{ "has_next_page":true, "end_cursor":"QVFCUFJ4TjhSWUNORmpoc1JuY0NpU3N3ZFo5R2M4ZnJyNC1CWmowTG55ZHd6bzI1QkNHSGFGZUhwdTY0OVA2UkhXeS0yaFU1NVQ3VDNiY1JMQ0ItQWp4cA==" }, "edges":[ { "node":{ "id":"17926872490309142", "text":"Love these soft colours \ud83d\ude0d", "created_at":1566742952, "did_report_as_spam":false, "owner":{ "id":"178548294", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/4e56dc1ed1127c6aa7143cdfe4fbc757/5DFB45AF/t51.2885-19/s150x150/60207369_1069359416582248_7611132281343705088_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"clancywhiteside" }, "viewer_has_liked":false } }, { "node":{ "id":"17886040774395916", "text":"\u606d\u559c\u53d1\u8d22\u8d22\u8fd0\u6eda\u6eda", "created_at":1566746198, "did_report_as_spam":false, "owner":{ "id":"296852447", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/803fc113b05cd13756959c302ea38632/5DF8E15A/t51.2885-19/s150x150/42494087_269469293907798_1214459997887397888_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"lingyang37" }, "viewer_has_liked":false } } ] }, "gating_info":null, "media_preview":"ACoqsyRFee34UwHNaQwfzP8AD/n86pzxbBuTHJxj3/z60DKu8LwSAaUMG6HNROu7kgZNIMx9hz2FRd3sVZWvrcsFgoy1Q+cx6Co5Ac85JzgADp7emfzqE7gfuH/vo1RmdDn/ANCP8Wf0/pVaWTIx3BzUAvWMm3GFyTnABx68/wA6gnZhkjJH8qTd9i2miQyCR+TjA7cdaJgMAjoP/r1SjTfznH+e9X43AbnoSAPfPWmkK5E03JGcbG+lRM7Ek5PU9/8A61XZrNJMkcFutZx02T1/Q1Vn0J9Vcvtk5zyTWfL8xbFaB6VQkHzn6CpYyWEYFPZXLAjG0EH3oSphVokug5paij6VJTGf/9k=", "comments_disabled":false, "taken_at_timestamp":1566739531, "edge_media_preview_like":{ "count":2432, "edges":[ ] }, "edge_media_to_sponsor_user":{ "edges":[ ] }, "location":null, "viewer_has_liked":false, "viewer_has_saved":false, "viewer_has_saved_to_collection":false, "viewer_in_photo_of_you":false, "viewer_can_reshare":true, "owner":{ "id":"3468082085", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/1f1d7f216ca0db2ef61fb3c97684bd1f/5E09D9AF/t51.2885-19/s150x150/29088365_857696394412136_6657610564803493888_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"dreamermagazine", "followed_by_viewer":true, "full_name":"Dreamer Magazine", "is_private":false, "requested_by_viewer":false, "blocked_by_viewer":false, "has_blocked_viewer":false } } }, { "node":{ "__typename":"GraphImage", "id":"2118363188411259641", "dimensions":{ "height":720, "width":1080 }, "display_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/815edcb93bf99ca182af26333e782a2d/5DDA3A0C/t51.2885-15/e35/67758159_228810251346840_1820141147555273790_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "display_resources":[ { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/c381a9e65286f7d7532472225eff2ccd/5DDBCFE9/t51.2885-15/sh0.08/e35/s640x640/67758159_228810251346840_1820141147555273790_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":640, "config_height":426 }, { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/1b6b9a47b22180dc18f2e953284ee1f7/5E078CE9/t51.2885-15/sh0.08/e35/s750x750/67758159_228810251346840_1820141147555273790_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":750, "config_height":500 }, { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/815edcb93bf99ca182af26333e782a2d/5DDA3A0C/t51.2885-15/e35/67758159_228810251346840_1820141147555273790_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":1080, "config_height":720 } ], "follow_hashtag_info":null, "is_video":false, "should_log_client_event":false, "tracking_token":"eyJ2ZXJzaW9uIjo1LCJwYXlsb2FkIjp7ImlzX2FuYWx5dGljc190cmFja2VkIjp0cnVlLCJ1dWlkIjoiZDNkNWVkZTkzNjg3NDM0MmI5MzdmMGMzNDA1NWVlMTIyMTE4MzYzMTg4NDExMjU5NjQxIiwic2VydmVyX3Rva2VuIjoiMTU2Njc0ODY2MTIyMnwyMTE4MzYzMTg4NDExMjU5NjQxfDg3ODM4MzgxMTl8ZGEzMDQxM2Y2NTBiYmM0ZWM2Nzc1Y2FjMzE0YjQxNTExNzcxZDE0M2QxNTU3MGM3YmNjZmIxNjY4M2FlZWY5NyJ9LCJzaWduYXR1cmUiOiIifQ==", "edge_media_to_tagged_user":{ "edges":[ { "node":{ "user":{ "full_name":"National Geographic", "id":"787132", "is_verified":true, "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/06ec75947ace6228666ef7ac7c8d9e1b/5E1141E8/t51.2885-19/s150x150/13597791_261499887553333_1855531912_a.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"natgeo" }, "x":0.16064453, "y":0.29320475 } }, { "node":{ "user":{ "full_name":"Emily Harrington", "id":"2111892", "is_verified":true, "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/14de7d046fbc7832e15492b14cbac7c2/5DF87F25/t51.2885-19/s150x150/30841415_118979385642417_7215694693940592640_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"emilyaharrington" }, "x":0.8378906, "y":0.4833903 } }, { "node":{ "user":{ "full_name":"Renan Ozturk", "id":"4326362", "is_verified":true, "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/0778dbbd7fdc7259847bd3107455345c/5DFF0858/t51.2885-19/10818112_782853255108470_946076930_a.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"renan_ozturk" }, "x":0.8527832, "y":0.13703613 } }, { "node":{ "user":{ "full_name":"Hilaree Nelson (ONeill)", "id":"14999609", "is_verified":true, "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/d8d07b6f6c6d8aac8954134754fe7c25/5E0528F1/t51.2885-19/s150x150/40542885_2133241663559023_7643319590893649920_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"hilareenelson" }, "x":0.6057129, "y":0.19656576 } }, { "node":{ "user":{ "full_name":"Cory Richards", "id":"19028900", "is_verified":true, "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/34065202c8a29a3c4b6e4ef8a02a0491/5E165C53/t51.2885-19/57674276_1190161047810775_5208218548769390592_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"coryrichards" }, "x":0.6813965, "y":0.8799967 } }, { "node":{ "user":{ "full_name":"National Geographic Travel", "id":"23947096", "is_verified":true, "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/e56487890a4a526c8e866eadbc3159fb/5DF5DD39/t51.2885-19/s150x150/12132724_850743081710560_180824582_a.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"natgeotravel" }, "x":0.35473633, "y":0.529777 } }, { "node":{ "user":{ "full_name":"National Geographic Adventure", "id":"414805671", "is_verified":true, "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/6c8274ce8b5c0eba7753b77e1a61800e/5DFA6E24/t51.2885-19/s150x150/12724642_511974045653432_550060489_a.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"natgeoadventure" }, "x":0.2944336, "y":0.7671224 } } ] }, "accessibility_caption":"\u041d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f: \u043d\u0435\u0431\u043e, \u043f\u0440\u0438\u0440\u043e\u0434\u0430 \u0438 \u043d\u0430 \u0443\u043b\u0438\u0446\u0435", "attribution":null, "shortcode":"B1l8BimhFr5", "edge_media_to_caption":{ "edges":[ { "node":{ "text":"Photo by @coryrichards | Believing and doubting are very much two sides of the same coin for me. It follows me through life.. I believe I can accomplish the goals I attempt, yet the journey of exploring this potential success is littered with doubt. Or another example would be: Doubt feeds my discernment on the mountain keeping me safe. At the same time, intense doubt can create stagnation, preventing me from going deeper or trying harder, which as result, could end in final failure. Join the conversation about this on my main feed: @coryrichards \nPictured here: An expedition teammate sets up a tent while on #expedition to attempt summiting Hkakabo Razi, Southeast Asia\u2019s tallest mountain. Shot #onassignment for #natgeo magazine\u2019s article \u201cHow A remote Peak in Myanmar Nearly Broke an Elite Team of Climbers\u201d. #followme @coryrichards for more stories about the tallest #mountains of the world shot #onassignment for #natgeo.\n\n#yeswesleptthere #travel #adventure #climbing #mountains #nature" } } ] }, "edge_media_preview_comment":{ "count":1, "page_info":{ "has_next_page":false, "end_cursor":null }, "edges":[ { "node":{ "id":"17981765863273328", "text":"\ud83d\ude0d", "created_at":1566748621, "did_report_as_spam":false, "owner":{ "id":"9065557070", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/4d50996537fb9c6ac3889c5c87e70911/5DFD7A80/t51.2885-19/s150x150/66647324_473121356862840_463404860746760192_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"xipolita_maria" }, "viewer_has_liked":false } } ] }, "gating_info":null, "media_preview":"ACoctWrYAxWtHJkc1z9vLitBJc1z83KzS1zU3ComK+tVPMzULyVTmLlLrFfUVX+T1FZjzFelVjcGldhYhDhcAVdjlrFVyTVxCcUpLUpGqJQKgkkP51XRiTipXNTHXQb7leRyCQeCKq76nkqrgVryk3P/2Q==", "comments_disabled":false, "taken_at_timestamp":1566748592, "edge_media_preview_like":{ "count":247, "edges":[ ] }, "edge_media_to_sponsor_user":{ "edges":[ ] }, "location":{ "id":"566972341", "has_public_page":true, "name":"Myanmar", "slug":"myanmar" }, "viewer_has_liked":false, "viewer_has_saved":false, "viewer_has_saved_to_collection":false, "viewer_in_photo_of_you":false, "viewer_can_reshare":true, "owner":{ "id":"414805671", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/6c8274ce8b5c0eba7753b77e1a61800e/5DFA6E24/t51.2885-19/s150x150/12724642_511974045653432_550060489_a.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"natgeoadventure", "followed_by_viewer":true, "full_name":"National Geographic Adventure", "is_private":false, "requested_by_viewer":false, "blocked_by_viewer":false, "has_blocked_viewer":false } } }, { "node":{ "__typename":"GraphImage", "id":"2118332148355221552", "dimensions":{ "height":1260, "width":1080 }, "display_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/737829f54a4db52c3d96a4d12e35cf01/5DFD5F4B/t51.2885-15/e35/67503943_151408589261654_3928871968013976403_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "display_resources":[ { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/0314f5bc174611bb6b7ff191be8bac33/5E09F0BD/t51.2885-15/sh0.08/e35/p640x640/67503943_151408589261654_3928871968013976403_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":640, "config_height":746 }, { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/df12b15d492d1866a0172a98fea6383e/5DF366BD/t51.2885-15/sh0.08/e35/p750x750/67503943_151408589261654_3928871968013976403_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":750, "config_height":875 }, { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/737829f54a4db52c3d96a4d12e35cf01/5DFD5F4B/t51.2885-15/e35/67503943_151408589261654_3928871968013976403_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":1080, "config_height":1260 } ], "follow_hashtag_info":null, "is_video":false, "should_log_client_event":false, "tracking_token":"eyJ2ZXJzaW9uIjo1LCJwYXlsb2FkIjp7ImlzX2FuYWx5dGljc190cmFja2VkIjp0cnVlLCJ1dWlkIjoiZDNkNWVkZTkzNjg3NDM0MmI5MzdmMGMzNDA1NWVlMTIyMTE4MzMyMTQ4MzU1MjIxNTUyIiwic2VydmVyX3Rva2VuIjoiMTU2Njc0ODY2MTIyMnwyMTE4MzMyMTQ4MzU1MjIxNTUyfDg3ODM4MzgxMTl8YjFhOTQ4OWYwMmNmNGM3NDcyN2NkZjUzZDE2YWZlYThmY2U3Nzg3YTY5NDQ0NDdkNjVkZjljNjFlOWU1MGFmOSJ9LCJzaWduYXR1cmUiOiIifQ==", "edge_media_to_tagged_user":{ "edges":[ ] }, "accessibility_caption":"\u041d\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0444\u043e\u0442\u043e.", "attribution":null, "shortcode":"B1l092TAMgw", "edge_media_to_caption":{ "edges":[ { "node":{ "text":"\u041f\u043e\u043b\u0443\u043e\u0441\u0442\u0440\u043e\u0432 \u0420\u044b\u0431\u0430\u0447\u0438\u0439, \u041c\u0443\u0440\u043c\u0430\u043d\u0441\u043a\u0430\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u044c. \u0410\u0432\u0442\u043e\u0440 \u0444\u043e\u0442\u043e: @ksergart." } } ] }, "edge_media_preview_comment":{ "count":12, "page_info":{ "has_next_page":true, "end_cursor":"QVFDNUtWVWFJaDBYc0xvRE52bHh4SFVCaGI3bV9VNnhzWTNDS0ZzRUQzS2ZiSG80cU5IZGtVMTROMm9oa0dac1pVbHhBS2ZJVjlkX3JBNV9EaXVtMWFscg==" }, "edges":[ { "node":{ "id":"17890215628384852", "text":"\u0411\u0443\u0434\u0442\u043e \u0441\u043a\u0430\u0437\u043a\u0430 \ud83d\udc9a", "created_at":1566747768, "did_report_as_spam":false, "owner":{ "id":"1318188656", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/ddae0523184feb0c3f7532b1116552f4/5E0BAB9A/t51.2885-19/s150x150/35999127_2123071171056159_1209990032148922368_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"elvira_mva" }, "viewer_has_liked":false } }, { "node":{ "id":"18075684361128313", "text":"\ud83d\udc4d", "created_at":1566748420, "did_report_as_spam":false, "owner":{ "id":"827758337", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/aa82522da7085d993a1a63584067dd77/5DF0BA2B/t51.2885-19/s150x150/12353182_1009321239130297_1860918634_a.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"petrkob62" }, "viewer_has_liked":false } } ] }, "gating_info":null, "media_preview":"ACQqgECSDKkGowhiPqKoWzKjZbOPatyLZJ91s+xrJ+76HO046bopPAHG5aznj2mt0x+Wcr0PUVDcW+4bh0oUiou2nQwmGDRUsi4bFFbGxMIyeasRK0ZBXrTIlT+Mj6DJ/wDrVJIFZfkJGOpIAz+XP4VDfQi5fNyxHQA/oajaUkfOxPfAxj6etUoJ0ZdjD6N3x70SIoOcZXsynBH1ByKiyQtiJ1BOefyNFRFVz95h9R/hxRWhQAqg55JHA9Pc/wBKcsm0YqseopaAsODnOTTmfP4VF3pwpjE3GikNFAz/2Q==", "comments_disabled":false, "taken_at_timestamp":1566744892, "edge_media_preview_like":{ "count":1757, "edges":[ ] }, "edge_media_to_sponsor_user":{ "edges":[ ] }, "location":null, "viewer_has_liked":false, "viewer_has_saved":false, "viewer_has_saved_to_collection":false, "viewer_in_photo_of_you":false, "viewer_can_reshare":true, "owner":{ "id":"22563005", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/adbf0833f39d8466c28cd856428cb57c/5DF0D946/t51.2885-19/s150x150/29416770_171824350185992_3381245009872289792_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"natgeomagazineru", "followed_by_viewer":true, "full_name":"National Geographic Russia", "is_private":false, "requested_by_viewer":false, "blocked_by_viewer":false, "has_blocked_viewer":false } } }, { "node":{ "__typename":"GraphImage", "id":"2118335134316253776", "dimensions":{ "height":1080, "width":1080 }, "display_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/bce316215da7fb723aae9918b9c788b9/5DF82138/t51.2885-15/e35/67887681_2465654650378600_5958631488163850516_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "display_resources":[ { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/9c10d2e28c91592f0193b0dc4e4e21db/5E0A2282/t51.2885-15/sh0.08/e35/s640x640/67887681_2465654650378600_5958631488163850516_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":640, "config_height":640 }, { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/177982c8ccc90e94d75f85dcf9b18433/5E0DA546/t51.2885-15/sh0.08/e35/s750x750/67887681_2465654650378600_5958631488163850516_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":750, "config_height":750 }, { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/bce316215da7fb723aae9918b9c788b9/5DF82138/t51.2885-15/e35/67887681_2465654650378600_5958631488163850516_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":1080, "config_height":1080 } ], "follow_hashtag_info":null, "is_video":false, "should_log_client_event":false, "tracking_token":"eyJ2ZXJzaW9uIjo1LCJwYXlsb2FkIjp7ImlzX2FuYWx5dGljc190cmFja2VkIjp0cnVlLCJ1dWlkIjoiZDNkNWVkZTkzNjg3NDM0MmI5MzdmMGMzNDA1NWVlMTIyMTE4MzM1MTM0MzE2MjUzNzc2Iiwic2VydmVyX3Rva2VuIjoiMTU2Njc0ODY2MTIyMnwyMTE4MzM1MTM0MzE2MjUzNzc2fDg3ODM4MzgxMTl8MDdkZTJjZjE4OWEwMmMwM2E1ZWExNWJmM2VlMzJjNmQ0MDAzNzcxNzgwZTJkYmU0ZDczNGNhOTg3YzIwY2Y5OCJ9LCJzaWduYXR1cmUiOiIifQ==", "edge_media_to_tagged_user":{ "edges":[ ] }, "accessibility_caption":"\u041d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f: \u0442\u0435\u043a\u0441\u0442", "attribution":null, "shortcode":"B1l1pTMJlJQ", "edge_media_to_caption":{ "edges":[ { "node":{ "text":"\u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0439\u0442\u0435 \u0441\u0432\u043e\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445\u00a0\ud83d\ude09\n\u2800\n#adme #adme_\u0432\u043e\u043f\u0440\u043e\u0441" } } ] }, "edge_media_preview_comment":{ "count":54, "page_info":{ "has_next_page":true, "end_cursor":"QVFBbk9vUFR3M0FCRFZMZE9LRTFHYjlKbHdvRlFxbVhZdUJoMFFjZzhPRUxYaEpELU5NYjRhQ3dWQWJET0VMcGJ6TWY4R0g2U2VSQm5SUXh4N2ZpbHBpYw==" }, "edges":[ { "node":{ "id":"18094140058027449", "text":"\u042f\u0431\u043b\u043e\u043a\u043e", "created_at":1566748247, "did_report_as_spam":false, "owner":{ "id":"10749647140", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/35267ebedde45d759e1d13e7cc8ccfc1/5DFC312A/t51.2885-19/s150x150/68706303_492164288009157_6648378867608190976_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"thisislauka" }, "viewer_has_liked":false } }, { "node":{ "id":"17900024605364359", "text":"\ud83c\udf4b", "created_at":1566748421, "did_report_as_spam":false, "owner":{ "id":"8441599909", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/29365d002b2a3e2fa551e6803d2c87c4/5DFCADF9/t51.2885-19/s150x150/66410920_2440993229292400_5166820540119252992_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"photo_by_vlados" }, "viewer_has_liked":false } } ] }, "gating_info":null, "media_preview":"ACoqzwtPC1IFqQJXPcRCFp22pwtLtpXEV9tG2pytNxRcCWOFjg4yOD16jP8A9arAjHTZz/vVVWpBQUT+XgZK9P8AaoMeOq/+Pf57VDSE07/1/SAe0ZPQY/HP41BSk0zNSIaGp4aq4pwpjJ91IXqLNNNFgHlqZuphptMR/9k=", "comments_disabled":false, "taken_at_timestamp":1566745248, "edge_media_preview_like":{ "count":561, "edges":[ ] }, "edge_media_to_sponsor_user":{ "edges":[ ] }, "location":null, "viewer_has_liked":false, "viewer_has_saved":false, "viewer_has_saved_to_collection":false, "viewer_in_photo_of_you":false, "viewer_can_reshare":true, "owner":{ "id":"2779425302", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/62dd5481e860975939110e0651cf9499/5E08C764/t51.2885-19/s150x150/12816771_994305067322963_421387549_a.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"adme.ru", "followed_by_viewer":true, "full_name":"AdMe", "is_private":false, "requested_by_viewer":false, "blocked_by_viewer":false, "has_blocked_viewer":false } } }, { "node":{ "__typename":"GraphImage", "id":"2118305769246977062", "dimensions":{ "height":1349, "width":1080 }, "display_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/d4d22101153d599c04ac36ead09e446f/5E008836/t51.2885-15/e35/p1080x1080/67303980_161116331703747_7430462062728824761_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "display_resources":[ { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/93653283a63e13cca89203de4c9d6724/5DF766D3/t51.2885-15/sh0.08/e35/p640x640/67303980_161116331703747_7430462062728824761_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":640, "config_height":799 }, { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/1e32a346c9a3949c35ae6225f133c5f2/5DF18DD3/t51.2885-15/sh0.08/e35/p750x750/67303980_161116331703747_7430462062728824761_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":750, "config_height":937 }, { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/d4d22101153d599c04ac36ead09e446f/5E008836/t51.2885-15/e35/p1080x1080/67303980_161116331703747_7430462062728824761_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":1080, "config_height":1349 } ], "follow_hashtag_info":null, "is_video":false, "should_log_client_event":false, "tracking_token":"eyJ2ZXJzaW9uIjo1LCJwYXlsb2FkIjp7ImlzX2FuYWx5dGljc190cmFja2VkIjp0cnVlLCJ1dWlkIjoiZDNkNWVkZTkzNjg3NDM0MmI5MzdmMGMzNDA1NWVlMTIyMTE4MzA1NzY5MjQ2OTc3MDYyIiwic2VydmVyX3Rva2VuIjoiMTU2Njc0ODY2MTIyMnwyMTE4MzA1NzY5MjQ2OTc3MDYyfDg3ODM4MzgxMTl8NTVlZDEyYzAzNjMwMWQ4ZDgzOTdmMWJlZDgyMWY5ZmM2ZmRiYmY3ZDBiNTNjODNlMTAxNjAxNWQ5ZjU4MTVlOSJ9LCJzaWduYXR1cmUiOiIifQ==", "edge_media_to_tagged_user":{ "edges":[ ] }, "accessibility_caption":"\u041d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f: \u043e\u0434\u0438\u043d \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a, \u043b\u044e\u0434\u0438 \u0441\u0438\u0434\u044f\u0442, \u0431\u043e\u0440\u043e\u0434\u0430, \u0432 \u043f\u043e\u043c\u0435\u0449\u0435\u043d\u0438\u0438 \u0438 \u0447\u0430\u0441\u0442\u044c \u0442\u0435\u043b\u0430 \u043a\u0440\u0443\u043f\u043d\u044b\u043c \u043f\u043b\u0430\u043d\u043e\u043c", "attribution":null, "shortcode":"B1lu9-1oGwm", "edge_media_to_caption":{ "edges":[ { "node":{ "text":"Sunday is for shopping! Get inspired by @anthony_colette who is wearing our new Grand Petite in Melrose. Tap to shop the look! #DanielWellington" } } ] }, "edge_media_preview_comment":{ "count":7, "page_info":{ "has_next_page":true, "end_cursor":"QVFEOHp1TzZoOHE0V0VnXzNfVEFiQmZQY3hHa3daNmRUSGNyVkpxNWpZNVNBWkpPanNuNmdLdTRIZG12Rmd3MzlhSVFMM1VUSm5zVERGWmdCOFE3NkdVSQ==" }, "edges":[ { "node":{ "id":"17883424486407650", "text":"#cool", "created_at":1566747095, "did_report_as_spam":false, "owner":{ "id":"3023386633", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/5590a713d4dde5cdba6bdc9b45c87f94/5E0FC332/t51.2885-19/s150x150/65580253_2161849217447103_2123178831798861824_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"arcadieus_arcd" }, "viewer_has_liked":false } }, { "node":{ "id":"17854795318526180", "text":"Woow \u2764\ufe0f", "created_at":1566747735, "did_report_as_spam":false, "owner":{ "id":"5908938021", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/52a8f3c8d912f774be052aee4c1f445b/5DFED1BC/t51.2885-19/s150x150/65314269_521974431700622_5216210486474833920_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"capturemoments__" }, "viewer_has_liked":false } } ] }, "gating_info":null, "media_preview":"ACEqdNcxx98t6Dn/AOtWbZxJI7GT7iDOPX/PWqm8DGBgd607VVSMyH5iw4PoeRioeiLjqyrcRJHiWM456VqqMgE+gqo86fIjgBcjO3/Z7n6k1LLqUacKNxo1YO1ybYaKo/2m/wDd/nRRYVyDTyomDOQFUHk4HXjuR/X6VozoRzG2C3p6n6evtWECCPeprSfypM5wCMfT0P4Gm11BO2gm0qTu4PcentWjaIWBZQuQerDn8KoM+5iW5PPPue9aemtw4PqD/OjoJbljbL6r+VFWcj1H5iipLORFJTn60ytTItAF13AHj9ff/Gmn9KvCqX8VSMOPSilop3A//9k=", "comments_disabled":false, "taken_at_timestamp":1566741747, "edge_media_preview_like":{ "count":6507, "edges":[ ] }, "edge_media_to_sponsor_user":{ "edges":[ ] }, "location":null, "viewer_has_liked":false, "viewer_has_saved":false, "viewer_has_saved_to_collection":false, "viewer_in_photo_of_you":false, "viewer_can_reshare":true, "owner":{ "id":"47340181", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/200d102d62d14fdc91b31fcae730ebc4/5DF76D17/t51.2885-19/s150x150/36159707_670363839963003_7852937393920278528_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"danielwellington", "followed_by_viewer":true, "full_name":"Daniel Wellington", "is_private":false, "requested_by_viewer":false, "blocked_by_viewer":false, "has_blocked_viewer":false } } }, { "node":{ "__typename":"GraphImage", "id":"2118272670440360478", "dimensions":{ "height":1349, "width":1080 }, "display_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/437b34008def65237fd1b313fad3ab7b/5DDA21AC/t51.2885-15/e35/p1080x1080/67787998_3521450197881108_6632484576980197817_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "display_resources":[ { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/3c8fb0eb371ac8523281acb4132498c8/5E076C69/t51.2885-15/sh0.08/e35/p640x640/67787998_3521450197881108_6632484576980197817_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":640, "config_height":799 }, { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/a172a928cd4caebe457e999d76d63040/5DF25CAD/t51.2885-15/sh0.08/e35/p750x750/67787998_3521450197881108_6632484576980197817_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":750, "config_height":936 }, { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/437b34008def65237fd1b313fad3ab7b/5DDA21AC/t51.2885-15/e35/p1080x1080/67787998_3521450197881108_6632484576980197817_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":1080, "config_height":1349 } ], "follow_hashtag_info":null, "is_video":false, "should_log_client_event":false, "tracking_token":"eyJ2ZXJzaW9uIjo1LCJwYXlsb2FkIjp7ImlzX2FuYWx5dGljc190cmFja2VkIjp0cnVlLCJ1dWlkIjoiZDNkNWVkZTkzNjg3NDM0MmI5MzdmMGMzNDA1NWVlMTIyMTE4MjcyNjcwNDQwMzYwNDc4Iiwic2VydmVyX3Rva2VuIjoiMTU2Njc0ODY2MTIyM3wyMTE4MjcyNjcwNDQwMzYwNDc4fDg3ODM4MzgxMTl8NTExZTA0Y2M2ZmFmY2UyNGVmNjdhMThiMmZkOWE5MzhmOTYyMDllZmMxMTk0MWY5ZWI2NjM1MWQ4YWFlNWNkNCJ9LCJzaWduYXR1cmUiOiIifQ==", "edge_media_to_tagged_user":{ "edges":[ ] }, "accessibility_caption":"\u041d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f: \u043d\u0430 \u0443\u043b\u0438\u0446\u0435 \u0438 \u043f\u0440\u0438\u0440\u043e\u0434\u0430", "attribution":null, "shortcode":"B1lncVLBAoe", "edge_media_to_caption":{ "edges":[ { "node":{ "text":"Photo @coreyrichproductions | For most of us, every day is a chance to celebrate climbing around the world. Still, happy global climbing day to everyone who has built a life around chasing rock, making friends in different places, and having incredible adventures with people you love." } } ] }, "edge_media_preview_comment":{ "count":71, "page_info":{ "has_next_page":true, "end_cursor":"QVFEeE50bWJ4XzNSY0FWclVyRkpKcThOQkZVSmdlM3lyZ0tjckxpS0djMUlCdlA0d2J0eXgwU3pER0thRzhvZ0hXei0tcGprdy13NzJXWnh5bVlPb1pyQQ==" }, "edges":[ { "node":{ "id":"17862621742481329", "text":"Amazing", "created_at":1566748582, "did_report_as_spam":false, "owner":{ "id":"2137876030", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/c0879fb2bdc75469c347736caeb177f6/5DF3DC1E/t51.2885-19/s150x150/12950311_1031636496901792_515202217_a.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"ahmad.qabaa" }, "viewer_has_liked":false } }, { "node":{ "id":"17922483298316433", "text":"Courage and strength\ud83d\udc99\ud83c\udf35\ud83d\ude0e", "created_at":1566748648, "did_report_as_spam":false, "owner":{ "id":"8621536104", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/e328e713e61401462754448c98026483/5DD98E7F/t51.2885-19/s150x150/41280361_319736438803081_2140821784356716544_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"janiceimbeault" }, "viewer_has_liked":false } } ] }, "gating_info":null, "media_preview":"ACEq5miniNj0BPOOnf0+tMoAKKKKACiiigDqo1VBgDvu/GkaCJzuZQTnPPf6+o9B0FVxLTvNrqsc9ylc6eAGeM+4X278/wAqySMV0ZkBGDyDWTdgM2R2AB9//r1lKNtUaRlfQpUUuKKyNC95hp3mmqpNJW3OzHkRYaY9BUGaSkNQ23uaJJbC0U2ikM//2Q==", "comments_disabled":false, "taken_at_timestamp":1566737801, "edge_media_preview_like":{ "count":21183, "edges":[ ] }, "edge_media_to_sponsor_user":{ "edges":[ ] }, "location":null, "viewer_has_liked":false, "viewer_has_saved":false, "viewer_has_saved_to_collection":false, "viewer_in_photo_of_you":false, "viewer_can_reshare":true, "owner":{ "id":"414805671", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/6c8274ce8b5c0eba7753b77e1a61800e/5DFA6E24/t51.2885-19/s150x150/12724642_511974045653432_550060489_a.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"natgeoadventure", "followed_by_viewer":true, "full_name":"National Geographic Adventure", "is_private":false, "requested_by_viewer":false, "blocked_by_viewer":false, "has_blocked_viewer":false } } }, { "node":{ "__typename":"GraphImage", "id":"2118327269893232788", "dimensions":{ "height":1350, "width":1080 }, "display_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/26e647d89ce68cf54d82bfa1cec7f185/5DDC96D3/t51.2885-15/fr/e15/p1080x1080/67479187_1080461632158935_7347868240441614334_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "display_resources":[ { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/c9fd2abd0cb13cd260ba38c3bbfec748/5E05151B/t51.2885-15/sh0.08/e35/p640x640/67479187_1080461632158935_7347868240441614334_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":640, "config_height":800 }, { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/83a3b2437c88a515cd7127fb74614606/5DDA05DF/t51.2885-15/sh0.08/e35/p750x750/67479187_1080461632158935_7347868240441614334_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":750, "config_height":937 }, { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/26e647d89ce68cf54d82bfa1cec7f185/5DDC96D3/t51.2885-15/fr/e15/p1080x1080/67479187_1080461632158935_7347868240441614334_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":1080, "config_height":1350 } ], "follow_hashtag_info":null, "is_video":false, "should_log_client_event":false, "tracking_token":"eyJ2ZXJzaW9uIjo1LCJwYXlsb2FkIjp7ImlzX2FuYWx5dGljc190cmFja2VkIjp0cnVlLCJ1dWlkIjoiZDNkNWVkZTkzNjg3NDM0MmI5MzdmMGMzNDA1NWVlMTIyMTE4MzI3MjY5ODkzMjMyNzg4Iiwic2VydmVyX3Rva2VuIjoiMTU2Njc0ODY2MTIyM3wyMTE4MzI3MjY5ODkzMjMyNzg4fDg3ODM4MzgxMTl8NjIyMTFhZWY2M2QwOTcyNDgwNTIzYzExYjUyMzJmZGRkODcyNWVmMTdkNzcwYzZkOTllYTI1ODFhYmZjYmNmOSJ9LCJzaWduYXR1cmUiOiIifQ==", "edge_media_to_tagged_user":{ "edges":[ ] }, "accessibility_caption":"\u041d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f: \u043d\u0435\u0431\u043e, \u0433\u043e\u0440\u0430, \u043d\u0430 \u0443\u043b\u0438\u0446\u0435 \u0438 \u0435\u0434\u0430", "attribution":null, "shortcode":"B1lz224AliU", "edge_media_to_caption":{ "edges":[ { "node":{ "text":"repost @yogabyada : apero with a view \ud83d\ude0d\u2600 #myasconalocarno .\n.\n.\n#switzerland #urlaub #suisse #schweiz #landschaft #switzerland\ud83c\udde8\ud83c\udded #myswitzerland #inlovewithswitzerland #svizzera #visitswitzerland #ticino #switzerlandwonderland #switzerlandpictures #switzerland_vacations #blickheimat #amazingswitzerland #tessin #ticinomoments #visitticino #reise #reisen #reizen #voyage #voyages #voyager #ferien #vakantie #vacances" } } ] }, "edge_media_preview_comment":{ "count":1, "page_info":{ "has_next_page":false, "end_cursor":null }, "edges":[ { "node":{ "id":"17888396074385239", "text":"\u2665\ufe0f\ud83c\udde8\ud83c\udded\ud83c\udf79\ud83c\udfe8\ud83c\udf0a\u2600\ufe0f\ud83e\udd20\ud83d\udc4d", "created_at":1566745792, "did_report_as_spam":false, "owner":{ "id":"9489672931", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/8cb5d0fbc56bb46034a11a83256753f9/5E0F79A5/t51.2885-19/s150x150/59814578_318105222220041_1893677838452654080_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"sandrolandi88" }, "viewer_has_liked":false } } ] }, "gating_info":null, "media_preview":"ACEqsBKesZNZXnzYxk4/X8+tXLe9kHBG4evQ/wD166LmFh8NsjSSFlBIfHI/2Qa0UQDtmspLtw8m0Y3MDzz/AAgU57ic8BsfTj9ako19ntRWBsm9/wDvr/69FAFaRtncHPpk/wAqYk5z6j6VblgBKhMLxnnj1/OpUsRjJJz2yMf5FYuVtWacqK0DFmbA68nLY6D6elSCcH1H4A/4VrR2oEW1TyQcFh6/TqB29qxZrWW2OHHH94dP/rfjSTY7Ik84/wB4/wDfH/16Kq7hRTu+4rLsdU/I4AYjoD29/wAKy2tJdxkLDex5AJ/zxVOFiZASSTuHf3roqT0K3Mzy5YVy7gDGBkknn04z9PSq7XKmAw8t7uc5z+vB6VJqRO5R7H+dU5VAgBxyS+T+FCXUL9DH80+tFRUUxH//2Q==", "comments_disabled":false, "taken_at_timestamp":1566744310, "edge_media_preview_like":{ "count":276, "edges":[ ] }, "edge_media_to_sponsor_user":{ "edges":[ ] }, "location":{ "id":"2368275479952352", "has_public_page":true, "name":"Hotel Casa Berno", "slug":"hotel-casa-berno" }, "viewer_has_liked":false, "viewer_has_saved":false, "viewer_has_saved_to_collection":false, "viewer_in_photo_of_you":false, "viewer_can_reshare":true, "owner":{ "id":"10326379", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/61a298fb784d22c06efc77d9d5c5773c/5DDBF4FA/t51.2885-19/10958802_763286217112123_367851535_a.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"ascona_locarno", "followed_by_viewer":true, "full_name":"#MyAsconaLocarno", "is_private":false, "requested_by_viewer":false, "blocked_by_viewer":false, "has_blocked_viewer":false } } }, { "node":{ "__typename":"GraphImage", "id":"2118271896163192516", "dimensions":{ "height":1350, "width":1080 }, "display_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/9e429a54698127e4232e575e00115e18/5DF001DA/t51.2885-15/fr/e15/p1080x1080/68694466_466076210902073_853238738301639785_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "display_resources":[ { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/37d826be8c9d7f9b5840d90faa0769e7/5DFD78E3/t51.2885-15/sh0.08/e35/p640x640/68694466_466076210902073_853238738301639785_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":640, "config_height":800 }, { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/233b68b468dad0b6251556f2f6d377d1/5E0CFB1C/t51.2885-15/sh0.08/e35/p750x750/68694466_466076210902073_853238738301639785_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":750, "config_height":937 }, { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/9e429a54698127e4232e575e00115e18/5DF001DA/t51.2885-15/fr/e15/p1080x1080/68694466_466076210902073_853238738301639785_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":1080, "config_height":1350 } ], "follow_hashtag_info":null, "is_video":false, "should_log_client_event":false, "tracking_token":"eyJ2ZXJzaW9uIjo1LCJwYXlsb2FkIjp7ImlzX2FuYWx5dGljc190cmFja2VkIjp0cnVlLCJ1dWlkIjoiZDNkNWVkZTkzNjg3NDM0MmI5MzdmMGMzNDA1NWVlMTIyMTE4MjcxODk2MTYzMTkyNTE2Iiwic2VydmVyX3Rva2VuIjoiMTU2Njc0ODY2MTIyM3wyMTE4MjcxODk2MTYzMTkyNTE2fDg3ODM4MzgxMTl8ZDExMTdlNmU0ZDM0Y2Y2NGZlODYyYTUxZjY5NTkxNmY4NTk1ZTFiNGYzYmFjNzhkOTg0OTNiMWYwZTEwZjdiNSJ9LCJzaWduYXR1cmUiOiIifQ==", "edge_media_to_tagged_user":{ "edges":[ ] }, "accessibility_caption":"\u041d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f: \u0433\u043e\u0440\u0430, \u043d\u0435\u0431\u043e, \u043d\u0430 \u0443\u043b\u0438\u0446\u0435, \u043f\u0440\u0438\u0440\u043e\u0434\u0430 \u0438 \u0432\u043e\u0434\u0430", "attribution":null, "shortcode":"B1lnREEgA7E", "edge_media_to_caption":{ "edges":[ { "node":{ "text":"\ud83d\udccdMALLORCA \ud83c\uddea\ud83c\uddf8\n-\nNestled perfectly between the mountains and the sea, this little group of houses seemed to melt right into the landscape. The pop of green from the surrounding nature brought this charming scene to life. -\n\ufffdPhoto by @vickarellaaa #visitmallorca #mallorca #spain #discovermallorca #ig_mallorca #earthpix #tourtheplanet #discoverglobe #ourplanetdaily #earthfocus #amazingdestinations #cheapflights #jacksflightclub" } } ] }, "edge_media_preview_comment":{ "count":4, "page_info":{ "has_next_page":true, "end_cursor":"QVFENTd4Wl93N3p5TGt0eHFxWnNHc1A2QnZoay1iWlpUejUxbWVaZzdDT0ZsWTdFRVB4YUtScGloTGYwWmgxZm1VV085NkFQbmRqT2lDQTg5eUUtN1gzbQ==" }, "edges":[ { "node":{ "id":"17981334010272066", "text":"@benrichardson23", "created_at":1566741489, "did_report_as_spam":false, "owner":{ "id":"338824606", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/12cdd412282fd2612c2a558c6c1c424e/5DF20C07/t51.2885-19/s150x150/39336092_1694262494012680_2312725105895014400_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"britanyleigh_" }, "viewer_has_liked":false } }, { "node":{ "id":"17867827162457041", "text":"@cristina_f_dasilva", "created_at":1566743315, "did_report_as_spam":false, "owner":{ "id":"1139258710", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/b28175041513b9672e7f5ca479735304/5DF088CF/t51.2885-19/s150x150/30589941_540396623023288_5576886880621821952_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"ddsergio07" }, "viewer_has_liked":false } } ] }, "gating_info":null, "media_preview":"ACEq30kVxkYINSZFctBeFOD0PJ9a0hcjbu3ZUDJ//V1oEa+RUUkqxjJIrBk1Mn7oyPWqcl075LYwe3+eaTb6DNv7Sv8Ae/nRXPfaX/vfoKKm0guidbU7vmI+Xrzx9OtJsBZhjP8AdAJx+ffiriwpuLHqef8A9Xv+NJIoLZHDHpzyfb6VoSUY+Tjpx1qRrJgNy/MP55qVcRnLckZPzDH4jmpnk80dSp4xg/n3pDKPlyf3RRV3c3qKKVgJ4wB7/Wq28qxP5VNVd+9bGRRd2c/NzjpTDLjripHqB6llIf5lFQ0VJR//2Q==", "comments_disabled":false, "taken_at_timestamp":1566737709, "edge_media_preview_like":{ "count":353, "edges":[ ] }, "edge_media_to_sponsor_user":{ "edges":[ ] }, "location":null, "viewer_has_liked":false, "viewer_has_saved":false, "viewer_has_saved_to_collection":false, "viewer_in_photo_of_you":false, "viewer_can_reshare":true, "owner":{ "id":"3945672602", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/12bc576c6aac1a0e7fea5cbbe72fab68/5DFCC502/t51.2885-19/s150x150/26430072_177513656188084_7526879711784337408_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"jacksflightclub", "followed_by_viewer":true, "full_name":"Jack's Flight Club", "is_private":false, "requested_by_viewer":false, "blocked_by_viewer":false, "has_blocked_viewer":false } } }, { "node":{ "__typename":"GraphVideo", "id":"2118325174486904341", "dimensions":{ "height":937, "width":750 }, "display_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/13be8d30a48eb14ed80671b299ef12b9/5D64C46D/t51.2885-15/e35/69264712_912030972487091_8762021111054461246_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "display_resources":[ { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/ecdf9ae3cf91b76e7d42650ea14b984b/5D65BB5B/t51.2885-15/sh0.08/e35/p640x640/69264712_912030972487091_8762021111054461246_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":640, "config_height":800 }, { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/13be8d30a48eb14ed80671b299ef12b9/5D64C46D/t51.2885-15/e35/69264712_912030972487091_8762021111054461246_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":750, "config_height":937 }, { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/13be8d30a48eb14ed80671b299ef12b9/5D64C46D/t51.2885-15/e35/69264712_912030972487091_8762021111054461246_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":1080, "config_height":1350 } ], "follow_hashtag_info":null, "is_video":true, "should_log_client_event":false, "tracking_token":"eyJ2ZXJzaW9uIjo1LCJwYXlsb2FkIjp7ImlzX2FuYWx5dGljc190cmFja2VkIjp0cnVlLCJ1dWlkIjoiZDNkNWVkZTkzNjg3NDM0MmI5MzdmMGMzNDA1NWVlMTIyMTE4MzI1MTc0NDg2OTA0MzQxIiwic2VydmVyX3Rva2VuIjoiMTU2Njc0ODY2MTIyNHwyMTE4MzI1MTc0NDg2OTA0MzQxfDg3ODM4MzgxMTl8ZDA1NTk3MzQ4NWMzNDRlYWVhNDI3NGU5YmY2N2YxM2NjYmQ0NjczNjE3ZGFhZTUwMzcwOTM4OWY1OTRjMmYzMyJ9LCJzaWduYXR1cmUiOiIifQ==", "edge_media_to_tagged_user":{ "edges":[ ] }, "dash_info":{ "is_dash_eligible":true, "video_dash_manifest":"\n \n \n \n https://instagram.fhel2-1.fna.fbcdn.net/v/t50.2886-16/69645550_480225799441722_2175072939320684476_n.mp4?_nc_ht=instagram.fhel2-1.fna.fbcdn.net&oh=8e9fe032ea72563a8391957fe1e0a895&oe=5D6536D1\n \n \n \n \n \n https://instagram.fhel2-1.fna.fbcdn.net/v/t50.2886-16/70183676_117711399319110_8282320485829783906_n.mp4?_nc_ht=instagram.fhel2-1.fna.fbcdn.net&oh=6bd92b8c63be58720bbe47d6397f6e02&oe=5D65BD57\n \n \n \n \n \n https://instagram.fhel2-1.fna.fbcdn.net/v/t50.2886-16/69881952_350061425899503_7193270124713242713_n.mp4?_nc_ht=instagram.fhel2-1.fna.fbcdn.net&oh=9c1db1af31c9b1171a2d03408111fb4d&oe=5D658FEF\n \n \n \n \n \n https://instagram.fhel2-1.fna.fbcdn.net/v/t50.2886-16/70118498_425225504779268_5310078796542193137_n.mp4?_nc_ht=instagram.fhel2-1.fna.fbcdn.net&oh=ade57d5a98faec912206f45a540d029f&oe=5D65C070\n \n \n \n \n \n \n \n \n https://instagram.fhel2-1.fna.fbcdn.net/v/t50.2886-16/69832620_374445850122732_9090818804720417562_n.mp4?_nc_ht=instagram.fhel2-1.fna.fbcdn.net&oh=608f815048c27e043dc498ecdfcea94c&oe=5D6594B8\n \n \n \n \n \n \n", "number_of_qualities":4 }, "video_url":"https://scontent.cdninstagram.com/vp/1011cfdd3e091df8c1ad7564efa6964f/5D64B41F/t50.2886-16/69649533_141762473707062_42645298134425542_n.mp4?_nc_ht=scontent.cdninstagram.com", "video_view_count":567703, "attribution":null, "shortcode":"B1lzYXYDy4V", "edge_media_to_caption":{ "edges":[ { "node":{ "text":"Video by Ronan Donovan @ronan_donovan | As with many social mammals, the adolescent males always seem to engage in the roughest play. Here, two yearling arctic wolves play with 10-week-old pups on the tundra of Canada\u2019s Ellesmere Island. Even though Gray Mane, as he's called, was only a year old, he was the largest wolf in his pack and he clearly liked to play a little rough with the small pups. \nAs with humans, play reinforces social bonds, promotes physical awareness, and just plain feels good. Check out the current issue of National Geographic for my article on the wolves (written by Neil Shea @neilshea13). A related three-part series on @natgeowild premieres tonight, August 25 at 8 p.m. EST, directed by Tony Gerber and filmed by Luke Padgett and me." } } ] }, "edge_media_preview_comment":{ "count":745, "page_info":{ "has_next_page":true, "end_cursor":"QVFDeGZZQzFMNVZFUVpUbVREVlRaZDJRZmh1dEp4N1lDOENPRmt1OFlfdVNFUDVvQXJ1NGVKUXVwTnJHdEJFZV9ENXQtd3lUUlM5M2MwVGhpNkhjQ2U0dQ==" }, "edges":[ { "node":{ "id":"18023172757222524", "text":"Superb!!!!!", "created_at":1566748647, "did_report_as_spam":false, "owner":{ "id":"1697221883", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/d5b51f68d742d6eec423e0dcca920832/5DF7CBDC/t51.2885-19/s150x150/12120393_999447203470795_784571526_a.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"fernandacremilde" }, "viewer_has_liked":false } }, { "node":{ "id":"17911987840339602", "text":"This guy has to be the best", "created_at":1566748654, "did_report_as_spam":false, "owner":{ "id":"11707329041", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/74f911388bb105752598dcfd75ca7337/5E0EEAE2/t51.2885-19/s150x150/59919097_331233930837803_9049611661652000768_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"jeremyakin_" }, "viewer_has_liked":false } } ] }, "gating_info":null, "media_preview":"ACEqhFs3qKBbZP3v0qVZMHB6fypcjsQcdfX2pDIDaYGQd36GqzKV61aMpUZHFNkIIDdSaAKePeip+KKVx2HCTnHelU7c46t1pEXOTTjGexAB6g0wIRwCW5wM07duG7HHb/PvUoQL1OfpUQfrx7UgG5PpRS80UhkoYj3PrSFmpppe1FwsIcmjmlNMzQAbj7UUlFMR/9k=", "comments_disabled":false, "taken_at_timestamp":1566744093, "edge_media_preview_like":{ "count":173756, "edges":[ { "node":{ "id":"320965496", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/26f2a6b06a14d18ff8a1915317b7561e/5DF8A6A4/t51.2885-19/s150x150/40533016_1968510403450030_7907013785250955264_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"irinchik55" } } ] }, "edge_media_to_sponsor_user":{ "edges":[ ] }, "location":null, "viewer_has_liked":false, "viewer_has_saved":false, "viewer_has_saved_to_collection":false, "viewer_in_photo_of_you":false, "viewer_can_reshare":true, "owner":{ "id":"787132", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/06ec75947ace6228666ef7ac7c8d9e1b/5E1141E8/t51.2885-19/s150x150/13597791_261499887553333_1855531912_a.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"natgeo", "followed_by_viewer":true, "full_name":"National Geographic", "is_private":false, "requested_by_viewer":false, "blocked_by_viewer":false, "has_blocked_viewer":false } } }, { "node":{ "__typename":"GraphVideo", "id":"2117022749628464153", "dimensions":{ "height":422, "width":750 }, "display_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/0e69ec5084ff3c9ede40d3159f8e6c26/5D65210A/t51.2885-15/e35/67119652_2559484460769742_3380884424279150627_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "display_resources":[ { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/745529ffa742381f0e885ad745152391/5D652070/t51.2885-15/sh0.08/e35/s640x640/67119652_2559484460769742_3380884424279150627_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":640, "config_height":360 }, { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/0e69ec5084ff3c9ede40d3159f8e6c26/5D65210A/t51.2885-15/e35/67119652_2559484460769742_3380884424279150627_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":750, "config_height":422 }, { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/0e69ec5084ff3c9ede40d3159f8e6c26/5D65210A/t51.2885-15/e35/67119652_2559484460769742_3380884424279150627_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":1080, "config_height":609 } ], "follow_hashtag_info":null, "is_video":true, "should_log_client_event":false, "tracking_token":"eyJ2ZXJzaW9uIjo1LCJwYXlsb2FkIjp7ImlzX2FuYWx5dGljc190cmFja2VkIjp0cnVlLCJ1dWlkIjoiZDNkNWVkZTkzNjg3NDM0MmI5MzdmMGMzNDA1NWVlMTIyMTE3MDIyNzQ5NjI4NDY0MTUzIiwic2VydmVyX3Rva2VuIjoiMTU2Njc0ODY2MTIyNHwyMTE3MDIyNzQ5NjI4NDY0MTUzfDg3ODM4MzgxMTl8ODYzN2Y4NDFlNzNlYmQ5YjM0NjE1ZjkxOWQzMmZlZDViZGYxYzYzZGVmODI4MDY1MjkxNTUwNWEwYmYzNTEyZCJ9LCJzaWduYXR1cmUiOiIifQ==", "edge_media_to_tagged_user":{ "edges":[ ] }, "dash_info":{ "is_dash_eligible":true, "video_dash_manifest":"\n \n \n \n https://instagram.fhel2-1.fna.fbcdn.net/v/t50.2886-16/69414956_547626535980296_8152974537214640359_n.mp4?_nc_ht=instagram.fhel2-1.fna.fbcdn.net&oh=df28f713b5f700d0f1d561374fde63c6&oe=5D65B685\n \n \n \n \n \n \n \n \n https://instagram.fhel2-1.fna.fbcdn.net/v/t50.2886-16/69600379_665246090552701_572347131944147546_n.mp4?_nc_ht=instagram.fhel2-1.fna.fbcdn.net&oh=704693dd3a1591790d21b88563f39423&oe=5D653B89\n \n \n \n \n \n \n", "number_of_qualities":1 }, "video_url":"https://scontent.cdninstagram.com/vp/ca404406fa1161b8c621bca6dc651fbc/5D65BE04/t50.2886-16/69750299_170045060719808_7002627152866847262_n.mp4?_nc_ht=scontent.cdninstagram.com", "video_view_count":776, "attribution":null, "shortcode":"B1hLPltBnwZg1BhgTymFZBu_SMeXTQBw0o7Kx40", "edge_media_to_caption":{ "edges":[ { "node":{ "text":"\u041f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435! \u0414\u0435\u043d\u0435\u0436\u043d\u0430\u044f \u0447\u0430\u043a\u0440\u0430! \u0414\u0435\u043d\u0435\u0436\u043d\u0430\u044f \u041c\u0435\u0434\u0438\u0442\u0430\u0446\u0438\u044f! \u0410\u043b\u043b\u0438\u043b\u0443\u044f! #227\n\n\u041f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u0438\u0434\u0435\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043c\u043e\u0435\u043c \u044e\u0442\u0443\u0431 \u043a\u0430\u043d\u0430\u043b\u0435.\n\n#\u0441\u043c\u044b\u0441\u043b\u0436\u0438\u0437\u043d\u0438 #\u0434\u0443\u0445\u043e\u0432\u043d\u043e\u0441\u0442\u044c #\u0430\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440\u043a\u043e\u0440\u043e\u043b\u044c #\u0434\u0437\u0435\u043d #\u043c\u0430\u0433\u0438\u044f #\u0430\u0441\u0442\u0440\u043e\u043b\u043e\u0433\u0438\u044f #\u0441\u0430\u043c\u043e\u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435 #\u0441\u0430\u043c\u043e\u043f\u043e\u0437\u043d\u0430\u043d\u0438\u0435\n#\u043f\u0441\u0438\u0445\u043e\u043b\u043e\u0433\u0438\u044f #\u0442\u0435\u043e\u043b\u043e\u0433\u0438\u044f #\u0431\u0443\u0434\u0434\u0438\u0437\u043c #\u0439\u043e\u0433\u0430 #\u0441\u0430\u043c\u043e\u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435 #\u0441\u043e\u0446\u0438\u043e\u043b\u043e\u0433\u0438\u044f #\u043b\u0430\u0439\u0444\u0445\u0430\u043a #\u0444\u0438\u043b\u043e\u0441\u043e\u0444\u0438\u044f #\u043c\u0435\u0434\u0438\u0442\u0430\u0446\u0438\u044f" } } ] }, "edge_media_preview_comment":{ "count":2, "page_info":{ "has_next_page":false, "end_cursor":null }, "edges":[ { "node":{ "id":"17971027423303829", "text":"\ud83d\udc4d", "created_at":1566632816, "did_report_as_spam":false, "owner":{ "id":"5614861126", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/d2b48cf5e1baf77aca502892b92e5a9b/5DF8C99F/t51.2885-19/s150x150/35988631_1734823516608919_2917821848269881344_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"guryanova_natalya_555" }, "viewer_has_liked":false } }, { "node":{ "id":"17846204974594318", "text":"\u0412 \u0414\u043d\u0435\u0432\u043d\u0438\u043a\u0435 \u043e\u0431\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u0441\u0442\u0432 \u043c\u043e\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u043b\u043e \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u043d\u0430 29.06. \u041f\u043b\u0430\u043d\u0438\u0440\u0443\u044e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0443 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c.", "created_at":1566741569, "did_report_as_spam":false, "owner":{ "id":"728458486", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/eb3ee5eb1ec510158bd7549df47a337f/5DFD0D63/t51.2885-19/s150x150/52328454_325651801433400_6764441670063751168_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"natalia_peshkova_" }, "viewer_has_liked":false } } ] }, "gating_info":null, "media_preview":"ACoXuItThcDNRpTpZRGhJpgRLdI0nlYOem7+HOM4+v8AXip2UVipI6vkL8zHcBjjjvjvWssnmKGPB6EehHWgCtKoqkVFXJTVSgZoK1MuFDoQelFFAjG3FjliSRwD3Hpj0/CtaEKicZ+b5jk5JJHNFFICKQ1XzRRTA//Z", "comments_disabled":false, "taken_at_timestamp":1566588862, "edge_media_preview_like":{ "count":110, "edges":[ ] }, "edge_media_to_sponsor_user":{ "edges":[ ] }, "location":null, "viewer_has_liked":false, "viewer_has_saved":false, "viewer_has_saved_to_collection":false, "viewer_in_photo_of_you":false, "viewer_can_reshare":true, "owner":{ "id":"13846418535", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/c799dbeb8dd63a90765c788cc2203fa9/5E0071C7/t51.2885-19/s150x150/60779355_2621644501196839_286519566123663360_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"akchapters", "followed_by_viewer":true, "full_name":"\u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440 \u041a\u043e\u0440\u043e\u043b\u044c | \u0413\u043b\u0430\u0432\u044b", "is_private":true, "requested_by_viewer":false, "blocked_by_viewer":false, "has_blocked_viewer":false } } }, { "node":{ "__typename":"GraphImage", "id":"2118275964722976214", "dimensions":{ "height":720, "width":1080 }, "display_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/1085b370651736213d955a4b230d0778/5E04B310/t51.2885-15/fr/e15/s1080x1080/67730127_467681310751565_4014535606315768508_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "display_resources":[ { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/7f43bcc1f960132f210de3f3fb2bfc9e/5E1126AA/t51.2885-15/sh0.08/e35/s640x640/67730127_467681310751565_4014535606315768508_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":640, "config_height":426 }, { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/02030df1e61d53d8e363e956b6003d50/5DF4D6AA/t51.2885-15/sh0.08/e35/s750x750/67730127_467681310751565_4014535606315768508_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":750, "config_height":500 }, { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/1085b370651736213d955a4b230d0778/5E04B310/t51.2885-15/fr/e15/s1080x1080/67730127_467681310751565_4014535606315768508_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":1080, "config_height":720 } ], "follow_hashtag_info":null, "is_video":false, "should_log_client_event":false, "tracking_token":"eyJ2ZXJzaW9uIjo1LCJwYXlsb2FkIjp7ImlzX2FuYWx5dGljc190cmFja2VkIjp0cnVlLCJ1dWlkIjoiZDNkNWVkZTkzNjg3NDM0MmI5MzdmMGMzNDA1NWVlMTIyMTE4Mjc1OTY0NzIyOTc2MjE0Iiwic2VydmVyX3Rva2VuIjoiMTU2Njc0ODY2MTIyNXwyMTE4Mjc1OTY0NzIyOTc2MjE0fDg3ODM4MzgxMTl8ZTk3NWRhMTFkOTMyYWE5MTlhYTBlODM5YzQzNjE3OTRmZTZkNDU2ODI1YTUwYWEwNjA2MTFkZDJkODZmZjM0NyJ9LCJzaWduYXR1cmUiOiIifQ==", "edge_media_to_tagged_user":{ "edges":[ ] }, "accessibility_caption":"\u041d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f: \u043d\u0435\u0431\u043e, \u043e\u0431\u043b\u0430\u043a\u043e, \u043e\u043a\u0435\u0430\u043d, \u043d\u0430 \u0443\u043b\u0438\u0446\u0435, \u043f\u0440\u0438\u0440\u043e\u0434\u0430 \u0438 \u0432\u043e\u0434\u0430", "attribution":null, "shortcode":"B1loMRNj5XW", "edge_media_to_caption":{ "edges":[ { "node":{ "text":"Photo by @bethjwald | The sun sets over a panoramic view looking towards the White Rim region of Canyonlands National Park in southeastern Utah. The vast Canyonlands National Park protects dramatic landscapes of canyons carved by the Colorado River, fragile desert ecosystems, Native American rock paintings, dark skies and important watersheds and rivers from an array of threats, including mining, over-grazing, off-road vehicle use and development so that visitors will forever be able to lose themselves amongst its canyons and natural wonders. I have spent many weeks exploring the canyon worlds of this national park and its dramatic vistas helped form my photographic eye. National parks make available to all the natural wonders and heritage of our country and are an intrinsic part of America. In honor of the 103rd anniversary of the founding of the National Park Service we celebrate the National Parks today. For more photos of our ancient and modern relationship with nature and of national parks around the world, follow me at @bethjwald. #canyonlove #canyonlandsnationalpark #americasbestidea #nationalparklove #findyourpark" } } ] }, "edge_media_preview_comment":{ "count":242, "page_info":{ "has_next_page":true, "end_cursor":"QVFCbGdQZnNMSG9IWE0yNkp0YXRlQjVtTG5tcXR0WWhacmREdDktZWxpWlpKYjlwYWFxRm9MTUdBaGluWG14eFlLSlpZVjFjMGs0UjRRVUNvVnY0anNjMg==" }, "edges":[ { "node":{ "id":"18014094958243085", "text":"@ohhverbatim", "created_at":1566748562, "did_report_as_spam":false, "owner":{ "id":"511750325", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/436f8a8d5a3e49237fdec94b16cd7b2a/5DF7E380/t51.2885-19/s150x150/28433529_154752318545706_5371696231099662336_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"pave_my_own_path" }, "viewer_has_liked":false } }, { "node":{ "id":"17843042854610326", "text":"I got the GREATEST SPEAKING VOICE of all time If you doubt me check my IG and see!\ud83d\ude4f\ud83c\udfff\ud83d\ude4f\ud83c\udfff", "created_at":1566748606, "did_report_as_spam":false, "owner":{ "id":"3166297639", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/5ee97b877de5019265b5d87331dca9e9/5DF39CF8/t51.2885-19/s150x150/66825378_2154949204810780_4891192315273543680_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"peoplesparadisepodcast" }, "viewer_has_liked":false } } ] }, "gating_info":null, "media_preview":"ACoclEk46qp/z9aPPfPMYx3rJ30F6jlfVr7v+CaXXZ/ebHmk/wAGPrjH8qiMgPZfzFZLvn1phI7UW8xaGx16KPzpmG/uiswISMk4FGxvf8qd/MnlXYZmk3UAZwPWpY0HWncoiALdBmp/Lx7nPAqw3yDirSKFGQO1ZuRoolbkHGCMD8B/n/JpmD/lv/r0E7pMHp1/L+lSbF9KBH//2Q==", "comments_disabled":false, "taken_at_timestamp":1566738194, "edge_media_preview_like":{ "count":116360, "edges":[ ] }, "edge_media_to_sponsor_user":{ "edges":[ ] }, "location":null, "viewer_has_liked":false, "viewer_has_saved":false, "viewer_has_saved_to_collection":false, "viewer_in_photo_of_you":false, "viewer_can_reshare":true, "owner":{ "id":"23947096", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/e56487890a4a526c8e866eadbc3159fb/5DF5DD39/t51.2885-19/s150x150/12132724_850743081710560_180824582_a.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"natgeotravel", "followed_by_viewer":true, "full_name":"National Geographic Travel", "is_private":false, "requested_by_viewer":false, "blocked_by_viewer":false, "has_blocked_viewer":false } } }, { "node":{ "__typename":"GraphImage", "id":"2118003247143649215", "dimensions":{ "height":771, "width":1080 }, "display_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/d45df7f87a045312aa73523f8b210777/5DF280A0/t51.2885-15/fr/e15/s1080x1080/67617540_2065364250426167_7422279937392285823_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "display_resources":[ { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/562fd3830b407d0b9efb49a7f8521535/5DF50E69/t51.2885-15/sh0.08/e35/s640x640/67617540_2065364250426167_7422279937392285823_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":640, "config_height":456 }, { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/a6985f213dc53c31a14ac50b003494de/5DF091AD/t51.2885-15/sh0.08/e35/s750x750/67617540_2065364250426167_7422279937392285823_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":750, "config_height":535 }, { "src":"https://instagram.fhel2-1.fna.fbcdn.net/vp/d45df7f87a045312aa73523f8b210777/5DF280A0/t51.2885-15/fr/e15/s1080x1080/67617540_2065364250426167_7422279937392285823_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "config_width":1080, "config_height":771 } ], "follow_hashtag_info":null, "is_video":false, "should_log_client_event":false, "tracking_token":"eyJ2ZXJzaW9uIjo1LCJwYXlsb2FkIjp7ImlzX2FuYWx5dGljc190cmFja2VkIjp0cnVlLCJ1dWlkIjoiZDNkNWVkZTkzNjg3NDM0MmI5MzdmMGMzNDA1NWVlMTIyMTE4MDAzMjQ3MTQzNjQ5MjE1Iiwic2VydmVyX3Rva2VuIjoiMTU2Njc0ODY2MTIyNXwyMTE4MDAzMjQ3MTQzNjQ5MjE1fDg3ODM4MzgxMTl8NmYwMWQ1OTBhZjkxY2ZhZTFkYzlhOTAzZDdhYWZhYzNmOTc1Y2ExZDQzZTFlZTJlZjAwZTYxZGZjY2QxMzc3MyJ9LCJzaWduYXR1cmUiOiIifQ==", "edge_media_to_tagged_user":{ "edges":[ ] }, "accessibility_caption":"\u041d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f: \u043d\u0435\u0431\u043e, \u0434\u0435\u0440\u0435\u0432\u043e, \u043d\u0430 \u0443\u043b\u0438\u0446\u0435 \u0438 \u043f\u0440\u0438\u0440\u043e\u0434\u0430", "attribution":null, "shortcode":"B1kqLtLHv-_", "edge_media_to_caption":{ "edges":[ { "node":{ "text":"Photo by @MichaelGeorge | If cities are the heart of the US, National Parks are its soul. Every time I get the opportunity to wander into this wild silence of nature I am humbled beyond measure. Our National Parks also showcase the diversity of land that makes up this country. From the face-melting swamps of the Everglades, to the crisp serene setting seen here. This image was taken during a hike on Hurricane Ridge in Olympic National Park. These two deer stood silently on the ridge, as the fog began to roll in. Their silhouettes illustrate one of many painterly moments I experienced on this hike. Visiting a National Park is one of the best (and least expensive!) adventures you can take yourself on. For this 103rd anniversary of the National Park\u2019s founding, I am forever grateful for this protected land. #nationalparks #hurricaneridge #olympicnationalpark #washington #deer" } } ] }, "edge_media_preview_comment":{ "count":505, "page_info":{ "has_next_page":true, "end_cursor":"QVFEY0tTNkNhcnV2Qm5CSnF2NjJwXzlFaUE0VXdPVzF4b0ZqbVItMmNVeEFCbC00aGdqRTdRNGxSOW9WOHc2dGhad0RBOFJJOHNOWnMzSV85NWhRUW9rVg==" }, "edges":[ { "node":{ "id":"17847469972575823", "text":"I love this\ud83d\udc4c\ud83d\udc4c\ud83d\udc4c\ud83d\udc4c", "created_at":1566748528, "did_report_as_spam":false, "owner":{ "id":"16635492189", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/048f2e98959113e152b2c5c002153adb/5E14C866/t51.2885-19/s150x150/69955433_1465673260242266_8501495765061861376_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"supertramp_ll" }, "viewer_has_liked":false } }, { "node":{ "id":"17860151434493563", "text":"\u2618\ufe0f\u2618\ufe0f", "created_at":1566748544, "did_report_as_spam":false, "owner":{ "id":"4075637980", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/ce544a4474591eae6598094134630083/5E13CF05/t51.2885-19/s150x150/15803591_236849253431666_2280179815115915264_n.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"alexandermmaltsev" }, "viewer_has_liked":false } } ] }, "gating_info":null, "media_preview":"ACod6GlqPdSeYvrQK5JS1lPqsYVnUMQgzyNvOcADPXPP5U06vDkj0AOfXPpRYLmqTioROhGQwwfcVkz6zDtITLMQccYAPuf8K5nJ9TTA07jVZZT8nyL6d/xqot3KpyDyM4zzjP8AWq1FMRO91LIuxmJX0zxUFFFABRRRQB//2Q==", "comments_disabled":false, "taken_at_timestamp":1566705684, "edge_media_preview_like":{ "count":235639, "edges":[ ] }, "edge_media_to_sponsor_user":{ "edges":[ ] }, "location":null, "viewer_has_liked":false, "viewer_has_saved":false, "viewer_has_saved_to_collection":false, "viewer_in_photo_of_you":false, "viewer_can_reshare":true, "owner":{ "id":"23947096", "profile_pic_url":"https://instagram.fhel2-1.fna.fbcdn.net/vp/e56487890a4a526c8e866eadbc3159fb/5DF5DD39/t51.2885-19/s150x150/12132724_850743081710560_180824582_a.jpg?_nc_ht=instagram.fhel2-1.fna.fbcdn.net", "username":"natgeotravel", "followed_by_viewer":true, "full_name":"National Geographic Travel", "is_private":false, "requested_by_viewer":false, "blocked_by_viewer":false, "has_blocked_viewer":false } } } ] } } }, "status":"ok" } ================================================ FILE: 4-api/3_graphql/intro/readme.md ================================================ query ($number_of_repos: Int!) { viewer { name login repositories { totalCount } followers { totalCount } starredRepositories(last: $number_of_repos) { totalCount nodes { name description forkCount homepageUrl stargazers { totalCount } updatedAt } } } } ----- query ($number_of_repos: Int!) { viewer { name login starredRepositories(last: $number_of_repos) { totalCount nodes { name description homepageUrl updatedAt issues(last: 3, states: OPEN) { edges { node { title url } } } } } } } ================================================ FILE: 4-api/3_graphql/intro/schema.public.graphql ================================================ """ Defines what type of global IDs are accepted for a mutation argument of type ID. """ directive @possibleTypes( """ Abstract type of accepted global ID """ abstractType: String """ Accepted types of global IDs. """ concreteTypes: [String!]! ) on INPUT_FIELD_DEFINITION """ Marks an element of a GraphQL schema as only available via a preview header """ directive @preview( """ The identifier of the API preview that toggles this field. """ toggledBy: String ) on SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINITION | INTERFACE | UNION | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION """ Autogenerated input type of AcceptBusinessMemberInvitation """ input AcceptBusinessMemberInvitationInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The id of the invitation being accepted """ invitationId: ID! @possibleTypes(concreteTypes: ["BusinessMemberInvitation"]) } """ Autogenerated return type of AcceptBusinessMemberInvitation """ type AcceptBusinessMemberInvitationPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The invitation that was accepted. """ invitation: BusinessMemberInvitation @preview(toggledBy: "gwenpool-preview") """ A message confirming the result of accepting an administrator invitation. """ message: String } """ Autogenerated input type of AcceptTopicSuggestion """ input AcceptTopicSuggestionInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The name of the suggested topic. """ name: String! """ The Node ID of the repository. """ repositoryId: ID! @possibleTypes(concreteTypes: ["Repository"]) } """ Autogenerated return type of AcceptTopicSuggestion """ type AcceptTopicSuggestionPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The accepted topic. """ topic: Topic } """ Represents an object which can take actions on GitHub. Typically a User or Bot. """ interface Actor { """ A URL pointing to the actor's public avatar. """ avatarUrl( """ The size of the resulting square image. """ size: Int ): URI! """ The username of the actor. """ login: String! """ The HTTP path for this actor. """ resourcePath: URI! """ The HTTP URL for this actor. """ url: URI! } """ Autogenerated input type of AddAssigneesToAssignable """ input AddAssigneesToAssignableInput @preview(toggledBy: "starfire-preview") { """ The id of the assignable object to add assignees to. """ assignableId: ID! @possibleTypes(concreteTypes: ["Issue", "PullRequest"], abstractType: "Assignable") """ The id of users to add as assignees. """ assigneeIds: [ID!]! @possibleTypes(concreteTypes: ["User"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String } """ Autogenerated return type of AddAssigneesToAssignable """ type AddAssigneesToAssignablePayload @preview(toggledBy: "starfire-preview") { """ The item that was assigned. """ assignable: Assignable """ A unique identifier for the client performing the mutation. """ clientMutationId: String } """ Autogenerated input type of AddComment """ input AddCommentInput { """ The contents of the comment. """ body: String! """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The Node ID of the subject to modify. """ subjectId: ID! @possibleTypes(concreteTypes: ["Issue", "PullRequest"], abstractType: "IssueOrPullRequest") } """ Autogenerated return type of AddComment """ type AddCommentPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The edge from the subject's comment connection. """ commentEdge: IssueCommentEdge """ The subject """ subject: Node """ The edge from the subject's timeline connection. """ timelineEdge: IssueTimelineItemEdge } """ Autogenerated input type of AddLabelsToLabelable """ input AddLabelsToLabelableInput @preview(toggledBy: "starfire-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The ids of the labels to add. """ labelIds: [ID!]! @possibleTypes(concreteTypes: ["Label"]) """ The id of the labelable object to add labels to. """ labelableId: ID! @possibleTypes(concreteTypes: ["Issue", "PullRequest"], abstractType: "Labelable") } """ Autogenerated return type of AddLabelsToLabelable """ type AddLabelsToLabelablePayload @preview(toggledBy: "starfire-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The item that was labeled. """ labelable: Labelable } """ Autogenerated input type of AddProjectCard """ input AddProjectCardInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The content of the card. Must be a member of the ProjectCardItem union """ contentId: ID @possibleTypes(concreteTypes: ["Issue", "PullRequest"], abstractType: "ProjectCardItem") """ The note on the card. """ note: String """ The Node ID of the ProjectColumn. """ projectColumnId: ID! @possibleTypes(concreteTypes: ["ProjectColumn"]) } """ Autogenerated return type of AddProjectCard """ type AddProjectCardPayload { """ The edge from the ProjectColumn's card connection. """ cardEdge: ProjectCardEdge """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The ProjectColumn """ projectColumn: ProjectColumn } """ Autogenerated input type of AddProjectColumn """ input AddProjectColumnInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The name of the column. """ name: String! """ The Node ID of the project. """ projectId: ID! @possibleTypes(concreteTypes: ["Project"]) } """ Autogenerated return type of AddProjectColumn """ type AddProjectColumnPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The edge from the project's column connection. """ columnEdge: ProjectColumnEdge """ The project """ project: Project } """ Autogenerated input type of AddPullRequestReviewComment """ input AddPullRequestReviewCommentInput { """ The text of the comment. """ body: String! """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The SHA of the commit to comment on. """ commitOID: GitObjectID """ The comment id to reply to. """ inReplyTo: ID @possibleTypes(concreteTypes: ["PullRequestReviewComment"]) """ The relative path of the file to comment on. """ path: String """ The line index in the diff to comment on. """ position: Int """ The Node ID of the review to modify. """ pullRequestReviewId: ID! @possibleTypes(concreteTypes: ["PullRequestReview"]) } """ Autogenerated return type of AddPullRequestReviewComment """ type AddPullRequestReviewCommentPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The newly created comment. """ comment: PullRequestReviewComment """ The edge from the review's comment connection. """ commentEdge: PullRequestReviewCommentEdge } """ Autogenerated input type of AddPullRequestReview """ input AddPullRequestReviewInput { """ The contents of the review body comment. """ body: String """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The review line comments. """ comments: [DraftPullRequestReviewComment] """ The commit OID the review pertains to. """ commitOID: GitObjectID """ The event to perform on the pull request review. """ event: PullRequestReviewEvent """ The Node ID of the pull request to modify. """ pullRequestId: ID! @possibleTypes(concreteTypes: ["PullRequest"]) } """ Autogenerated return type of AddPullRequestReview """ type AddPullRequestReviewPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The newly created pull request review. """ pullRequestReview: PullRequestReview """ The edge from the pull request's review connection. """ reviewEdge: PullRequestReviewEdge } """ Autogenerated input type of AddReaction """ input AddReactionInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The name of the emoji to react with. """ content: ReactionContent! """ The Node ID of the subject to modify. """ subjectId: ID! @possibleTypes(concreteTypes: ["CommitComment", "Issue", "IssueComment", "PullRequest", "PullRequestReview", "PullRequestReviewComment", "TeamDiscussion", "TeamDiscussionComment"], abstractType: "Reactable") } """ Autogenerated return type of AddReaction """ type AddReactionPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The reaction object. """ reaction: Reaction """ The reactable subject. """ subject: Reactable } """ Autogenerated input type of AddStar """ input AddStarInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The Starrable ID to star. """ starrableId: ID! @possibleTypes(concreteTypes: ["Gist", "Repository", "Topic"], abstractType: "Starrable") } """ Autogenerated return type of AddStar """ type AddStarPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The starrable. """ starrable: Starrable } """ Represents a 'added_to_project' event on a given issue or pull request. """ type AddedToProjectEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Identifies the primary key from the database. """ databaseId: Int id: ID! """ Project referenced by event. """ project: Project @preview(toggledBy: "starfox-preview") """ Project card referenced by this project event. """ projectCard: ProjectCard @preview(toggledBy: "starfox-preview") """ Column name referenced by this project event. """ projectColumnName: String! @preview(toggledBy: "starfox-preview") } """ A GitHub App. """ type App implements Node { """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Identifies the primary key from the database. """ databaseId: Int """ The description of the app. """ description: String id: ID! """ The hex color code, without the leading '#', for the logo background. """ logoBackgroundColor: String! """ A URL pointing to the app's logo. """ logoUrl( """ The size of the resulting image. """ size: Int ): URI! """ The name of the app. """ name: String! """ A slug based on the name of the app for use in URLs. """ slug: String! """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! """ The URL to the app's homepage. """ url: URI! } """ An object that can have users assigned to it. """ interface Assignable { """ A list of Users assigned to this object. """ assignees( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): UserConnection! } """ Represents an 'assigned' event on any assignable object. """ type AssignedEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the assignable associated with the event. """ assignable: Assignable! """ Identifies the date and time when the object was created. """ createdAt: DateTime! id: ID! """ Identifies the user who was assigned. """ user: User } """ Represents a 'base_ref_changed' event on a given issue or pull request. """ type BaseRefChangedEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Identifies the primary key from the database. """ databaseId: Int id: ID! } """ Represents a 'base_ref_force_pushed' event on a given pull request. """ type BaseRefForcePushedEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the after commit SHA for the 'base_ref_force_pushed' event. """ afterCommit: Commit """ Identifies the before commit SHA for the 'base_ref_force_pushed' event. """ beforeCommit: Commit """ Identifies the date and time when the object was created. """ createdAt: DateTime! id: ID! """ PullRequest referenced by event. """ pullRequest: PullRequest! """ Identifies the fully qualified ref name for the 'base_ref_force_pushed' event. """ ref: Ref } """ Represents a Git blame. """ type Blame { """ The list of ranges from a Git blame. """ ranges: [BlameRange!]! } """ Represents a range of information from a Git blame. """ type BlameRange { """ Identifies the recency of the change, from 1 (new) to 10 (old). This is calculated as a 2-quantile and determines the length of distance between the median age of all the changes in the file and the recency of the current range's change. """ age: Int! """ Identifies the line author """ commit: Commit! """ The ending line for the range """ endingLine: Int! """ The starting line for the range """ startingLine: Int! } """ Represents a Git blob. """ type Blob implements GitObject & Node { """ An abbreviated version of the Git object ID """ abbreviatedOid: String! """ Byte size of Blob object """ byteSize: Int! """ The HTTP path for this Git object """ commitResourcePath: URI! """ The HTTP URL for this Git object """ commitUrl: URI! id: ID! """ Indicates whether the Blob is binary or text """ isBinary: Boolean! """ Indicates whether the contents is truncated """ isTruncated: Boolean! """ The Git object ID """ oid: GitObjectID! """ The Repository the Git object belongs to """ repository: Repository! """ UTF8 text data or null if the Blob is binary """ text: String } """ A special type of user which takes actions on behalf of GitHub Apps. """ type Bot implements Actor & Node & UniformResourceLocatable { """ A URL pointing to the GitHub App's public avatar. """ avatarUrl( """ The size of the resulting square image. """ size: Int ): URI! """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Identifies the primary key from the database. """ databaseId: Int id: ID! """ The username of the actor. """ login: String! """ The HTTP path for this bot """ resourcePath: URI! """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! """ The HTTP URL for this bot """ url: URI! } """ A branch protection rule. """ type BranchProtectionRule implements Node { """ A list of conflicts matching branches protection rule and other branch protection rules """ branchProtectionRuleConflicts( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): BranchProtectionRuleConflictConnection! """ The actor who created this branch protection rule. """ creator: Actor """ Identifies the primary key from the database. """ databaseId: Int """ Will new commits pushed to matching branches dismiss pull request review approvals. """ dismissesStaleReviews: Boolean! id: ID! """ Can admins overwrite branch protection. """ isAdminEnforced: Boolean! """ Repository refs that are protected by this rule """ matchingRefs( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): RefConnection! """ Identifies the protection rule pattern. """ pattern: String! """ A list push allowances for this branch protection rule. """ pushAllowances( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): PushAllowanceConnection! """ The repository associated with this branch protection rule. """ repository: Repository """ Number of approving reviews required to update matching branches. """ requiredApprovingReviewCount: Int """ List of required status check contexts that must pass for commits to be accepted to matching branches. """ requiredStatusCheckContexts: [String] """ Are approving reviews required to update matching branches. """ requiresApprovingReviews: Boolean! """ Are commits required to be signed. """ requiresCommitSignatures: Boolean! """ Are status checks required to update matching branches. """ requiresStatusChecks: Boolean! """ Are branches required to be up to date before merging. """ requiresStrictStatusChecks: Boolean! """ Is pushing to matching branches restricted. """ restrictsPushes: Boolean! """ Is dismissal of pull request reviews restricted. """ restrictsReviewDismissals: Boolean! """ A list review dismissal allowances for this branch protection rule. """ reviewDismissalAllowances( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): ReviewDismissalAllowanceConnection! } """ A conflict between two branch protection rules. """ type BranchProtectionRuleConflict { """ Identifies the branch protection rule. """ branchProtectionRule: BranchProtectionRule """ Identifies the conflicting branch protection rule. """ conflictingBranchProtectionRule: BranchProtectionRule """ Identifies the branch ref that has conflicting rules """ ref: Ref } """ The connection type for BranchProtectionRuleConflict. """ type BranchProtectionRuleConflictConnection { """ A list of edges. """ edges: [BranchProtectionRuleConflictEdge] """ A list of nodes. """ nodes: [BranchProtectionRuleConflict] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type BranchProtectionRuleConflictEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: BranchProtectionRuleConflict } """ The connection type for BranchProtectionRule. """ type BranchProtectionRuleConnection { """ A list of edges. """ edges: [BranchProtectionRuleEdge] """ A list of nodes. """ nodes: [BranchProtectionRule] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type BranchProtectionRuleEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: BranchProtectionRule } """ A group of one or more organizations with consolidated billing. """ type Business implements Node @preview(toggledBy: "gwenpool-preview") { """ Business information only visible to admins """ adminInfo: BusinessAdminInfo """ A URL pointing to the business's public avatar. """ avatarUrl( """ The size of the resulting square image. """ size: Int ): URI! """ Business billing information visible to billing managers """ billingInfo: BusinessBillingInfo """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Identifies the primary key from the database. """ databaseId: Int """ The description of the business """ description: String """ The description of the business as HTML. """ descriptionHTML: HTML! id: ID! """ The location of the business """ location: String """ The name of the business """ name: String! """ A list of organizations that belong to this business. """ organizations( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for organizations returned from the connection. """ orderBy: OrganizationOrder = {field: LOGIN, direction: ASC} ): OrganizationConnection! """ The HTTP path for this business. """ resourcePath: URI! """ The HTTP URL for this business. """ url: URI! """ Is the current viewer an admin of this business? """ viewerIsAdmin: Boolean! """ The URL for the business's website """ websiteUrl: URI } """ Business information only visible to admins """ type BusinessAdminInfo @preview(toggledBy: "gwenpool-preview") { """ A list of all of the admins for this business. """ admins( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ The search string to look for. """ query: String ): UserConnection! """ A list of users in the business who currently have two-factor authentication disabled """ affiliatedUsersWithTwoFactorDisabled( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): UserConnection! """ Whether or not affiliated users with two-factor auth disabled exist in the business. """ affiliatedUsersWithTwoFactorDisabledExist: Boolean! """ The setting value for whether private repository forking is enabled for repositories in organizations in this business. """ allowPrivateRepositoryForkingSetting: BusinessEnabledDisabledSettingValue! """ The setting value for base repository permissions for organizations in this business. """ defaultRepositoryPermissionSetting: BusinessDefaultRepositoryPermissionSettingValue! """ Whether or not the default repository permission is currently being updated. """ isUpdatingDefaultRepositoryPermission: Boolean! """ Whether the two factor requirement is currently being enforced """ isUpdatingTwoFactorRequirement: Boolean! """ The setting value for whether organization members with admin permissions on a repository can change repository visibility. """ membersCanChangeRepositoryVisibilitySetting: BusinessEnabledDisabledSettingValue! """ The setting value for whether members of organizations in the business can create repositories. """ membersCanCreateRepositoriesSetting: BusinessMembersCanCreateRepositoriesSettingValue! """ The setting value for whether members with admin permissions for repositories can delete issues. """ membersCanDeleteIssuesSetting: BusinessEnabledDisabledSettingValue! """ The setting value for whether members with admin permissions for repositories can delete or transfer repositories. """ membersCanDeleteRepositoriesSetting: BusinessEnabledDisabledSettingValue! """ The setting value for whether members of organizations in the business can invite outside collaborators. """ membersCanInviteCollaboratorsSetting: BusinessEnabledDisabledSettingValue! """ The setting value for whether members with admin permissions for repositories can update protected branches. """ membersCanUpdateProtectedBranchesSetting: BusinessEnabledDisabledSettingValue! """ The setting value for whether organization projects are enabled for organizations in this business. """ organizationProjectsSetting: BusinessEnabledDisabledSettingValue! """ A list of pending admin invitations for the business. """ pendingAdminInvitations( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ The search string to look for. """ query: String ): BusinessMemberInvitationConnection! """ A list of pending member invitations in the business. """ pendingMemberInvitations( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ The search string to look for. """ query: String ): BusinessPendingMemberInvitationConnection! """ The setting value for whether repository projects are enabled in this business. """ repositoryProjectsSetting: BusinessEnabledDisabledSettingValue! """ The setting value for whether team discussions are enabled for organizations in this business. """ teamDiscussionsSetting: BusinessEnabledDisabledSettingValue! """ The setting value for whether the business requires two factor authentication for its organizations and users """ twoFactorRequiredSetting: BusinessEnabledSettingValue! } """ Business billing information visible to billing managers and admins """ type BusinessBillingInfo @preview(toggledBy: "gwenpool-preview") { """ The number of data packs used by all organizations owned by the business """ assetPacks: Int! """ The number of available seats across all owned organizations based on the unique number of billable users """ availableSeats: Int! """ The bandwidth quota in GB for all organizations owned by the business """ bandwidthQuota: Float! """ The bandwidth usage in GB for all organizations owned by the business """ bandwidthUsage: Float! """ The bandwidth usage as a percentage of the bandwidth quota """ bandwidthUsagePercentage: Int! """ A list of all of the billing managers for this business. """ billingManagers( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): UserConnection! """ A list of pending billing manager invitations for the business. """ pendingBillingManagerInvitations( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ The search string to look for. """ query: String ): BusinessMemberInvitationConnection! """ The total seats across all organizations owned by the business """ seats: Int! """ The storage quota in GB for all organizations owned by the business """ storageQuota: Float! """ The storage usage in GB for all organizations owned by the business """ storageUsage: Float! """ The storage usage as a percentage of the storage quota """ storageUsagePercentage: Int! """ The total number of billable users across all organizations owned by the business """ totalBillableUsers: Int! """ The unique number of billable users across all organizations owned by the business """ uniqueBillableUsersCount: Int! """ The unique number of billable users as a percentage of seats """ uniqueBillableUsersPercent: Int! } """ The possible values for the business default repository permission setting. """ enum BusinessDefaultRepositoryPermissionSettingValue @preview(toggledBy: "gwenpool-preview") { """ Organization members will be able to clone, pull, push, and add new collaborators to all organization repositories. """ ADMIN """ Organization members will only be able to clone and pull public repositories. """ NONE """ Organizations in the business choose default repository permissions for their members. """ NO_POLICY """ Organization members will be able to clone and pull all organization repositories. """ READ """ Organization members will be able to clone, pull, and push all organization repositories. """ WRITE } """ The possible values for an enabled/disabled business setting. """ enum BusinessEnabledDisabledSettingValue @preview(toggledBy: "gwenpool-preview") { """ The setting is disabled for organizations in the business. """ DISABLED """ The setting is enabled for organizations in the business. """ ENABLED """ There is no policy set for organizations in the business. """ NO_POLICY } """ The possible values for an enabled/no policy business setting. """ enum BusinessEnabledSettingValue @preview(toggledBy: "gwenpool-preview") { """ The setting is enabled for organizations in the business. """ ENABLED """ There is no policy set for organizations in the business. """ NO_POLICY } """ An invitation for a user to become an admin or billing manager of a business. """ type BusinessMemberInvitation implements Node @preview(toggledBy: "gwenpool-preview") { """ The business the invitation is for. """ business: Business! """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ The email of the person who was invited to the business. """ email: String id: ID! """ The user who was invited to the business. """ invitee: User """ The user who created the invitation. """ inviter: User! """ The invitee's pending role in the business (admin or billing_manager). """ role: BusinessMemberInvitationRole! } """ The connection type for BusinessMemberInvitation. """ type BusinessMemberInvitationConnection { """ A list of edges. """ edges: [BusinessMemberInvitationEdge] """ A list of nodes. """ nodes: [BusinessMemberInvitation] @preview(toggledBy: "gwenpool-preview") """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type BusinessMemberInvitationEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: BusinessMemberInvitation @preview(toggledBy: "gwenpool-preview") } """ The possible business member invitation roles. """ enum BusinessMemberInvitationRole @preview(toggledBy: "gwenpool-preview") { """ The invitee is invited to be an administrator of the business. """ ADMIN """ The invitee is invited to be a billing manager of the business. """ BILLING_MANAGER } """ The possible values for the business members can create repositories setting. """ enum BusinessMembersCanCreateRepositoriesSettingValue @preview(toggledBy: "gwenpool-preview") { """ Members will be able to create public and private repositories. """ ALL """ Members will not be able to create public or private repositories. """ DISABLED """ Organization administrators choose whether to allow members to create repositories. """ NO_POLICY """ Members will be able to create only private repositories. """ PRIVATE } """ The connection type for OrganizationInvitation. """ type BusinessPendingMemberInvitationConnection @preview(toggledBy: "gwenpool-preview") { """ A list of edges. """ edges: [OrganizationInvitationEdge] """ A list of nodes. """ nodes: [OrganizationInvitation] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! """ Identifies the total count of unique users in the connection. """ totalUniqueUserCount: Int! } """ A subset of repository information queryable from a business. """ type BusinessRepositoryInfo implements Node @preview(toggledBy: "gwenpool-preview") { id: ID! """ The repository's name. """ name: String! """ The repository's name with owner. """ nameWithOwner: String! } """ Autogenerated input type of CancelBusinessAdminInvitation """ input CancelBusinessAdminInvitationInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The Node ID of the pending business admin invitation. """ invitationId: ID! @possibleTypes(concreteTypes: ["BusinessMemberInvitation"]) } """ Autogenerated return type of CancelBusinessAdminInvitation """ type CancelBusinessAdminInvitationPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The invitation that was canceled. """ invitation: BusinessMemberInvitation @preview(toggledBy: "gwenpool-preview") """ A message confirming the result of canceling an administrator invitation. """ message: String } """ Autogenerated input type of CancelBusinessBillingManagerInvitation """ input CancelBusinessBillingManagerInvitationInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The Node ID of the pending business billing manager invitation. """ invitationId: ID! @possibleTypes(concreteTypes: ["BusinessMemberInvitation"]) } """ Autogenerated return type of CancelBusinessBillingManagerInvitation """ type CancelBusinessBillingManagerInvitationPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The invitation that was canceled. """ invitation: BusinessMemberInvitation @preview(toggledBy: "gwenpool-preview") """ A message confirming the result of canceling a billing manager invitation. """ message: String } """ A single check annotation. """ type CheckAnnotation @preview(toggledBy: "antiope-preview") { """ The annotation's severity level. """ annotationLevel: CheckAnnotationLevel """ The path to the file that this annotation was made on. """ blobUrl: URI! """ Identifies the primary key from the database. """ databaseId: Int """ The position of this annotation. """ location: CheckAnnotationSpan! """ The annotation's message. """ message: String! """ The path that this annotation was made on. """ path: String! """ Additional information about the annotation. """ rawDetails: String """ The annotation's title """ title: String } """ The connection type for CheckAnnotation. """ type CheckAnnotationConnection { """ A list of edges. """ edges: [CheckAnnotationEdge] """ A list of nodes. """ nodes: [CheckAnnotation] @preview(toggledBy: "antiope-preview") """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ Information from a check run analysis to specific lines of code. """ input CheckAnnotationData @preview(toggledBy: "antiope-preview") { """ Represents an annotation's information level """ annotationLevel: CheckAnnotationLevel! """ The location of the annotation """ location: CheckAnnotationRange! """ A short description of the feedback for these lines of code. """ message: String! """ The path of the file to add an annotation to. """ path: String! """ Details about this annotation. """ rawDetails: String """ The title that represents the annotation. """ title: String } """ An edge in a connection. """ type CheckAnnotationEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: CheckAnnotation @preview(toggledBy: "antiope-preview") } """ Represents an annotation's information level. """ enum CheckAnnotationLevel @preview(toggledBy: "antiope-preview") { """ An annotation indicating an inescapable error. """ FAILURE """ An annotation indicating some information. """ NOTICE """ An annotation indicating an ignorable error. """ WARNING } """ A character position in a check annotation. """ type CheckAnnotationPosition @preview(toggledBy: "antiope-preview") { """ Column number (1 indexed). """ column: Int """ Line number (1 indexed). """ line: Int! } """ Information from a check run analysis to specific lines of code. """ input CheckAnnotationRange @preview(toggledBy: "antiope-preview") { """ The ending column of the range. """ endColumn: Int """ The ending line of the range. """ endLine: Int! """ The starting column of the range. """ startColumn: Int """ The starting line of the range. """ startLine: Int! } """ An inclusive pair of positions for a check annotation. """ type CheckAnnotationSpan @preview(toggledBy: "antiope-preview") { """ End position (inclusive). """ end: CheckAnnotationPosition! """ Start position (inclusive). """ start: CheckAnnotationPosition! } """ The possible states for a check suite or run conclusion. """ enum CheckConclusionState @preview(toggledBy: "antiope-preview") { """ The check suite or run requires action. """ ACTION_REQUIRED """ The check suite or run has been cancelled. """ CANCELLED """ The check suite or run has failed. """ FAILURE """ The check suite or run was neutral. """ NEUTRAL """ The check suite or run has succeeded. """ SUCCESS """ The check suite or run has timed out. """ TIMED_OUT } """ A check run. """ type CheckRun implements Node & UniformResourceLocatable @preview(toggledBy: "antiope-preview") { """ The check run's annotations """ annotations( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): CheckAnnotationConnection """ The check suite that this run is a part of. """ checkSuite: CheckSuite! """ Identifies the date and time when the check run was completed. """ completedAt: DateTime """ The conclusion of the check run. """ conclusion: CheckConclusionState """ Identifies the primary key from the database. """ databaseId: Int """ The URL from which to find full details of the check run on the integrator's site. """ detailsUrl: URI """ A reference for the check run on the integrator's system. """ externalId: String id: ID! """ The name of the check for this check run. """ name: String! """ The permalink to the check run summary. """ permalink: URI! """ The repository associated with this check run. """ repository: Repository! """ The HTTP path for this check run. """ resourcePath: URI! """ Identifies the date and time when the check run was started. """ startedAt: DateTime """ The current status of the check run. """ status: CheckStatusState! """ A string representing the check run's summary """ summary: String """ A string representing the check run's text """ text: String """ A string representing the check run """ title: String """ The HTTP URL for this check run. """ url: URI! } """ Possible further actions the integrator can perform. """ input CheckRunAction @preview(toggledBy: "antiope-preview") { """ A short explanation of what this action would do. """ description: String! """ A reference for the action on the integrator's system. """ identifier: String! """ The text to be displayed on a button in the web UI. """ label: String! } """ The connection type for CheckRun. """ type CheckRunConnection { """ A list of edges. """ edges: [CheckRunEdge] """ A list of nodes. """ nodes: [CheckRun] @preview(toggledBy: "antiope-preview") """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type CheckRunEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: CheckRun @preview(toggledBy: "antiope-preview") } """ The filters that are available when fetching check runs. """ input CheckRunFilter @preview(toggledBy: "antiope-preview") { """ Filters the check runs created by this application ID. """ appId: Int """ Filters the check runs by this name. """ checkName: String """ Filters the check runs by this type. """ checkType: CheckRunType """ Filters the check runs by this status. """ status: CheckStatusState } """ Descriptive details about the check run. """ input CheckRunOutput @preview(toggledBy: "antiope-preview") { """ The annotations that are made as part of the check run. """ annotations: [CheckAnnotationData!] """ Images attached to the check run output displayed in the GitHub pull request UI. """ images: [CheckRunOutputImage!] """ The summary of the check run (supports Commonmark). """ summary: String! """ The details of the check run (supports Commonmark). """ text: String """ A title to provide for this check run. """ title: String! } """ Images attached to the check run output displayed in the GitHub pull request UI. """ input CheckRunOutputImage @preview(toggledBy: "antiope-preview") { """ The alternative text for the image. """ alt: String! """ A short image description. """ caption: String """ The full URL of the image. """ imageUrl: URI! } """ The possible types of check runs. """ enum CheckRunType @preview(toggledBy: "antiope-preview") { """ Every check run available. """ ALL """ The latest check run. """ LATEST } """ The possible states for a check suite or run status. """ enum CheckStatusState @preview(toggledBy: "antiope-preview") { """ The check suite or run has been completed. """ COMPLETED """ The check suite or run is in progress. """ IN_PROGRESS """ The check suite or run has been queued. """ QUEUED """ The check suite or run has been requested. """ REQUESTED } """ A check suite. """ type CheckSuite implements Node @preview(toggledBy: "antiope-preview") { """ The GitHub App which created this check suite. """ app: App """ The name of the branch for this check suite. """ branch: Ref """ The check runs associated with a check suite. """ checkRuns( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Filters the check runs by this type. """ filterBy: CheckRunFilter """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): CheckRunConnection """ The commit for this check suite """ commit: Commit! """ The conclusion of this check suite. """ conclusion: CheckConclusionState """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Identifies the primary key from the database. """ databaseId: Int id: ID! """ A list of open pull requests matching the check suite. """ matchingPullRequests( """ Returns the elements in the list that come after the specified cursor. """ after: String """ The base ref name to filter the pull requests by. """ baseRefName: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ The head ref name to filter the pull requests by. """ headRefName: String """ A list of label names to filter the pull requests by. """ labels: [String!] """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for pull requests returned from the connection. """ orderBy: IssueOrder """ A list of states to filter the pull requests by. """ states: [PullRequestState!] ): PullRequestConnection """ The push that triggered this check suite. """ push: Push """ The repository associated with this check suite. """ repository: Repository! """ The status of this check suite. """ status: CheckStatusState! """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! } """ The auto-trigger preferences that are available for check suites. """ input CheckSuiteAutoTriggerPreference @preview(toggledBy: "antiope-preview") { """ The node ID of the application that owns the check suite. """ appId: ID! """ Set to `true` to enable automatic creation of CheckSuite events upon pushes to the repository. """ setting: Boolean! } """ The connection type for CheckSuite. """ type CheckSuiteConnection { """ A list of edges. """ edges: [CheckSuiteEdge] """ A list of nodes. """ nodes: [CheckSuite] @preview(toggledBy: "antiope-preview") """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type CheckSuiteEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: CheckSuite @preview(toggledBy: "antiope-preview") } """ The filters that are available when fetching check suites. """ input CheckSuiteFilter @preview(toggledBy: "antiope-preview") { """ Filters the check suites created by this application ID. """ appId: Int """ Filters the check suites by this name. """ checkName: String } """ Autogenerated input type of ClearLabelsFromLabelable """ input ClearLabelsFromLabelableInput @preview(toggledBy: "starfire-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The id of the labelable object to clear the labels from. """ labelableId: ID! @possibleTypes(concreteTypes: ["Issue", "PullRequest"], abstractType: "Labelable") } """ Autogenerated return type of ClearLabelsFromLabelable """ type ClearLabelsFromLabelablePayload @preview(toggledBy: "starfire-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The item that was unlabeled. """ labelable: Labelable } """ An object that can be closed """ interface Closable { """ `true` if the object is closed (definition of closed may depend on type) """ closed: Boolean! """ Identifies the date and time when the object was closed. """ closedAt: DateTime } """ Autogenerated input type of CloseIssue """ input CloseIssueInput @preview(toggledBy: "starfire-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ ID of the issue to be closed. """ issueId: ID! @possibleTypes(concreteTypes: ["Issue"]) } """ Autogenerated return type of CloseIssue """ type CloseIssuePayload @preview(toggledBy: "starfire-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The issue that was closed. """ issue: Issue } """ Autogenerated input type of ClosePullRequest """ input ClosePullRequestInput @preview(toggledBy: "ocelot-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ ID of the pull request to be closed. """ pullRequestId: ID! @possibleTypes(concreteTypes: ["PullRequest"]) } """ Autogenerated return type of ClosePullRequest """ type ClosePullRequestPayload @preview(toggledBy: "ocelot-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The pull request that was closed. """ pullRequest: PullRequest } """ Represents a 'closed' event on any `Closable`. """ type ClosedEvent implements Node & UniformResourceLocatable { """ Identifies the actor who performed the event. """ actor: Actor """ Object that was closed. """ closable: Closable! """ Object which triggered the creation of this event. """ closer: Closer """ Identifies the date and time when the object was created. """ createdAt: DateTime! id: ID! """ The HTTP path for this closed event. """ resourcePath: URI! """ The HTTP URL for this closed event. """ url: URI! } """ The object which triggered a `ClosedEvent`. """ union Closer = Commit | PullRequest """ The Code of Conduct for a repository """ type CodeOfConduct implements Node { """ The body of the Code of Conduct """ body: String id: ID! """ The key for the Code of Conduct """ key: String! """ The formal name of the Code of Conduct """ name: String! """ The HTTP path for this Code of Conduct """ resourcePath: URI """ The HTTP URL for this Code of Conduct """ url: URI } """ Collaborators affiliation level with a subject. """ enum CollaboratorAffiliation { """ All collaborators the authenticated user can see. """ ALL """ All collaborators with permissions to an organization-owned subject, regardless of organization membership status. """ DIRECT """ All outside collaborators of an organization-owned subject. """ OUTSIDE } """ Types that can be inside Collection Items. """ union CollectionItemContent = Organization | Repository | User """ Represents a comment. """ interface Comment { """ The actor who authored the comment. """ author: Actor """ Author's association with the subject of the comment. """ authorAssociation: CommentAuthorAssociation! """ The body as Markdown. """ body: String! """ The body rendered to HTML. """ bodyHTML: HTML! """ The body rendered to text. """ bodyText: String! """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Check if this comment was created via an email reply. """ createdViaEmail: Boolean! """ The actor who edited the comment. """ editor: Actor id: ID! """ Check if this comment was edited and includes an edit with the creation data """ includesCreatedEdit: Boolean! """ The moment the editor made the last edit """ lastEditedAt: DateTime """ Identifies when the comment was published at. """ publishedAt: DateTime """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! """ A list of edits to this content. """ userContentEdits( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): UserContentEditConnection """ Did the viewer author this comment. """ viewerDidAuthor: Boolean! } """ A comment author association with repository. """ enum CommentAuthorAssociation { """ Author has been invited to collaborate on the repository. """ COLLABORATOR """ Author has previously committed to the repository. """ CONTRIBUTOR """ Author has not previously committed to GitHub. """ FIRST_TIMER """ Author has not previously committed to the repository. """ FIRST_TIME_CONTRIBUTOR """ Author is a member of the organization that owns the repository. """ MEMBER """ Author has no association with the repository. """ NONE """ Author is the owner of the repository. """ OWNER } """ The possible errors that will prevent a user from updating a comment. """ enum CommentCannotUpdateReason { """ You cannot update this comment """ DENIED """ You must be the author or have write access to this repository to update this comment. """ INSUFFICIENT_ACCESS """ Unable to create comment because issue is locked. """ LOCKED """ You must be logged in to update this comment. """ LOGIN_REQUIRED """ Repository is under maintenance. """ MAINTENANCE """ At least one email address must be verified to update this comment. """ VERIFIED_EMAIL_REQUIRED } """ Represents a 'comment_deleted' event on a given issue or pull request. """ type CommentDeletedEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Identifies the primary key from the database. """ databaseId: Int id: ID! } """ Represents a Git commit. """ type Commit implements GitObject & Node & Subscribable & UniformResourceLocatable { """ An abbreviated version of the Git object ID """ abbreviatedOid: String! """ The number of additions in this commit. """ additions: Int! """ Authorship details of the commit. """ author: GitActor """ Check if the committer and the author match. """ authoredByCommitter: Boolean! """ The datetime when this commit was authored. """ authoredDate: DateTime! """ Fetches `git blame` information. """ blame( """ The file whose Git blame information you want. """ path: String! ): Blame! """ The number of changed files in this commit. """ changedFiles: Int! """ The check suites associated with a commit. """ checkSuites( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Filters the check suites by this type. """ filterBy: CheckSuiteFilter """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): CheckSuiteConnection @preview(toggledBy: "antiope-preview") """ Comments made on the commit. """ comments( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): CommitCommentConnection! """ The HTTP path for this Git object """ commitResourcePath: URI! """ The HTTP URL for this Git object """ commitUrl: URI! """ The datetime when this commit was committed. """ committedDate: DateTime! """ Check if commited via GitHub web UI. """ committedViaWeb: Boolean! """ Committership details of the commit. """ committer: GitActor """ The number of deletions in this commit. """ deletions: Int! """ The deployments associated with a commit. """ deployments( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Environments to list deployments for """ environments: [String!] """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for deployments returned from the connection. """ orderBy: DeploymentOrder = {field: CREATED_AT, direction: ASC} ): DeploymentConnection """ The linear commit history starting from (and including) this commit, in the same order as `git log`. """ history( """ Returns the elements in the list that come after the specified cursor. """ after: String """ If non-null, filters history to only show commits with matching authorship. """ author: CommitAuthor """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ If non-null, filters history to only show commits touching files under this path. """ path: String """ Allows specifying a beginning time or date for fetching commits. """ since: GitTimestamp """ Allows specifying an ending time or date for fetching commits. """ until: GitTimestamp ): CommitHistoryConnection! id: ID! """ The Git commit message """ message: String! """ The Git commit message body """ messageBody: String! """ The commit message body rendered to HTML. """ messageBodyHTML: HTML! """ The Git commit message headline """ messageHeadline: String! """ The commit message headline rendered to HTML. """ messageHeadlineHTML: HTML! """ The Git object ID """ oid: GitObjectID! """ The parents of a commit. """ parents( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): CommitConnection! """ The datetime when this commit was pushed. """ pushedDate: DateTime """ The Repository this commit belongs to """ repository: Repository! """ The HTTP path for this commit """ resourcePath: URI! """ Commit signing information, if present. """ signature: GitSignature """ Status information for this commit """ status: Status """ Returns a URL to download a tarball archive for a repository. Note: For private repositories, these links are temporary and expire after five minutes. """ tarballUrl: URI! """ Commit's root Tree """ tree: Tree! """ The HTTP path for the tree of this commit """ treeResourcePath: URI! """ The HTTP URL for the tree of this commit """ treeUrl: URI! """ The HTTP URL for this commit """ url: URI! """ Check if the viewer is able to change their subscription status for the repository. """ viewerCanSubscribe: Boolean! """ Identifies if the viewer is watching, not watching, or ignoring the subscribable entity. """ viewerSubscription: SubscriptionState """ Returns a URL to download a zipball archive for a repository. Note: For private repositories, these links are temporary and expire after five minutes. """ zipballUrl: URI! } """ Specifies an author for filtering Git commits. """ input CommitAuthor { """ Email addresses to filter by. Commits authored by any of the specified email addresses will be returned. """ emails: [String!] """ ID of a User to filter by. If non-null, only commits authored by this user will be returned. This field takes precedence over emails. """ id: ID } """ Represents a comment on a given Commit. """ type CommitComment implements Comment & Deletable & Minimizable & Node & Reactable & RepositoryNode & Updatable & UpdatableComment { """ The actor who authored the comment. """ author: Actor """ Author's association with the subject of the comment. """ authorAssociation: CommentAuthorAssociation! """ Identifies the comment body. """ body: String! """ Identifies the comment body rendered to HTML. """ bodyHTML: HTML! """ The body rendered to text. """ bodyText: String! """ Identifies the commit associated with the comment, if the commit exists. """ commit: Commit """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Check if this comment was created via an email reply. """ createdViaEmail: Boolean! """ Identifies the primary key from the database. """ databaseId: Int """ The actor who edited the comment. """ editor: Actor id: ID! """ Check if this comment was edited and includes an edit with the creation data """ includesCreatedEdit: Boolean! """ Returns whether or not a comment has been minimized. """ isMinimized: Boolean! """ The moment the editor made the last edit """ lastEditedAt: DateTime """ Returns why the comment was minimized. """ minimizedReason: String """ Identifies the file path associated with the comment. """ path: String """ Identifies the line position associated with the comment. """ position: Int """ Identifies when the comment was published at. """ publishedAt: DateTime """ A list of reactions grouped by content left on the subject. """ reactionGroups: [ReactionGroup!] """ A list of Reactions left on the Issue. """ reactions( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Allows filtering Reactions by emoji. """ content: ReactionContent """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Allows specifying the order in which reactions are returned. """ orderBy: ReactionOrder ): ReactionConnection! """ The repository associated with this node. """ repository: Repository! """ The HTTP path permalink for this commit comment. """ resourcePath: URI! """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! """ The HTTP URL permalink for this commit comment. """ url: URI! """ A list of edits to this content. """ userContentEdits( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): UserContentEditConnection """ Check if the current viewer can delete this object. """ viewerCanDelete: Boolean! """ Check if the current viewer can minimize this object. """ viewerCanMinimize: Boolean! """ Can user react to this subject """ viewerCanReact: Boolean! """ Check if the current viewer can update this object. """ viewerCanUpdate: Boolean! """ Reasons why the current viewer can not update this comment. """ viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! """ Did the viewer author this comment. """ viewerDidAuthor: Boolean! } """ The connection type for CommitComment. """ type CommitCommentConnection { """ A list of edges. """ edges: [CommitCommentEdge] """ A list of nodes. """ nodes: [CommitComment] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type CommitCommentEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: CommitComment } """ A thread of comments on a commit. """ type CommitCommentThread implements Node & RepositoryNode { """ The comments that exist in this thread. """ comments( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): CommitCommentConnection! """ The commit the comments were made on. """ commit: Commit! id: ID! """ The file the comments were made on. """ path: String """ The position in the diff for the commit that the comment was made on. """ position: Int """ The repository associated with this node. """ repository: Repository! } """ The connection type for Commit. """ type CommitConnection { """ A list of edges. """ edges: [CommitEdge] """ A list of nodes. """ nodes: [Commit] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type CommitEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: Commit } """ The connection type for Commit. """ type CommitHistoryConnection { """ A list of edges. """ edges: [CommitEdge] """ A list of nodes. """ nodes: [Commit] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ A content attachment """ type ContentAttachment { """ The body text of the content attachment. This parameter supports markdown. """ body: String! """ The content reference that the content attachment is attached to. """ contentReference: ContentReference! """ Identifies the primary key from the database. """ databaseId: Int! id: ID! """ The title of the content attachment. """ title: String! } """ A content reference """ type ContentReference { """ Identifies the primary key from the database. """ databaseId: Int! id: ID! """ The reference of the content reference. """ reference: String! } """ Represents a contribution a user made on GitHub, such as opening an issue. """ interface Contribution { """ Whether this contribution is associated with a record you do not have access to. For example, your own 'first issue' contribution may have been made on a repository you can no longer access. """ isRestricted: Boolean! """ When this contribution was made. """ occurredAt: DateTime! """ The HTTP path for this contribution. """ resourcePath: URI! """ The HTTP URL for this contribution. """ url: URI! """ The user who made this contribution. """ user: User! } """ A calendar of contributions made on GitHub by a user. """ type ContributionCalendar { """ A list of hex color codes used in this calendar. The darker the color, the more contributions it represents. """ colors: [String!]! """ Determine if the color set was chosen because it's currently Halloween. """ isHalloween: Boolean! """ A list of the months of contributions in this calendar. """ months: [ContributionCalendarMonth!]! """ The count of total contributions in the calendar. """ totalContributions: Int! """ A list of the weeks of contributions in this calendar. """ weeks: [ContributionCalendarWeek!]! } """ Represents a single day of contributions on GitHub by a user. """ type ContributionCalendarDay { """ The hex color code that represents how many contributions were made on this day compared to others in the calendar. """ color: String! """ How many contributions were made by the user on this day. """ contributionCount: Int! """ The day this square represents. """ date: Date! """ A number representing which day of the week this square represents, e.g., 1 is Monday. """ weekday: Int! } """ A month of contributions in a user's contribution graph. """ type ContributionCalendarMonth { """ The date of the first day of this month. """ firstDay: Date! """ The name of the month. """ name: String! """ How many weeks started in this month. """ totalWeeks: Int! """ The year the month occurred in. """ year: Int! } """ A week of contributions in a user's contribution graph. """ type ContributionCalendarWeek { """ The days of contributions in this week. """ contributionDays: [ContributionCalendarDay!]! """ The date of the earliest square in this week. """ firstDay: Date! } """ A contributions collection aggregates contributions such as opened issues and commits created by a user. """ type ContributionsCollection { """ A calendar of this user's contributions on GitHub. """ contributionCalendar: ContributionCalendar! """ Determine if this collection's time span ends in the current month. """ doesEndInCurrentMonth: Boolean! """ The date of the first restricted contribution the user made in this time period. Can only be non-null when the user has enabled private contribution counts. """ earliestRestrictedContributionDate: Date """ The ending date and time of this collection. """ endedAt: DateTime! """ The first issue the user opened on GitHub. This will be null if that issue was opened outside the collection's time range and ignoreTimeRange is false. If the issue is not visible but the user has opted to show private contributions, a RestrictedContribution will be returned. """ firstIssueContribution( """ If true, the first issue will be returned even if it was opened outside of the collection's time range. """ ignoreTimeRange: Boolean = false ): CreatedIssueOrRestrictedContribution """ The first pull request the user opened on GitHub. This will be null if that pull request was opened outside the collection's time range and ignoreTimeRange is not true. If the pull request is not visible but the user has opted to show private contributions, a RestrictedContribution will be returned. """ firstPullRequestContribution( """ If true, the first pull request will be returned even if it was opened outside of the collection's time range. """ ignoreTimeRange: Boolean = false ): CreatedPullRequestOrRestrictedContribution """ Does the user have any more activity in the timeline that occurred prior to the collection's time range? """ hasActivityInThePast: Boolean! """ Determine if there are any contributions in this collection. """ hasAnyContributions: Boolean! """ Determine if the user made any contributions in this time frame whose details are not visible because they were made in a private repository. Can only be true if the user enabled private contribution counts. """ hasAnyRestrictedContributions: Boolean! """ Whether or not the collector's time span is all within the same day. """ isSingleDay: Boolean! """ A list of issues the user opened. """ issueContributions( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Should the user's first issue ever be excluded from the result. """ excludeFirst: Boolean = false """ Should the user's most commented issue be excluded from the result. """ excludePopular: Boolean = false """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): CreatedIssueContributionConnection! """ When the user signed up for GitHub. This will be null if that sign up date falls outside the collection's time range and ignoreTimeRange is false. """ joinedGitHubContribution( """ If true, the contribution will be returned even if the user signed up outside of the collection's time range. """ ignoreTimeRange: Boolean = false ): JoinedGitHubContribution """ The date of the most recent restricted contribution the user made in this time period. Can only be non-null when the user has enabled private contribution counts. """ latestRestrictedContributionDate: Date """ When this collection's time range does not include any activity from the user, use this to get a different collection from an earlier time range that does have activity. """ mostRecentCollectionWithActivity: ContributionsCollection """ Returns a different contributions collection from an earlier time range than this one that does not have any contributions. """ mostRecentCollectionWithoutActivity: ContributionsCollection """ The issue the user opened on GitHub that received the most comments in the specified time frame. """ popularIssueContribution: CreatedIssueContribution """ The pull request the user opened on GitHub that received the most comments in the specified time frame. """ popularPullRequestContribution: CreatedPullRequestContribution """ A count of contributions made by the user that the viewer cannot access. Only non-zero when the user has chosen to share their private contribution counts. """ restrictedContributionsCount: Int! """ The beginning date and time of this collection. """ startedAt: DateTime! """ How many commits were made by the user in this time span. """ totalCommitContributions: Int! """ How many issues the user opened. """ totalIssueContributions( """ Should the user's first issue ever be excluded from this count. """ excludeFirst: Boolean = false """ Should the user's most commented issue be excluded from this count. """ excludePopular: Boolean = false ): Int! """ How many pull requests the user opened. """ totalPullRequestContributions( """ Should the user's first pull request ever be excluded from this count. """ excludeFirst: Boolean = false """ Should the user's most commented pull request be excluded from this count. """ excludePopular: Boolean = false ): Int! """ How many pull request reviews the user left. """ totalPullRequestReviewContributions: Int! """ How many different repositories the user committed to. """ totalRepositoriesWithContributedCommits: Int! """ How many different repositories the user opened issues in. """ totalRepositoriesWithContributedIssues( """ Should the user's first issue ever be excluded from this count. """ excludeFirst: Boolean = false """ Should the user's most commented issue be excluded from this count. """ excludePopular: Boolean = false ): Int! """ How many different repositories the user left pull request reviews in. """ totalRepositoriesWithContributedPullRequestReviews: Int! """ How many different repositories the user opened pull requests in. """ totalRepositoriesWithContributedPullRequests( """ Should the user's first pull request ever be excluded from this count. """ excludeFirst: Boolean = false """ Should the user's most commented pull request be excluded from this count. """ excludePopular: Boolean = false ): Int! """ How many repositories the user created. """ totalRepositoryContributions( """ Should the user's first repository ever be excluded from this count. """ excludeFirst: Boolean = false ): Int! """ The user who made the contributions in this collection. """ user: User! } """ Autogenerated input type of ConvertProjectCardNoteToIssue """ input ConvertProjectCardNoteToIssueInput @preview(toggledBy: "starfire-preview") { """ The body of the newly created issue. """ body: String """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The ProjectCard ID to convert. """ projectCardId: ID! @possibleTypes(concreteTypes: ["ProjectCard"]) """ The ID of the repository to create the issue in. """ repositoryId: ID! @possibleTypes(concreteTypes: ["Repository"]) """ The title of the newly created issue. Defaults to the card's note text. """ title: String } """ Autogenerated return type of ConvertProjectCardNoteToIssue """ type ConvertProjectCardNoteToIssuePayload @preview(toggledBy: "starfire-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The updated ProjectCard. """ projectCard: ProjectCard } """ Represents a 'converted_note_to_issue' event on a given issue or pull request. """ type ConvertedNoteToIssueEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Identifies the primary key from the database. """ databaseId: Int id: ID! """ Project referenced by event. """ project: Project @preview(toggledBy: "starfox-preview") """ Project card referenced by this project event. """ projectCard: ProjectCard @preview(toggledBy: "starfox-preview") """ Column name referenced by this project event. """ projectColumnName: String! @preview(toggledBy: "starfox-preview") } """ Autogenerated input type of CreateBranchProtectionRule """ input CreateBranchProtectionRuleInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ Will new commits pushed to matching branches dismiss pull request review approvals. """ dismissesStaleReviews: Boolean """ Can admins overwrite branch protection. """ isAdminEnforced: Boolean """ The glob-like pattern used to determine matching branches. """ pattern: String! """ A list of User or Team IDs allowed to push to matching branches. """ pushActorIds: [ID!] """ The global relay id of the repository in which a new branch protection rule should be created in. """ repositoryId: ID! @possibleTypes(concreteTypes: ["Repository"]) """ Number of approving reviews required to update matching branches. """ requiredApprovingReviewCount: Int """ List of required status check contexts that must pass for commits to be accepted to matching branches. """ requiredStatusCheckContexts: [String!] """ Are approving reviews required to update matching branches. """ requiresApprovingReviews: Boolean """ Are reviews from code owners required to update matching branches. """ requiresCodeOwnerReviews: Boolean """ Are commits required to be signed. """ requiresCommitSignatures: Boolean """ Are status checks required to update matching branches. """ requiresStatusChecks: Boolean """ Are branches required to be up to date before merging. """ requiresStrictStatusChecks: Boolean """ Is pushing to matching branches restricted. """ restrictsPushes: Boolean """ Is dismissal of pull request reviews restricted. """ restrictsReviewDismissals: Boolean """ A list of User or Team IDs allowed to dismiss reviews on pull requests targeting matching branches. """ reviewDismissalActorIds: [ID!] } """ Autogenerated return type of CreateBranchProtectionRule """ type CreateBranchProtectionRulePayload { """ The newly created BranchProtectionRule. """ branchProtectionRule: BranchProtectionRule """ A unique identifier for the client performing the mutation. """ clientMutationId: String } """ Autogenerated input type of CreateCheckRun """ input CreateCheckRunInput @preview(toggledBy: "antiope-preview") { """ Possible further actions the integrator can perform, which a user may trigger. """ actions: [CheckRunAction!] """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The time that the check run finished. """ completedAt: DateTime """ The final conclusion of the check. """ conclusion: CheckConclusionState """ The URL of the integrator's site that has the full details of the check. """ detailsUrl: URI """ A reference for the run on the integrator's system. """ externalId: String """ The SHA of the head commit. """ headSha: GitObjectID! """ The name of the check. """ name: String! """ Descriptive details about the run. """ output: CheckRunOutput """ The node ID of the repository. """ repositoryId: ID! @possibleTypes(concreteTypes: ["Repository"]) """ The time that the check run began. """ startedAt: DateTime """ The current status. """ status: RequestableCheckStatusState } """ Autogenerated return type of CreateCheckRun """ type CreateCheckRunPayload @preview(toggledBy: "antiope-preview") { """ The newly created check run. """ checkRun: CheckRun """ A unique identifier for the client performing the mutation. """ clientMutationId: String } """ Autogenerated input type of CreateCheckSuite """ input CreateCheckSuiteInput @preview(toggledBy: "antiope-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The SHA of the head commit. """ headSha: GitObjectID! """ The Node ID of the repository. """ repositoryId: ID! @possibleTypes(concreteTypes: ["Repository"]) } """ Autogenerated return type of CreateCheckSuite """ type CreateCheckSuitePayload @preview(toggledBy: "antiope-preview") { """ The newly created check suite. """ checkSuite: CheckSuite """ A unique identifier for the client performing the mutation. """ clientMutationId: String } """ Autogenerated input type of CreateContentAttachment """ input CreateContentAttachmentInput { """ The body of the content attachment, which may contain markdown. """ body: String! """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The node ID of the content_reference. """ contentReferenceId: ID! @possibleTypes(concreteTypes: ["ContentReference"]) """ The title of the content attachment. """ title: String! } """ Autogenerated return type of CreateContentAttachment """ type CreateContentAttachmentPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The newly created content attachment. """ contentAttachment: ContentAttachment } """ Autogenerated input type of CreateDeployment """ input CreateDeploymentInput @preview(toggledBy: "flash-preview") { """ Attempt to automatically merge the default branch into the requested ref, defaults to true. """ autoMerge: Boolean = true """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ Short description of the deployment. """ description: String = "" """ Name for the target deployment environment. """ environment: String = "production" """ JSON payload with extra information about the deployment. """ payload: String = "{}" """ The node ID of the ref to be deployed. """ refId: ID! @possibleTypes(concreteTypes: ["Ref"]) """ The node ID of the repository. """ repositoryId: ID! @possibleTypes(concreteTypes: ["Repository"]) """ The status contexts to verify against commit status checks. To bypass required contexts, pass an empty array. Defaults to all unique contexts. """ requiredContexts: [String!] """ Specifies a task to execute. """ task: String = "deploy" } """ Autogenerated return type of CreateDeployment """ type CreateDeploymentPayload @preview(toggledBy: "flash-preview") { """ True if the default branch has been auto-merged into the deployment ref. """ autoMerged: Boolean """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The new deployment. """ deployment: Deployment } """ Autogenerated input type of CreateDeploymentStatus """ input CreateDeploymentStatusInput @preview(toggledBy: "flash-preview") { """ Adds a new inactive status to all non-transient, non-production environment deployments with the same repository and environment name as the created status's deployment. """ autoInactive: Boolean = true """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The node ID of the deployment. """ deploymentId: ID! @possibleTypes(concreteTypes: ["Deployment"]) """ A short description of the status. Maximum length of 140 characters. """ description: String = "" """ If provided, updates the environment of the deploy. Otherwise, does not modify the environment. """ environment: String """ Sets the URL for accessing your environment. """ environmentUrl: String = "" """ The log URL to associate with this status. This URL should contain output to keep the user updated while the task is running or serve as historical information for what happened in the deployment. """ logUrl: String = "" """ The state of the deployment. """ state: DeploymentStatusState! } """ Autogenerated return type of CreateDeploymentStatus """ type CreateDeploymentStatusPayload @preview(toggledBy: "flash-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The new deployment status. """ deploymentStatus: DeploymentStatus } """ Autogenerated input type of CreateIssue """ input CreateIssueInput @preview(toggledBy: "starfire-preview") { """ The Node ID for the user assignee for this issue. """ assigneeIds: [ID!] @possibleTypes(concreteTypes: ["User"]) """ The body for the issue description. """ body: String """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ An array of Node IDs of labels for this issue. """ labelIds: [ID!] @possibleTypes(concreteTypes: ["Label"]) """ The Node ID of the milestone for this issue. """ milestoneId: ID @possibleTypes(concreteTypes: ["Milestone"]) """ An array of Node IDs for projects associated with this issue. """ projectIds: [ID!] @possibleTypes(concreteTypes: ["Project"]) """ The Node ID of the repository. """ repositoryId: ID! @possibleTypes(concreteTypes: ["Repository"]) """ The title for the issue. """ title: String! } """ Autogenerated return type of CreateIssue """ type CreateIssuePayload @preview(toggledBy: "starfire-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The new issue. """ issue: Issue } """ Autogenerated input type of CreateProject """ input CreateProjectInput { """ The description of project. """ body: String """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The name of project. """ name: String! """ The owner ID to create the project under. """ ownerId: ID! } """ Autogenerated return type of CreateProject """ type CreateProjectPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The new project. """ project: Project } """ Autogenerated input type of CreatePullRequest """ input CreatePullRequestInput @preview(toggledBy: "ocelot-preview") { """ The name of the branch you want your changes pulled into. This should be an existing branch on the current repository. You cannot update the base branch on a pull request to point to another repository. """ baseRefName: String! """ The contents of the pull request. """ body: String """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The name of the branch where your changes are implemented. For cross-repository pull requests in the same network, namespace `head_ref_name` with a user like this: `username:branch`. """ headRefName: String! """ Indicates whether maintainers can modify the pull request. """ maintainerCanModify: Boolean = true """ The Node ID of the repository. """ repositoryId: ID! @possibleTypes(concreteTypes: ["Repository"]) """ The title of the pull request. """ title: String! } """ Autogenerated return type of CreatePullRequest """ type CreatePullRequestPayload @preview(toggledBy: "ocelot-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The new pull request. """ pullRequest: PullRequest } """ Autogenerated input type of CreateTeamDiscussionComment """ input CreateTeamDiscussionCommentInput @preview(toggledBy: "echo-preview") { """ The content of the comment. """ body: String! """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The ID of the discussion to which the comment belongs. """ discussionId: ID! @possibleTypes(concreteTypes: ["TeamDiscussion"]) } """ Autogenerated return type of CreateTeamDiscussionComment """ type CreateTeamDiscussionCommentPayload @preview(toggledBy: "echo-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The new comment. """ teamDiscussionComment: TeamDiscussionComment } """ Autogenerated input type of CreateTeamDiscussion """ input CreateTeamDiscussionInput @preview(toggledBy: "echo-preview") { """ The content of the discussion. """ body: String! """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ If true, restricts the visiblity of this discussion to team members and organization admins. If false or not specified, allows any organization member to view this discussion. """ private: Boolean """ The ID of the team to which the discussion belongs. """ teamId: ID! @possibleTypes(concreteTypes: ["Team"]) """ The title of the discussion. """ title: String! } """ Autogenerated return type of CreateTeamDiscussion """ type CreateTeamDiscussionPayload @preview(toggledBy: "echo-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The new discussion. """ teamDiscussion: TeamDiscussion } """ Represents the contribution a user made on GitHub by opening an issue. """ type CreatedIssueContribution implements Contribution { """ Whether this contribution is associated with a record you do not have access to. For example, your own 'first issue' contribution may have been made on a repository you can no longer access. """ isRestricted: Boolean! """ The issue that was opened. """ issue: Issue! """ When this contribution was made. """ occurredAt: DateTime! """ The HTTP path for this contribution. """ resourcePath: URI! """ The HTTP URL for this contribution. """ url: URI! """ The user who made this contribution. """ user: User! } """ The connection type for CreatedIssueContribution. """ type CreatedIssueContributionConnection { """ A list of edges. """ edges: [CreatedIssueContributionEdge] """ A list of nodes. """ nodes: [CreatedIssueContribution] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type CreatedIssueContributionEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: CreatedIssueContribution } """ Represents either a issue the viewer can access or a restricted contribution. """ union CreatedIssueOrRestrictedContribution = CreatedIssueContribution | RestrictedContribution """ Represents the contribution a user made on GitHub by opening a pull request. """ type CreatedPullRequestContribution implements Contribution { """ Whether this contribution is associated with a record you do not have access to. For example, your own 'first issue' contribution may have been made on a repository you can no longer access. """ isRestricted: Boolean! """ When this contribution was made. """ occurredAt: DateTime! """ The pull request that was opened. """ pullRequest: PullRequest! """ The HTTP path for this contribution. """ resourcePath: URI! """ The HTTP URL for this contribution. """ url: URI! """ The user who made this contribution. """ user: User! } """ An edge in a connection. """ type CreatedPullRequestContributionEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: CreatedPullRequestContribution } """ Represents either a pull request the viewer can access or a restricted contribution. """ union CreatedPullRequestOrRestrictedContribution = CreatedPullRequestContribution | RestrictedContribution """ Represents a mention made by one issue or pull request to another. """ type CrossReferencedEvent implements Node & UniformResourceLocatable { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! id: ID! """ Reference originated in a different repository. """ isCrossRepository: Boolean! """ Identifies when the reference was made. """ referencedAt: DateTime! """ The HTTP path for this pull request. """ resourcePath: URI! """ Issue or pull request that made the reference. """ source: ReferencedSubject! """ Issue or pull request to which the reference was made. """ target: ReferencedSubject! """ The HTTP URL for this pull request. """ url: URI! """ Checks if the target will be closed when the source is merged. """ willCloseTarget: Boolean! } """ An ISO-8601 encoded date string. """ scalar Date """ An ISO-8601 encoded UTC date string. """ scalar DateTime """ Autogenerated input type of DeclineTopicSuggestion """ input DeclineTopicSuggestionInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The name of the suggested topic. """ name: String! """ The reason why the suggested topic is declined. """ reason: TopicSuggestionDeclineReason! """ The Node ID of the repository. """ repositoryId: ID! @possibleTypes(concreteTypes: ["Repository"]) } """ Autogenerated return type of DeclineTopicSuggestion """ type DeclineTopicSuggestionPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The declined topic. """ topic: Topic } """ The possible default permissions for repositories. """ enum DefaultRepositoryPermissionField { """ Can read, write, and administrate repos by default """ ADMIN """ No access """ NONE """ Can read repos by default """ READ """ Can read and write repos by default """ WRITE } """ Entities that can be deleted. """ interface Deletable { """ Check if the current viewer can delete this object. """ viewerCanDelete: Boolean! } """ Autogenerated input type of DeleteBranchProtectionRule """ input DeleteBranchProtectionRuleInput { """ The global relay id of the branch protection rule to be deleted. """ branchProtectionRuleId: ID! @possibleTypes(concreteTypes: ["BranchProtectionRule"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String } """ Autogenerated return type of DeleteBranchProtectionRule """ type DeleteBranchProtectionRulePayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String } """ Autogenerated input type of DeleteIssueComment """ input DeleteIssueCommentInput @preview(toggledBy: "starfire-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The ID of the comment to delete. """ id: ID! @possibleTypes(concreteTypes: ["IssueComment"]) } """ Autogenerated return type of DeleteIssueComment """ type DeleteIssueCommentPayload @preview(toggledBy: "starfire-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String } """ Autogenerated input type of DeleteIssue """ input DeleteIssueInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The ID of the issue to delete. """ issueId: ID! @possibleTypes(concreteTypes: ["Issue"]) } """ Autogenerated return type of DeleteIssue """ type DeleteIssuePayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The repository the issue belonged to """ repository: Repository } """ Autogenerated input type of DeleteProjectCard """ input DeleteProjectCardInput { """ The id of the card to delete. """ cardId: ID! @possibleTypes(concreteTypes: ["ProjectCard"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String } """ Autogenerated return type of DeleteProjectCard """ type DeleteProjectCardPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The column the deleted card was in. """ column: ProjectColumn """ The deleted card ID. """ deletedCardId: ID } """ Autogenerated input type of DeleteProjectColumn """ input DeleteProjectColumnInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The id of the column to delete. """ columnId: ID! @possibleTypes(concreteTypes: ["ProjectColumn"]) } """ Autogenerated return type of DeleteProjectColumn """ type DeleteProjectColumnPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The deleted column ID. """ deletedColumnId: ID """ The project the deleted column was in. """ project: Project } """ Autogenerated input type of DeleteProject """ input DeleteProjectInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The Project ID to update. """ projectId: ID! @possibleTypes(concreteTypes: ["Project"]) } """ Autogenerated return type of DeleteProject """ type DeleteProjectPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The repository or organization the project was removed from. """ owner: ProjectOwner } """ Autogenerated input type of DeletePullRequestReviewComment """ input DeletePullRequestReviewCommentInput @preview(toggledBy: "ocelot-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The ID of the comment to delete. """ id: ID! @possibleTypes(concreteTypes: ["PullRequestReviewComment"]) } """ Autogenerated return type of DeletePullRequestReviewComment """ type DeletePullRequestReviewCommentPayload @preview(toggledBy: "ocelot-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The pull request review the deleted comment belonged to. """ pullRequestReview: PullRequestReview } """ Autogenerated input type of DeletePullRequestReview """ input DeletePullRequestReviewInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The Node ID of the pull request review to delete. """ pullRequestReviewId: ID! @possibleTypes(concreteTypes: ["PullRequestReview"]) } """ Autogenerated return type of DeletePullRequestReview """ type DeletePullRequestReviewPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The deleted pull request review. """ pullRequestReview: PullRequestReview } """ Autogenerated input type of DeleteTeamDiscussionComment """ input DeleteTeamDiscussionCommentInput @preview(toggledBy: "echo-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The ID of the comment to delete. """ id: ID! @possibleTypes(concreteTypes: ["TeamDiscussionComment"]) } """ Autogenerated return type of DeleteTeamDiscussionComment """ type DeleteTeamDiscussionCommentPayload @preview(toggledBy: "echo-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String } """ Autogenerated input type of DeleteTeamDiscussion """ input DeleteTeamDiscussionInput @preview(toggledBy: "echo-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The discussion ID to delete. """ id: ID! @possibleTypes(concreteTypes: ["TeamDiscussion"]) } """ Autogenerated return type of DeleteTeamDiscussion """ type DeleteTeamDiscussionPayload @preview(toggledBy: "echo-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String } """ Represents a 'demilestoned' event on a given issue or pull request. """ type DemilestonedEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! id: ID! """ Identifies the milestone title associated with the 'demilestoned' event. """ milestoneTitle: String! """ Object referenced by event. """ subject: MilestoneItem! } """ A dependency manifest entry """ type DependencyGraphDependency @preview(toggledBy: "hawkgirl-preview") { """ Does the dependency itself have dependencies? """ hasDependencies: Boolean! """ The dependency package manager """ packageManager: String """ The required package name """ packageName: String! """ The repository containing the package """ repository: Repository """ The dependency version requirements """ requirements: String! } """ The connection type for DependencyGraphDependency. """ type DependencyGraphDependencyConnection @preview(toggledBy: "hawkgirl-preview") { """ A list of edges. """ edges: [DependencyGraphDependencyEdge] """ A list of nodes. """ nodes: [DependencyGraphDependency] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type DependencyGraphDependencyEdge @preview(toggledBy: "hawkgirl-preview") { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: DependencyGraphDependency } """ Dependency manifest for a repository """ type DependencyGraphManifest implements Node @preview(toggledBy: "hawkgirl-preview") { """ Path to view the manifest file blob """ blobPath: String! """ A list of manifest dependencies """ dependencies( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): DependencyGraphDependencyConnection """ The number of dependencies listed in the manifest """ dependenciesCount: Int """ Is the manifest too big to parse? """ exceedsMaxSize: Boolean! """ Fully qualified manifest filename """ filename: String! id: ID! """ Were we able to parse the manifest? """ parseable: Boolean! """ The repository containing the manifest """ repository: Repository! } """ The connection type for DependencyGraphManifest. """ type DependencyGraphManifestConnection @preview(toggledBy: "hawkgirl-preview") { """ A list of edges. """ edges: [DependencyGraphManifestEdge] """ A list of nodes. """ nodes: [DependencyGraphManifest] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type DependencyGraphManifestEdge @preview(toggledBy: "hawkgirl-preview") { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: DependencyGraphManifest } """ A repository deploy key. """ type DeployKey implements Node { """ Identifies the date and time when the object was created. """ createdAt: DateTime! id: ID! """ The deploy key. """ key: String! """ Whether or not the deploy key is read only. """ readOnly: Boolean! """ The deploy key title. """ title: String! """ Whether or not the deploy key has been verified. """ verified: Boolean! } """ The connection type for DeployKey. """ type DeployKeyConnection { """ A list of edges. """ edges: [DeployKeyEdge] """ A list of nodes. """ nodes: [DeployKey] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type DeployKeyEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: DeployKey } """ Represents a 'deployed' event on a given pull request. """ type DeployedEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Identifies the primary key from the database. """ databaseId: Int """ The deployment associated with the 'deployed' event. """ deployment: Deployment! id: ID! """ PullRequest referenced by event. """ pullRequest: PullRequest! """ The ref associated with the 'deployed' event. """ ref: Ref } """ Represents triggered deployment instance. """ type Deployment implements Node { """ Identifies the commit sha of the deployment. """ commit: Commit """ Identifies the oid of the deployment commit, even if the commit has been deleted. """ commitOid: String! """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Identifies the actor who triggered the deployment. """ creator: Actor """ Identifies the primary key from the database. """ databaseId: Int """ The deployment description. """ description: String """ The environment to which this deployment was made. """ environment: String id: ID! """ The latest status of this deployment. """ latestStatus: DeploymentStatus """ Extra information that a deployment system might need. """ payload: String """ Identifies the Ref of the deployment, if the deployment was created by ref. """ ref: Ref """ Identifies the repository associated with the deployment. """ repository: Repository! """ The current state of the deployment. """ state: DeploymentState """ A list of statuses associated with the deployment. """ statuses( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): DeploymentStatusConnection """ The deployment task. """ task: String """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! } """ The connection type for Deployment. """ type DeploymentConnection { """ A list of edges. """ edges: [DeploymentEdge] """ A list of nodes. """ nodes: [Deployment] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type DeploymentEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: Deployment } """ Represents a 'deployment_environment_changed' event on a given pull request. """ type DeploymentEnvironmentChangedEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ The deployment status that updated the deployment environment. """ deploymentStatus: DeploymentStatus! id: ID! """ PullRequest referenced by event. """ pullRequest: PullRequest! } """ Ordering options for deployment connections """ input DeploymentOrder { """ The ordering direction. """ direction: OrderDirection! """ The field to order deployments by. """ field: DeploymentOrderField! } """ Properties by which deployment connections can be ordered. """ enum DeploymentOrderField { """ Order collection by creation time """ CREATED_AT } """ The possible states in which a deployment can be. """ enum DeploymentState { """ The pending deployment was not updated after 30 minutes. """ ABANDONED """ The deployment is currently active. """ ACTIVE """ An inactive transient deployment. """ DESTROYED """ The deployment experienced an error. """ ERROR """ The deployment has failed. """ FAILURE """ The deployment is inactive. """ INACTIVE """ The deployment is in progress. """ IN_PROGRESS @preview(toggledBy: "flash-preview") """ The deployment is pending. """ PENDING """ The deployment has queued """ QUEUED @preview(toggledBy: "flash-preview") } """ Describes the status of a given deployment attempt. """ type DeploymentStatus implements Node { """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Identifies the actor who triggered the deployment. """ creator: Actor """ Identifies the deployment associated with status. """ deployment: Deployment! """ Identifies the description of the deployment. """ description: String """ Identifies the environment of the deployment at the time of this deployment status """ environment: String @preview(toggledBy: "flash-preview") """ Identifies the environment URL of the deployment. """ environmentUrl: URI id: ID! """ Identifies the log URL of the deployment. """ logUrl: URI """ Identifies the current state of the deployment. """ state: DeploymentStatusState! """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! } """ The connection type for DeploymentStatus. """ type DeploymentStatusConnection { """ A list of edges. """ edges: [DeploymentStatusEdge] """ A list of nodes. """ nodes: [DeploymentStatus] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type DeploymentStatusEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: DeploymentStatus } """ The possible states for a deployment status. """ enum DeploymentStatusState { """ The deployment experienced an error. """ ERROR """ The deployment has failed. """ FAILURE """ The deployment is inactive. """ INACTIVE """ The deployment is in progress. """ IN_PROGRESS """ The deployment is pending. """ PENDING """ The deployment is queued """ QUEUED """ The deployment was successful. """ SUCCESS } """ Autogenerated input type of DismissPullRequestReview """ input DismissPullRequestReviewInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The contents of the pull request review dismissal message. """ message: String! """ The Node ID of the pull request review to modify. """ pullRequestReviewId: ID! @possibleTypes(concreteTypes: ["PullRequestReview"]) } """ Autogenerated return type of DismissPullRequestReview """ type DismissPullRequestReviewPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The dismissed pull request review. """ pullRequestReview: PullRequestReview } """ Specifies a review comment to be left with a Pull Request Review. """ input DraftPullRequestReviewComment { """ Body of the comment to leave. """ body: String! """ Path to the file being commented on. """ path: String! """ Position in the file to leave a comment on. """ position: Int! } """ An external identity provisioned by SAML SSO or SCIM. """ type ExternalIdentity implements Node { """ The GUID for this identity """ guid: String! id: ID! """ Organization invitation for this SCIM-provisioned external identity """ organizationInvitation: OrganizationInvitation """ SAML Identity attributes """ samlIdentity: ExternalIdentitySamlAttributes """ SCIM Identity attributes """ scimIdentity: ExternalIdentityScimAttributes """ User linked to this external identity. Will be NULL if this identity has not been claimed by an organization member. """ user: User } """ The connection type for ExternalIdentity. """ type ExternalIdentityConnection { """ A list of edges. """ edges: [ExternalIdentityEdge] """ A list of nodes. """ nodes: [ExternalIdentity] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type ExternalIdentityEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: ExternalIdentity } """ SAML attributes for the External Identity """ type ExternalIdentitySamlAttributes { """ The NameID of the SAML identity """ nameId: String } """ SCIM attributes for the External Identity """ type ExternalIdentityScimAttributes { """ The userName of the SCIM identity """ username: String } """ The connection type for User. """ type FollowerConnection { """ A list of edges. """ edges: [UserEdge] """ A list of nodes. """ nodes: [User] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ The connection type for User. """ type FollowingConnection { """ A list of edges. """ edges: [UserEdge] """ A list of nodes. """ nodes: [User] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ A generic hovercard context with a message and icon """ type GenericHovercardContext implements HovercardContext @preview(toggledBy: "hagar-preview") { """ A string describing this context """ message: String! """ An octicon to accompany this context """ octicon: String! } """ A Gist. """ type Gist implements Node & Starrable { """ A list of comments associated with the gist """ comments( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): GistCommentConnection! """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ The gist description. """ description: String id: ID! """ Whether the gist is public or not. """ isPublic: Boolean! """ The gist name. """ name: String! """ The gist owner. """ owner: RepositoryOwner """ Identifies when the gist was last pushed to. """ pushedAt: DateTime """ A list of users who have starred this starrable. """ stargazers( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Order for connection """ orderBy: StarOrder ): StargazerConnection! """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! """ Returns a boolean indicating whether the viewing user has starred this starrable. """ viewerHasStarred: Boolean! } """ Represents a comment on an Gist. """ type GistComment implements Comment & Deletable & Minimizable & Node & Updatable & UpdatableComment { """ The actor who authored the comment. """ author: Actor """ Author's association with the gist. """ authorAssociation: CommentAuthorAssociation! """ Identifies the comment body. """ body: String! """ The comment body rendered to HTML. """ bodyHTML: HTML! """ The body rendered to text. """ bodyText: String! """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Check if this comment was created via an email reply. """ createdViaEmail: Boolean! """ Identifies the primary key from the database. """ databaseId: Int """ The actor who edited the comment. """ editor: Actor """ The associated gist. """ gist: Gist! id: ID! """ Check if this comment was edited and includes an edit with the creation data """ includesCreatedEdit: Boolean! """ Returns whether or not a comment has been minimized. """ isMinimized: Boolean! """ The moment the editor made the last edit """ lastEditedAt: DateTime """ Returns why the comment was minimized. """ minimizedReason: String """ Identifies when the comment was published at. """ publishedAt: DateTime """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! """ A list of edits to this content. """ userContentEdits( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): UserContentEditConnection """ Check if the current viewer can delete this object. """ viewerCanDelete: Boolean! """ Check if the current viewer can minimize this object. """ viewerCanMinimize: Boolean! """ Check if the current viewer can update this object. """ viewerCanUpdate: Boolean! """ Reasons why the current viewer can not update this comment. """ viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! """ Did the viewer author this comment. """ viewerDidAuthor: Boolean! } """ The connection type for GistComment. """ type GistCommentConnection { """ A list of edges. """ edges: [GistCommentEdge] """ A list of nodes. """ nodes: [GistComment] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type GistCommentEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: GistComment } """ The connection type for Gist. """ type GistConnection { """ A list of edges. """ edges: [GistEdge] """ A list of nodes. """ nodes: [Gist] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type GistEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: Gist } """ Ordering options for gist connections """ input GistOrder { """ The ordering direction. """ direction: OrderDirection! """ The field to order repositories by. """ field: GistOrderField! } """ Properties by which gist connections can be ordered. """ enum GistOrderField { """ Order gists by creation time """ CREATED_AT """ Order gists by push time """ PUSHED_AT """ Order gists by update time """ UPDATED_AT } """ The privacy of a Gist """ enum GistPrivacy { """ Gists that are public and secret """ ALL """ Public """ PUBLIC """ Secret """ SECRET } """ Represents an actor in a Git commit (ie. an author or committer). """ type GitActor { """ A URL pointing to the author's public avatar. """ avatarUrl( """ The size of the resulting square image. """ size: Int ): URI! """ The timestamp of the Git action (authoring or committing). """ date: GitTimestamp """ The email in the Git commit. """ email: String """ The name in the Git commit. """ name: String """ The GitHub user corresponding to the email field. Null if no such user exists. """ user: User } """ Represents information about the GitHub instance. """ type GitHubMetadata { """ Returns a String that's a SHA of `github-services` """ gitHubServicesSha: GitObjectID! """ IP addresses that users connect to for git operations """ gitIpAddresses: [String!] """ IP addresses that service hooks are sent from """ hookIpAddresses: [String!] """ IP addresses that the importer connects from """ importerIpAddresses: [String!] """ Whether or not users are verified """ isPasswordAuthenticationVerifiable: Boolean! """ IP addresses for GitHub Pages' A records """ pagesIpAddresses: [String!] } """ Represents a Git object. """ interface GitObject { """ An abbreviated version of the Git object ID """ abbreviatedOid: String! """ The HTTP path for this Git object """ commitResourcePath: URI! """ The HTTP URL for this Git object """ commitUrl: URI! id: ID! """ The Git object ID """ oid: GitObjectID! """ The Repository the Git object belongs to """ repository: Repository! } """ A Git object ID. """ scalar GitObjectID """ Git SSH string """ scalar GitSSHRemote """ Information about a signature (GPG or S/MIME) on a Commit or Tag. """ interface GitSignature { """ Email used to sign this object. """ email: String! """ True if the signature is valid and verified by GitHub. """ isValid: Boolean! """ Payload for GPG signing object. Raw ODB object without the signature header. """ payload: String! """ ASCII-armored signature header from object. """ signature: String! """ GitHub user corresponding to the email signing this commit. """ signer: User """ The state of this signature. `VALID` if signature is valid and verified by GitHub, otherwise represents reason why signature is considered invalid. """ state: GitSignatureState! """ True if the signature was made with GitHub's signing key. """ wasSignedByGitHub: Boolean! } """ The state of a Git signature. """ enum GitSignatureState { """ The signing certificate or its chain could not be verified """ BAD_CERT """ Invalid email used for signing """ BAD_EMAIL """ Signing key expired """ EXPIRED_KEY """ Internal error - the GPG verification service misbehaved """ GPGVERIFY_ERROR """ Internal error - the GPG verification service is unavailable at the moment """ GPGVERIFY_UNAVAILABLE """ Invalid signature """ INVALID """ Malformed signature """ MALFORMED_SIG """ The usage flags for the key that signed this don't allow signing """ NOT_SIGNING_KEY """ Email used for signing not known to GitHub """ NO_USER """ Valid siganture, though certificate revocation check failed """ OCSP_ERROR """ Valid signature, pending certificate revocation checking """ OCSP_PENDING """ One or more certificates in chain has been revoked """ OCSP_REVOKED """ Key used for signing not known to GitHub """ UNKNOWN_KEY """ Unknown signature type """ UNKNOWN_SIG_TYPE """ Unsigned """ UNSIGNED """ Email used for signing unverified on GitHub """ UNVERIFIED_EMAIL """ Valid signature and verified by GitHub """ VALID } """ An ISO-8601 encoded date string. Unlike the DateTime type, GitTimestamp is not converted in UTC. """ scalar GitTimestamp """ Represents a GPG signature on a Commit or Tag. """ type GpgSignature implements GitSignature { """ Email used to sign this object. """ email: String! """ True if the signature is valid and verified by GitHub. """ isValid: Boolean! """ Hex-encoded ID of the key that signed this object. """ keyId: String """ Payload for GPG signing object. Raw ODB object without the signature header. """ payload: String! """ ASCII-armored signature header from object. """ signature: String! """ GitHub user corresponding to the email signing this commit. """ signer: User """ The state of this signature. `VALID` if signature is valid and verified by GitHub, otherwise represents reason why signature is considered invalid. """ state: GitSignatureState! """ True if the signature was made with GitHub's signing key. """ wasSignedByGitHub: Boolean! } """ A string containing HTML code. """ scalar HTML """ Represents a 'head_ref_deleted' event on a given pull request. """ type HeadRefDeletedEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Identifies the Ref associated with the `head_ref_deleted` event. """ headRef: Ref """ Identifies the name of the Ref associated with the `head_ref_deleted` event. """ headRefName: String! id: ID! """ PullRequest referenced by event. """ pullRequest: PullRequest! } """ Represents a 'head_ref_force_pushed' event on a given pull request. """ type HeadRefForcePushedEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the after commit SHA for the 'head_ref_force_pushed' event. """ afterCommit: Commit """ Identifies the before commit SHA for the 'head_ref_force_pushed' event. """ beforeCommit: Commit """ Identifies the date and time when the object was created. """ createdAt: DateTime! id: ID! """ PullRequest referenced by event. """ pullRequest: PullRequest! """ Identifies the fully qualified ref name for the 'head_ref_force_pushed' event. """ ref: Ref } """ Represents a 'head_ref_restored' event on a given pull request. """ type HeadRefRestoredEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! id: ID! """ PullRequest referenced by event. """ pullRequest: PullRequest! } """ Detail needed to display a hovercard for a user """ type Hovercard @preview(toggledBy: "hagar-preview") { """ Each of the contexts for this hovercard """ contexts: [HovercardContext!]! } """ An individual line of a hovercard """ interface HovercardContext @preview(toggledBy: "hagar-preview") { """ A string describing this context """ message: String! """ An octicon to accompany this context """ octicon: String! } """ Autogenerated input type of InviteBusinessAdmin """ input InviteBusinessAdminInput { """ The ID of the business to which you want to invite an administrator. """ businessId: ID! @possibleTypes(concreteTypes: ["Business"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The email of the person to invite as an administrator. """ email: String """ The login of a user to invite as an administrator. """ invitee: String } """ Autogenerated return type of InviteBusinessAdmin """ type InviteBusinessAdminPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The created business administrator invitation """ invitation: BusinessMemberInvitation @preview(toggledBy: "gwenpool-preview") } """ Autogenerated input type of InviteBusinessBillingManager """ input InviteBusinessBillingManagerInput { """ The ID of the business to which you want to invite a billing manager. """ businessId: ID! @possibleTypes(concreteTypes: ["Business"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The email of the person to invite as a billing manager. """ email: String """ The login of a user to invite as a billing manager. """ invitee: String } """ Autogenerated return type of InviteBusinessBillingManager """ type InviteBusinessBillingManagerPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The created business billing manager invitation """ invitation: BusinessMemberInvitation @preview(toggledBy: "gwenpool-preview") } """ An Issue is a place to discuss ideas, enhancements, tasks, and bugs for a project. """ type Issue implements Assignable & Closable & Comment & Labelable & Lockable & Node & Reactable & RepositoryNode & Subscribable & UniformResourceLocatable & Updatable & UpdatableComment { """ Reason that the conversation was locked. """ activeLockReason: LockReason """ A list of Users assigned to this object. """ assignees( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): UserConnection! """ The actor who authored the comment. """ author: Actor """ Author's association with the subject of the comment. """ authorAssociation: CommentAuthorAssociation! """ Identifies the body of the issue. """ body: String! """ Identifies the body of the issue rendered to HTML. """ bodyHTML: HTML! """ Identifies the body of the issue rendered to text. """ bodyText: String! """ `true` if the object is closed (definition of closed may depend on type) """ closed: Boolean! """ Identifies the date and time when the object was closed. """ closedAt: DateTime """ A list of comments associated with the Issue. """ comments( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): IssueCommentConnection! """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Check if this comment was created via an email reply. """ createdViaEmail: Boolean! """ Identifies the primary key from the database. """ databaseId: Int """ The actor who edited the comment. """ editor: Actor """ The hovercard information for this issue """ hovercard( """ Whether or not to include notification contexts """ includeNotificationContexts: Boolean = true ): Hovercard! @preview(toggledBy: "hagar-preview") id: ID! """ Check if this comment was edited and includes an edit with the creation data """ includesCreatedEdit: Boolean! """ A list of labels associated with the object. """ labels( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): LabelConnection """ The moment the editor made the last edit """ lastEditedAt: DateTime """ `true` if the object is locked """ locked: Boolean! """ Identifies the milestone associated with the issue. """ milestone: Milestone """ Identifies the issue number. """ number: Int! """ A list of Users that are participating in the Issue conversation. """ participants( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): UserConnection! """ List of project cards associated with this issue. """ projectCards( """ Returns the elements in the list that come after the specified cursor. """ after: String """ A list of archived states to filter the cards by """ archivedStates: [ProjectCardArchivedState] = [ARCHIVED, NOT_ARCHIVED] """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): ProjectCardConnection! """ Identifies when the comment was published at. """ publishedAt: DateTime """ A list of reactions grouped by content left on the subject. """ reactionGroups: [ReactionGroup!] """ A list of Reactions left on the Issue. """ reactions( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Allows filtering Reactions by emoji. """ content: ReactionContent """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Allows specifying the order in which reactions are returned. """ orderBy: ReactionOrder ): ReactionConnection! """ The repository associated with this node. """ repository: Repository! """ The HTTP path for this issue """ resourcePath: URI! """ Identifies the state of the issue. """ state: IssueState! """ A list of events, comments, commits, etc. associated with the issue. """ timeline( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Allows filtering timeline events by a `since` timestamp. """ since: DateTime ): IssueTimelineConnection! """ A list of events, comments, commits, etc. associated with the issue. """ timelineItems( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Filter timeline items by type. """ itemTypes: [IssueTimelineItemsItemType!] """ Returns the last _n_ elements from the list. """ last: Int """ Filter timeline items by a `since` timestamp. """ since: DateTime """ Skips the first _n_ elements in the list. """ skip: Int ): IssueTimelineItemsConnection! @preview(toggledBy: "starfire-preview") """ Identifies the issue title. """ title: String! """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! """ The HTTP URL for this issue """ url: URI! """ A list of edits to this content. """ userContentEdits( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): UserContentEditConnection """ Can user react to this subject """ viewerCanReact: Boolean! """ Check if the viewer is able to change their subscription status for the repository. """ viewerCanSubscribe: Boolean! """ Check if the current viewer can update this object. """ viewerCanUpdate: Boolean! """ Reasons why the current viewer can not update this comment. """ viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! """ Did the viewer author this comment. """ viewerDidAuthor: Boolean! """ Identifies if the viewer is watching, not watching, or ignoring the subscribable entity. """ viewerSubscription: SubscriptionState } """ Represents a comment on an Issue. """ type IssueComment implements Comment & Deletable & Minimizable & Node & Reactable & RepositoryNode & Updatable & UpdatableComment { """ The actor who authored the comment. """ author: Actor """ Author's association with the subject of the comment. """ authorAssociation: CommentAuthorAssociation! """ The body as Markdown. """ body: String! """ The body rendered to HTML. """ bodyHTML: HTML! """ The body rendered to text. """ bodyText: String! """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Check if this comment was created via an email reply. """ createdViaEmail: Boolean! """ Identifies the primary key from the database. """ databaseId: Int """ The actor who edited the comment. """ editor: Actor id: ID! """ Check if this comment was edited and includes an edit with the creation data """ includesCreatedEdit: Boolean! """ Returns whether or not a comment has been minimized. """ isMinimized: Boolean! """ Identifies the issue associated with the comment. """ issue: Issue! """ The moment the editor made the last edit """ lastEditedAt: DateTime """ Returns why the comment was minimized. """ minimizedReason: String """ Identifies when the comment was published at. """ publishedAt: DateTime """ Returns the pull request associated with the comment, if this comment was made on a pull request. """ pullRequest: PullRequest """ A list of reactions grouped by content left on the subject. """ reactionGroups: [ReactionGroup!] """ A list of Reactions left on the Issue. """ reactions( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Allows filtering Reactions by emoji. """ content: ReactionContent """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Allows specifying the order in which reactions are returned. """ orderBy: ReactionOrder ): ReactionConnection! """ The repository associated with this node. """ repository: Repository! """ The HTTP path for this issue comment """ resourcePath: URI! """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! """ The HTTP URL for this issue comment """ url: URI! """ A list of edits to this content. """ userContentEdits( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): UserContentEditConnection """ Check if the current viewer can delete this object. """ viewerCanDelete: Boolean! """ Check if the current viewer can minimize this object. """ viewerCanMinimize: Boolean! """ Can user react to this subject """ viewerCanReact: Boolean! """ Check if the current viewer can update this object. """ viewerCanUpdate: Boolean! """ Reasons why the current viewer can not update this comment. """ viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! """ Did the viewer author this comment. """ viewerDidAuthor: Boolean! } """ The connection type for IssueComment. """ type IssueCommentConnection { """ A list of edges. """ edges: [IssueCommentEdge] """ A list of nodes. """ nodes: [IssueComment] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type IssueCommentEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: IssueComment } """ The connection type for Issue. """ type IssueConnection { """ A list of edges. """ edges: [IssueEdge] """ A list of nodes. """ nodes: [Issue] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type IssueEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: Issue } """ Ways in which to filter lists of issues. """ input IssueFilters @preview(toggledBy: "starfire-preview") { """ List issues assigned to given name. Pass in `null` for issues with no assigned user, and `*` for issues assigned to any user. """ assignee: String """ List issues created by given name. """ createdBy: String """ List issues where the list of label names exist on the issue. """ labels: [String!] """ List issues where the given name is mentioned in the issue. """ mentioned: String """ List issues by given milestone argument. If an string representation of an integer is passed, it should refer to a milestone by its number field. Pass in `null` for issues with no milestone, and `*` for issues that are assigned to any milestone. """ milestone: String """ List issues that have been updated at or after the given date. """ since: DateTime """ List issues filtered by the list of states given. """ states: [IssueState!] """ List issues subscribed to by viewer. """ viewerSubscribed: Boolean = false } """ Used for return value of Repository.issueOrPullRequest. """ union IssueOrPullRequest = Issue | PullRequest """ Ways in which lists of issues can be ordered upon return. """ input IssueOrder { """ The direction in which to order issues by the specified field. """ direction: OrderDirection! """ The field in which to order issues by. """ field: IssueOrderField! } """ Properties by which issue connections can be ordered. """ enum IssueOrderField { """ Order issues by comment count """ COMMENTS """ Order issues by creation time """ CREATED_AT """ Order issues by update time """ UPDATED_AT } """ The possible states of an issue. """ enum IssueState { """ An issue that has been closed """ CLOSED """ An issue that is still open """ OPEN } """ The connection type for IssueTimelineItem. """ type IssueTimelineConnection { """ A list of edges. """ edges: [IssueTimelineItemEdge] """ A list of nodes. """ nodes: [IssueTimelineItem] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An item in an issue timeline """ union IssueTimelineItem = AssignedEvent | ClosedEvent | Commit | CrossReferencedEvent | DemilestonedEvent | IssueComment | LabeledEvent | LockedEvent | MilestonedEvent | ReferencedEvent | RenamedTitleEvent | ReopenedEvent | SubscribedEvent | TransferredEvent | UnassignedEvent | UnlabeledEvent | UnlockedEvent | UnsubscribedEvent """ An edge in a connection. """ type IssueTimelineItemEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: IssueTimelineItem } """ An item in an issue timeline """ union IssueTimelineItems = AddedToProjectEvent | AssignedEvent | ClosedEvent | CommentDeletedEvent | ConvertedNoteToIssueEvent | CrossReferencedEvent | DemilestonedEvent | IssueComment | LabeledEvent | LockedEvent | MentionedEvent | MilestonedEvent | MovedColumnsInProjectEvent | PinnedEvent | ReferencedEvent | RemovedFromProjectEvent | RenamedTitleEvent | ReopenedEvent | SubscribedEvent | TransferredEvent | UnassignedEvent | UnlabeledEvent | UnlockedEvent | UnpinnedEvent | UnsubscribedEvent """ The connection type for IssueTimelineItems. """ type IssueTimelineItemsConnection { """ A list of edges. """ edges: [IssueTimelineItemsEdge] """ Identifies the count of items after applying `before` and `after` filters. """ filteredCount: Int! """ A list of nodes. """ nodes: [IssueTimelineItems] """ Identifies the count of items after applying `before`/`after` filters and `first`/`last`/`skip` slicing. """ pageCount: Int! """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! """ Identifies the date and time when the timeline was last updated. """ updatedAt: DateTime! } """ An edge in a connection. """ type IssueTimelineItemsEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: IssueTimelineItems } """ The possible item types found in a timeline. """ enum IssueTimelineItemsItemType { """ Represents a 'added_to_project' event on a given issue or pull request. """ ADDED_TO_PROJECT_EVENT """ Represents an 'assigned' event on any assignable object. """ ASSIGNED_EVENT """ Represents a 'closed' event on any `Closable`. """ CLOSED_EVENT """ Represents a 'comment_deleted' event on a given issue or pull request. """ COMMENT_DELETED_EVENT """ Represents a 'converted_note_to_issue' event on a given issue or pull request. """ CONVERTED_NOTE_TO_ISSUE_EVENT """ Represents a mention made by one issue or pull request to another. """ CROSS_REFERENCED_EVENT """ Represents a 'demilestoned' event on a given issue or pull request. """ DEMILESTONED_EVENT """ Represents a comment on an Issue. """ ISSUE_COMMENT """ Represents a 'labeled' event on a given issue or pull request. """ LABELED_EVENT """ Represents a 'locked' event on a given issue or pull request. """ LOCKED_EVENT """ Represents a 'mentioned' event on a given issue or pull request. """ MENTIONED_EVENT """ Represents a 'milestoned' event on a given issue or pull request. """ MILESTONED_EVENT """ Represents a 'moved_columns_in_project' event on a given issue or pull request. """ MOVED_COLUMNS_IN_PROJECT_EVENT """ Represents a 'pinned' event on a given issue or pull request. """ PINNED_EVENT """ Represents a 'referenced' event on a given `ReferencedSubject`. """ REFERENCED_EVENT """ Represents a 'removed_from_project' event on a given issue or pull request. """ REMOVED_FROM_PROJECT_EVENT """ Represents a 'renamed' event on a given issue or pull request """ RENAMED_TITLE_EVENT """ Represents a 'reopened' event on any `Closable`. """ REOPENED_EVENT """ Represents a 'subscribed' event on a given `Subscribable`. """ SUBSCRIBED_EVENT """ Represents a 'transferred' event on a given issue or pull request. """ TRANSFERRED_EVENT """ Represents an 'unassigned' event on any assignable object. """ UNASSIGNED_EVENT """ Represents an 'unlabeled' event on a given issue or pull request. """ UNLABELED_EVENT """ Represents an 'unlocked' event on a given issue or pull request. """ UNLOCKED_EVENT """ Represents an 'unpinned' event on a given issue or pull request. """ UNPINNED_EVENT """ Represents an 'unsubscribed' event on a given `Subscribable`. """ UNSUBSCRIBED_EVENT } """ Represents a user signing up for a GitHub account. """ type JoinedGitHubContribution implements Contribution { """ Whether this contribution is associated with a record you do not have access to. For example, your own 'first issue' contribution may have been made on a repository you can no longer access. """ isRestricted: Boolean! """ When this contribution was made. """ occurredAt: DateTime! """ The HTTP path for this contribution. """ resourcePath: URI! """ The HTTP URL for this contribution. """ url: URI! """ The user who made this contribution. """ user: User! } """ A label for categorizing Issues or Milestones with a given Repository. """ type Label implements Node { """ Identifies the label color. """ color: String! """ Identifies the date and time when the label was created. """ createdAt: DateTime """ A brief description of this label. """ description: String id: ID! """ Indicates whether or not this is a default label. """ isDefault: Boolean! """ A list of issues associated with this label. """ issues( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Filtering options for issues returned from the connection. """ filterBy: IssueFilters @preview(toggledBy: "starfire-preview") """ Returns the first _n_ elements from the list. """ first: Int """ A list of label names to filter the pull requests by. """ labels: [String!] """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for issues returned from the connection. """ orderBy: IssueOrder """ A list of states to filter the issues by. """ states: [IssueState!] ): IssueConnection! """ Identifies the label name. """ name: String! """ A list of pull requests associated with this label. """ pullRequests( """ Returns the elements in the list that come after the specified cursor. """ after: String """ The base ref name to filter the pull requests by. """ baseRefName: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ The head ref name to filter the pull requests by. """ headRefName: String """ A list of label names to filter the pull requests by. """ labels: [String!] """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for pull requests returned from the connection. """ orderBy: IssueOrder """ A list of states to filter the pull requests by. """ states: [PullRequestState!] ): PullRequestConnection! """ The repository associated with this label. """ repository: Repository! """ The HTTP path for this label. """ resourcePath: URI! """ Identifies the date and time when the label was last updated. """ updatedAt: DateTime """ The HTTP URL for this label. """ url: URI! } """ The connection type for Label. """ type LabelConnection { """ A list of edges. """ edges: [LabelEdge] """ A list of nodes. """ nodes: [Label] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type LabelEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: Label } """ An object that can have labels assigned to it. """ interface Labelable { """ A list of labels associated with the object. """ labels( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): LabelConnection } """ Represents a 'labeled' event on a given issue or pull request. """ type LabeledEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! id: ID! """ Identifies the label associated with the 'labeled' event. """ label: Label! """ Identifies the `Labelable` associated with the event. """ labelable: Labelable! } """ Represents a given language found in repositories. """ type Language implements Node { """ The color defined for the current language. """ color: String id: ID! """ The name of the current language. """ name: String! } """ A list of languages associated with the parent. """ type LanguageConnection { """ A list of edges. """ edges: [LanguageEdge] """ A list of nodes. """ nodes: [Language] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! """ The total size in bytes of files written in that language. """ totalSize: Int! } """ Represents the language of a repository. """ type LanguageEdge { cursor: String! node: Language! """ The number of bytes of code written in the language. """ size: Int! } """ Ordering options for language connections. """ input LanguageOrder { """ The ordering direction. """ direction: OrderDirection! """ The field to order languages by. """ field: LanguageOrderField! } """ Properties by which language connections can be ordered. """ enum LanguageOrderField { """ Order languages by the size of all files containing the language """ SIZE } """ A repository's open source license """ type License implements Node { """ The full text of the license """ body: String! """ The conditions set by the license """ conditions: [LicenseRule]! """ A human-readable description of the license """ description: String """ Whether the license should be featured """ featured: Boolean! """ Whether the license should be displayed in license pickers """ hidden: Boolean! id: ID! """ Instructions on how to implement the license """ implementation: String """ The lowercased SPDX ID of the license """ key: String! """ The limitations set by the license """ limitations: [LicenseRule]! """ The license full name specified by """ name: String! """ Customary short name if applicable (e.g, GPLv3) """ nickname: String """ The permissions set by the license """ permissions: [LicenseRule]! """ Whether the license is a pseudo-license placeholder (e.g., other, no-license) """ pseudoLicense: Boolean! """ Short identifier specified by """ spdxId: String """ URL to the license on """ url: URI } """ Describes a License's conditions, permissions, and limitations """ type LicenseRule { """ A description of the rule """ description: String! """ The machine-readable rule key """ key: String! """ The human-readable rule label """ label: String! } """ Autogenerated input type of LockLockable """ input LockLockableInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ A reason for why the issue or pull request will be locked. """ lockReason: LockReason """ ID of the issue or pull request to be locked. """ lockableId: ID! @possibleTypes(concreteTypes: ["Issue", "PullRequest"], abstractType: "Lockable") } """ Autogenerated return type of LockLockable """ type LockLockablePayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The item that was locked. """ lockedRecord: Lockable } """ The possible reasons that an issue or pull request was locked. """ enum LockReason { """ The issue or pull request was locked because the conversation was off-topic. """ OFF_TOPIC """ The issue or pull request was locked because the conversation was resolved. """ RESOLVED """ The issue or pull request was locked because the conversation was spam. """ SPAM """ The issue or pull request was locked because the conversation was too heated. """ TOO_HEATED } """ An object that can be locked. """ interface Lockable { """ Reason that the conversation was locked. """ activeLockReason: LockReason """ `true` if the object is locked """ locked: Boolean! } """ Represents a 'locked' event on a given issue or pull request. """ type LockedEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! id: ID! """ Reason that the conversation was locked (optional). """ lockReason: LockReason """ Object that was locked. """ lockable: Lockable! } """ A public description of a Marketplace category. """ type MarketplaceCategory implements Node { """ The category's description. """ description: String """ The technical description of how apps listed in this category work with GitHub. """ howItWorks: String id: ID! """ The category's name. """ name: String! """ How many Marketplace listings have this as their primary category. """ primaryListingCount: Int! """ The HTTP path for this Marketplace category. """ resourcePath: URI! """ How many Marketplace listings have this as their secondary category. """ secondaryListingCount: Int! """ The short name of the category used in its URL. """ slug: String! """ The HTTP URL for this Marketplace category. """ url: URI! } """ A listing in the GitHub integration marketplace. """ type MarketplaceListing implements Node { """ The GitHub App this listing represents. """ app: App """ URL to the listing owner's company site. """ companyUrl: URI """ The HTTP path for configuring access to the listing's integration or OAuth app """ configurationResourcePath: URI! """ The HTTP URL for configuring access to the listing's integration or OAuth app """ configurationUrl: URI! """ URL to the listing's documentation. """ documentationUrl: URI """ The listing's detailed description. """ extendedDescription: String """ The listing's detailed description rendered to HTML. """ extendedDescriptionHTML: HTML! """ The listing's introductory description. """ fullDescription: String! """ The listing's introductory description rendered to HTML. """ fullDescriptionHTML: HTML! """ Whether this listing has been submitted for review from GitHub for approval to be displayed in the Marketplace. """ hasApprovalBeenRequested: Boolean! """ Does this listing have any plans with a free trial? """ hasPublishedFreeTrialPlans: Boolean! """ Does this listing have a terms of service link? """ hasTermsOfService: Boolean! """ A technical description of how this app works with GitHub. """ howItWorks: String """ The listing's technical description rendered to HTML. """ howItWorksHTML: HTML! id: ID! """ URL to install the product to the viewer's account or organization. """ installationUrl: URI """ Whether this listing's app has been installed for the current viewer """ installedForViewer: Boolean! """ Whether this listing has been approved for display in the Marketplace. """ isApproved: Boolean! """ Whether this listing has been removed from the Marketplace. """ isDelisted: Boolean! """ Whether this listing is still an editable draft that has not been submitted for review and is not publicly visible in the Marketplace. """ isDraft: Boolean! """ Whether the product this listing represents is available as part of a paid plan. """ isPaid: Boolean! """ Whether this listing has been rejected by GitHub for display in the Marketplace. """ isRejected: Boolean! """ The hex color code, without the leading '#', for the logo background. """ logoBackgroundColor: String! """ URL for the listing's logo image. """ logoUrl( """ The size in pixels of the resulting square image. """ size: Int = 400 ): URI """ The listing's full name. """ name: String! """ The listing's very short description without a trailing period or ampersands. """ normalizedShortDescription: String! """ URL to the listing's detailed pricing. """ pricingUrl: URI """ The category that best describes the listing. """ primaryCategory: MarketplaceCategory! """ URL to the listing's privacy policy. """ privacyPolicyUrl: URI! """ The HTTP path for the Marketplace listing. """ resourcePath: URI! """ The URLs for the listing's screenshots. """ screenshotUrls: [String]! """ An alternate category that describes the listing. """ secondaryCategory: MarketplaceCategory """ The listing's very short description. """ shortDescription: String! """ The short name of the listing used in its URL. """ slug: String! """ URL to the listing's status page. """ statusUrl: URI """ An email address for support for this listing's app. """ supportEmail: String """ Either a URL or an email address for support for this listing's app. """ supportUrl: URI! """ URL to the listing's terms of service. """ termsOfServiceUrl: URI """ The HTTP URL for the Marketplace listing. """ url: URI! """ Can the current viewer add plans for this Marketplace listing. """ viewerCanAddPlans: Boolean! """ Can the current viewer approve this Marketplace listing. """ viewerCanApprove: Boolean! """ Can the current viewer delist this Marketplace listing. """ viewerCanDelist: Boolean! """ Can the current viewer edit this Marketplace listing. """ viewerCanEdit: Boolean! """ Can the current viewer edit the primary and secondary category of this Marketplace listing. """ viewerCanEditCategories: Boolean! """ Can the current viewer edit the plans for this Marketplace listing. """ viewerCanEditPlans: Boolean! """ Can the current viewer return this Marketplace listing to draft state so it becomes editable again. """ viewerCanRedraft: Boolean! """ Can the current viewer reject this Marketplace listing by returning it to an editable draft state or rejecting it entirely. """ viewerCanReject: Boolean! """ Can the current viewer request this listing be reviewed for display in the Marketplace. """ viewerCanRequestApproval: Boolean! """ Indicates whether the current user has an active subscription to this Marketplace listing. """ viewerHasPurchased: Boolean! """ Indicates if the current user has purchased a subscription to this Marketplace listing for all of the organizations the user owns. """ viewerHasPurchasedForAllOrganizations: Boolean! """ Does the current viewer role allow them to administer this Marketplace listing. """ viewerIsListingAdmin: Boolean! } """ Look up Marketplace Listings """ type MarketplaceListingConnection { """ A list of edges. """ edges: [MarketplaceListingEdge] """ A list of nodes. """ nodes: [MarketplaceListing] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type MarketplaceListingEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: MarketplaceListing } """ Represents a 'mentioned' event on a given issue or pull request. """ type MentionedEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Identifies the primary key from the database. """ databaseId: Int id: ID! } """ Autogenerated input type of MergePullRequest """ input MergePullRequestInput @preview(toggledBy: "ocelot-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ Commit body to use for the merge commit; if omitted, a default message will be used """ commitBody: String """ Commit headline to use for the merge commit; if omitted, a default message will be used. """ commitHeadline: String """ OID that the pull request head ref must match to allow merge; if omitted, no check is performed. """ expectedHeadOid: GitObjectID """ ID of the pull request to be merged. """ pullRequestId: ID! @possibleTypes(concreteTypes: ["PullRequest"]) } """ Autogenerated return type of MergePullRequest """ type MergePullRequestPayload @preview(toggledBy: "ocelot-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The pull request that was merged. """ pullRequest: PullRequest } """ Detailed status information about a pull request merge. """ enum MergeStateStatus { """ The head ref is out of date. """ BEHIND """ The merge is blocked. """ BLOCKED """ Mergeable and passing commit status. """ CLEAN """ The merge commit cannot be cleanly created. """ DIRTY """ Mergeable with passing commit status and pre-recieve hooks. """ HAS_HOOKS """ The state cannot currently be determined. """ UNKNOWN """ Mergeable with non-passing commit status. """ UNSTABLE } """ Whether or not a PullRequest can be merged. """ enum MergeableState { """ The pull request cannot be merged due to merge conflicts. """ CONFLICTING """ The pull request can be merged. """ MERGEABLE """ The mergeability of the pull request is still being calculated. """ UNKNOWN } """ Represents a 'merged' event on a given pull request. """ type MergedEvent implements Node & UniformResourceLocatable { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the commit associated with the `merge` event. """ commit: Commit """ Identifies the date and time when the object was created. """ createdAt: DateTime! id: ID! """ Identifies the Ref associated with the `merge` event. """ mergeRef: Ref """ Identifies the name of the Ref associated with the `merge` event. """ mergeRefName: String! """ PullRequest referenced by event. """ pullRequest: PullRequest! """ The HTTP path for this merged event. """ resourcePath: URI! """ The HTTP URL for this merged event. """ url: URI! } """ Represents a Milestone object on a given repository. """ type Milestone implements Closable & Node & UniformResourceLocatable { """ `true` if the object is closed (definition of closed may depend on type) """ closed: Boolean! """ Identifies the date and time when the object was closed. """ closedAt: DateTime """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Identifies the actor who created the milestone. """ creator: Actor """ Identifies the description of the milestone. """ description: String """ Identifies the due date of the milestone. """ dueOn: DateTime id: ID! """ A list of issues associated with the milestone. """ issues( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Filtering options for issues returned from the connection. """ filterBy: IssueFilters @preview(toggledBy: "starfire-preview") """ Returns the first _n_ elements from the list. """ first: Int """ A list of label names to filter the pull requests by. """ labels: [String!] """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for issues returned from the connection. """ orderBy: IssueOrder """ A list of states to filter the issues by. """ states: [IssueState!] ): IssueConnection! """ Identifies the number of the milestone. """ number: Int! """ A list of pull requests associated with the milestone. """ pullRequests( """ Returns the elements in the list that come after the specified cursor. """ after: String """ The base ref name to filter the pull requests by. """ baseRefName: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ The head ref name to filter the pull requests by. """ headRefName: String """ A list of label names to filter the pull requests by. """ labels: [String!] """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for pull requests returned from the connection. """ orderBy: IssueOrder """ A list of states to filter the pull requests by. """ states: [PullRequestState!] ): PullRequestConnection! """ The repository associated with this milestone. """ repository: Repository! """ The HTTP path for this milestone """ resourcePath: URI! """ Identifies the state of the milestone. """ state: MilestoneState! """ Identifies the title of the milestone. """ title: String! """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! """ The HTTP URL for this milestone """ url: URI! } """ The connection type for Milestone. """ type MilestoneConnection { """ A list of edges. """ edges: [MilestoneEdge] """ A list of nodes. """ nodes: [Milestone] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type MilestoneEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: Milestone } """ Types that can be inside a Milestone. """ union MilestoneItem = Issue | PullRequest """ Ordering options for milestone connections. """ input MilestoneOrder { """ The ordering direction. """ direction: OrderDirection! """ The field to order milestones by. """ field: MilestoneOrderField! } """ Properties by which milestone connections can be ordered. """ enum MilestoneOrderField { """ Order milestones by when they were created. """ CREATED_AT """ Order milestones by when they are due. """ DUE_DATE """ Order milestones by their number. """ NUMBER """ Order milestones by when they were last updated. """ UPDATED_AT } """ The possible states of a milestone. """ enum MilestoneState { """ A milestone that has been closed. """ CLOSED """ A milestone that is still open. """ OPEN } """ Represents a 'milestoned' event on a given issue or pull request. """ type MilestonedEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! id: ID! """ Identifies the milestone title associated with the 'milestoned' event. """ milestoneTitle: String! """ Object referenced by event. """ subject: MilestoneItem! } """ Entities that can be minimized. """ interface Minimizable @preview(toggledBy: "queen-beryl-preview") { """ Returns whether or not a comment has been minimized. """ isMinimized: Boolean! """ Returns why the comment was minimized. """ minimizedReason: String """ Check if the current viewer can minimize this object. """ viewerCanMinimize: Boolean! } """ Autogenerated input type of MinimizeComment """ input MinimizeCommentInput { """ The classification of comment """ classifier: ReportedContentClassifiers! """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The Node ID of the subject to modify. """ subjectId: ID! @possibleTypes(concreteTypes: ["CommitComment", "GistComment", "IssueComment", "PullRequestReviewComment"], abstractType: "Minimizable") } """ Autogenerated return type of MinimizeComment """ type MinimizeCommentPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The comment that was minimized. """ minimizedComment: Minimizable } """ Autogenerated input type of MoveProjectCard """ input MoveProjectCardInput { """ Place the new card after the card with this id. Pass null to place it at the top. """ afterCardId: ID @possibleTypes(concreteTypes: ["ProjectCard"]) """ The id of the card to move. """ cardId: ID! @possibleTypes(concreteTypes: ["ProjectCard"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The id of the column to move it into. """ columnId: ID! @possibleTypes(concreteTypes: ["ProjectColumn"]) } """ Autogenerated return type of MoveProjectCard """ type MoveProjectCardPayload { """ The new edge of the moved card. """ cardEdge: ProjectCardEdge """ A unique identifier for the client performing the mutation. """ clientMutationId: String } """ Autogenerated input type of MoveProjectColumn """ input MoveProjectColumnInput { """ Place the new column after the column with this id. Pass null to place it at the front. """ afterColumnId: ID @possibleTypes(concreteTypes: ["ProjectColumn"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The id of the column to move. """ columnId: ID! @possibleTypes(concreteTypes: ["ProjectColumn"]) } """ Autogenerated return type of MoveProjectColumn """ type MoveProjectColumnPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The new edge of the moved column. """ columnEdge: ProjectColumnEdge } """ Represents a 'moved_columns_in_project' event on a given issue or pull request. """ type MovedColumnsInProjectEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Identifies the primary key from the database. """ databaseId: Int id: ID! """ Column name the issue or pull request was moved from. """ previousProjectColumnName: String! @preview(toggledBy: "starfox-preview") """ Project referenced by event. """ project: Project @preview(toggledBy: "starfox-preview") """ Project card referenced by this project event. """ projectCard: ProjectCard @preview(toggledBy: "starfox-preview") """ Column name the issue or pull request was moved to. """ projectColumnName: String! @preview(toggledBy: "starfox-preview") } """ The root query for implementing GraphQL mutations. """ type Mutation { """ Accepts a pending invitation for a user to join a business. """ acceptBusinessMemberInvitation(input: AcceptBusinessMemberInvitationInput!): AcceptBusinessMemberInvitationPayload @preview(toggledBy: "gwenpool-preview") """ Applies a suggested topic to the repository. """ acceptTopicSuggestion(input: AcceptTopicSuggestionInput!): AcceptTopicSuggestionPayload """ Adds assignees to an assignable object. """ addAssigneesToAssignable(input: AddAssigneesToAssignableInput!): AddAssigneesToAssignablePayload @preview(toggledBy: "starfire-preview") """ Adds a comment to an Issue or Pull Request. """ addComment(input: AddCommentInput!): AddCommentPayload """ Adds labels to a labelable object. """ addLabelsToLabelable(input: AddLabelsToLabelableInput!): AddLabelsToLabelablePayload @preview(toggledBy: "starfire-preview") """ Adds a card to a ProjectColumn. Either `contentId` or `note` must be provided but **not** both. """ addProjectCard(input: AddProjectCardInput!): AddProjectCardPayload """ Adds a column to a Project. """ addProjectColumn(input: AddProjectColumnInput!): AddProjectColumnPayload """ Adds a review to a Pull Request. """ addPullRequestReview(input: AddPullRequestReviewInput!): AddPullRequestReviewPayload """ Adds a comment to a review. """ addPullRequestReviewComment(input: AddPullRequestReviewCommentInput!): AddPullRequestReviewCommentPayload """ Adds a reaction to a subject. """ addReaction(input: AddReactionInput!): AddReactionPayload """ Adds a star to a Starrable. """ addStar(input: AddStarInput!): AddStarPayload """ Cancels a pending invitation for an administrator to join a business. """ cancelBusinessAdminInvitation(input: CancelBusinessAdminInvitationInput!): CancelBusinessAdminInvitationPayload @preview(toggledBy: "gwenpool-preview") """ Cancels a pending invitation for a billing manager to join a business. """ cancelBusinessBillingManagerInvitation(input: CancelBusinessBillingManagerInvitationInput!): CancelBusinessBillingManagerInvitationPayload @preview(toggledBy: "gwenpool-preview") """ Clears all labels from a labelable object. """ clearLabelsFromLabelable(input: ClearLabelsFromLabelableInput!): ClearLabelsFromLabelablePayload @preview(toggledBy: "starfire-preview") """ Close an issue. """ closeIssue(input: CloseIssueInput!): CloseIssuePayload @preview(toggledBy: "starfire-preview") """ Close a pull request. """ closePullRequest(input: ClosePullRequestInput!): ClosePullRequestPayload @preview(toggledBy: "ocelot-preview") """ Convert a project note card to one associated with a newly created issue. """ convertProjectCardNoteToIssue(input: ConvertProjectCardNoteToIssueInput!): ConvertProjectCardNoteToIssuePayload @preview(toggledBy: "starfire-preview") """ Create a new branch protection rule """ createBranchProtectionRule(input: CreateBranchProtectionRuleInput!): CreateBranchProtectionRulePayload """ Create a check run. """ createCheckRun(input: CreateCheckRunInput!): CreateCheckRunPayload @preview(toggledBy: "antiope-preview") """ Create a check suite """ createCheckSuite(input: CreateCheckSuiteInput!): CreateCheckSuitePayload @preview(toggledBy: "antiope-preview") """ Create a content attachment. """ createContentAttachment(input: CreateContentAttachmentInput!): CreateContentAttachmentPayload @preview(toggledBy: "corsair-preview") """ Creates a new deployment event. """ createDeployment(input: CreateDeploymentInput!): CreateDeploymentPayload @preview(toggledBy: "flash-preview") """ Create a deployment status. """ createDeploymentStatus(input: CreateDeploymentStatusInput!): CreateDeploymentStatusPayload @preview(toggledBy: "flash-preview") """ Creates a new issue. """ createIssue(input: CreateIssueInput!): CreateIssuePayload @preview(toggledBy: "starfire-preview") """ Creates a new project. """ createProject(input: CreateProjectInput!): CreateProjectPayload """ Create a new pull request """ createPullRequest(input: CreatePullRequestInput!): CreatePullRequestPayload @preview(toggledBy: "ocelot-preview") """ Creates a new team discussion. """ createTeamDiscussion(input: CreateTeamDiscussionInput!): CreateTeamDiscussionPayload @preview(toggledBy: "echo-preview") """ Creates a new team discussion comment. """ createTeamDiscussionComment(input: CreateTeamDiscussionCommentInput!): CreateTeamDiscussionCommentPayload @preview(toggledBy: "echo-preview") """ Rejects a suggested topic for the repository. """ declineTopicSuggestion(input: DeclineTopicSuggestionInput!): DeclineTopicSuggestionPayload """ Delete a branch protection rule """ deleteBranchProtectionRule(input: DeleteBranchProtectionRuleInput!): DeleteBranchProtectionRulePayload """ Deletes an Issue object. """ deleteIssue(input: DeleteIssueInput!): DeleteIssuePayload @preview(toggledBy: "starfire-preview") """ Deletes an IssueComment object. """ deleteIssueComment(input: DeleteIssueCommentInput!): DeleteIssueCommentPayload @preview(toggledBy: "starfire-preview") """ Deletes a project. """ deleteProject(input: DeleteProjectInput!): DeleteProjectPayload """ Deletes a project card. """ deleteProjectCard(input: DeleteProjectCardInput!): DeleteProjectCardPayload """ Deletes a project column. """ deleteProjectColumn(input: DeleteProjectColumnInput!): DeleteProjectColumnPayload """ Deletes a pull request review. """ deletePullRequestReview(input: DeletePullRequestReviewInput!): DeletePullRequestReviewPayload """ Deletes a pull request review comment. """ deletePullRequestReviewComment(input: DeletePullRequestReviewCommentInput!): DeletePullRequestReviewCommentPayload @preview(toggledBy: "ocelot-preview") """ Deletes a team discussion. """ deleteTeamDiscussion(input: DeleteTeamDiscussionInput!): DeleteTeamDiscussionPayload @preview(toggledBy: "echo-preview") """ Deletes a team discussion comment. """ deleteTeamDiscussionComment(input: DeleteTeamDiscussionCommentInput!): DeleteTeamDiscussionCommentPayload @preview(toggledBy: "echo-preview") """ Dismisses an approved or rejected pull request review. """ dismissPullRequestReview(input: DismissPullRequestReviewInput!): DismissPullRequestReviewPayload """ Invite someone to become an administrator of the business """ inviteBusinessAdmin(input: InviteBusinessAdminInput!): InviteBusinessAdminPayload @preview(toggledBy: "gwenpool-preview") """ Invite someone to become a billing manager of the business """ inviteBusinessBillingManager(input: InviteBusinessBillingManagerInput!): InviteBusinessBillingManagerPayload @preview(toggledBy: "gwenpool-preview") """ Lock a lockable object """ lockLockable(input: LockLockableInput!): LockLockablePayload """ Merge a pull request. """ mergePullRequest(input: MergePullRequestInput!): MergePullRequestPayload @preview(toggledBy: "ocelot-preview") """ Minimizes a comment on an Issue, Commit, Pull Request, or Gist """ minimizeComment(input: MinimizeCommentInput!): MinimizeCommentPayload @preview(toggledBy: "queen-beryl-preview") """ Moves a project card to another place. """ moveProjectCard(input: MoveProjectCardInput!): MoveProjectCardPayload """ Moves a project column to another place. """ moveProjectColumn(input: MoveProjectColumnInput!): MoveProjectColumnPayload """ Pin an issue to a repository """ pinIssue(input: PinIssueInput!): PinIssuePayload @preview(toggledBy: "elektra-preview") """ Removes assignees from an assignable object. """ removeAssigneesFromAssignable(input: RemoveAssigneesFromAssignableInput!): RemoveAssigneesFromAssignablePayload @preview(toggledBy: "starfire-preview") """ Removes an admin from the business """ removeBusinessAdmin(input: RemoveBusinessAdminInput!): RemoveBusinessAdminPayload @preview(toggledBy: "gwenpool-preview") """ Removes a billing manager from the business """ removeBusinessBillingManager(input: RemoveBusinessBillingManagerInput!): RemoveBusinessBillingManagerPayload @preview(toggledBy: "gwenpool-preview") """ Removes labels from a Labelable object. """ removeLabelsFromLabelable(input: RemoveLabelsFromLabelableInput!): RemoveLabelsFromLabelablePayload @preview(toggledBy: "starfire-preview") """ Removes outside collaborator from all repositories in an organization. """ removeOutsideCollaborator(input: RemoveOutsideCollaboratorInput!): RemoveOutsideCollaboratorPayload """ Removes a reaction from a subject. """ removeReaction(input: RemoveReactionInput!): RemoveReactionPayload """ Removes a star from a Starrable. """ removeStar(input: RemoveStarInput!): RemoveStarPayload """ Reopen a issue. """ reopenIssue(input: ReopenIssueInput!): ReopenIssuePayload @preview(toggledBy: "starfire-preview") """ Reopen a pull request. """ reopenPullRequest(input: ReopenPullRequestInput!): ReopenPullRequestPayload @preview(toggledBy: "ocelot-preview") """ Set review requests on a pull request. """ requestReviews(input: RequestReviewsInput!): RequestReviewsPayload """ Rerequests an existing check suite. """ rerequestCheckSuite(input: RerequestCheckSuiteInput!): RerequestCheckSuitePayload @preview(toggledBy: "antiope-preview") """ Marks a review thread as resolved. """ resolveReviewThread(input: ResolveReviewThreadInput!): ResolveReviewThreadPayload @preview(toggledBy: "cateye-preview") """ Submits a pending pull request review. """ submitPullRequestReview(input: SubmitPullRequestReviewInput!): SubmitPullRequestReviewPayload """ Unlock a lockable object """ unlockLockable(input: UnlockLockableInput!): UnlockLockablePayload """ Unmark an issue as a duplicate of another issue. """ unmarkIssueAsDuplicate(input: UnmarkIssueAsDuplicateInput!): UnmarkIssueAsDuplicatePayload @preview(toggledBy: "starfire-preview") """ Unminimizes a comment on an Issue, Commit, Pull Request, or Gist """ unminimizeComment(input: UnminimizeCommentInput!): UnminimizeCommentPayload @preview(toggledBy: "queen-beryl-preview") """ Unpin a pinned issue from a repository """ unpinIssue(input: UnpinIssueInput!): UnpinIssuePayload @preview(toggledBy: "elektra-preview") """ Marks a review thread as unresolved. """ unresolveReviewThread(input: UnresolveReviewThreadInput!): UnresolveReviewThreadPayload @preview(toggledBy: "cateye-preview") """ Create a new branch protection rule """ updateBranchProtectionRule(input: UpdateBranchProtectionRuleInput!): UpdateBranchProtectionRulePayload """ Sets whether private repository forks are enabled for a business. """ updateBusinessAllowPrivateRepositoryForkingSetting(input: UpdateBusinessAllowPrivateRepositoryForkingSettingInput!): UpdateBusinessAllowPrivateRepositoryForkingSettingPayload @preview(toggledBy: "gwenpool-preview") """ Sets the default repository permission for organizations in a business. """ updateBusinessDefaultRepositoryPermissionSetting(input: UpdateBusinessDefaultRepositoryPermissionSettingInput!): UpdateBusinessDefaultRepositoryPermissionSettingPayload @preview(toggledBy: "gwenpool-preview") """ Sets whether organization members with admin permissions on a repository can change repository visibility. """ updateBusinessMembersCanChangeRepositoryVisibilitySetting(input: UpdateBusinessMembersCanChangeRepositoryVisibilitySettingInput!): UpdateBusinessMembersCanChangeRepositoryVisibilitySettingPayload @preview(toggledBy: "gwenpool-preview") """ Sets the members can create repositories setting for a business. """ updateBusinessMembersCanCreateRepositoriesSetting(input: UpdateBusinessMembersCanCreateRepositoriesSettingInput!): UpdateBusinessMembersCanCreateRepositoriesSettingPayload @preview(toggledBy: "gwenpool-preview") """ Sets the members can delete issues setting for a business. """ updateBusinessMembersCanDeleteIssuesSetting(input: UpdateBusinessMembersCanDeleteIssuesSettingInput!): UpdateBusinessMembersCanDeleteIssuesSettingPayload @preview(toggledBy: "gwenpool-preview") """ Sets the members can delete repositories setting for a business. """ updateBusinessMembersCanDeleteRepositoriesSetting(input: UpdateBusinessMembersCanDeleteRepositoriesSettingInput!): UpdateBusinessMembersCanDeleteRepositoriesSettingPayload @preview(toggledBy: "gwenpool-preview") """ Sets whether members can invite collaborators are enabled for a business. """ updateBusinessMembersCanInviteCollaboratorsSetting(input: UpdateBusinessMembersCanInviteCollaboratorsSettingInput!): UpdateBusinessMembersCanInviteCollaboratorsSettingPayload @preview(toggledBy: "gwenpool-preview") """ Sets the members can update protected branches setting for a business. """ updateBusinessMembersCanUpdateProtectedBranchesSetting(input: UpdateBusinessMembersCanUpdateProtectedBranchesSettingInput!): UpdateBusinessMembersCanUpdateProtectedBranchesSettingPayload @preview(toggledBy: "gwenpool-preview") """ Sets whether organization projects are enabled for a business. """ updateBusinessOrganizationProjectsSetting(input: UpdateBusinessOrganizationProjectsSettingInput!): UpdateBusinessOrganizationProjectsSettingPayload @preview(toggledBy: "gwenpool-preview") """ Updates business's profile """ updateBusinessProfile(input: UpdateBusinessProfileInput!): UpdateBusinessProfilePayload @preview(toggledBy: "gwenpool-preview") """ Sets whether repository projects are enabled for a business. """ updateBusinessRepositoryProjectsSetting(input: UpdateBusinessRepositoryProjectsSettingInput!): UpdateBusinessRepositoryProjectsSettingPayload @preview(toggledBy: "gwenpool-preview") """ Sets whether team discussions are enabled for a business. """ updateBusinessTeamDiscussionsSetting(input: UpdateBusinessTeamDiscussionsSettingInput!): UpdateBusinessTeamDiscussionsSettingPayload @preview(toggledBy: "gwenpool-preview") """ Sets whether two factor authentication is required for all users in a business. """ updateBusinessTwoFactorAuthenticationRequiredSetting(input: UpdateBusinessTwoFactorAuthenticationRequiredSettingInput!): UpdateBusinessTwoFactorAuthenticationRequiredSettingPayload @preview(toggledBy: "gwenpool-preview") """ Update a check run """ updateCheckRun(input: UpdateCheckRunInput!): UpdateCheckRunPayload @preview(toggledBy: "antiope-preview") """ Modifies the settings of an existing check suite """ updateCheckSuitePreferences(input: UpdateCheckSuitePreferencesInput!): UpdateCheckSuitePreferencesPayload @preview(toggledBy: "antiope-preview") """ Updates an Issue. """ updateIssue(input: UpdateIssueInput!): UpdateIssuePayload @preview(toggledBy: "starfire-preview") """ Updates an IssueComment object. """ updateIssueComment(input: UpdateIssueCommentInput!): UpdateIssueCommentPayload @preview(toggledBy: "starfire-preview") """ Updates an existing project. """ updateProject(input: UpdateProjectInput!): UpdateProjectPayload """ Updates an existing project card. """ updateProjectCard(input: UpdateProjectCardInput!): UpdateProjectCardPayload """ Updates an existing project column. """ updateProjectColumn(input: UpdateProjectColumnInput!): UpdateProjectColumnPayload """ Update a pull request """ updatePullRequest(input: UpdatePullRequestInput!): UpdatePullRequestPayload @preview(toggledBy: "ocelot-preview") """ Updates the body of a pull request review. """ updatePullRequestReview(input: UpdatePullRequestReviewInput!): UpdatePullRequestReviewPayload """ Updates a pull request review comment. """ updatePullRequestReviewComment(input: UpdatePullRequestReviewCommentInput!): UpdatePullRequestReviewCommentPayload """ Updates the state for subscribable subjects. """ updateSubscription(input: UpdateSubscriptionInput!): UpdateSubscriptionPayload """ Updates a team discussion. """ updateTeamDiscussion(input: UpdateTeamDiscussionInput!): UpdateTeamDiscussionPayload @preview(toggledBy: "echo-preview") """ Updates a discussion comment. """ updateTeamDiscussionComment(input: UpdateTeamDiscussionCommentInput!): UpdateTeamDiscussionCommentPayload @preview(toggledBy: "echo-preview") """ Replaces the repository's topics with the given topics. """ updateTopics(input: UpdateTopicsInput!): UpdateTopicsPayload } """ An object with an ID. """ interface Node { """ ID of the object. """ id: ID! } """ Possible directions in which to order a list of items when provided an `orderBy` argument. """ enum OrderDirection { """ Specifies an ascending order for a given `orderBy` argument. """ ASC """ Specifies a descending order for a given `orderBy` argument. """ DESC } """ An account on GitHub, with one or more owners, that has repositories, members and teams. """ type Organization implements Actor & Node & ProjectOwner & RegistryPackageOwner & RegistryPackageSearch & RepositoryOwner & UniformResourceLocatable { """ A URL pointing to the organization's public avatar. """ avatarUrl( """ The size of the resulting square image. """ size: Int ): URI! """ Identifies the primary key from the database. """ databaseId: Int """ The organization's public profile description. """ description: String """ The organization's public email. """ email: String id: ID! """ Whether the organization has verified its profile email and website. """ isVerified: Boolean! """ The organization's public profile location. """ location: String """ The organization's login name. """ login: String! """ A list of users who are members of this organization. """ members( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): UserConnection! @deprecated(reason: "The `members` field is deprecated and will be removed soon. Use `Organization.membersWithRole` instead. Removal on 2019-04-01 UTC.") """ A list of users who are members of this organization. """ membersWithRole( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): OrganizationMemberConnection! """ The organization's public profile name. """ name: String """ The HTTP path creating a new team """ newTeamResourcePath: URI! """ The HTTP URL creating a new team """ newTeamUrl: URI! """ The billing email for the organization. """ organizationBillingEmail: String """ A list of users who have been invited to join this organization. """ pendingMembers( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): UserConnection! """ A list of repositories this user has pinned to their profile """ pinnedRepositories( """ Array of viewer's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the current viewer owns. """ affiliations: [RepositoryAffiliation] = [OWNER, COLLABORATOR] """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ If non-null, filters repositories according to whether they have been locked """ isLocked: Boolean """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for repositories returned from the connection """ orderBy: RepositoryOrder """ Array of owner's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the organization or user being viewed owns. """ ownerAffiliations: [RepositoryAffiliation] = [OWNER, COLLABORATOR] """ If non-null, filters repositories according to privacy """ privacy: RepositoryPrivacy ): RepositoryConnection! """ Find project by number. """ project( """ The project number to find. """ number: Int! ): Project """ A list of projects under the owner. """ projects( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for projects returned from the connection """ orderBy: ProjectOrder """ Query to search projects by, currently only searching by name. """ search: String """ A list of states to filter the projects by. """ states: [ProjectState!] ): ProjectConnection! """ The HTTP path listing organization's projects """ projectsResourcePath: URI! """ The HTTP URL listing organization's projects """ projectsUrl: URI! """ A list of repositories that the user owns. """ repositories( """ Array of viewer's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the current viewer owns. """ affiliations: [RepositoryAffiliation] = [OWNER, COLLABORATOR] """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ If non-null, filters repositories according to whether they are forks of another repository """ isFork: Boolean """ If non-null, filters repositories according to whether they have been locked """ isLocked: Boolean """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for repositories returned from the connection """ orderBy: RepositoryOrder """ Array of owner's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the organization or user being viewed owns. """ ownerAffiliations: [RepositoryAffiliation] = [OWNER, COLLABORATOR] """ If non-null, filters repositories according to privacy """ privacy: RepositoryPrivacy ): RepositoryConnection! """ Find Repository. """ repository( """ Name of Repository to find. """ name: String! ): Repository """ When true the organization requires all members, billing managers, and outside collaborators to enable two-factor authentication. """ requiresTwoFactorAuthentication: Boolean """ The HTTP path for this organization. """ resourcePath: URI! """ The Organization's SAML Identity Providers """ samlIdentityProvider: OrganizationIdentityProvider """ Find an organization's team by its slug. """ team( """ The name or slug of the team to find. """ slug: String! ): Team """ A list of teams in this organization. """ teams( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ If true, filters teams that are mapped to an LDAP Group (Enterprise only) """ ldapMapped: Boolean """ Ordering options for teams returned from the connection """ orderBy: TeamOrder """ If non-null, filters teams according to privacy """ privacy: TeamPrivacy """ If non-null, filters teams with query on team name and team slug """ query: String """ If non-null, filters teams according to whether the viewer is an admin or member on team """ role: TeamRole """ If true, restrict to only root teams """ rootTeamsOnly: Boolean = false """ User logins to filter by """ userLogins: [String!] ): TeamConnection! """ The HTTP path listing organization's teams """ teamsResourcePath: URI! """ The HTTP URL listing organization's teams """ teamsUrl: URI! """ The HTTP URL for this organization. """ url: URI! """ Organization is adminable by the viewer. """ viewerCanAdminister: Boolean! """ Can the current viewer create new projects on this owner. """ viewerCanCreateProjects: Boolean! """ Viewer can create repositories on this organization """ viewerCanCreateRepositories: Boolean! """ Viewer can create teams on this organization. """ viewerCanCreateTeams: Boolean! """ Viewer is an active member of this organization. """ viewerIsAMember: Boolean! """ The organization's public profile URL. """ websiteUrl: URI } """ The connection type for Organization. """ type OrganizationConnection { """ A list of edges. """ edges: [OrganizationEdge] """ A list of nodes. """ nodes: [Organization] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type OrganizationEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: Organization } """ An Identity Provider configured to provision SAML and SCIM identities for Organizations """ type OrganizationIdentityProvider implements Node { """ The digest algorithm used to sign SAML requests for the Identity Provider. """ digestMethod: URI """ External Identities provisioned by this Identity Provider """ externalIdentities( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): ExternalIdentityConnection! id: ID! """ The x509 certificate used by the Identity Provder to sign assertions and responses. """ idpCertificate: X509Certificate """ The Issuer Entity ID for the SAML Identity Provider """ issuer: String """ Organization this Identity Provider belongs to """ organization: Organization """ The signature algorithm used to sign SAML requests for the Identity Provider. """ signatureMethod: URI """ The URL endpoint for the Identity Provider's SAML SSO. """ ssoUrl: URI } """ An Invitation for a user to an organization. """ type OrganizationInvitation implements Node { """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ The email address of the user invited to the organization. """ email: String id: ID! """ The type of invitation that was sent (e.g. email, user). """ invitationType: OrganizationInvitationType! """ The user who was invited to the organization. """ invitee: User """ The user who created the invitation. """ inviter: User! """ The organization the invite is for """ organization: Organization! """ The user's pending role in the organization (e.g. member, owner). """ role: OrganizationInvitationRole! } """ The connection type for OrganizationInvitation. """ type OrganizationInvitationConnection { """ A list of edges. """ edges: [OrganizationInvitationEdge] """ A list of nodes. """ nodes: [OrganizationInvitation] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type OrganizationInvitationEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: OrganizationInvitation } """ The possible organization invitation roles. """ enum OrganizationInvitationRole { """ The user is invited to be an admin of the organization. """ ADMIN """ The user is invited to be a billing manager of the organization. """ BILLING_MANAGER """ The user is invited to be a direct member of the organization. """ DIRECT_MEMBER """ The user's previous role will be reinstated. """ REINSTATE } """ The possible organization invitation types. """ enum OrganizationInvitationType { """ The invitation was to an email address. """ EMAIL """ The invitation was to an existing user. """ USER } """ The connection type for User. """ type OrganizationMemberConnection { """ A list of edges. """ edges: [OrganizationMemberEdge] """ A list of nodes. """ nodes: [User] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ Represents a user within an organization. """ type OrganizationMemberEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: User """ The role this user has in the organization. """ role: OrganizationMemberRole } """ The possible roles within an organization for its members. """ enum OrganizationMemberRole { """ The user is an administrator of the organization. """ ADMIN """ The user is a member of the organization. """ MEMBER } """ Ordering options for organization connections. """ input OrganizationOrder @preview(toggledBy: "gwenpool-preview") { """ The ordering direction. """ direction: OrderDirection! """ The field to order organizations by. """ field: OrganizationOrderField! } """ Properties by which organization connections can be ordered. """ enum OrganizationOrderField @preview(toggledBy: "gwenpool-preview") { """ Order organizations by creation time """ CREATED_AT """ Order organizations by login """ LOGIN } """ An organization teams hovercard context """ type OrganizationTeamsHovercardContext implements HovercardContext @preview(toggledBy: "hagar-preview") { """ A string describing this context """ message: String! """ An octicon to accompany this context """ octicon: String! """ Teams in this organization the user is a member of that are relevant """ relevantTeams( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): TeamConnection! """ The path for the full team list for this user """ teamsResourcePath: URI! """ The URL for the full team list for this user """ teamsUrl: URI! """ The total number of teams the user is on in the organization """ totalTeamCount: Int! } """ An organization list hovercard context """ type OrganizationsHovercardContext implements HovercardContext @preview(toggledBy: "hagar-preview") { """ A string describing this context """ message: String! """ An octicon to accompany this context """ octicon: String! """ Organizations this user is a member of that are relevant """ relevantOrganizations( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): OrganizationConnection! """ The total number of organizations this user is in """ totalOrganizationCount: Int! } """ Information about pagination in a connection. """ type PageInfo { """ When paginating forwards, the cursor to continue. """ endCursor: String """ When paginating forwards, are there more items? """ hasNextPage: Boolean! """ When paginating backwards, are there more items? """ hasPreviousPage: Boolean! """ When paginating backwards, the cursor to continue. """ startCursor: String } """ Autogenerated input type of PinIssue """ input PinIssueInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The ID of the issue to be pinned """ issueId: ID! @possibleTypes(concreteTypes: ["Issue"]) } """ Autogenerated return type of PinIssue """ type PinIssuePayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The issue that was pinned """ issue: Issue } """ Represents a 'pinned' event on a given issue or pull request. """ type PinnedEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! id: ID! """ Identifies the issue associated with the event. """ issue: Issue! } """ A Pinned Issue is a issue pinned to a repository's index page. """ type PinnedIssue implements Node @preview(toggledBy: "elektra-preview") { """ Identifies the primary key from the database. """ databaseId: Int id: ID! """ The issue that was pinned. """ issue: Issue! """ The actor that pinned this issue. """ pinnedBy: Actor! """ The repository that this issue was pinned to. """ repository: Repository! } """ The connection type for PinnedIssue. """ type PinnedIssueConnection @preview(toggledBy: "elektra-preview") { """ A list of edges. """ edges: [PinnedIssueEdge] """ A list of nodes. """ nodes: [PinnedIssue] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type PinnedIssueEdge @preview(toggledBy: "elektra-preview") { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: PinnedIssue } """ Projects manage issues, pull requests and notes within a project owner. """ type Project implements Closable & Node & Updatable { """ The project's description body. """ body: String """ The projects description body rendered to HTML. """ bodyHTML: HTML! """ `true` if the object is closed (definition of closed may depend on type) """ closed: Boolean! """ Identifies the date and time when the object was closed. """ closedAt: DateTime """ List of columns in the project """ columns( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): ProjectColumnConnection! """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ The actor who originally created the project. """ creator: Actor """ Identifies the primary key from the database. """ databaseId: Int id: ID! """ The project's name. """ name: String! """ The project's number. """ number: Int! """ The project's owner. Currently limited to repositories and organizations. """ owner: ProjectOwner! """ List of pending cards in this project """ pendingCards( """ Returns the elements in the list that come after the specified cursor. """ after: String """ A list of archived states to filter the cards by """ archivedStates: [ProjectCardArchivedState] = [ARCHIVED, NOT_ARCHIVED] """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): ProjectCardConnection! """ The HTTP path for this project """ resourcePath: URI! """ Whether the project is open or closed. """ state: ProjectState! """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! """ The HTTP URL for this project """ url: URI! """ Check if the current viewer can update this object. """ viewerCanUpdate: Boolean! } """ A card in a project. """ type ProjectCard implements Node { """ The project column this card is associated under. A card may only belong to one project column at a time. The column field will be null if the card is created in a pending state and has yet to be associated with a column. Once cards are associated with a column, they will not become pending in the future. """ column: ProjectColumn """ The card content item """ content: ProjectCardItem """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ The actor who created this card """ creator: Actor """ Identifies the primary key from the database. """ databaseId: Int id: ID! """ Whether the card is archived """ isArchived: Boolean! """ The card note """ note: String """ The project that contains this card. """ project: Project! """ The HTTP path for this card """ resourcePath: URI! """ The state of ProjectCard """ state: ProjectCardState """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! """ The HTTP URL for this card """ url: URI! } """ The possible archived states of a project card. """ enum ProjectCardArchivedState { """ A project card that is archived """ ARCHIVED """ A project card that is not archived """ NOT_ARCHIVED } """ The connection type for ProjectCard. """ type ProjectCardConnection { """ A list of edges. """ edges: [ProjectCardEdge] """ A list of nodes. """ nodes: [ProjectCard] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type ProjectCardEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: ProjectCard } """ Types that can be inside Project Cards. """ union ProjectCardItem = Issue | PullRequest """ Various content states of a ProjectCard """ enum ProjectCardState { """ The card has content only. """ CONTENT_ONLY """ The card has a note only. """ NOTE_ONLY """ The card is redacted. """ REDACTED } """ A column inside a project. """ type ProjectColumn implements Node { """ List of cards in the column """ cards( """ Returns the elements in the list that come after the specified cursor. """ after: String """ A list of archived states to filter the cards by """ archivedStates: [ProjectCardArchivedState] = [ARCHIVED, NOT_ARCHIVED] """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): ProjectCardConnection! """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Identifies the primary key from the database. """ databaseId: Int id: ID! """ The project column's name. """ name: String! """ The project that contains this column. """ project: Project! """ The semantic purpose of the column """ purpose: ProjectColumnPurpose """ The HTTP path for this project column """ resourcePath: URI! """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! """ The HTTP URL for this project column """ url: URI! } """ The connection type for ProjectColumn. """ type ProjectColumnConnection { """ A list of edges. """ edges: [ProjectColumnEdge] """ A list of nodes. """ nodes: [ProjectColumn] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type ProjectColumnEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: ProjectColumn } """ The semantic purpose of the column - todo, in progress, or done. """ enum ProjectColumnPurpose { """ The column contains cards which are complete """ DONE """ The column contains cards which are currently being worked on """ IN_PROGRESS """ The column contains cards still to be worked on """ TODO } """ A list of projects associated with the owner. """ type ProjectConnection { """ A list of edges. """ edges: [ProjectEdge] """ A list of nodes. """ nodes: [Project] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type ProjectEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: Project } """ Ways in which lists of projects can be ordered upon return. """ input ProjectOrder { """ The direction in which to order projects by the specified field. """ direction: OrderDirection! """ The field in which to order projects by. """ field: ProjectOrderField! } """ Properties by which project connections can be ordered. """ enum ProjectOrderField { """ Order projects by creation time """ CREATED_AT """ Order projects by name """ NAME """ Order projects by update time """ UPDATED_AT } """ Represents an owner of a Project. """ interface ProjectOwner { id: ID! """ Find project by number. """ project( """ The project number to find. """ number: Int! ): Project """ A list of projects under the owner. """ projects( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for projects returned from the connection """ orderBy: ProjectOrder """ Query to search projects by, currently only searching by name. """ search: String """ A list of states to filter the projects by. """ states: [ProjectState!] ): ProjectConnection! """ The HTTP path listing owners projects """ projectsResourcePath: URI! """ The HTTP URL listing owners projects """ projectsUrl: URI! """ Can the current viewer create new projects on this owner. """ viewerCanCreateProjects: Boolean! } """ State of the project; either 'open' or 'closed' """ enum ProjectState { """ The project is closed. """ CLOSED """ The project is open. """ OPEN } """ A repository protected branch. """ type ProtectedBranch implements Node { """ The actor who created this protected branch. """ creator: Actor """ Will new commits pushed to this branch dismiss pull request review approvals. """ hasDismissableStaleReviews: Boolean! """ Are reviews required to update this branch. """ hasRequiredReviews: Boolean! """ Are commits required to be signed. """ hasRequiredSignatures: Boolean! @preview(toggledBy: "zzzax-preview") """ Are status checks required to update this branch. """ hasRequiredStatusChecks: Boolean! """ Is pushing to this branch restricted. """ hasRestrictedPushes: Boolean! """ Is dismissal of pull request reviews restricted. """ hasRestrictedReviewDismissals: Boolean! """ Are branches required to be up to date before merging. """ hasStrictRequiredStatusChecks: Boolean! id: ID! """ Can admins overwrite branch protection. """ isAdminEnforced: Boolean! """ The name of the protected branch rule. """ name: String! """ A list push allowances for this protected branch. """ pushAllowances( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): PushAllowanceConnection! """ The repository associated with this protected branch. """ repository: Repository! """ Number of approving reviews required to update this branch. """ requiredApprovingReviewCount: Int @preview(toggledBy: "luke-cage-preview") """ List of required status check contexts that must pass for commits to be accepted to this branch. """ requiredStatusCheckContexts: [String] """ A list review dismissal allowances for this protected branch. """ reviewDismissalAllowances( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): ReviewDismissalAllowanceConnection! } """ The connection type for ProtectedBranch. """ type ProtectedBranchConnection { """ A list of edges. """ edges: [ProtectedBranchEdge] """ A list of nodes. """ nodes: [ProtectedBranch] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type ProtectedBranchEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: ProtectedBranch } """ A user's public key. """ type PublicKey implements Node { id: ID! """ The public key string """ key: String! } """ The connection type for PublicKey. """ type PublicKeyConnection { """ A list of edges. """ edges: [PublicKeyEdge] """ A list of nodes. """ nodes: [PublicKey] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type PublicKeyEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: PublicKey } """ A repository pull request. """ type PullRequest implements Assignable & Closable & Comment & Labelable & Lockable & Node & Reactable & RepositoryNode & Subscribable & UniformResourceLocatable & Updatable & UpdatableComment { """ Reason that the conversation was locked. """ activeLockReason: LockReason """ The number of additions in this pull request. """ additions: Int! """ A list of Users assigned to this object. """ assignees( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): UserConnection! """ The actor who authored the comment. """ author: Actor """ Author's association with the subject of the comment. """ authorAssociation: CommentAuthorAssociation! """ Identifies the base Ref associated with the pull request. """ baseRef: Ref """ Identifies the name of the base Ref associated with the pull request, even if the ref has been deleted. """ baseRefName: String! """ Identifies the oid of the base ref associated with the pull request, even if the ref has been deleted. """ baseRefOid: GitObjectID! """ The body as Markdown. """ body: String! """ The body rendered to HTML. """ bodyHTML: HTML! """ The body rendered to text. """ bodyText: String! """ Whether or not the pull request is rebaseable. """ canBeRebased: Boolean! @preview(toggledBy: "merge-info-preview") """ The number of changed files in this pull request. """ changedFiles: Int! """ `true` if the pull request is closed """ closed: Boolean! """ Identifies the date and time when the object was closed. """ closedAt: DateTime """ A list of comments associated with the pull request. """ comments( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): IssueCommentConnection! """ A list of commits present in this pull request's head branch not present in the base branch. """ commits( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): PullRequestCommitConnection! """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Check if this comment was created via an email reply. """ createdViaEmail: Boolean! """ Identifies the primary key from the database. """ databaseId: Int """ The number of deletions in this pull request. """ deletions: Int! """ The actor who edited this pull request's body. """ editor: Actor """ Lists the files changed within this pull request. """ files( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): PullRequestChangedFileConnection @preview(toggledBy: "ocelot-preview") """ Identifies the head Ref associated with the pull request. """ headRef: Ref """ Identifies the name of the head Ref associated with the pull request, even if the ref has been deleted. """ headRefName: String! """ Identifies the oid of the head ref associated with the pull request, even if the ref has been deleted. """ headRefOid: GitObjectID! """ The repository associated with this pull request's head Ref. """ headRepository: Repository """ The owner of the repository associated with this pull request's head Ref. """ headRepositoryOwner: RepositoryOwner """ The hovercard information for this issue """ hovercard( """ Whether or not to include notification contexts """ includeNotificationContexts: Boolean = true ): Hovercard! @preview(toggledBy: "hagar-preview") id: ID! """ Check if this comment was edited and includes an edit with the creation data """ includesCreatedEdit: Boolean! """ The head and base repositories are different. """ isCrossRepository: Boolean! """ A list of labels associated with the object. """ labels( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): LabelConnection """ The moment the editor made the last edit """ lastEditedAt: DateTime """ `true` if the pull request is locked """ locked: Boolean! """ Indicates whether maintainers can modify the pull request. """ maintainerCanModify: Boolean! """ The commit that was created when this pull request was merged. """ mergeCommit: Commit """ Detailed information about the current pull request merge state status. """ mergeStateStatus: MergeStateStatus! @preview(toggledBy: "merge-info-preview") """ Whether or not the pull request can be merged based on the existence of merge conflicts. """ mergeable: MergeableState! """ Whether or not the pull request was merged. """ merged: Boolean! """ The date and time that the pull request was merged. """ mergedAt: DateTime """ The actor who merged the pull request. """ mergedBy: Actor """ Identifies the milestone associated with the pull request. """ milestone: Milestone """ Identifies the pull request number. """ number: Int! """ A list of Users that are participating in the Pull Request conversation. """ participants( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): UserConnection! """ The permalink to the pull request. """ permalink: URI! """ The commit that GitHub automatically generated to test if this pull request could be merged. This field will not return a value if the pull request is merged, or if the test merge commit is still being generated. See the `mergeable` field for more details on the mergeability of the pull request. """ potentialMergeCommit: Commit """ List of project cards associated with this pull request. """ projectCards( """ Returns the elements in the list that come after the specified cursor. """ after: String """ A list of archived states to filter the cards by """ archivedStates: [ProjectCardArchivedState] = [ARCHIVED, NOT_ARCHIVED] """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): ProjectCardConnection! """ Identifies when the comment was published at. """ publishedAt: DateTime """ A list of reactions grouped by content left on the subject. """ reactionGroups: [ReactionGroup!] """ A list of Reactions left on the Issue. """ reactions( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Allows filtering Reactions by emoji. """ content: ReactionContent """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Allows specifying the order in which reactions are returned. """ orderBy: ReactionOrder ): ReactionConnection! """ The repository associated with this node. """ repository: Repository! """ The HTTP path for this pull request. """ resourcePath: URI! """ The HTTP path for reverting this pull request. """ revertResourcePath: URI! """ The HTTP URL for reverting this pull request. """ revertUrl: URI! """ A list of review requests associated with the pull request. """ reviewRequests( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): ReviewRequestConnection """ The list of all review threads for this pull request. """ reviewThreads( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): PullRequestReviewThreadConnection! @preview(toggledBy: "ocelot-preview") """ A list of reviews associated with the pull request. """ reviews( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Filter by author of the review. """ author: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ A list of states to filter the reviews. """ states: [PullRequestReviewState!] ): PullRequestReviewConnection """ Identifies the state of the pull request. """ state: PullRequestState! """ A list of reviewer suggestions based on commit history and past review comments. """ suggestedReviewers: [SuggestedReviewer]! """ A list of events, comments, commits, etc. associated with the pull request. """ timeline( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Allows filtering timeline events by a `since` timestamp. """ since: DateTime ): PullRequestTimelineConnection! """ A list of events, comments, commits, etc. associated with the pull request. """ timelineItems( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Filter timeline items by type. """ itemTypes: [PullRequestTimelineItemsItemType!] """ Returns the last _n_ elements from the list. """ last: Int """ Filter timeline items by a `since` timestamp. """ since: DateTime """ Skips the first _n_ elements in the list. """ skip: Int ): PullRequestTimelineItemsConnection! @preview(toggledBy: "starfire-preview") """ Identifies the pull request title. """ title: String! """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! """ The HTTP URL for this pull request. """ url: URI! """ A list of edits to this content. """ userContentEdits( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): UserContentEditConnection """ Whether or not the viewer can apply suggestion. """ viewerCanApplySuggestion: Boolean! """ Can user react to this subject """ viewerCanReact: Boolean! """ Check if the viewer is able to change their subscription status for the repository. """ viewerCanSubscribe: Boolean! """ Check if the current viewer can update this object. """ viewerCanUpdate: Boolean! """ Reasons why the current viewer can not update this comment. """ viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! """ Did the viewer author this comment. """ viewerDidAuthor: Boolean! """ Identifies if the viewer is watching, not watching, or ignoring the subscribable entity. """ viewerSubscription: SubscriptionState } """ A file changed in a pull request. """ type PullRequestChangedFile @preview(toggledBy: "ocelot-preview") { """ The number of additions to the file. """ additions: Int! """ The number of deletions to the file. """ deletions: Int! """ The path of the file. """ path: String! } """ The connection type for PullRequestChangedFile. """ type PullRequestChangedFileConnection @preview(toggledBy: "ocelot-preview") { """ A list of edges. """ edges: [PullRequestChangedFileEdge] """ A list of nodes. """ nodes: [PullRequestChangedFile] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type PullRequestChangedFileEdge @preview(toggledBy: "ocelot-preview") { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: PullRequestChangedFile } """ Represents a Git commit part of a pull request. """ type PullRequestCommit implements Node & UniformResourceLocatable { """ The Git commit object """ commit: Commit! id: ID! """ The pull request this commit belongs to """ pullRequest: PullRequest! """ The HTTP path for this pull request commit """ resourcePath: URI! """ The HTTP URL for this pull request commit """ url: URI! } """ Represents a commit comment thread part of a pull request. """ type PullRequestCommitCommentThread implements Node & RepositoryNode @preview(toggledBy: "starfire-preview") { """ The comments that exist in this thread. """ comments( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): CommitCommentConnection! """ The commit the comments were made on. """ commit: Commit! id: ID! """ The file the comments were made on. """ path: String """ The position in the diff for the commit that the comment was made on. """ position: Int """ The pull request this commit comment thread belongs to """ pullRequest: PullRequest! """ The repository associated with this node. """ repository: Repository! } """ The connection type for PullRequestCommit. """ type PullRequestCommitConnection { """ A list of edges. """ edges: [PullRequestCommitEdge] """ A list of nodes. """ nodes: [PullRequestCommit] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type PullRequestCommitEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: PullRequestCommit } """ The connection type for PullRequest. """ type PullRequestConnection { """ A list of edges. """ edges: [PullRequestEdge] """ A list of nodes. """ nodes: [PullRequest] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type PullRequestEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: PullRequest } """ Properties by which pull_requests connections can be ordered. """ enum PullRequestOrderField { """ Order pull_requests by creation time """ CREATED_AT """ Order pull_requests by update time """ UPDATED_AT } """ A review object for a given pull request. """ type PullRequestReview implements Comment & Deletable & Node & Reactable & RepositoryNode & Updatable & UpdatableComment { """ The actor who authored the comment. """ author: Actor """ Author's association with the subject of the comment. """ authorAssociation: CommentAuthorAssociation! """ Identifies the pull request review body. """ body: String! """ The body of this review rendered to HTML. """ bodyHTML: HTML! """ The body of this review rendered as plain text. """ bodyText: String! """ A list of review comments for the current pull request review. """ comments( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): PullRequestReviewCommentConnection! """ Identifies the commit associated with this pull request review. """ commit: Commit """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Check if this comment was created via an email reply. """ createdViaEmail: Boolean! """ Identifies the primary key from the database. """ databaseId: Int """ The actor who edited the comment. """ editor: Actor id: ID! """ Check if this comment was edited and includes an edit with the creation data """ includesCreatedEdit: Boolean! """ The moment the editor made the last edit """ lastEditedAt: DateTime """ A list of teams that this review was made on behalf of. """ onBehalfOf( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): TeamConnection! """ Identifies when the comment was published at. """ publishedAt: DateTime """ Identifies the pull request associated with this pull request review. """ pullRequest: PullRequest! """ A list of reactions grouped by content left on the subject. """ reactionGroups: [ReactionGroup!] """ A list of Reactions left on the Issue. """ reactions( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Allows filtering Reactions by emoji. """ content: ReactionContent """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Allows specifying the order in which reactions are returned. """ orderBy: ReactionOrder ): ReactionConnection! """ The repository associated with this node. """ repository: Repository! """ The HTTP path permalink for this PullRequestReview. """ resourcePath: URI! """ Identifies the current state of the pull request review. """ state: PullRequestReviewState! """ Identifies when the Pull Request Review was submitted """ submittedAt: DateTime """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! """ The HTTP URL permalink for this PullRequestReview. """ url: URI! """ A list of edits to this content. """ userContentEdits( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): UserContentEditConnection """ Check if the current viewer can delete this object. """ viewerCanDelete: Boolean! """ Can user react to this subject """ viewerCanReact: Boolean! """ Check if the current viewer can update this object. """ viewerCanUpdate: Boolean! """ Reasons why the current viewer can not update this comment. """ viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! """ Did the viewer author this comment. """ viewerDidAuthor: Boolean! } """ A review comment associated with a given repository pull request. """ type PullRequestReviewComment implements Comment & Deletable & Minimizable & Node & Reactable & RepositoryNode & Updatable & UpdatableComment { """ The actor who authored the comment. """ author: Actor """ Author's association with the subject of the comment. """ authorAssociation: CommentAuthorAssociation! """ The comment body of this review comment. """ body: String! """ The comment body of this review comment rendered to HTML. """ bodyHTML: HTML! """ The comment body of this review comment rendered as plain text. """ bodyText: String! """ Identifies the commit associated with the comment. """ commit: Commit! """ Identifies when the comment was created. """ createdAt: DateTime! """ Check if this comment was created via an email reply. """ createdViaEmail: Boolean! """ Identifies the primary key from the database. """ databaseId: Int """ The diff hunk to which the comment applies. """ diffHunk: String! """ Identifies when the comment was created in a draft state. """ draftedAt: DateTime! """ The actor who edited the comment. """ editor: Actor id: ID! """ Check if this comment was edited and includes an edit with the creation data """ includesCreatedEdit: Boolean! """ Returns whether or not a comment has been minimized. """ isMinimized: Boolean! """ The moment the editor made the last edit """ lastEditedAt: DateTime """ Returns why the comment was minimized. """ minimizedReason: String """ Identifies the original commit associated with the comment. """ originalCommit: Commit """ The original line index in the diff to which the comment applies. """ originalPosition: Int! """ Identifies when the comment body is outdated """ outdated: Boolean! """ The path to which the comment applies. """ path: String! """ The line index in the diff to which the comment applies. """ position: Int """ Identifies when the comment was published at. """ publishedAt: DateTime """ The pull request associated with this review comment. """ pullRequest: PullRequest! """ The pull request review associated with this review comment. """ pullRequestReview: PullRequestReview """ A list of reactions grouped by content left on the subject. """ reactionGroups: [ReactionGroup!] """ A list of Reactions left on the Issue. """ reactions( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Allows filtering Reactions by emoji. """ content: ReactionContent """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Allows specifying the order in which reactions are returned. """ orderBy: ReactionOrder ): ReactionConnection! """ The comment this is a reply to. """ replyTo: PullRequestReviewComment """ The repository associated with this node. """ repository: Repository! """ The HTTP path permalink for this review comment. """ resourcePath: URI! """ Identifies the state of the comment. """ state: PullRequestReviewCommentState! """ Identifies when the comment was last updated. """ updatedAt: DateTime! """ The HTTP URL permalink for this review comment. """ url: URI! """ A list of edits to this content. """ userContentEdits( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): UserContentEditConnection """ Check if the current viewer can delete this object. """ viewerCanDelete: Boolean! """ Check if the current viewer can minimize this object. """ viewerCanMinimize: Boolean! """ Can user react to this subject """ viewerCanReact: Boolean! """ Check if the current viewer can update this object. """ viewerCanUpdate: Boolean! """ Reasons why the current viewer can not update this comment. """ viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! """ Did the viewer author this comment. """ viewerDidAuthor: Boolean! } """ The connection type for PullRequestReviewComment. """ type PullRequestReviewCommentConnection { """ A list of edges. """ edges: [PullRequestReviewCommentEdge] """ A list of nodes. """ nodes: [PullRequestReviewComment] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type PullRequestReviewCommentEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: PullRequestReviewComment } """ The possible states of a pull request review comment. """ enum PullRequestReviewCommentState { """ A comment that is part of a pending review """ PENDING """ A comment that is part of a submitted review """ SUBMITTED } """ The connection type for PullRequestReview. """ type PullRequestReviewConnection { """ A list of edges. """ edges: [PullRequestReviewEdge] """ A list of nodes. """ nodes: [PullRequestReview] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type PullRequestReviewEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: PullRequestReview } """ The possible events to perform on a pull request review. """ enum PullRequestReviewEvent { """ Submit feedback and approve merging these changes. """ APPROVE """ Submit general feedback without explicit approval. """ COMMENT """ Dismiss review so it now longer effects merging. """ DISMISS """ Submit feedback that must be addressed before merging. """ REQUEST_CHANGES } """ The possible states of a pull request review. """ enum PullRequestReviewState { """ A review allowing the pull request to merge. """ APPROVED """ A review blocking the pull request from merging. """ CHANGES_REQUESTED """ An informational review. """ COMMENTED """ A review that has been dismissed. """ DISMISSED """ A review that has not yet been submitted. """ PENDING } """ A threaded list of comments for a given pull request. """ type PullRequestReviewThread implements Node { """ A list of pull request comments associated with the thread. """ comments( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): PullRequestReviewCommentConnection! id: ID! """ Whether this thread has been resolved """ isResolved: Boolean! @preview(toggledBy: "cateye-preview") """ Identifies the pull request associated with this thread. """ pullRequest: PullRequest! """ Identifies the repository associated with this thread. """ repository: Repository! """ The user who resolved this thread """ resolvedBy: User @preview(toggledBy: "cateye-preview") """ Whether or not the viewer can resolve this thread """ viewerCanResolve: Boolean! @preview(toggledBy: "cateye-preview") """ Whether or not the viewer can unresolve this thread """ viewerCanUnresolve: Boolean! @preview(toggledBy: "cateye-preview") } """ Review comment threads for a pull request review. """ type PullRequestReviewThreadConnection { """ A list of edges. """ edges: [PullRequestReviewThreadEdge] """ A list of nodes. """ nodes: [PullRequestReviewThread] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type PullRequestReviewThreadEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: PullRequestReviewThread } """ Represents the latest point in the pull request timeline for which the viewer has seen the pull request's commits. """ type PullRequestRevisionMarker @preview(toggledBy: "starfire-preview") { """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ The last commit the viewer has seen. """ lastSeenCommit: Commit! """ The pull request to which the marker belongs. """ pullRequest: PullRequest! } """ The possible states of a pull request. """ enum PullRequestState { """ A pull request that has been closed without being merged. """ CLOSED """ A pull request that has been closed by being merged. """ MERGED """ A pull request that is still open. """ OPEN } """ The connection type for PullRequestTimelineItem. """ type PullRequestTimelineConnection { """ A list of edges. """ edges: [PullRequestTimelineItemEdge] """ A list of nodes. """ nodes: [PullRequestTimelineItem] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An item in an pull request timeline """ union PullRequestTimelineItem = AssignedEvent | BaseRefForcePushedEvent | ClosedEvent | Commit | CommitCommentThread | CrossReferencedEvent | DemilestonedEvent | DeployedEvent | DeploymentEnvironmentChangedEvent | HeadRefDeletedEvent | HeadRefForcePushedEvent | HeadRefRestoredEvent | IssueComment | LabeledEvent | LockedEvent | MergedEvent | MilestonedEvent | PullRequestReview | PullRequestReviewComment | PullRequestReviewThread | ReferencedEvent | RenamedTitleEvent | ReopenedEvent | ReviewDismissedEvent | ReviewRequestRemovedEvent | ReviewRequestedEvent | SubscribedEvent | UnassignedEvent | UnlabeledEvent | UnlockedEvent | UnsubscribedEvent """ An edge in a connection. """ type PullRequestTimelineItemEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: PullRequestTimelineItem } """ An item in a pull request timeline """ union PullRequestTimelineItems = AddedToProjectEvent | AssignedEvent | BaseRefChangedEvent | BaseRefForcePushedEvent | ClosedEvent | CommentDeletedEvent | ConvertedNoteToIssueEvent | CrossReferencedEvent | DemilestonedEvent | DeployedEvent | DeploymentEnvironmentChangedEvent | HeadRefDeletedEvent | HeadRefForcePushedEvent | HeadRefRestoredEvent | IssueComment | LabeledEvent | LockedEvent | MentionedEvent | MergedEvent | MilestonedEvent | MovedColumnsInProjectEvent | PinnedEvent | PullRequestCommit | PullRequestCommitCommentThread | PullRequestReview | PullRequestReviewThread | PullRequestRevisionMarker | ReferencedEvent | RemovedFromProjectEvent | RenamedTitleEvent | ReopenedEvent | ReviewDismissedEvent | ReviewRequestRemovedEvent | ReviewRequestedEvent | SubscribedEvent | TransferredEvent | UnassignedEvent | UnlabeledEvent | UnlockedEvent | UnpinnedEvent | UnsubscribedEvent """ The connection type for PullRequestTimelineItems. """ type PullRequestTimelineItemsConnection { """ A list of edges. """ edges: [PullRequestTimelineItemsEdge] """ Identifies the count of items after applying `before` and `after` filters. """ filteredCount: Int! """ A list of nodes. """ nodes: [PullRequestTimelineItems] """ Identifies the count of items after applying `before`/`after` filters and `first`/`last`/`skip` slicing. """ pageCount: Int! """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! """ Identifies the date and time when the timeline was last updated. """ updatedAt: DateTime! } """ An edge in a connection. """ type PullRequestTimelineItemsEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: PullRequestTimelineItems } """ The possible item types found in a timeline. """ enum PullRequestTimelineItemsItemType { """ Represents a 'added_to_project' event on a given issue or pull request. """ ADDED_TO_PROJECT_EVENT """ Represents an 'assigned' event on any assignable object. """ ASSIGNED_EVENT """ Represents a 'base_ref_changed' event on a given issue or pull request. """ BASE_REF_CHANGED_EVENT """ Represents a 'base_ref_force_pushed' event on a given pull request. """ BASE_REF_FORCE_PUSHED_EVENT """ Represents a 'closed' event on any `Closable`. """ CLOSED_EVENT """ Represents a 'comment_deleted' event on a given issue or pull request. """ COMMENT_DELETED_EVENT """ Represents a 'converted_note_to_issue' event on a given issue or pull request. """ CONVERTED_NOTE_TO_ISSUE_EVENT """ Represents a mention made by one issue or pull request to another. """ CROSS_REFERENCED_EVENT """ Represents a 'demilestoned' event on a given issue or pull request. """ DEMILESTONED_EVENT """ Represents a 'deployed' event on a given pull request. """ DEPLOYED_EVENT """ Represents a 'deployment_environment_changed' event on a given pull request. """ DEPLOYMENT_ENVIRONMENT_CHANGED_EVENT """ Represents a 'head_ref_deleted' event on a given pull request. """ HEAD_REF_DELETED_EVENT """ Represents a 'head_ref_force_pushed' event on a given pull request. """ HEAD_REF_FORCE_PUSHED_EVENT """ Represents a 'head_ref_restored' event on a given pull request. """ HEAD_REF_RESTORED_EVENT """ Represents a comment on an Issue. """ ISSUE_COMMENT """ Represents a 'labeled' event on a given issue or pull request. """ LABELED_EVENT """ Represents a 'locked' event on a given issue or pull request. """ LOCKED_EVENT """ Represents a 'mentioned' event on a given issue or pull request. """ MENTIONED_EVENT """ Represents a 'merged' event on a given pull request. """ MERGED_EVENT """ Represents a 'milestoned' event on a given issue or pull request. """ MILESTONED_EVENT """ Represents a 'moved_columns_in_project' event on a given issue or pull request. """ MOVED_COLUMNS_IN_PROJECT_EVENT """ Represents a 'pinned' event on a given issue or pull request. """ PINNED_EVENT """ Represents a Git commit part of a pull request. """ PULL_REQUEST_COMMIT """ Represents a commit comment thread part of a pull request. """ PULL_REQUEST_COMMIT_COMMENT_THREAD """ A review object for a given pull request. """ PULL_REQUEST_REVIEW """ A threaded list of comments for a given pull request. """ PULL_REQUEST_REVIEW_THREAD """ Represents the latest point in the pull request timeline for which the viewer has seen the pull request's commits. """ PULL_REQUEST_REVISION_MARKER """ Represents a 'referenced' event on a given `ReferencedSubject`. """ REFERENCED_EVENT """ Represents a 'removed_from_project' event on a given issue or pull request. """ REMOVED_FROM_PROJECT_EVENT """ Represents a 'renamed' event on a given issue or pull request """ RENAMED_TITLE_EVENT """ Represents a 'reopened' event on any `Closable`. """ REOPENED_EVENT """ Represents a 'review_dismissed' event on a given issue or pull request. """ REVIEW_DISMISSED_EVENT """ Represents an 'review_requested' event on a given pull request. """ REVIEW_REQUESTED_EVENT """ Represents an 'review_request_removed' event on a given pull request. """ REVIEW_REQUEST_REMOVED_EVENT """ Represents a 'subscribed' event on a given `Subscribable`. """ SUBSCRIBED_EVENT """ Represents a 'transferred' event on a given issue or pull request. """ TRANSFERRED_EVENT """ Represents an 'unassigned' event on any assignable object. """ UNASSIGNED_EVENT """ Represents an 'unlabeled' event on a given issue or pull request. """ UNLABELED_EVENT """ Represents an 'unlocked' event on a given issue or pull request. """ UNLOCKED_EVENT """ Represents an 'unpinned' event on a given issue or pull request. """ UNPINNED_EVENT """ Represents an 'unsubscribed' event on a given `Subscribable`. """ UNSUBSCRIBED_EVENT } """ A Git push. """ type Push implements Node @preview(toggledBy: "antiope-preview") { id: ID! """ The SHA after the push """ nextSha: GitObjectID """ The permalink for this push. """ permalink: URI! """ The SHA before the push """ previousSha: GitObjectID """ The user who pushed """ pusher: User! """ The repository that was pushed to """ repository: Repository! } """ A team or user who has the ability to push to a protected branch. """ type PushAllowance implements Node { """ The actor that can push. """ actor: PushAllowanceActor """ Identifies the branch protection rule associated with the allowed user or team. """ branchProtectionRule: BranchProtectionRule id: ID! } """ Types that can be an actor. """ union PushAllowanceActor = Team | User """ The connection type for PushAllowance. """ type PushAllowanceConnection { """ A list of edges. """ edges: [PushAllowanceEdge] """ A list of nodes. """ nodes: [PushAllowance] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type PushAllowanceEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: PushAllowance } """ The query root of GitHub's GraphQL interface. """ type Query { """ Look up a business by URL slug. """ business( """ The business invitation token """ invitationToken: String """ The business URL slug. """ slug: String! ): Business @preview(toggledBy: "gwenpool-preview") """ Look up a pending business member invitation by invitee, business and role. """ businessMemberInvitation( """ The slug of the business the user was invited to join """ businessSlug: String! """ The role for the business member invitation. """ role: BusinessMemberInvitationRole! """ The login of the user invited to join the business """ userLogin: String! ): BusinessMemberInvitation @preview(toggledBy: "gwenpool-preview") """ Look up a pending business member invitation by invitation token """ businessMemberInvitationByToken( """ The invitation token sent with the invitation email. """ invitationToken: String! ): BusinessMemberInvitation @preview(toggledBy: "gwenpool-preview") """ Look up a code of conduct by its key """ codeOfConduct( """ The code of conduct's key """ key: String! ): CodeOfConduct """ Look up a code of conduct by its key """ codesOfConduct: [CodeOfConduct] """ Look up an open source license by its key """ license( """ The license's downcased SPDX ID """ key: String! ): License """ Return a list of known open source licenses """ licenses: [License]! """ Get alphabetically sorted list of Marketplace categories """ marketplaceCategories( """ Exclude categories with no listings. """ excludeEmpty: Boolean """ Returns top level categories only, excluding any subcategories. """ excludeSubcategories: Boolean """ Return only the specified categories. """ includeCategories: [String!] ): [MarketplaceCategory!]! """ Look up a Marketplace category by its slug. """ marketplaceCategory( """ The URL slug of the category. """ slug: String! """ Also check topic aliases for the category slug """ useTopicAliases: Boolean ): MarketplaceCategory """ Look up a single Marketplace listing """ marketplaceListing( """ Select the listing that matches this slug. It's the short name of the listing used in its URL. """ slug: String! ): MarketplaceListing """ Look up Marketplace listings """ marketplaceListings( """ Select listings that can be administered by the specified user. """ adminId: ID """ Returns the elements in the list that come after the specified cursor. """ after: String """ Select listings visible to the viewer even if they are not approved. If omitted or false, only approved listings will be returned. """ allStates: Boolean """ Returns the elements in the list that come before the specified cursor. """ before: String """ Select only listings with the given category. """ categorySlug: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Select listings for products owned by the specified organization. """ organizationId: ID """ Select only listings where the primary category matches the given category slug. """ primaryCategoryOnly: Boolean = false """ Select the listings with these slugs, if they are visible to the viewer. """ slugs: [String] """ Also check topic aliases for the category slug """ useTopicAliases: Boolean """ Select listings to which user has admin access. If omitted, listings visible to the viewer are returned. """ viewerCanAdmin: Boolean """ Select only listings that offer a free trial. """ withFreeTrialsOnly: Boolean = false ): MarketplaceListingConnection! """ Return information about the GitHub instance """ meta: GitHubMetadata! """ Fetches an object given its ID. """ node( """ ID of the object. """ id: ID! ): Node """ Lookup nodes by a list of IDs. """ nodes( """ The list of node IDs. """ ids: [ID!]! ): [Node]! """ Lookup a organization by login. """ organization( """ The organization's login. """ login: String! ): Organization """ The client's rate limit information. """ rateLimit( """ If true, calculate the cost for the query without evaluating it """ dryRun: Boolean = false ): RateLimit """ Hack to workaround https://github.com/facebook/relay/issues/112 re-exposing the root query object """ relay: Query! """ Lookup a given repository by the owner and repository name. """ repository( """ The name of the repository """ name: String! """ The login field of a user or organization """ owner: String! ): Repository """ Lookup a repository owner (ie. either a User or an Organization) by login. """ repositoryOwner( """ The username to lookup the owner by. """ login: String! ): RepositoryOwner """ Lookup resource by a URL. """ resource( """ The URL. """ url: URI! ): UniformResourceLocatable """ Perform a search across resources. """ search( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ The search string to look for. """ query: String! """ The types of search items to search within. """ type: SearchType! ): SearchResultItemConnection! """ GitHub Security Advisories """ securityAdvisories( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Filter advisories by identifier, e.g. GHSA or CVE. """ identifier: SecurityAdvisoryIdentifierFilter """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for the returned topics. """ orderBy: SecurityAdvisoryOrder = {field: UPDATED_AT, direction: DESC} """ Filter advisories to those published since a time in the past. """ publishedSince: DateTime """ Filter advisories to those updated since a time in the past. """ updatedSince: DateTime ): SecurityAdvisoryConnection! """ Fetch a Security Advisory by its GHSA ID """ securityAdvisory( """ GitHub Security Advisory ID. """ ghsaId: String! ): SecurityAdvisory """ Software Vulnerabilities documented by GitHub Security Advisories """ securityVulnerabilities( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ An ecosystem to filter vulnerabilities by. """ ecosystem: SecurityAdvisoryEcosystem """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for the returned topics. """ orderBy: SecurityVulnerabilityOrder = {field: UPDATED_AT, direction: DESC} """ A package name to filter vulnerabilities by. """ package: String """ A list of severities to filter vulnerabilities by. """ severities: [SecurityAdvisorySeverity!] ): SecurityVulnerabilityConnection! """ Look up a topic by name. """ topic( """ The topic's name. """ name: String! ): Topic """ Lookup a user by login. """ user( """ The user's login. """ login: String! ): User """ The currently authenticated user. """ viewer: User! } """ Represents the client's rate limit. """ type RateLimit { """ The point cost for the current query counting against the rate limit. """ cost: Int! """ The maximum number of points the client is permitted to consume in a 60 minute window. """ limit: Int! """ The maximum number of nodes this query may return """ nodeCount: Int! """ The number of points remaining in the current rate limit window. """ remaining: Int! """ The time at which the current rate limit window resets in UTC epoch seconds. """ resetAt: DateTime! } """ Represents a subject that can be reacted on. """ interface Reactable { """ Identifies the primary key from the database. """ databaseId: Int id: ID! """ A list of reactions grouped by content left on the subject. """ reactionGroups: [ReactionGroup!] """ A list of Reactions left on the Issue. """ reactions( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Allows filtering Reactions by emoji. """ content: ReactionContent """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Allows specifying the order in which reactions are returned. """ orderBy: ReactionOrder ): ReactionConnection! """ Can user react to this subject """ viewerCanReact: Boolean! } """ The connection type for User. """ type ReactingUserConnection { """ A list of edges. """ edges: [ReactingUserEdge] """ A list of nodes. """ nodes: [User] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ Represents a user that's made a reaction. """ type ReactingUserEdge { """ A cursor for use in pagination. """ cursor: String! node: User! """ The moment when the user made the reaction. """ reactedAt: DateTime! } """ An emoji reaction to a particular piece of content. """ type Reaction implements Node { """ Identifies the emoji reaction. """ content: ReactionContent! """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Identifies the primary key from the database. """ databaseId: Int id: ID! """ The reactable piece of content """ reactable: Reactable! """ Identifies the user who created this reaction. """ user: User } """ A list of reactions that have been left on the subject. """ type ReactionConnection { """ A list of edges. """ edges: [ReactionEdge] """ A list of nodes. """ nodes: [Reaction] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! """ Whether or not the authenticated user has left a reaction on the subject. """ viewerHasReacted: Boolean! } """ Emojis that can be attached to Issues, Pull Requests and Comments. """ enum ReactionContent { """ Represents the 😕 emoji. """ CONFUSED """ Represents the 👀 emoji. """ EYES """ Represents the ❤️ emoji. """ HEART """ Represents the 🎉 emoji. """ HOORAY """ Represents the 😄 emoji. """ LAUGH """ Represents the 🚀 emoji. """ ROCKET """ Represents the 👎 emoji. """ THUMBS_DOWN """ Represents the 👍 emoji. """ THUMBS_UP } """ An edge in a connection. """ type ReactionEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: Reaction } """ A group of emoji reactions to a particular piece of content. """ type ReactionGroup { """ Identifies the emoji reaction. """ content: ReactionContent! """ Identifies when the reaction was created. """ createdAt: DateTime """ The subject that was reacted to. """ subject: Reactable! """ Users who have reacted to the reaction subject with the emotion represented by this reaction group """ users( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): ReactingUserConnection! """ Whether or not the authenticated user has left a reaction on the subject. """ viewerHasReacted: Boolean! } """ Ways in which lists of reactions can be ordered upon return. """ input ReactionOrder { """ The direction in which to order reactions by the specified field. """ direction: OrderDirection! """ The field in which to order reactions by. """ field: ReactionOrderField! } """ A list of fields that reactions can be ordered by. """ enum ReactionOrderField { """ Allows ordering a list of reactions by when they were created. """ CREATED_AT } """ Represents a Git reference. """ type Ref implements Node { """ A list of pull requests with this ref as the head ref. """ associatedPullRequests( """ Returns the elements in the list that come after the specified cursor. """ after: String """ The base ref name to filter the pull requests by. """ baseRefName: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ The head ref name to filter the pull requests by. """ headRefName: String """ A list of label names to filter the pull requests by. """ labels: [String!] """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for pull requests returned from the connection. """ orderBy: IssueOrder """ A list of states to filter the pull requests by. """ states: [PullRequestState!] ): PullRequestConnection! id: ID! """ The ref name. """ name: String! """ The ref's prefix, such as `refs/heads/` or `refs/tags/`. """ prefix: String! """ The repository the ref belongs to. """ repository: Repository! """ The object the ref points to. """ target: GitObject! } """ The connection type for Ref. """ type RefConnection { """ A list of edges. """ edges: [RefEdge] """ A list of nodes. """ nodes: [Ref] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type RefEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: Ref } """ Ways in which lists of git refs can be ordered upon return. """ input RefOrder { """ The direction in which to order refs by the specified field. """ direction: OrderDirection! """ The field in which to order refs by. """ field: RefOrderField! } """ Properties by which ref connections can be ordered. """ enum RefOrderField { """ Order refs by their alphanumeric name """ ALPHABETICAL """ Order refs by underlying commit date if the ref prefix is refs/tags/ """ TAG_COMMIT_DATE } """ Represents a 'referenced' event on a given `ReferencedSubject`. """ type ReferencedEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the commit associated with the 'referenced' event. """ commit: Commit """ Identifies the repository associated with the 'referenced' event. """ commitRepository: Repository! """ Identifies the date and time when the object was created. """ createdAt: DateTime! id: ID! """ Reference originated in a different repository. """ isCrossRepository: Boolean! """ Checks if the commit message itself references the subject. Can be false in the case of a commit comment reference. """ isDirectReference: Boolean! """ Object referenced by event. """ subject: ReferencedSubject! } """ Any referencable object """ union ReferencedSubject = Issue | PullRequest """ Represents an owner of a registry package. """ interface RegistryPackageOwner { id: ID! } """ Represents an interface to search packages on an object. """ interface RegistryPackageSearch { id: ID! } """ A release contains the content for a release. """ type Release implements Node & UniformResourceLocatable { """ The author of the release """ author: User """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Identifies the description of the release. """ description: String id: ID! """ Whether or not the release is a draft """ isDraft: Boolean! """ Whether or not the release is a prerelease """ isPrerelease: Boolean! """ Identifies the title of the release. """ name: String """ Identifies the date and time when the release was created. """ publishedAt: DateTime """ List of releases assets which are dependent on this release. """ releaseAssets( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ A list of names to filter the assets by. """ name: String ): ReleaseAssetConnection! """ The HTTP path for this issue """ resourcePath: URI! """ The Git tag the release points to """ tag: Ref """ The name of the release's Git tag """ tagName: String! """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! """ The HTTP URL for this issue """ url: URI! } """ A release asset contains the content for a release asset. """ type ReleaseAsset implements Node { """ The asset's content-type """ contentType: String! """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ The number of times this asset was downloaded """ downloadCount: Int! """ Identifies the URL where you can download the release asset via the browser. """ downloadUrl: URI! id: ID! """ Identifies the title of the release asset. """ name: String! """ Release that the asset is associated with """ release: Release """ The size (in bytes) of the asset """ size: Int! """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! """ The user that performed the upload """ uploadedBy: User! """ Identifies the URL of the release asset. """ url: URI! } """ The connection type for ReleaseAsset. """ type ReleaseAssetConnection { """ A list of edges. """ edges: [ReleaseAssetEdge] """ A list of nodes. """ nodes: [ReleaseAsset] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type ReleaseAssetEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: ReleaseAsset } """ The connection type for Release. """ type ReleaseConnection { """ A list of edges. """ edges: [ReleaseEdge] """ A list of nodes. """ nodes: [Release] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type ReleaseEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: Release } """ Ways in which lists of releases can be ordered upon return. """ input ReleaseOrder { """ The direction in which to order releases by the specified field. """ direction: OrderDirection! """ The field in which to order releases by. """ field: ReleaseOrderField! } """ Properties by which release connections can be ordered. """ enum ReleaseOrderField { """ Order releases by creation time """ CREATED_AT """ Order releases alphabetically by name """ NAME } """ Autogenerated input type of RemoveAssigneesFromAssignable """ input RemoveAssigneesFromAssignableInput @preview(toggledBy: "starfire-preview") { """ The id of the assignable object to remove assignees from. """ assignableId: ID! @possibleTypes(concreteTypes: ["Issue", "PullRequest"], abstractType: "Assignable") """ The id of users to remove as assignees. """ assigneeIds: [ID!]! @possibleTypes(concreteTypes: ["User"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String } """ Autogenerated return type of RemoveAssigneesFromAssignable """ type RemoveAssigneesFromAssignablePayload @preview(toggledBy: "starfire-preview") { """ The item that was unassigned. """ assignable: Assignable """ A unique identifier for the client performing the mutation. """ clientMutationId: String } """ Autogenerated input type of RemoveBusinessAdmin """ input RemoveBusinessAdminInput { """ The Business ID to update. """ businessId: ID! @possibleTypes(concreteTypes: ["Business"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The login of the user to add as an admin. """ login: String! } """ Autogenerated return type of RemoveBusinessAdmin """ type RemoveBusinessAdminPayload { """ The user who was added as an admin. """ admin: User """ The updated business. """ business: Business @preview(toggledBy: "gwenpool-preview") """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The viewer performing the mutation. """ viewer: User } """ Autogenerated input type of RemoveBusinessBillingManager """ input RemoveBusinessBillingManagerInput { """ The Business ID to update. """ businessId: ID! @possibleTypes(concreteTypes: ["Business"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The login of the user to add as a billing manager. """ login: String! } """ Autogenerated return type of RemoveBusinessBillingManager """ type RemoveBusinessBillingManagerPayload { """ The user who was added as a billing manager. """ billingManager: User """ The updated business. """ business: Business @preview(toggledBy: "gwenpool-preview") """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The viewer performing the mutation. """ viewer: User } """ Autogenerated input type of RemoveLabelsFromLabelable """ input RemoveLabelsFromLabelableInput @preview(toggledBy: "starfire-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The ids of labels to remove. """ labelIds: [ID!]! @possibleTypes(concreteTypes: ["Label"]) """ The id of the Labelable to remove labels from. """ labelableId: ID! @possibleTypes(concreteTypes: ["Issue", "PullRequest"], abstractType: "Labelable") } """ Autogenerated return type of RemoveLabelsFromLabelable """ type RemoveLabelsFromLabelablePayload @preview(toggledBy: "starfire-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The Labelable the labels were removed from. """ labelable: Labelable } """ Autogenerated input type of RemoveOutsideCollaborator """ input RemoveOutsideCollaboratorInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The ID of the organization to remove the outside collaborator from. """ organizationId: ID! @possibleTypes(concreteTypes: ["Organization"]) """ The ID of the outside collaborator to remove. """ userId: ID! @possibleTypes(concreteTypes: ["User"]) } """ Autogenerated return type of RemoveOutsideCollaborator """ type RemoveOutsideCollaboratorPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The user that was removed as an outside collaborator. """ removedUser: User } """ Autogenerated input type of RemoveReaction """ input RemoveReactionInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The name of the emoji reaction to remove. """ content: ReactionContent! """ The Node ID of the subject to modify. """ subjectId: ID! @possibleTypes(concreteTypes: ["CommitComment", "Issue", "IssueComment", "PullRequest", "PullRequestReview", "PullRequestReviewComment", "TeamDiscussion", "TeamDiscussionComment"], abstractType: "Reactable") } """ Autogenerated return type of RemoveReaction """ type RemoveReactionPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The reaction object. """ reaction: Reaction """ The reactable subject. """ subject: Reactable } """ Autogenerated input type of RemoveStar """ input RemoveStarInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The Starrable ID to unstar. """ starrableId: ID! @possibleTypes(concreteTypes: ["Gist", "Repository", "Topic"], abstractType: "Starrable") } """ Autogenerated return type of RemoveStar """ type RemoveStarPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The starrable. """ starrable: Starrable } """ Represents a 'removed_from_project' event on a given issue or pull request. """ type RemovedFromProjectEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Identifies the primary key from the database. """ databaseId: Int id: ID! """ Project referenced by event. """ project: Project @preview(toggledBy: "starfox-preview") """ Column name referenced by this project event. """ projectColumnName: String! @preview(toggledBy: "starfox-preview") } """ Represents a 'renamed' event on a given issue or pull request """ type RenamedTitleEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Identifies the current title of the issue or pull request. """ currentTitle: String! id: ID! """ Identifies the previous title of the issue or pull request. """ previousTitle: String! """ Subject that was renamed. """ subject: RenamedTitleSubject! } """ An object which has a renamable title """ union RenamedTitleSubject = Issue | PullRequest """ Autogenerated input type of ReopenIssue """ input ReopenIssueInput @preview(toggledBy: "starfire-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ ID of the issue to be opened. """ issueId: ID! @possibleTypes(concreteTypes: ["Issue"]) } """ Autogenerated return type of ReopenIssue """ type ReopenIssuePayload @preview(toggledBy: "starfire-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The issue that was opened. """ issue: Issue } """ Autogenerated input type of ReopenPullRequest """ input ReopenPullRequestInput @preview(toggledBy: "ocelot-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ ID of the pull request to be reopened. """ pullRequestId: ID! @possibleTypes(concreteTypes: ["PullRequest"]) } """ Autogenerated return type of ReopenPullRequest """ type ReopenPullRequestPayload @preview(toggledBy: "ocelot-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The pull request that was reopened. """ pullRequest: PullRequest } """ Represents a 'reopened' event on any `Closable`. """ type ReopenedEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Object that was reopened. """ closable: Closable! """ Identifies the date and time when the object was created. """ createdAt: DateTime! id: ID! } """ The reasons a piece of content can be reported or minimized. """ enum ReportedContentClassifiers { """ An abusive or harassing piece of content """ ABUSE """ An irrelevant piece of content """ OFF_TOPIC """ An outdated piece of content """ OUTDATED """ The content has been resolved """ RESOLVED """ A spammy piece of content """ SPAM } """ A repository contains the content for a project. """ type Repository implements Node & ProjectOwner & RegistryPackageOwner & RepositoryInfo & Starrable & Subscribable & UniformResourceLocatable { """ A list of users that can be assigned to issues in this repository. """ assignableUsers( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): UserConnection! """ A list of branch protection rules for this repository. """ branchProtectionRules( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): BranchProtectionRuleConnection! """ Returns the code of conduct for this repository """ codeOfConduct: CodeOfConduct """ A list of collaborators associated with the repository. """ collaborators( """ Collaborators affiliation level with a repository. """ affiliation: CollaboratorAffiliation """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): RepositoryCollaboratorConnection """ A list of commit comments associated with the repository. """ commitComments( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): CommitCommentConnection! """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Identifies the primary key from the database. """ databaseId: Int """ The Ref associated with the repository's default branch. """ defaultBranchRef: Ref """ A list of dependency manifests contained in the repository """ dependencyGraphManifests( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Cursor to paginate dependencies """ dependenciesAfter: String """ Number of dependencies to fetch """ dependenciesFirst: Int """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Flag to scope to only manifests with dependencies """ withDependencies: Boolean ): DependencyGraphManifestConnection @preview(toggledBy: "hawkgirl-preview") """ A list of deploy keys that are on this repository. """ deployKeys( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): DeployKeyConnection! """ Deployments associated with the repository """ deployments( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Environments to list deployments for """ environments: [String!] """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for deployments returned from the connection. """ orderBy: DeploymentOrder = {field: CREATED_AT, direction: ASC} ): DeploymentConnection! """ The description of the repository. """ description: String """ The description of the repository rendered to HTML. """ descriptionHTML: HTML! """ The number of kilobytes this repository occupies on disk. """ diskUsage: Int """ Returns how many forks there are of this repository in the whole network. """ forkCount: Int! """ A list of direct forked repositories. """ forks( """ Array of viewer's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the current viewer owns. """ affiliations: [RepositoryAffiliation] = [OWNER, COLLABORATOR] """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ If non-null, filters repositories according to whether they have been locked """ isLocked: Boolean """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for repositories returned from the connection """ orderBy: RepositoryOrder """ Array of owner's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the organization or user being viewed owns. """ ownerAffiliations: [RepositoryAffiliation] = [OWNER, COLLABORATOR] """ If non-null, filters repositories according to privacy """ privacy: RepositoryPrivacy ): RepositoryConnection! """ Indicates if the repository has issues feature enabled. """ hasIssuesEnabled: Boolean! """ Indicates if the repository has wiki feature enabled. """ hasWikiEnabled: Boolean! """ The repository's URL. """ homepageUrl: URI id: ID! """ Indicates if the repository is unmaintained. """ isArchived: Boolean! """ Identifies if the repository is a fork. """ isFork: Boolean! """ Indicates if the repository has been locked or not. """ isLocked: Boolean! """ Identifies if the repository is a mirror. """ isMirror: Boolean! """ Identifies if the repository is private. """ isPrivate: Boolean! """ Returns a single issue from the current repository by number. """ issue( """ The number for the issue to be returned. """ number: Int! ): Issue """ Returns a single issue-like object from the current repository by number. """ issueOrPullRequest( """ The number for the issue to be returned. """ number: Int! ): IssueOrPullRequest """ A list of issues that have been opened in the repository. """ issues( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Filtering options for issues returned from the connection. """ filterBy: IssueFilters @preview(toggledBy: "starfire-preview") """ Returns the first _n_ elements from the list. """ first: Int """ A list of label names to filter the pull requests by. """ labels: [String!] """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for issues returned from the connection. """ orderBy: IssueOrder """ A list of states to filter the issues by. """ states: [IssueState!] ): IssueConnection! """ Returns a single label by name """ label( """ Label name """ name: String! ): Label """ A list of labels associated with the repository. """ labels( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ If provided, searches labels by name and description. """ query: String ): LabelConnection """ A list containing a breakdown of the language composition of the repository. """ languages( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Order for connection """ orderBy: LanguageOrder ): LanguageConnection """ The license associated with the repository """ licenseInfo: License """ The reason the repository has been locked. """ lockReason: RepositoryLockReason """ A list of Users that can be mentioned in the context of the repository. """ mentionableUsers( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): UserConnection! """ Whether or not PRs are merged with a merge commit on this repository. """ mergeCommitAllowed: Boolean! """ Returns a single milestone from the current repository by number. """ milestone( """ The number for the milestone to be returned. """ number: Int! ): Milestone """ A list of milestones associated with the repository. """ milestones( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for milestones. """ orderBy: MilestoneOrder """ Filter by the state of the milestones. """ states: [MilestoneState!] ): MilestoneConnection """ The repository's original mirror URL. """ mirrorUrl: URI """ The name of the repository. """ name: String! """ The repository's name with owner. """ nameWithOwner: String! """ A Git object in the repository """ object( """ A Git revision expression suitable for rev-parse """ expression: String """ The Git object ID """ oid: GitObjectID ): GitObject """ The User owner of the repository. """ owner: RepositoryOwner! """ The repository parent, if this is a fork. """ parent: Repository """ A list of pinned issues for this repository. """ pinnedIssues( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): PinnedIssueConnection @preview(toggledBy: "elektra-preview") """ The primary language of the repository's code. """ primaryLanguage: Language """ Find project by number. """ project( """ The project number to find. """ number: Int! ): Project """ A list of projects under the owner. """ projects( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for projects returned from the connection """ orderBy: ProjectOrder """ Query to search projects by, currently only searching by name. """ search: String """ A list of states to filter the projects by. """ states: [ProjectState!] ): ProjectConnection! """ The HTTP path listing the repository's projects """ projectsResourcePath: URI! """ The HTTP URL listing the repository's projects """ projectsUrl: URI! """ A list of protected branches that are on this repository. """ protectedBranches( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): ProtectedBranchConnection! @deprecated(reason: "The `ProtectedBranch` type is deprecated and will be removed soon. Use `Repository.branchProtectionRules` instead. Removal on 2019-01-01 UTC.") """ Returns a single pull request from the current repository by number. """ pullRequest( """ The number for the pull request to be returned. """ number: Int! ): PullRequest """ A list of pull requests that have been opened in the repository. """ pullRequests( """ Returns the elements in the list that come after the specified cursor. """ after: String """ The base ref name to filter the pull requests by. """ baseRefName: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ The head ref name to filter the pull requests by. """ headRefName: String """ A list of label names to filter the pull requests by. """ labels: [String!] """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for pull requests returned from the connection. """ orderBy: IssueOrder """ A list of states to filter the pull requests by. """ states: [PullRequestState!] ): PullRequestConnection! """ Identifies when the repository was last pushed to. """ pushedAt: DateTime """ Whether or not rebase-merging is enabled on this repository. """ rebaseMergeAllowed: Boolean! """ Fetch a given ref from the repository """ ref( """ The ref to retrieve. Fully qualified matches are checked in order (`refs/heads/master`) before falling back onto checks for short name matches (`master`). """ qualifiedName: String! ): Ref """ Fetch a list of refs from the repository """ refs( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ DEPRECATED: use orderBy. The ordering direction. """ direction: OrderDirection """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for refs returned from the connection. """ orderBy: RefOrder """ A ref name prefix like `refs/heads/`, `refs/tags/`, etc. """ refPrefix: String! ): RefConnection """ Lookup a single release given various criteria. """ release( """ The name of the Tag the Release was created from """ tagName: String! ): Release """ List of releases which are dependent on this repository. """ releases( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Order for connection """ orderBy: ReleaseOrder ): ReleaseConnection! """ A list of applied repository-topic associations for this repository. """ repositoryTopics( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): RepositoryTopicConnection! """ The HTTP path for this repository """ resourcePath: URI! """ A description of the repository, rendered to HTML without any links in it. """ shortDescriptionHTML( """ How many characters to return. """ limit: Int = 200 ): HTML! """ Whether or not squash-merging is enabled on this repository. """ squashMergeAllowed: Boolean! """ The SSH URL to clone this repository """ sshUrl: GitSSHRemote! """ A list of users who have starred this starrable. """ stargazers( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Order for connection """ orderBy: StarOrder ): StargazerConnection! """ Temporary authentication token for cloning this repository. """ tempCloneToken: String @preview(toggledBy: "daredevil-preview") """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! """ The HTTP URL for this repository """ url: URI! """ Indicates whether the viewer has admin permissions on this repository. """ viewerCanAdminister: Boolean! """ Can the current viewer create new projects on this owner. """ viewerCanCreateProjects: Boolean! """ Check if the viewer is able to change their subscription status for the repository. """ viewerCanSubscribe: Boolean! """ Indicates whether the viewer can update the topics of this repository. """ viewerCanUpdateTopics: Boolean! """ Returns a boolean indicating whether the viewing user has starred this starrable. """ viewerHasStarred: Boolean! """ The users permission level on the repository. Will return null if authenticated as an GitHub App. """ viewerPermission: RepositoryPermission """ Identifies if the viewer is watching, not watching, or ignoring the subscribable entity. """ viewerSubscription: SubscriptionState """ A list of vulnerability alerts that are on this repository. """ vulnerabilityAlerts( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): RepositoryVulnerabilityAlertConnection @preview(toggledBy: "vixen-preview") """ A list of users watching the repository. """ watchers( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): UserConnection! } """ The affiliation of a user to a repository """ enum RepositoryAffiliation { """ Repositories that the user has been added to as a collaborator. """ COLLABORATOR """ Repositories that the user has access to through being a member of an organization. This includes every repository on every team that the user is on. """ ORGANIZATION_MEMBER """ Repositories that are owned by the authenticated user. """ OWNER } """ The connection type for User. """ type RepositoryCollaboratorConnection { """ A list of edges. """ edges: [RepositoryCollaboratorEdge] """ A list of nodes. """ nodes: [User] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ Represents a user who is a collaborator of a repository. """ type RepositoryCollaboratorEdge { """ A cursor for use in pagination. """ cursor: String! node: User! """ The permission the user has on the repository. """ permission: RepositoryPermission! } """ A list of repositories owned by the subject. """ type RepositoryConnection { """ A list of edges. """ edges: [RepositoryEdge] """ A list of nodes. """ nodes: [Repository] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! """ The total size in kilobytes of all repositories in the connection. """ totalDiskUsage: Int! } """ The reason a repository is listed as 'contributed'. """ enum RepositoryContributionType { """ Created a commit """ COMMIT """ Created an issue """ ISSUE """ Created a pull request """ PULL_REQUEST """ Reviewed a pull request """ PULL_REQUEST_REVIEW """ Created the repository """ REPOSITORY } """ An edge in a connection. """ type RepositoryEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: Repository } """ A subset of repository info. """ interface RepositoryInfo { """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ The description of the repository. """ description: String """ The description of the repository rendered to HTML. """ descriptionHTML: HTML! """ Returns how many forks there are of this repository in the whole network. """ forkCount: Int! """ Indicates if the repository has issues feature enabled. """ hasIssuesEnabled: Boolean! """ Indicates if the repository has wiki feature enabled. """ hasWikiEnabled: Boolean! """ The repository's URL. """ homepageUrl: URI """ Indicates if the repository is unmaintained. """ isArchived: Boolean! """ Identifies if the repository is a fork. """ isFork: Boolean! """ Indicates if the repository has been locked or not. """ isLocked: Boolean! """ Identifies if the repository is a mirror. """ isMirror: Boolean! """ Identifies if the repository is private. """ isPrivate: Boolean! """ The license associated with the repository """ licenseInfo: License """ The reason the repository has been locked. """ lockReason: RepositoryLockReason """ The repository's original mirror URL. """ mirrorUrl: URI """ The name of the repository. """ name: String! """ The repository's name with owner. """ nameWithOwner: String! """ The User owner of the repository. """ owner: RepositoryOwner! """ Identifies when the repository was last pushed to. """ pushedAt: DateTime """ The HTTP path for this repository """ resourcePath: URI! """ A description of the repository, rendered to HTML without any links in it. """ shortDescriptionHTML( """ How many characters to return. """ limit: Int = 200 ): HTML! """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! """ The HTTP URL for this repository """ url: URI! } """ An invitation for a user to be added to a repository. """ type RepositoryInvitation implements Node { id: ID! """ The user who received the invitation. """ invitee: User! """ The user who created the invitation. """ inviter: User! """ The permission granted on this repository by this invitation. """ permission: RepositoryPermission! """ The Repository the user is invited to. """ repository: RepositoryInfo } """ The possible reasons a given repository could be in a locked state. """ enum RepositoryLockReason { """ The repository is locked due to a billing related reason. """ BILLING """ The repository is locked due to a migration. """ MIGRATING """ The repository is locked due to a move. """ MOVING """ The repository is locked due to a rename. """ RENAME } """ Represents a object that belongs to a repository. """ interface RepositoryNode { """ The repository associated with this node. """ repository: Repository! } """ Ordering options for repository connections """ input RepositoryOrder { """ The ordering direction. """ direction: OrderDirection! """ The field to order repositories by. """ field: RepositoryOrderField! } """ Properties by which repository connections can be ordered. """ enum RepositoryOrderField { """ Order repositories by creation time """ CREATED_AT """ Order repositories by name """ NAME """ Order repositories by push time """ PUSHED_AT """ Order repositories by number of stargazers """ STARGAZERS """ Order repositories by update time """ UPDATED_AT } """ Represents an owner of a Repository. """ interface RepositoryOwner { """ A URL pointing to the owner's public avatar. """ avatarUrl( """ The size of the resulting square image. """ size: Int ): URI! id: ID! """ The username used to login. """ login: String! """ A list of repositories this user has pinned to their profile """ pinnedRepositories( """ Array of viewer's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the current viewer owns. """ affiliations: [RepositoryAffiliation] = [OWNER, COLLABORATOR] """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ If non-null, filters repositories according to whether they have been locked """ isLocked: Boolean """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for repositories returned from the connection """ orderBy: RepositoryOrder """ Array of owner's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the organization or user being viewed owns. """ ownerAffiliations: [RepositoryAffiliation] = [OWNER, COLLABORATOR] """ If non-null, filters repositories according to privacy """ privacy: RepositoryPrivacy ): RepositoryConnection! """ A list of repositories that the user owns. """ repositories( """ Array of viewer's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the current viewer owns. """ affiliations: [RepositoryAffiliation] = [OWNER, COLLABORATOR] """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ If non-null, filters repositories according to whether they are forks of another repository """ isFork: Boolean """ If non-null, filters repositories according to whether they have been locked """ isLocked: Boolean """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for repositories returned from the connection """ orderBy: RepositoryOrder """ Array of owner's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the organization or user being viewed owns. """ ownerAffiliations: [RepositoryAffiliation] = [OWNER, COLLABORATOR] """ If non-null, filters repositories according to privacy """ privacy: RepositoryPrivacy ): RepositoryConnection! """ Find Repository. """ repository( """ Name of Repository to find. """ name: String! ): Repository """ The HTTP URL for the owner. """ resourcePath: URI! """ The HTTP URL for the owner. """ url: URI! } """ The access level to a repository """ enum RepositoryPermission { """ Can read, clone, push, and add collaborators """ ADMIN """ Can read and clone """ READ """ Can read, clone and push """ WRITE } """ The privacy of a repository """ enum RepositoryPrivacy { """ Private """ PRIVATE """ Public """ PUBLIC } """ A repository-topic connects a repository to a topic. """ type RepositoryTopic implements Node & UniformResourceLocatable { id: ID! """ The HTTP path for this repository-topic. """ resourcePath: URI! """ The topic. """ topic: Topic! """ The HTTP URL for this repository-topic. """ url: URI! } """ The connection type for RepositoryTopic. """ type RepositoryTopicConnection { """ A list of edges. """ edges: [RepositoryTopicEdge] """ A list of nodes. """ nodes: [RepositoryTopic] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type RepositoryTopicEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: RepositoryTopic } """ A alert for a repository with an affected vulnerability. """ type RepositoryVulnerabilityAlert implements Node & RepositoryNode @preview(toggledBy: "vixen-preview") { """ The affected version """ affectedRange: String! @deprecated(reason: "advisory specific fields are being removed from repositoryVulnerabilityAlert objects Use `securityVulnerability.vulnerableVersionRange` instead. Removal on 2019-07-01 UTC.") """ The reason the alert was dismissed """ dismissReason: String """ When was the alert dimissed? """ dismissedAt: DateTime """ The user who dismissed the alert """ dismisser: User """ The external identifier for the vulnerability """ externalIdentifier: String @deprecated(reason: "advisory specific fields are being removed from repositoryVulnerabilityAlert objects Use `securityAdvisory.identifiers` instead. Removal on 2019-07-01 UTC.") """ The external reference for the vulnerability """ externalReference: String! @deprecated(reason: "advisory specific fields are being removed from repositoryVulnerabilityAlert objects Use `securityAdvisory.references` instead. Removal on 2019-07-01 UTC.") """ The fixed version """ fixedIn: String @deprecated(reason: "advisory specific fields are being removed from repositoryVulnerabilityAlert objects Use `securityVulnerability.firstPatchedVersion` instead. Removal on 2019-07-01 UTC.") id: ID! """ The affected package """ packageName: String! @deprecated(reason: "advisory specific fields are being removed from repositoryVulnerabilityAlert objects Use `securityVulnerability.package` instead. Removal on 2019-07-01 UTC.") """ The associated repository """ repository: Repository! """ The associated security advisory """ securityAdvisory: SecurityAdvisory """ The associated security vulnerablity """ securityVulnerability: SecurityVulnerability """ The vulnerable manifest filename """ vulnerableManifestFilename: String! """ The vulnerable manifest path """ vulnerableManifestPath: String! """ The vulnerable requirements """ vulnerableRequirements: String } """ The connection type for RepositoryVulnerabilityAlert. """ type RepositoryVulnerabilityAlertConnection @preview(toggledBy: "vixen-preview") { """ A list of edges. """ edges: [RepositoryVulnerabilityAlertEdge] """ A list of nodes. """ nodes: [RepositoryVulnerabilityAlert] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type RepositoryVulnerabilityAlertEdge @preview(toggledBy: "vixen-preview") { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: RepositoryVulnerabilityAlert } """ Autogenerated input type of RequestReviews """ input RequestReviewsInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The Node ID of the pull request to modify. """ pullRequestId: ID! @possibleTypes(concreteTypes: ["PullRequest"]) """ The Node IDs of the team to request. """ teamIds: [ID!] @possibleTypes(concreteTypes: ["Team"]) """ Add users to the set rather than replace. """ union: Boolean """ The Node IDs of the user to request. """ userIds: [ID!] @possibleTypes(concreteTypes: ["User"]) } """ Autogenerated return type of RequestReviews """ type RequestReviewsPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The pull request that is getting requests. """ pullRequest: PullRequest """ The edge from the pull request to the requested reviewers. """ requestedReviewersEdge: UserEdge } """ The possible states that can be requested when creating a check run. """ enum RequestableCheckStatusState @preview(toggledBy: "antiope-preview") { """ The check suite or run has been completed. """ COMPLETED """ The check suite or run is in progress. """ IN_PROGRESS """ The check suite or run has been queued. """ QUEUED } """ Types that can be requested reviewers. """ union RequestedReviewer = Team | User """ Autogenerated input type of RerequestCheckSuite """ input RerequestCheckSuiteInput @preview(toggledBy: "antiope-preview") { """ The Node ID of the check suite. """ checkSuiteId: ID! @possibleTypes(concreteTypes: ["CheckSuite"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The Node ID of the repository. """ repositoryId: ID! @possibleTypes(concreteTypes: ["Repository"]) } """ Autogenerated return type of RerequestCheckSuite """ type RerequestCheckSuitePayload @preview(toggledBy: "antiope-preview") { """ The requested check suite. """ checkSuite: CheckSuite """ A unique identifier for the client performing the mutation. """ clientMutationId: String } """ Autogenerated input type of ResolveReviewThread """ input ResolveReviewThreadInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The ID of the thread to resolve """ threadId: ID! @possibleTypes(concreteTypes: ["PullRequestReviewThread"]) } """ Autogenerated return type of ResolveReviewThread """ type ResolveReviewThreadPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The thread to resolve. """ thread: PullRequestReviewThread } """ Represents a private contribution a user made on GitHub. """ type RestrictedContribution implements Contribution { """ Whether this contribution is associated with a record you do not have access to. For example, your own 'first issue' contribution may have been made on a repository you can no longer access. """ isRestricted: Boolean! """ When this contribution was made. """ occurredAt: DateTime! """ The HTTP path for this contribution. """ resourcePath: URI! """ The HTTP URL for this contribution. """ url: URI! """ The user who made this contribution. """ user: User! } """ A team or user who has the ability to dismiss a review on a protected branch. """ type ReviewDismissalAllowance implements Node { """ The actor that can dismiss. """ actor: ReviewDismissalAllowanceActor """ Identifies the branch protection rule associated with the allowed user or team. """ branchProtectionRule: BranchProtectionRule id: ID! } """ Types that can be an actor. """ union ReviewDismissalAllowanceActor = Team | User """ The connection type for ReviewDismissalAllowance. """ type ReviewDismissalAllowanceConnection { """ A list of edges. """ edges: [ReviewDismissalAllowanceEdge] """ A list of nodes. """ nodes: [ReviewDismissalAllowance] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type ReviewDismissalAllowanceEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: ReviewDismissalAllowance } """ Represents a 'review_dismissed' event on a given issue or pull request. """ type ReviewDismissedEvent implements Node & UniformResourceLocatable { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Identifies the primary key from the database. """ databaseId: Int """ Identifies the optional message associated with the 'review_dismissed' event. """ dismissalMessage: String """ Identifies the optional message associated with the event, rendered to HTML. """ dismissalMessageHTML: String id: ID! """ Identifies the message associated with the 'review_dismissed' event. """ message: String! @deprecated(reason: "`message` is being removed because it not nullable, whereas the underlying field is optional. Use `dismissalMessage` instead. Removal on 2019-07-01 UTC.") """ The message associated with the event, rendered to HTML. """ messageHtml: HTML! @deprecated(reason: "`messageHtml` is being removed because it not nullable, whereas the underlying field is optional. Use `dismissalMessageHTML` instead. Removal on 2019-07-01 UTC.") """ Identifies the previous state of the review with the 'review_dismissed' event. """ previousReviewState: PullRequestReviewState! """ PullRequest referenced by event. """ pullRequest: PullRequest! """ Identifies the commit which caused the review to become stale. """ pullRequestCommit: PullRequestCommit """ The HTTP path for this review dismissed event. """ resourcePath: URI! """ Identifies the review associated with the 'review_dismissed' event. """ review: PullRequestReview """ The HTTP URL for this review dismissed event. """ url: URI! } """ A request for a user to review a pull request. """ type ReviewRequest implements Node { """ Identifies the primary key from the database. """ databaseId: Int id: ID! """ Identifies the pull request associated with this review request. """ pullRequest: PullRequest! """ The reviewer that is requested. """ requestedReviewer: RequestedReviewer } """ The connection type for ReviewRequest. """ type ReviewRequestConnection { """ A list of edges. """ edges: [ReviewRequestEdge] """ A list of nodes. """ nodes: [ReviewRequest] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type ReviewRequestEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: ReviewRequest } """ Represents an 'review_request_removed' event on a given pull request. """ type ReviewRequestRemovedEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! id: ID! """ PullRequest referenced by event. """ pullRequest: PullRequest! """ Identifies the reviewer whose review request was removed. """ requestedReviewer: RequestedReviewer } """ Represents an 'review_requested' event on a given pull request. """ type ReviewRequestedEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! id: ID! """ PullRequest referenced by event. """ pullRequest: PullRequest! """ Identifies the reviewer whose review was requested. """ requestedReviewer: RequestedReviewer } """ A hovercard context with a message describing the current code review state of the pull request. """ type ReviewStatusHovercardContext implements HovercardContext @preview(toggledBy: "hagar-preview") { """ A string describing this context """ message: String! """ An octicon to accompany this context """ octicon: String! } """ The results of a search. """ union SearchResultItem = Issue | MarketplaceListing | Organization | PullRequest | Repository | User """ A list of results that matched against a search query. """ type SearchResultItemConnection { """ The number of pieces of code that matched the search query. """ codeCount: Int! """ A list of edges. """ edges: [SearchResultItemEdge] """ The number of issues that matched the search query. """ issueCount: Int! """ A list of nodes. """ nodes: [SearchResultItem] """ Information to aid in pagination. """ pageInfo: PageInfo! """ The number of repositories that matched the search query. """ repositoryCount: Int! """ The number of users that matched the search query. """ userCount: Int! """ The number of wiki pages that matched the search query. """ wikiCount: Int! } """ An edge in a connection. """ type SearchResultItemEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: SearchResultItem """ Text matches on the result found. """ textMatches: [TextMatch] } """ Represents the individual results of a search. """ enum SearchType { """ Returns results matching issues in repositories. """ ISSUE """ Returns results matching repositories. """ REPOSITORY """ Returns results matching users and organizations on GitHub. """ USER } """ A GitHub Security Advisory """ type SecurityAdvisory implements Node { """ Identifies the primary key from the database. """ databaseId: Int """ This is a long plaintext description of the advisory """ description: String! """ The GitHub Security Advisory ID """ ghsaId: String! id: ID! """ A list of identifiers for this advisory """ identifiers: [SecurityAdvisoryIdentifier!]! """ When the advisory was published """ publishedAt: DateTime! """ A list of references for this advisory """ references: [SecurityAdvisoryReference!]! """ The severity of the advisory """ severity: SecurityAdvisorySeverity! """ A short plaintext summary of the advisory """ summary: String! """ When the advisory was last updated """ updatedAt: DateTime! """ Vulnerabilities associated with this Advisory """ vulnerabilities( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ An ecosystem to filter vulnerabilities by. """ ecosystem: SecurityAdvisoryEcosystem """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for the returned topics. """ orderBy: SecurityVulnerabilityOrder = {field: UPDATED_AT, direction: DESC} """ A package name to filter vulnerabilities by. """ package: String """ A list of severities to filter vulnerabilities by. """ severities: [SecurityAdvisorySeverity!] ): SecurityVulnerabilityConnection! """ When the advisory was withdrawn, if it has been withdrawn """ withdrawnAt: DateTime } """ The connection type for SecurityAdvisory. """ type SecurityAdvisoryConnection { """ A list of edges. """ edges: [SecurityAdvisoryEdge] """ A list of nodes. """ nodes: [SecurityAdvisory] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ The possible ecosystems of a security vulnerability's package. """ enum SecurityAdvisoryEcosystem { """ Java artifacts hosted at the Maven central repository """ MAVEN """ JavaScript packages hosted at npmjs.com """ NPM """ .NET packages hosted at the NuGet Gallery """ NUGET """ Python packages hosted at PyPI.org """ PIP """ Ruby gems hosted at RubyGems.org """ RUBYGEMS } """ An edge in a connection. """ type SecurityAdvisoryEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: SecurityAdvisory } """ A GitHub Security Advisory Identifier """ type SecurityAdvisoryIdentifier { """ The identifier type, e.g. GHSA, CVE """ type: String! """ The identifier """ value: String! } """ An advisory identifier to filter results on. """ input SecurityAdvisoryIdentifierFilter { """ The identifier type. """ type: SecurityAdvisoryIdentifierType! """ The identifier string. Supports exact or partial matching. """ value: String! } """ Identifier formats available for advisories. """ enum SecurityAdvisoryIdentifierType { """ Common Vulnerabilities and Exposures Identifier. """ CVE """ GitHub Security Advisory ID. """ GHSA } """ Ordering options for security advisory connections """ input SecurityAdvisoryOrder { """ The ordering direction. """ direction: OrderDirection! """ The field to order security advisories by. """ field: SecurityAdvisoryOrderField! } """ Properties by which security advisory connections can be ordered. """ enum SecurityAdvisoryOrderField { """ Order advisories by publication time """ PUBLISHED_AT """ Order advisories by update time """ UPDATED_AT } """ An individual package """ type SecurityAdvisoryPackage { """ The ecosystem the package belongs to, e.g. RUBYGEMS, NPM """ ecosystem: SecurityAdvisoryEcosystem! """ The package name """ name: String! } """ An individual package version """ type SecurityAdvisoryPackageVersion { """ The package name or version """ identifier: String! } """ A GitHub Security Advisory Reference """ type SecurityAdvisoryReference { """ A publicly accessible reference """ url: URI! } """ Severity of the vulnerability. """ enum SecurityAdvisorySeverity { """ Critical. """ CRITICAL """ High. """ HIGH """ Low. """ LOW """ Moderate. """ MODERATE } """ An individual vulnerability within an Advisory """ type SecurityVulnerability { """ The Advisory associated with this Vulnerability """ advisory: SecurityAdvisory! """ The first version containing a fix for the vulnerability """ firstPatchedVersion: SecurityAdvisoryPackageVersion """ A description of the vulnerable package """ package: SecurityAdvisoryPackage! """ The severity of the vulnerability within this package """ severity: SecurityAdvisorySeverity! """ When the vulnerability was last updated """ updatedAt: DateTime! """ A string that describes the vulnerable package versions. This string follows a basic syntax with a few forms. + `= 0.2.0` denotes a single vulnerable version. + `<= 1.0.8` denotes a version range up to and including the specified version + `< 0.1.11` denotes a version range up to, but excluding, the specified version + `>= 4.3.0, < 4.3.5` denotes a version range with a known minimum and maximum version. + `>= 0.0.1` denotes a version range with a known minimum, but no known maximum """ vulnerableVersionRange: String! } """ The connection type for SecurityVulnerability. """ type SecurityVulnerabilityConnection { """ A list of edges. """ edges: [SecurityVulnerabilityEdge] """ A list of nodes. """ nodes: [SecurityVulnerability] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type SecurityVulnerabilityEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: SecurityVulnerability } """ Ordering options for security vulnerability connections """ input SecurityVulnerabilityOrder { """ The ordering direction. """ direction: OrderDirection! """ The field to order security vulnerabilities by. """ field: SecurityVulnerabilityOrderField! } """ Properties by which security vulnerability connections can be ordered. """ enum SecurityVulnerabilityOrderField { """ Order vulnerability by update time """ UPDATED_AT } """ Represents an S/MIME signature on a Commit or Tag. """ type SmimeSignature implements GitSignature { """ Email used to sign this object. """ email: String! """ True if the signature is valid and verified by GitHub. """ isValid: Boolean! """ Payload for GPG signing object. Raw ODB object without the signature header. """ payload: String! """ ASCII-armored signature header from object. """ signature: String! """ GitHub user corresponding to the email signing this commit. """ signer: User """ The state of this signature. `VALID` if signature is valid and verified by GitHub, otherwise represents reason why signature is considered invalid. """ state: GitSignatureState! """ True if the signature was made with GitHub's signing key. """ wasSignedByGitHub: Boolean! } """ Ways in which star connections can be ordered. """ input StarOrder { """ The direction in which to order nodes. """ direction: OrderDirection! """ The field in which to order nodes by. """ field: StarOrderField! } """ Properties by which star connections can be ordered. """ enum StarOrderField { """ Allows ordering a list of stars by when they were created. """ STARRED_AT } """ The connection type for User. """ type StargazerConnection { """ A list of edges. """ edges: [StargazerEdge] """ A list of nodes. """ nodes: [User] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ Represents a user that's starred a repository. """ type StargazerEdge { """ A cursor for use in pagination. """ cursor: String! node: User! """ Identifies when the item was starred. """ starredAt: DateTime! } """ Things that can be starred. """ interface Starrable { id: ID! """ A list of users who have starred this starrable. """ stargazers( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Order for connection """ orderBy: StarOrder ): StargazerConnection! """ Returns a boolean indicating whether the viewing user has starred this starrable. """ viewerHasStarred: Boolean! } """ The connection type for Repository. """ type StarredRepositoryConnection { """ A list of edges. """ edges: [StarredRepositoryEdge] """ A list of nodes. """ nodes: [Repository] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ Represents a starred repository. """ type StarredRepositoryEdge { """ A cursor for use in pagination. """ cursor: String! node: Repository! """ Identifies when the item was starred. """ starredAt: DateTime! } """ Represents a commit status. """ type Status implements Node { """ The commit this status is attached to. """ commit: Commit """ Looks up an individual status context by context name. """ context( """ The context name. """ name: String! ): StatusContext """ The individual status contexts for this commit. """ contexts: [StatusContext!]! id: ID! """ The combined commit status. """ state: StatusState! } """ Represents an individual commit status context """ type StatusContext implements Node { """ This commit this status context is attached to. """ commit: Commit """ The name of this status context. """ context: String! """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ The actor who created this status context. """ creator: Actor """ The description for this status context. """ description: String id: ID! """ The state of this status context. """ state: StatusState! """ The URL for this status context. """ targetUrl: URI } """ The possible commit status states. """ enum StatusState { """ Status is errored. """ ERROR """ Status is expected. """ EXPECTED """ Status is failing. """ FAILURE """ Status is pending. """ PENDING """ Status is successful. """ SUCCESS } """ Autogenerated input type of SubmitPullRequestReview """ input SubmitPullRequestReviewInput { """ The text field to set on the Pull Request Review. """ body: String """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The event to send to the Pull Request Review. """ event: PullRequestReviewEvent! """ The Pull Request Review ID to submit. """ pullRequestReviewId: ID! @possibleTypes(concreteTypes: ["PullRequestReview"]) } """ Autogenerated return type of SubmitPullRequestReview """ type SubmitPullRequestReviewPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The submitted pull request review. """ pullRequestReview: PullRequestReview } """ Entities that can be subscribed to for web and email notifications. """ interface Subscribable { id: ID! """ Check if the viewer is able to change their subscription status for the repository. """ viewerCanSubscribe: Boolean! """ Identifies if the viewer is watching, not watching, or ignoring the subscribable entity. """ viewerSubscription: SubscriptionState } """ Represents a 'subscribed' event on a given `Subscribable`. """ type SubscribedEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! id: ID! """ Object referenced by event. """ subscribable: Subscribable! } """ The possible states of a subscription. """ enum SubscriptionState { """ The User is never notified. """ IGNORED """ The User is notified of all conversations. """ SUBSCRIBED """ The User is only notified when participating or @mentioned. """ UNSUBSCRIBED } """ A suggestion to review a pull request based on a user's commit history and review comments. """ type SuggestedReviewer { """ Is this suggestion based on past commits? """ isAuthor: Boolean! """ Is this suggestion based on past review comments? """ isCommenter: Boolean! """ Identifies the user suggested to review the pull request. """ reviewer: User! } """ Represents a Git tag. """ type Tag implements GitObject & Node { """ An abbreviated version of the Git object ID """ abbreviatedOid: String! """ The HTTP path for this Git object """ commitResourcePath: URI! """ The HTTP URL for this Git object """ commitUrl: URI! id: ID! """ The Git tag message. """ message: String """ The Git tag name. """ name: String! """ The Git object ID """ oid: GitObjectID! """ The Repository the Git object belongs to """ repository: Repository! """ Details about the tag author. """ tagger: GitActor """ The Git object the tag points to. """ target: GitObject! } """ A team of users in an organization. """ type Team implements Node & Subscribable { """ A list of teams that are ancestors of this team. """ ancestors( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): TeamConnection! """ A URL pointing to the team's avatar. """ avatarUrl( """ The size in pixels of the resulting square image. """ size: Int = 400 ): URI """ List of child teams belonging to this team """ childTeams( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Whether to list immediate child teams or all descendant child teams. """ immediateOnly: Boolean = true """ Returns the last _n_ elements from the list. """ last: Int """ Order for connection """ orderBy: TeamOrder """ User logins to filter by """ userLogins: [String!] ): TeamConnection! """ The slug corresponding to the organization and team. """ combinedSlug: String! """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ The description of the team. """ description: String """ Find a team discussion by its number. """ discussion( """ The sequence number of the discussion to find. """ number: Int! ): TeamDiscussion @preview(toggledBy: "echo-preview") """ A list of team discussions. """ discussions( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ If provided, filters discussions according to whether or not they are pinned. """ isPinned: Boolean """ Returns the last _n_ elements from the list. """ last: Int """ Order for connection """ orderBy: TeamDiscussionOrder ): TeamDiscussionConnection! @preview(toggledBy: "echo-preview") """ The HTTP path for team discussions """ discussionsResourcePath: URI! @preview(toggledBy: "echo-preview") """ The HTTP URL for team discussions """ discussionsUrl: URI! @preview(toggledBy: "echo-preview") """ The HTTP path for editing this team """ editTeamResourcePath: URI! """ The HTTP URL for editing this team """ editTeamUrl: URI! id: ID! """ A list of pending invitations for users to this team """ invitations( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): OrganizationInvitationConnection """ A list of users who are members of this team. """ members( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Filter by membership type """ membership: TeamMembershipType = ALL """ Order for the connection. """ orderBy: TeamMemberOrder """ The search string to look for. """ query: String """ Filter by team member role """ role: TeamMemberRole ): TeamMemberConnection! """ The HTTP path for the team' members """ membersResourcePath: URI! """ The HTTP URL for the team' members """ membersUrl: URI! """ The name of the team. """ name: String! """ The HTTP path creating a new team """ newTeamResourcePath: URI! """ The HTTP URL creating a new team """ newTeamUrl: URI! """ The organization that owns this team. """ organization: Organization! """ The parent team of the team. """ parentTeam: Team """ The level of privacy the team has. """ privacy: TeamPrivacy! """ A list of repositories this team has access to. """ repositories( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Order for the connection. """ orderBy: TeamRepositoryOrder """ The search string to look for. """ query: String ): TeamRepositoryConnection! """ The HTTP path for this team's repositories """ repositoriesResourcePath: URI! """ The HTTP URL for this team's repositories """ repositoriesUrl: URI! """ The HTTP path for this team """ resourcePath: URI! """ The slug corresponding to the team. """ slug: String! """ The HTTP path for this team's teams """ teamsResourcePath: URI! """ The HTTP URL for this team's teams """ teamsUrl: URI! """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! """ The HTTP URL for this team """ url: URI! """ Team is adminable by the viewer. """ viewerCanAdminister: Boolean! """ Check if the viewer is able to change their subscription status for the repository. """ viewerCanSubscribe: Boolean! """ Identifies if the viewer is watching, not watching, or ignoring the subscribable entity. """ viewerSubscription: SubscriptionState } """ The connection type for Team. """ type TeamConnection { """ A list of edges. """ edges: [TeamEdge] """ A list of nodes. """ nodes: [Team] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ A team discussion. """ type TeamDiscussion implements Comment & Deletable & Node & Reactable & Subscribable & UniformResourceLocatable & Updatable & UpdatableComment @preview(toggledBy: "echo-preview") { """ The actor who authored the comment. """ author: Actor """ Author's association with the discussion's team. """ authorAssociation: CommentAuthorAssociation! """ The body as Markdown. """ body: String! """ The discussion body rendered to HTML. """ bodyHTML: HTML! """ The body rendered to text. """ bodyText: String! """ Identifies the discussion body hash. """ bodyVersion: String! """ A list of comments on this discussion. """ comments( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ When provided, filters the connection such that results begin with the comment with this number. """ fromComment: Int """ Returns the last _n_ elements from the list. """ last: Int """ Order for connection """ orderBy: TeamDiscussionCommentOrder ): TeamDiscussionCommentConnection! """ The HTTP path for discussion comments """ commentsResourcePath: URI! """ The HTTP URL for discussion comments """ commentsUrl: URI! """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Check if this comment was created via an email reply. """ createdViaEmail: Boolean! """ Identifies the primary key from the database. """ databaseId: Int """ The actor who edited the comment. """ editor: Actor id: ID! """ Check if this comment was edited and includes an edit with the creation data """ includesCreatedEdit: Boolean! """ Whether or not the discussion is pinned. """ isPinned: Boolean! """ Whether or not the discussion is only visible to team members and org admins. """ isPrivate: Boolean! """ The moment the editor made the last edit """ lastEditedAt: DateTime """ Identifies the discussion within its team. """ number: Int! """ Identifies when the comment was published at. """ publishedAt: DateTime """ A list of reactions grouped by content left on the subject. """ reactionGroups: [ReactionGroup!] """ A list of Reactions left on the Issue. """ reactions( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Allows filtering Reactions by emoji. """ content: ReactionContent """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Allows specifying the order in which reactions are returned. """ orderBy: ReactionOrder ): ReactionConnection! """ The HTTP path for this discussion """ resourcePath: URI! """ The team that defines the context of this discussion. """ team: Team! """ The title of the discussion """ title: String! """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! """ The HTTP URL for this discussion """ url: URI! """ A list of edits to this content. """ userContentEdits( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): UserContentEditConnection """ Check if the current viewer can delete this object. """ viewerCanDelete: Boolean! """ Whether or not the current viewer can pin this discussion. """ viewerCanPin: Boolean! """ Can user react to this subject """ viewerCanReact: Boolean! """ Check if the viewer is able to change their subscription status for the repository. """ viewerCanSubscribe: Boolean! """ Check if the current viewer can update this object. """ viewerCanUpdate: Boolean! """ Reasons why the current viewer can not update this comment. """ viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! """ Did the viewer author this comment. """ viewerDidAuthor: Boolean! """ Identifies if the viewer is watching, not watching, or ignoring the subscribable entity. """ viewerSubscription: SubscriptionState } """ A comment on a team discussion. """ type TeamDiscussionComment implements Comment & Deletable & Node & Reactable & UniformResourceLocatable & Updatable & UpdatableComment @preview(toggledBy: "echo-preview") { """ The actor who authored the comment. """ author: Actor """ Author's association with the comment's team. """ authorAssociation: CommentAuthorAssociation! """ The body as Markdown. """ body: String! """ The comment body rendered to HTML. """ bodyHTML: HTML! """ The body rendered to text. """ bodyText: String! """ The current version of the body content. """ bodyVersion: String! """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Check if this comment was created via an email reply. """ createdViaEmail: Boolean! """ Identifies the primary key from the database. """ databaseId: Int """ The discussion this comment is about. """ discussion: TeamDiscussion! """ The actor who edited the comment. """ editor: Actor id: ID! """ Check if this comment was edited and includes an edit with the creation data """ includesCreatedEdit: Boolean! """ The moment the editor made the last edit """ lastEditedAt: DateTime """ Identifies the comment number. """ number: Int! """ Identifies when the comment was published at. """ publishedAt: DateTime """ A list of reactions grouped by content left on the subject. """ reactionGroups: [ReactionGroup!] """ A list of Reactions left on the Issue. """ reactions( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Allows filtering Reactions by emoji. """ content: ReactionContent """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Allows specifying the order in which reactions are returned. """ orderBy: ReactionOrder ): ReactionConnection! """ The HTTP path for this comment """ resourcePath: URI! """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! """ The HTTP URL for this comment """ url: URI! """ A list of edits to this content. """ userContentEdits( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): UserContentEditConnection """ Check if the current viewer can delete this object. """ viewerCanDelete: Boolean! """ Can user react to this subject """ viewerCanReact: Boolean! """ Check if the current viewer can update this object. """ viewerCanUpdate: Boolean! """ Reasons why the current viewer can not update this comment. """ viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! """ Did the viewer author this comment. """ viewerDidAuthor: Boolean! } """ The connection type for TeamDiscussionComment. """ type TeamDiscussionCommentConnection @preview(toggledBy: "echo-preview") { """ A list of edges. """ edges: [TeamDiscussionCommentEdge] """ A list of nodes. """ nodes: [TeamDiscussionComment] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type TeamDiscussionCommentEdge @preview(toggledBy: "echo-preview") { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: TeamDiscussionComment } """ Ways in which team discussion comment connections can be ordered. """ input TeamDiscussionCommentOrder @preview(toggledBy: "echo-preview") { """ The direction in which to order nodes. """ direction: OrderDirection! """ The field by which to order nodes. """ field: TeamDiscussionCommentOrderField! } """ Properties by which team discussion comment connections can be ordered. """ enum TeamDiscussionCommentOrderField @preview(toggledBy: "echo-preview") { """ Allows sequential ordering of team discussion comments (which is equivalent to chronological ordering). """ NUMBER } """ The connection type for TeamDiscussion. """ type TeamDiscussionConnection @preview(toggledBy: "echo-preview") { """ A list of edges. """ edges: [TeamDiscussionEdge] """ A list of nodes. """ nodes: [TeamDiscussion] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type TeamDiscussionEdge @preview(toggledBy: "echo-preview") { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: TeamDiscussion } """ Ways in which team discussion connections can be ordered. """ input TeamDiscussionOrder @preview(toggledBy: "echo-preview") { """ The direction in which to order nodes. """ direction: OrderDirection! """ The field by which to order nodes. """ field: TeamDiscussionOrderField! } """ Properties by which team discussion connections can be ordered. """ enum TeamDiscussionOrderField @preview(toggledBy: "echo-preview") { """ Allows chronological ordering of team discussions. """ CREATED_AT } """ An edge in a connection. """ type TeamEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: Team } """ The connection type for User. """ type TeamMemberConnection { """ A list of edges. """ edges: [TeamMemberEdge] """ A list of nodes. """ nodes: [User] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ Represents a user who is a member of a team. """ type TeamMemberEdge { """ A cursor for use in pagination. """ cursor: String! """ The HTTP path to the organization's member access page. """ memberAccessResourcePath: URI! """ The HTTP URL to the organization's member access page. """ memberAccessUrl: URI! node: User! """ The role the member has on the team. """ role: TeamMemberRole! } """ Ordering options for team member connections """ input TeamMemberOrder { """ The ordering direction. """ direction: OrderDirection! """ The field to order team members by. """ field: TeamMemberOrderField! } """ Properties by which team member connections can be ordered. """ enum TeamMemberOrderField { """ Order team members by creation time """ CREATED_AT """ Order team members by login """ LOGIN } """ The possible team member roles; either 'maintainer' or 'member'. """ enum TeamMemberRole { """ A team maintainer has permission to add and remove team members. """ MAINTAINER """ A team member has no administrative permissions on the team. """ MEMBER } """ Defines which types of team members are included in the returned list. Can be one of IMMEDIATE, CHILD_TEAM or ALL. """ enum TeamMembershipType { """ Includes immediate and child team members for the team. """ ALL """ Includes only child team members for the team. """ CHILD_TEAM """ Includes only immediate members of the team. """ IMMEDIATE } """ Ways in which team connections can be ordered. """ input TeamOrder { """ The direction in which to order nodes. """ direction: OrderDirection! """ The field in which to order nodes by. """ field: TeamOrderField! } """ Properties by which team connections can be ordered. """ enum TeamOrderField { """ Allows ordering a list of teams by name. """ NAME } """ The possible team privacy values. """ enum TeamPrivacy { """ A secret team can only be seen by its members. """ SECRET """ A visible team can be seen and @mentioned by every member of the organization. """ VISIBLE } """ The connection type for Repository. """ type TeamRepositoryConnection { """ A list of edges. """ edges: [TeamRepositoryEdge] """ A list of nodes. """ nodes: [Repository] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ Represents a team repository. """ type TeamRepositoryEdge { """ A cursor for use in pagination. """ cursor: String! node: Repository! """ The permission level the team has on the repository """ permission: RepositoryPermission! } """ Ordering options for team repository connections """ input TeamRepositoryOrder { """ The ordering direction. """ direction: OrderDirection! """ The field to order repositories by. """ field: TeamRepositoryOrderField! } """ Properties by which team repository connections can be ordered. """ enum TeamRepositoryOrderField { """ Order repositories by creation time """ CREATED_AT """ Order repositories by name """ NAME """ Order repositories by permission """ PERMISSION """ Order repositories by push time """ PUSHED_AT """ Order repositories by number of stargazers """ STARGAZERS """ Order repositories by update time """ UPDATED_AT } """ The role of a user on a team. """ enum TeamRole { """ User has admin rights on the team. """ ADMIN """ User is a member of the team. """ MEMBER } """ A text match within a search result. """ type TextMatch { """ The specific text fragment within the property matched on. """ fragment: String! """ Highlights within the matched fragment. """ highlights: [TextMatchHighlight!]! """ The property matched on. """ property: String! } """ Represents a single highlight in a search result match. """ type TextMatchHighlight { """ The indice in the fragment where the matched text begins. """ beginIndice: Int! """ The indice in the fragment where the matched text ends. """ endIndice: Int! """ The text matched. """ text: String! } """ A topic aggregates entities that are related to a subject. """ type Topic implements Node & Starrable { id: ID! """ The topic's name. """ name: String! """ A list of related topics, including aliases of this topic, sorted with the most relevant first. Returns up to 10 Topics. """ relatedTopics( """ How many topics to return. """ first: Int = 3 ): [Topic!]! """ A list of users who have starred this starrable. """ stargazers( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Order for connection """ orderBy: StarOrder ): StargazerConnection! """ Returns a boolean indicating whether the viewing user has starred this starrable. """ viewerHasStarred: Boolean! } """ The connection type for Topic. """ type TopicConnection { """ A list of edges. """ edges: [TopicEdge] """ A list of nodes. """ nodes: [Topic] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type TopicEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: Topic } """ Reason that the suggested topic is declined. """ enum TopicSuggestionDeclineReason { """ The suggested topic is not relevant to the repository. """ NOT_RELEVANT """ The viewer does not like the suggested topic. """ PERSONAL_PREFERENCE """ The suggested topic is too general for the repository. """ TOO_GENERAL """ The suggested topic is too specific for the repository (e.g. #ruby-on-rails-version-4-2-1). """ TOO_SPECIFIC } """ Represents a 'transferred' event on a given issue or pull request. """ type TransferredEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ The repository this came from """ fromRepository: Repository id: ID! """ Identifies the issue associated with the event. """ issue: Issue! } """ Represents a Git tree. """ type Tree implements GitObject & Node { """ An abbreviated version of the Git object ID """ abbreviatedOid: String! """ The HTTP path for this Git object """ commitResourcePath: URI! """ The HTTP URL for this Git object """ commitUrl: URI! """ A list of tree entries. """ entries: [TreeEntry!] id: ID! """ The Git object ID """ oid: GitObjectID! """ The Repository the Git object belongs to """ repository: Repository! } """ Represents a Git tree entry. """ type TreeEntry { """ Entry file mode. """ mode: Int! """ Entry file name. """ name: String! """ Entry file object. """ object: GitObject """ Entry file Git object ID. """ oid: GitObjectID! """ The Repository the tree entry belongs to """ repository: Repository! """ Entry file type. """ type: String! } """ An RFC 3986, RFC 3987, and RFC 6570 (level 4) compliant URI string. """ scalar URI """ Represents an 'unassigned' event on any assignable object. """ type UnassignedEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the assignable associated with the event. """ assignable: Assignable! """ Identifies the date and time when the object was created. """ createdAt: DateTime! id: ID! """ Identifies the subject (user) who was unassigned. """ user: User } """ Represents a type that can be retrieved by a URL. """ interface UniformResourceLocatable { """ The HTML path to this resource. """ resourcePath: URI! """ The URL to this resource. """ url: URI! } """ Represents an unknown signature on a Commit or Tag. """ type UnknownSignature implements GitSignature { """ Email used to sign this object. """ email: String! """ True if the signature is valid and verified by GitHub. """ isValid: Boolean! """ Payload for GPG signing object. Raw ODB object without the signature header. """ payload: String! """ ASCII-armored signature header from object. """ signature: String! """ GitHub user corresponding to the email signing this commit. """ signer: User """ The state of this signature. `VALID` if signature is valid and verified by GitHub, otherwise represents reason why signature is considered invalid. """ state: GitSignatureState! """ True if the signature was made with GitHub's signing key. """ wasSignedByGitHub: Boolean! } """ Represents an 'unlabeled' event on a given issue or pull request. """ type UnlabeledEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! id: ID! """ Identifies the label associated with the 'unlabeled' event. """ label: Label! """ Identifies the `Labelable` associated with the event. """ labelable: Labelable! } """ Autogenerated input type of UnlockLockable """ input UnlockLockableInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ ID of the issue or pull request to be unlocked. """ lockableId: ID! @possibleTypes(concreteTypes: ["Issue", "PullRequest"], abstractType: "Lockable") } """ Autogenerated return type of UnlockLockable """ type UnlockLockablePayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The item that was unlocked. """ unlockedRecord: Lockable } """ Represents an 'unlocked' event on a given issue or pull request. """ type UnlockedEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! id: ID! """ Object that was unlocked. """ lockable: Lockable! } """ Autogenerated input type of UnmarkIssueAsDuplicate """ input UnmarkIssueAsDuplicateInput @preview(toggledBy: "starfire-preview") { """ ID of the issue or pull request currently considered canonical/authoritative/original. """ canonicalId: ID! @possibleTypes(concreteTypes: ["Issue", "PullRequest"], abstractType: "IssueOrPullRequest") """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ ID of the issue or pull request currently marked as a duplicate. """ duplicateId: ID! @possibleTypes(concreteTypes: ["Issue", "PullRequest"], abstractType: "IssueOrPullRequest") } """ Autogenerated return type of UnmarkIssueAsDuplicate """ type UnmarkIssueAsDuplicatePayload @preview(toggledBy: "starfire-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The issue or pull request that was marked as a duplicate. """ duplicate: IssueOrPullRequest } """ Autogenerated input type of UnminimizeComment """ input UnminimizeCommentInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The Node ID of the subject to modify. """ subjectId: ID! @possibleTypes(concreteTypes: ["CommitComment", "GistComment", "IssueComment", "PullRequestReviewComment"], abstractType: "Minimizable") } """ Autogenerated return type of UnminimizeComment """ type UnminimizeCommentPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The comment that was unminimized. """ unminimizedComment: Minimizable } """ Autogenerated input type of UnpinIssue """ input UnpinIssueInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The ID of the issue to be unpinned """ issueId: ID! @possibleTypes(concreteTypes: ["Issue"]) } """ Autogenerated return type of UnpinIssue """ type UnpinIssuePayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The issue that was unpinned """ issue: Issue } """ Represents an 'unpinned' event on a given issue or pull request. """ type UnpinnedEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! id: ID! """ Identifies the issue associated with the event. """ issue: Issue! } """ Autogenerated input type of UnresolveReviewThread """ input UnresolveReviewThreadInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The ID of the thread to unresolve """ threadId: ID! @possibleTypes(concreteTypes: ["PullRequestReviewThread"]) } """ Autogenerated return type of UnresolveReviewThread """ type UnresolveReviewThreadPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The thread to resolve. """ thread: PullRequestReviewThread } """ Represents an 'unsubscribed' event on a given `Subscribable`. """ type UnsubscribedEvent implements Node { """ Identifies the actor who performed the event. """ actor: Actor """ Identifies the date and time when the object was created. """ createdAt: DateTime! id: ID! """ Object referenced by event. """ subscribable: Subscribable! } """ Entities that can be updated. """ interface Updatable { """ Check if the current viewer can update this object. """ viewerCanUpdate: Boolean! } """ Comments that can be updated. """ interface UpdatableComment { """ Reasons why the current viewer can not update this comment. """ viewerCannotUpdateReasons: [CommentCannotUpdateReason!]! } """ Autogenerated input type of UpdateBranchProtectionRule """ input UpdateBranchProtectionRuleInput { """ The global relay id of the branch protection rule to be updated. """ branchProtectionRuleId: ID! @possibleTypes(concreteTypes: ["BranchProtectionRule"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ Will new commits pushed to matching branches dismiss pull request review approvals. """ dismissesStaleReviews: Boolean """ Can admins overwrite branch protection. """ isAdminEnforced: Boolean """ The glob-like pattern used to determine matching branches. """ pattern: String """ A list of User or Team IDs allowed to push to matching branches. """ pushActorIds: [ID!] """ Number of approving reviews required to update matching branches. """ requiredApprovingReviewCount: Int """ List of required status check contexts that must pass for commits to be accepted to matching branches. """ requiredStatusCheckContexts: [String!] """ Are approving reviews required to update matching branches. """ requiresApprovingReviews: Boolean """ Are reviews from code owners required to update matching branches. """ requiresCodeOwnerReviews: Boolean """ Are commits required to be signed. """ requiresCommitSignatures: Boolean """ Are status checks required to update matching branches. """ requiresStatusChecks: Boolean """ Are branches required to be up to date before merging. """ requiresStrictStatusChecks: Boolean """ Is pushing to matching branches restricted. """ restrictsPushes: Boolean """ Is dismissal of pull request reviews restricted. """ restrictsReviewDismissals: Boolean """ A list of User or Team IDs allowed to dismiss reviews on pull requests targeting matching branches. """ reviewDismissalActorIds: [ID!] } """ Autogenerated return type of UpdateBranchProtectionRule """ type UpdateBranchProtectionRulePayload { """ The newly created BranchProtectionRule. """ branchProtectionRule: BranchProtectionRule """ A unique identifier for the client performing the mutation. """ clientMutationId: String } """ Autogenerated input type of UpdateBusinessAllowPrivateRepositoryForkingSetting """ input UpdateBusinessAllowPrivateRepositoryForkingSettingInput { """ The ID of the business on which to set the allow private repository forking setting. """ businessId: ID! @possibleTypes(concreteTypes: ["Business"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The value for the allow private repository forking setting on the business. """ settingValue: BusinessEnabledDisabledSettingValue! } """ Autogenerated return type of UpdateBusinessAllowPrivateRepositoryForkingSetting """ type UpdateBusinessAllowPrivateRepositoryForkingSettingPayload { """ The business with the updated allow private repository forking setting. """ business: Business @preview(toggledBy: "gwenpool-preview") """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ A message confirming the result of updating the allow private repository forking setting. """ message: String } """ Autogenerated input type of UpdateBusinessDefaultRepositoryPermissionSetting """ input UpdateBusinessDefaultRepositoryPermissionSettingInput { """ The ID of the business on which to set the default repository permission setting. """ businessId: ID! @possibleTypes(concreteTypes: ["Business"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The value for the default repository permission setting on the business. """ settingValue: BusinessDefaultRepositoryPermissionSettingValue! } """ Autogenerated return type of UpdateBusinessDefaultRepositoryPermissionSetting """ type UpdateBusinessDefaultRepositoryPermissionSettingPayload { """ The business with the updated default repository permission setting. """ business: Business @preview(toggledBy: "gwenpool-preview") """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ A message confirming the result of updating the default repository permission setting. """ message: String } """ Autogenerated input type of UpdateBusinessMembersCanChangeRepositoryVisibilitySetting """ input UpdateBusinessMembersCanChangeRepositoryVisibilitySettingInput { """ The ID of the business on which to set the members can change repository visibility setting. """ businessId: ID! @possibleTypes(concreteTypes: ["Business"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The value for the members can change repository visibility setting on the business. """ settingValue: BusinessEnabledDisabledSettingValue! } """ Autogenerated return type of UpdateBusinessMembersCanChangeRepositoryVisibilitySetting """ type UpdateBusinessMembersCanChangeRepositoryVisibilitySettingPayload { """ The business with the updated members can change repository visibility setting. """ business: Business @preview(toggledBy: "gwenpool-preview") """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ A message confirming the result of updating the members can change repository visibility setting. """ message: String } """ Autogenerated input type of UpdateBusinessMembersCanCreateRepositoriesSetting """ input UpdateBusinessMembersCanCreateRepositoriesSettingInput { """ The ID of the business on which to set the members can create repositories setting. """ businessId: ID! @possibleTypes(concreteTypes: ["Business"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The value for the members can create repositories setting on the business. """ settingValue: BusinessMembersCanCreateRepositoriesSettingValue! } """ Autogenerated return type of UpdateBusinessMembersCanCreateRepositoriesSetting """ type UpdateBusinessMembersCanCreateRepositoriesSettingPayload { """ The business with the updated members can create repositories setting. """ business: Business @preview(toggledBy: "gwenpool-preview") """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ A message confirming the result of updating the members can create repositories setting. """ message: String } """ Autogenerated input type of UpdateBusinessMembersCanDeleteIssuesSetting """ input UpdateBusinessMembersCanDeleteIssuesSettingInput { """ The ID of the business on which to set the members can delete issues setting. """ businessId: ID! @possibleTypes(concreteTypes: ["Business"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The value for the members can delete issues setting on the business. """ settingValue: BusinessEnabledDisabledSettingValue! } """ Autogenerated return type of UpdateBusinessMembersCanDeleteIssuesSetting """ type UpdateBusinessMembersCanDeleteIssuesSettingPayload { """ The business with the updated members can delete issues setting. """ business: Business @preview(toggledBy: "gwenpool-preview") """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ A message confirming the result of updating the members can delete issues setting. """ message: String } """ Autogenerated input type of UpdateBusinessMembersCanDeleteRepositoriesSetting """ input UpdateBusinessMembersCanDeleteRepositoriesSettingInput { """ The ID of the business on which to set the members can delete repositories setting. """ businessId: ID! @possibleTypes(concreteTypes: ["Business"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The value for the members can delete repositories setting on the business. """ settingValue: BusinessEnabledDisabledSettingValue! } """ Autogenerated return type of UpdateBusinessMembersCanDeleteRepositoriesSetting """ type UpdateBusinessMembersCanDeleteRepositoriesSettingPayload { """ The business with the updated members can delete repositories setting. """ business: Business @preview(toggledBy: "gwenpool-preview") """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ A message confirming the result of updating the members can delete repositories setting. """ message: String } """ Autogenerated input type of UpdateBusinessMembersCanInviteCollaboratorsSetting """ input UpdateBusinessMembersCanInviteCollaboratorsSettingInput { """ The ID of the business on which to set the members can invite collaborators setting. """ businessId: ID! @possibleTypes(concreteTypes: ["Business"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The value for the members can invite collaborators setting on the business. """ settingValue: BusinessEnabledDisabledSettingValue! } """ Autogenerated return type of UpdateBusinessMembersCanInviteCollaboratorsSetting """ type UpdateBusinessMembersCanInviteCollaboratorsSettingPayload { """ The business with the updated members can invite collaborators setting. """ business: Business @preview(toggledBy: "gwenpool-preview") """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ A message confirming the result of updating the members can invite collaborators setting. """ message: String } """ Autogenerated input type of UpdateBusinessMembersCanUpdateProtectedBranchesSetting """ input UpdateBusinessMembersCanUpdateProtectedBranchesSettingInput { """ The ID of the business on which to set the members can update protected branches setting. """ businessId: ID! @possibleTypes(concreteTypes: ["Business"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The value for the members can update protected branches setting on the business. """ settingValue: BusinessEnabledDisabledSettingValue! } """ Autogenerated return type of UpdateBusinessMembersCanUpdateProtectedBranchesSetting """ type UpdateBusinessMembersCanUpdateProtectedBranchesSettingPayload { """ The business with the updated members can update protected branches setting. """ business: Business @preview(toggledBy: "gwenpool-preview") """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ A message confirming the result of updating the members can update protected branches setting. """ message: String } """ Autogenerated input type of UpdateBusinessOrganizationProjectsSetting """ input UpdateBusinessOrganizationProjectsSettingInput { """ The ID of the business on which to set the organization projects setting. """ businessId: ID! @possibleTypes(concreteTypes: ["Business"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The value for the organization projects setting on the business. """ settingValue: BusinessEnabledDisabledSettingValue! } """ Autogenerated return type of UpdateBusinessOrganizationProjectsSetting """ type UpdateBusinessOrganizationProjectsSettingPayload { """ The business with the updated organization projects setting. """ business: Business @preview(toggledBy: "gwenpool-preview") """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ A message confirming the result of updating the organization projects setting. """ message: String } """ Autogenerated input type of UpdateBusinessProfile """ input UpdateBusinessProfileInput { """ The Business ID to update. """ businessId: ID! @possibleTypes(concreteTypes: ["Business"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The description of the business. """ description: String """ The location of the business """ location: String """ The name of business. """ name: String """ The URL of the business's website """ websiteUrl: String } """ Autogenerated return type of UpdateBusinessProfile """ type UpdateBusinessProfilePayload { """ The updated business. """ business: Business @preview(toggledBy: "gwenpool-preview") """ A unique identifier for the client performing the mutation. """ clientMutationId: String } """ Autogenerated input type of UpdateBusinessRepositoryProjectsSetting """ input UpdateBusinessRepositoryProjectsSettingInput { """ The ID of the business on which to set the repository projects setting. """ businessId: ID! @possibleTypes(concreteTypes: ["Business"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The value for the repository projects setting on the business. """ settingValue: BusinessEnabledDisabledSettingValue! } """ Autogenerated return type of UpdateBusinessRepositoryProjectsSetting """ type UpdateBusinessRepositoryProjectsSettingPayload { """ The business with the updated repository projects setting. """ business: Business @preview(toggledBy: "gwenpool-preview") """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ A message confirming the result of updating the repository projects setting. """ message: String } """ Autogenerated input type of UpdateBusinessTeamDiscussionsSetting """ input UpdateBusinessTeamDiscussionsSettingInput { """ The ID of the business on which to set the team discussions setting. """ businessId: ID! @possibleTypes(concreteTypes: ["Business"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The value for the team discussions setting on the business. """ settingValue: BusinessEnabledDisabledSettingValue! } """ Autogenerated return type of UpdateBusinessTeamDiscussionsSetting """ type UpdateBusinessTeamDiscussionsSettingPayload { """ The business with the updated team discussions setting. """ business: Business @preview(toggledBy: "gwenpool-preview") """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ A message confirming the result of updating the team discussions setting. """ message: String } """ Autogenerated input type of UpdateBusinessTwoFactorAuthenticationRequiredSetting """ input UpdateBusinessTwoFactorAuthenticationRequiredSettingInput { """ The ID of the business on which to set the two factor authentication required setting. """ businessId: ID! @possibleTypes(concreteTypes: ["Business"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The value for the two factor authentication required setting on the business. """ settingValue: BusinessEnabledSettingValue! } """ Autogenerated return type of UpdateBusinessTwoFactorAuthenticationRequiredSetting """ type UpdateBusinessTwoFactorAuthenticationRequiredSettingPayload { """ The business with the updated two factor authentication required setting. """ business: Business @preview(toggledBy: "gwenpool-preview") """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ A message confirming the result of updating the two factor authentication required setting. """ message: String } """ Autogenerated input type of UpdateCheckRun """ input UpdateCheckRunInput @preview(toggledBy: "antiope-preview") { """ Possible further actions the integrator can perform, which a user may trigger. """ actions: [CheckRunAction!] """ The node of the check. """ checkRunId: ID! @possibleTypes(concreteTypes: ["CheckRun"]) """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The time that the check run finished. """ completedAt: DateTime """ The final conclusion of the check. """ conclusion: CheckConclusionState """ The URL of the integrator's site that has the full details of the check. """ detailsUrl: URI """ A reference for the run on the integrator's system. """ externalId: String """ The name of the check. """ name: String """ Descriptive details about the run. """ output: CheckRunOutput """ The node ID of the repository. """ repositoryId: ID! @possibleTypes(concreteTypes: ["Repository"]) """ The time that the check run began. """ startedAt: DateTime """ The current status. """ status: RequestableCheckStatusState } """ Autogenerated return type of UpdateCheckRun """ type UpdateCheckRunPayload @preview(toggledBy: "antiope-preview") { """ The updated check run. """ checkRun: CheckRun """ A unique identifier for the client performing the mutation. """ clientMutationId: String } """ Autogenerated input type of UpdateCheckSuitePreferences """ input UpdateCheckSuitePreferencesInput @preview(toggledBy: "antiope-preview") { """ The check suite preferences to modify. """ autoTriggerPreferences: [CheckSuiteAutoTriggerPreference!]! """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The Node ID of the repository. """ repositoryId: ID! @possibleTypes(concreteTypes: ["Repository"]) } """ Autogenerated return type of UpdateCheckSuitePreferences """ type UpdateCheckSuitePreferencesPayload @preview(toggledBy: "antiope-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The updated repository. """ repository: Repository } """ Autogenerated input type of UpdateIssueComment """ input UpdateIssueCommentInput @preview(toggledBy: "starfire-preview") { """ The updated text of the comment. """ body: String! """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The ID of the IssueComment to modify. """ id: ID! @possibleTypes(concreteTypes: ["IssueComment"]) } """ Autogenerated return type of UpdateIssueComment """ type UpdateIssueCommentPayload @preview(toggledBy: "starfire-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The updated comment. """ issueComment: IssueComment } """ Autogenerated input type of UpdateIssue """ input UpdateIssueInput @preview(toggledBy: "starfire-preview") { """ An array of Node IDs of users for this issue. """ assigneeIds: [ID!] @possibleTypes(concreteTypes: ["User"]) """ The body for the issue description. """ body: String """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The ID of the Issue to modify. """ id: ID! @possibleTypes(concreteTypes: ["Issue"]) """ An array of Node IDs of labels for this issue. """ labelIds: [ID!] @possibleTypes(concreteTypes: ["Label"]) """ The Node ID of the milestone for this issue. """ milestoneId: ID @possibleTypes(concreteTypes: ["Milestone"]) """ An array of Node IDs for projects associated with this issue. """ projectIds: [ID!] """ The desired issue state. """ state: IssueState """ The title for the issue. """ title: String } """ Autogenerated return type of UpdateIssue """ type UpdateIssuePayload @preview(toggledBy: "starfire-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The issue. """ issue: Issue } """ Autogenerated input type of UpdateProjectCard """ input UpdateProjectCardInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ Whether or not the ProjectCard should be archived """ isArchived: Boolean """ The note of ProjectCard. """ note: String """ The ProjectCard ID to update. """ projectCardId: ID! @possibleTypes(concreteTypes: ["ProjectCard"]) } """ Autogenerated return type of UpdateProjectCard """ type UpdateProjectCardPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The updated ProjectCard. """ projectCard: ProjectCard } """ Autogenerated input type of UpdateProjectColumn """ input UpdateProjectColumnInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The name of project column. """ name: String! """ The ProjectColumn ID to update. """ projectColumnId: ID! @possibleTypes(concreteTypes: ["ProjectColumn"]) } """ Autogenerated return type of UpdateProjectColumn """ type UpdateProjectColumnPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The updated project column. """ projectColumn: ProjectColumn } """ Autogenerated input type of UpdateProject """ input UpdateProjectInput { """ The description of project. """ body: String """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The name of project. """ name: String """ The Project ID to update. """ projectId: ID! @possibleTypes(concreteTypes: ["Project"]) """ Whether the project is public or not. """ public: Boolean """ Whether the project is open or closed. """ state: ProjectState } """ Autogenerated return type of UpdateProject """ type UpdateProjectPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The updated project. """ project: Project } """ Autogenerated input type of UpdatePullRequest """ input UpdatePullRequestInput @preview(toggledBy: "ocelot-preview") { """ The name of the branch you want your changes pulled into. This should be an existing branch on the current repository. """ baseRefName: String """ The contents of the pull request. """ body: String """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ Indicates whether maintainers can modify the pull request. """ maintainerCanModify: Boolean """ The Node ID of the pull request. """ pullRequestId: ID! @possibleTypes(concreteTypes: ["PullRequest"]) """ The title of the pull request. """ title: String } """ Autogenerated return type of UpdatePullRequest """ type UpdatePullRequestPayload @preview(toggledBy: "ocelot-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The updated pull request. """ pullRequest: PullRequest } """ Autogenerated input type of UpdatePullRequestReviewComment """ input UpdatePullRequestReviewCommentInput { """ The text of the comment. """ body: String! """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The Node ID of the comment to modify. """ pullRequestReviewCommentId: ID! @possibleTypes(concreteTypes: ["PullRequestReviewComment"]) } """ Autogenerated return type of UpdatePullRequestReviewComment """ type UpdatePullRequestReviewCommentPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The updated comment. """ pullRequestReviewComment: PullRequestReviewComment } """ Autogenerated input type of UpdatePullRequestReview """ input UpdatePullRequestReviewInput { """ The contents of the pull request review body. """ body: String! """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The Node ID of the pull request review to modify. """ pullRequestReviewId: ID! @possibleTypes(concreteTypes: ["PullRequestReview"]) } """ Autogenerated return type of UpdatePullRequestReview """ type UpdatePullRequestReviewPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The updated pull request review. """ pullRequestReview: PullRequestReview } """ Autogenerated input type of UpdateSubscription """ input UpdateSubscriptionInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The new state of the subscription. """ state: SubscriptionState! """ The Node ID of the subscribable object to modify. """ subscribableId: ID! @possibleTypes(concreteTypes: ["Commit", "Issue", "PullRequest", "Repository", "Team", "TeamDiscussion"], abstractType: "Subscribable") } """ Autogenerated return type of UpdateSubscription """ type UpdateSubscriptionPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The input subscribable entity. """ subscribable: Subscribable } """ Autogenerated input type of UpdateTeamDiscussionComment """ input UpdateTeamDiscussionCommentInput @preview(toggledBy: "echo-preview") { """ The updated text of the comment. """ body: String! """ The current version of the body content. """ bodyVersion: String """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The ID of the comment to modify. """ id: ID! @possibleTypes(concreteTypes: ["TeamDiscussionComment"]) } """ Autogenerated return type of UpdateTeamDiscussionComment """ type UpdateTeamDiscussionCommentPayload @preview(toggledBy: "echo-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The updated comment. """ teamDiscussionComment: TeamDiscussionComment } """ Autogenerated input type of UpdateTeamDiscussion """ input UpdateTeamDiscussionInput @preview(toggledBy: "echo-preview") { """ The updated text of the discussion. """ body: String """ The current version of the body content. If provided, this update operation will be rejected if the given version does not match the latest version on the server. """ bodyVersion: String """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The Node ID of the discussion to modify. """ id: ID! @possibleTypes(concreteTypes: ["TeamDiscussion"]) """ If provided, sets the pinned state of the updated discussion. """ pinned: Boolean """ The updated title of the discussion. """ title: String } """ Autogenerated return type of UpdateTeamDiscussion """ type UpdateTeamDiscussionPayload @preview(toggledBy: "echo-preview") { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The updated discussion. """ teamDiscussion: TeamDiscussion } """ Autogenerated input type of UpdateTopics """ input UpdateTopicsInput { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ The Node ID of the repository. """ repositoryId: ID! @possibleTypes(concreteTypes: ["Repository"]) """ An array of topic names. """ topicNames: [String!]! } """ Autogenerated return type of UpdateTopics """ type UpdateTopicsPayload { """ A unique identifier for the client performing the mutation. """ clientMutationId: String """ Names of the provided topics that are not valid. """ invalidTopicNames: [String!] """ The updated repository. """ repository: Repository } """ A user is an individual's account on GitHub that owns repositories and can make new content. """ type User implements Actor & Node & RegistryPackageOwner & RegistryPackageSearch & RepositoryOwner & UniformResourceLocatable { """ A URL pointing to the user's public avatar. """ avatarUrl( """ The size of the resulting square image. """ size: Int ): URI! """ The user's public profile bio. """ bio: String """ The user's public profile bio as HTML. """ bioHTML: HTML! """ A list of commit comments made by this user. """ commitComments( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): CommitCommentConnection! """ The user's public profile company. """ company: String """ The user's public profile company as HTML. """ companyHTML: HTML! """ The collection of contributions this user has made to different repositories. """ contributionsCollection( """ Only contributions made at this time or later will be counted. If omitted, defaults to a year ago. """ from: DateTime """ The ID of the organization used to filter contributions. """ organizationID: ID """ Only contributions made before and up to and including this time will be counted. If omitted, defaults to the current time. """ to: DateTime ): ContributionsCollection! """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Identifies the primary key from the database. """ databaseId: Int """ The user's publicly visible profile email. """ email: String! """ A list of users the given user is followed by. """ followers( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): FollowerConnection! """ A list of users the given user is following. """ following( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): FollowingConnection! """ Find gist by repo name. """ gist( """ The gist name to find. """ name: String! ): Gist """ A list of gist comments made by this user. """ gistComments( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): GistCommentConnection! """ A list of the Gists the user has created. """ gists( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for gists returned from the connection """ orderBy: GistOrder """ Filters Gists according to privacy. """ privacy: GistPrivacy ): GistConnection! """ The hovercard information for this user in a given context """ hovercard( """ The ID of the subject to get the hovercard in the context of """ primarySubjectId: ID ): Hovercard! @preview(toggledBy: "hagar-preview") id: ID! """ Whether or not this user is a participant in the GitHub Security Bug Bounty. """ isBountyHunter: Boolean! """ Whether or not this user is a participant in the GitHub Campus Experts Program. """ isCampusExpert: Boolean! """ Whether or not this user is a GitHub Developer Program member. """ isDeveloperProgramMember: Boolean! """ Whether or not this user is a GitHub employee. """ isEmployee: Boolean! """ Whether or not the user has marked themselves as for hire. """ isHireable: Boolean! """ Whether or not this user is a site administrator. """ isSiteAdmin: Boolean! """ Whether or not this user is the viewing user. """ isViewer: Boolean! """ A list of issue comments made by this user. """ issueComments( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): IssueCommentConnection! """ A list of issues associated with this user. """ issues( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Filtering options for issues returned from the connection. """ filterBy: IssueFilters @preview(toggledBy: "starfire-preview") """ Returns the first _n_ elements from the list. """ first: Int """ A list of label names to filter the pull requests by. """ labels: [String!] """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for issues returned from the connection. """ orderBy: IssueOrder """ A list of states to filter the issues by. """ states: [IssueState!] ): IssueConnection! """ The user's public profile location. """ location: String """ The username used to login. """ login: String! """ The user's public profile name. """ name: String """ Find an organization by its login that the user belongs to. """ organization( """ The login of the organization to find. """ login: String! ): Organization """ A list of organizations the user belongs to. """ organizations( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): OrganizationConnection! """ A list of repositories this user has pinned to their profile """ pinnedRepositories( """ Array of viewer's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the current viewer owns. """ affiliations: [RepositoryAffiliation] = [OWNER, COLLABORATOR] """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ If non-null, filters repositories according to whether they have been locked """ isLocked: Boolean """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for repositories returned from the connection """ orderBy: RepositoryOrder """ Array of owner's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the organization or user being viewed owns. """ ownerAffiliations: [RepositoryAffiliation] = [OWNER, COLLABORATOR] """ If non-null, filters repositories according to privacy """ privacy: RepositoryPrivacy ): RepositoryConnection! """ A list of public keys associated with this user. """ publicKeys( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int ): PublicKeyConnection! """ A list of pull requests associated with this user. """ pullRequests( """ Returns the elements in the list that come after the specified cursor. """ after: String """ The base ref name to filter the pull requests by. """ baseRefName: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ The head ref name to filter the pull requests by. """ headRefName: String """ A list of label names to filter the pull requests by. """ labels: [String!] """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for pull requests returned from the connection. """ orderBy: IssueOrder """ A list of states to filter the pull requests by. """ states: [PullRequestState!] ): PullRequestConnection! """ A list of repositories that the user owns. """ repositories( """ Array of viewer's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the current viewer owns. """ affiliations: [RepositoryAffiliation] = [OWNER, COLLABORATOR] """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ If non-null, filters repositories according to whether they are forks of another repository """ isFork: Boolean """ If non-null, filters repositories according to whether they have been locked """ isLocked: Boolean """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for repositories returned from the connection """ orderBy: RepositoryOrder """ Array of owner's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the organization or user being viewed owns. """ ownerAffiliations: [RepositoryAffiliation] = [OWNER, COLLABORATOR] """ If non-null, filters repositories according to privacy """ privacy: RepositoryPrivacy ): RepositoryConnection! """ A list of repositories that the user recently contributed to. """ repositoriesContributedTo( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ If non-null, include only the specified types of contributions. The GitHub.com UI uses [COMMIT, ISSUE, PULL_REQUEST, REPOSITORY] """ contributionTypes: [RepositoryContributionType] """ Returns the first _n_ elements from the list. """ first: Int """ If true, include user repositories """ includeUserRepositories: Boolean """ If non-null, filters repositories according to whether they have been locked """ isLocked: Boolean """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for repositories returned from the connection """ orderBy: RepositoryOrder """ If non-null, filters repositories according to privacy """ privacy: RepositoryPrivacy ): RepositoryConnection! """ Find Repository. """ repository( """ Name of Repository to find. """ name: String! ): Repository """ The HTTP path for this user """ resourcePath: URI! """ Repositories the user has starred. """ starredRepositories( """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ Returns the last _n_ elements from the list. """ last: Int """ Order for connection """ orderBy: StarOrder """ Filters starred repositories to only return repositories owned by the viewer. """ ownedByViewer: Boolean ): StarredRepositoryConnection! """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! """ The HTTP URL for this user """ url: URI! """ Whether or not the viewer is able to follow the user. """ viewerCanFollow: Boolean! """ Whether or not this user is followed by the viewer. """ viewerIsFollowing: Boolean! """ A list of repositories the given user is watching. """ watching( """ Affiliation options for repositories returned from the connection """ affiliations: [RepositoryAffiliation] = [OWNER, COLLABORATOR, ORGANIZATION_MEMBER] """ Returns the elements in the list that come after the specified cursor. """ after: String """ Returns the elements in the list that come before the specified cursor. """ before: String """ Returns the first _n_ elements from the list. """ first: Int """ If non-null, filters repositories according to whether they have been locked """ isLocked: Boolean """ Returns the last _n_ elements from the list. """ last: Int """ Ordering options for repositories returned from the connection """ orderBy: RepositoryOrder """ Array of owner's affiliation options for repositories returned from the connection. For example, OWNER will include only repositories that the organization or user being viewed owns. """ ownerAffiliations: [RepositoryAffiliation] = [OWNER, COLLABORATOR] """ If non-null, filters repositories according to privacy """ privacy: RepositoryPrivacy ): RepositoryConnection! """ A URL pointing to the user's public website/blog. """ websiteUrl: URI } """ The connection type for User. """ type UserConnection { """ A list of edges. """ edges: [UserEdge] """ A list of nodes. """ nodes: [User] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edit on user content """ type UserContentEdit implements Node { """ Identifies the date and time when the object was created. """ createdAt: DateTime! """ Identifies the date and time when the object was deleted. """ deletedAt: DateTime """ The actor who deleted this content """ deletedBy: Actor """ A summary of the changes for this edit """ diff: String """ When this content was edited """ editedAt: DateTime! """ The actor who edited this content """ editor: Actor id: ID! """ Identifies the date and time when the object was last updated. """ updatedAt: DateTime! } """ A list of edits to content. """ type UserContentEditConnection { """ A list of edges. """ edges: [UserContentEditEdge] """ A list of nodes. """ nodes: [UserContentEdit] """ Information to aid in pagination. """ pageInfo: PageInfo! """ Identifies the total count of items in the connection. """ totalCount: Int! } """ An edge in a connection. """ type UserContentEditEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: UserContentEdit } """ Represents a user. """ type UserEdge { """ A cursor for use in pagination. """ cursor: String! """ The item at the end of the edge. """ node: User } """ A hovercard context with a message describing how the viewer is related. """ type ViewerHovercardContext implements HovercardContext @preview(toggledBy: "hagar-preview") { """ A string describing this context """ message: String! """ An octicon to accompany this context """ octicon: String! """ Identifies the user who is related to this context. """ viewer: User! } """ A valid x509 certificate string """ scalar X509Certificate ================================================ FILE: 4-api/4_swagger/docs/docs.go ================================================ // GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // This file was generated by swaggo/swag at // 2019-09-25 15:54:20.870705 +0300 MSK m=+0.021560440 package docs import ( "bytes" "encoding/json" "strings" "github.com/alecthomas/template" "github.com/swaggo/swag" ) var doc = `{ "schemes": {{ marshal .Schemes }}, "swagger": "2.0", "info": { "description": "{{.Description}}", "title": "{{.Title}}", "termsOfService": "http://swagger.io/terms/", "contact": { "name": "API Support", "url": "http://www.swagger.io/support", "email": "support@swagger.io" }, "license": { "name": "Apache 2.0", "url": "http://www.apache.org/licenses/LICENSE-2.0.html" }, "version": "{{.Version}}" }, "host": "{{.Host}}", "basePath": "{{.BasePath}}", "paths": { "/user/{id}": { "get": { "description": "get user by ID", "consumes": [ "application/json" ], "produces": [ "application/json" ], "summary": "Show a account", "operationId": "get-user-by-int", "parameters": [ { "type": "integer", "description": "User ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/model.User" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/model.Error" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/model.Error" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/main.myError" } } } } } }, "definitions": { "main.myError": { "type": "object", "properties": { "error": { "type": "string" }, "status": { "type": "integer" } } }, "model.Error": { "type": "object", "properties": { "message": { "type": "string" } } }, "model.User": { "type": "object", "properties": { "email": { "type": "string" }, "id": { "type": "integer" }, "name": { "type": "string" } } } } }` type swaggerInfo struct { Version string Host string BasePath string Schemes []string Title string Description string } // SwaggerInfo holds exported Swagger Info so clients can modify it var SwaggerInfo = swaggerInfo{ Version: "1.0", Host: "petstore.swagger.io", BasePath: "/api/v1", Schemes: []string{}, Title: "Sample Project API", Description: "This is a sample server Petstore server.", } type s struct{} func (s *s) ReadDoc() string { sInfo := SwaggerInfo sInfo.Description = strings.Replace(sInfo.Description, "\n", "\\n", -1) t, err := template.New("swagger_info").Funcs(template.FuncMap{ "marshal": func(v interface{}) string { a, _ := json.Marshal(v) return string(a) }, }).Parse(doc) if err != nil { return doc } var tpl bytes.Buffer if err := t.Execute(&tpl, sInfo); err != nil { return doc } return tpl.String() } func init() { swag.Register(swag.Name, &s{}) } ================================================ FILE: 4-api/4_swagger/docs/swagger/swagger.json ================================================ { "swagger": "2.0", "info": { "description": "This is a sample server Petstore server.", "title": "Sample Project API", "termsOfService": "http://swagger.io/terms/", "contact": { "name": "API Support", "url": "http://www.swagger.io/support", "email": "support@swagger.io" }, "license": { "name": "Apache 2.0", "url": "http://www.apache.org/licenses/LICENSE-2.0.html" }, "version": "1.0" }, "host": "petstore.swagger.io", "basePath": "/api/v1", "paths": { "/user/{id}": { "get": { "description": "get user by ID", "consumes": [ "application/json" ], "produces": [ "application/json" ], "summary": "Show a account", "operationId": "get-user-by-int", "parameters": [ { "type": "integer", "description": "User ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "type": "object", "$ref": "#/definitions/model.User" } }, "400": { "description": "Bad Request", "schema": { "type": "object", "$ref": "#/definitions/model.Error" } }, "404": { "description": "Not Found", "schema": { "type": "object", "$ref": "#/definitions/model.Error" } }, "500": { "description": "Internal Server Error", "schema": { "type": "object", "$ref": "#/definitions/model.Error" } } } } } }, "definitions": { "model.Error": { "type": "object", "properties": { "message": { "type": "string" } } }, "model.User": { "type": "object", "properties": { "email": { "type": "string" }, "id": { "type": "integer" }, "name": { "type": "string" } } } } } ================================================ FILE: 4-api/4_swagger/docs/swagger/swagger.yaml ================================================ basePath: /api/v1 definitions: model.Error: properties: message: type: string type: object model.User: properties: email: type: string id: type: integer name: type: string type: object host: petstore.swagger.io info: contact: email: support@swagger.io name: API Support url: http://www.swagger.io/support description: This is a sample server Petstore server. license: name: Apache 2.0 url: http://www.apache.org/licenses/LICENSE-2.0.html termsOfService: http://swagger.io/terms/ title: Sample Project API version: "1.0" paths: /user/{id}: get: consumes: - application/json description: get user by ID operationId: get-user-by-int parameters: - description: User ID in: path name: id required: true type: integer produces: - application/json responses: "200": description: OK schema: $ref: '#/definitions/model.User' type: object "400": description: Bad Request schema: $ref: '#/definitions/model.Error' type: object "404": description: Not Found schema: $ref: '#/definitions/model.Error' type: object "500": description: Internal Server Error schema: $ref: '#/definitions/model.Error' type: object summary: Show a account swagger: "2.0" ================================================ FILE: 4-api/4_swagger/docs/swagger.json ================================================ { "swagger": "2.0", "info": { "description": "This is a sample server Petstore server.", "title": "Sample Project API", "termsOfService": "http://swagger.io/terms/", "contact": { "name": "API Support", "url": "http://www.swagger.io/support", "email": "support@swagger.io" }, "license": { "name": "Apache 2.0", "url": "http://www.apache.org/licenses/LICENSE-2.0.html" }, "version": "1.0" }, "host": "petstore.swagger.io", "basePath": "/api/v1", "paths": { "/user/{id}": { "get": { "description": "get user by ID", "consumes": [ "application/json" ], "produces": [ "application/json" ], "summary": "Show a account", "operationId": "get-user-by-int", "parameters": [ { "type": "integer", "description": "User ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/model.User" } }, "400": { "description": "Bad Request", "schema": { "$ref": "#/definitions/model.Error" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/model.Error" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/main.myError" } } } } } }, "definitions": { "main.myError": { "type": "object", "properties": { "error": { "type": "string" }, "status": { "type": "integer" } } }, "model.Error": { "type": "object", "properties": { "message": { "type": "string" } } }, "model.User": { "type": "object", "properties": { "email": { "type": "string" }, "id": { "type": "integer" }, "name": { "type": "string" } } } } } ================================================ FILE: 4-api/4_swagger/docs/swagger.yaml ================================================ basePath: /api/v1 definitions: main.myError: properties: error: type: string status: type: integer type: object model.Error: properties: message: type: string type: object model.User: properties: email: type: string id: type: integer name: type: string type: object host: petstore.swagger.io info: contact: email: support@swagger.io name: API Support url: http://www.swagger.io/support description: This is a sample server Petstore server. license: name: Apache 2.0 url: http://www.apache.org/licenses/LICENSE-2.0.html termsOfService: http://swagger.io/terms/ title: Sample Project API version: "1.0" paths: /user/{id}: get: consumes: - application/json description: get user by ID operationId: get-user-by-int parameters: - description: User ID in: path name: id required: true type: integer produces: - application/json responses: "200": description: OK schema: $ref: '#/definitions/model.User' "400": description: Bad Request schema: $ref: '#/definitions/model.Error' "404": description: Not Found schema: $ref: '#/definitions/model.Error' "500": description: Internal Server Error schema: $ref: '#/definitions/main.myError' summary: Show a account swagger: "2.0" ================================================ FILE: 4-api/4_swagger/main.go ================================================ package main import ( "net/http" _ "github.com/go-park-mail-ru/lectures/4-api/4_swagger/docs" httpSwagger "github.com/swaggo/http-swagger" ) // swag init type myError struct { Status int Error string } // ShowAccount godoc // @Summary Show a account // @Description get user by ID // @ID get-user-by-int // @Accept json // @Produce json // @Param id path int true "User ID" // @Success 200 {object} model.User // @Failure 400 {object} model.Error // @Failure 404 {object} model.Error // @Failure 500 {object} myError // @Router /user/{id} [get] func handleUsers(w http.ResponseWriter, r *http.Request) { w.Write([]byte(`{"status": "ok"}`)) } // @title Sample Project API // @version 1.0 // @description This is a sample server Petstore server. // @termsOfService http://swagger.io/terms/ // @contact.name API Support // @contact.url http://www.swagger.io/support // @contact.email support@swagger.io // @license.name Apache 2.0 // @license.url http://www.apache.org/licenses/LICENSE-2.0.html // @host petstore.swagger.io // @BasePath /api/v1 func main() { http.HandleFunc("/docs/", httpSwagger.WrapHandler) http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("url: " + r.URL.String())) }) http.ListenAndServe(":8080", nil) } ================================================ FILE: 4-api/4_swagger/model/user.go ================================================ package model type User struct { ID int Name string Email string } type Error struct { Message string } ================================================ FILE: 4-api/5_sessions/main.go ================================================ package main import ( "math/rand" "net/http" "time" "github.com/gorilla/mux" ) type User struct { ID uint `json:"id"` Username string `json:"username"` Password string `json:"password"` } var ( letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") ) func RandStringRunes(n int) string { b := make([]rune, n) for i := range b { b[i] = letterRunes[rand.Intn(len(letterRunes))] } return string(b) } type MyHandler struct { sessions map[string]uint users map[string]*User } func NewMyHandler() *MyHandler { return &MyHandler{ sessions: make(map[string]uint, 10), users: map[string]*User{ "rvasily": {1, "rvasily", "love"}, }, } } // http://127.0.0.1:8080/login?login=rvsily&password=love func (api *MyHandler) Login(w http.ResponseWriter, r *http.Request) { user, ok := api.users[r.FormValue("login")] if !ok { http.Error(w, `no user`, 404) return } if user.Password != r.FormValue("password") { http.Error(w, `bad pass`, 400) return } SID := RandStringRunes(32) api.sessions[SID] = user.ID cookie := &http.Cookie{ Name: "session_id", Value: SID, Expires: time.Now().Add(10 * time.Hour), } http.SetCookie(w, cookie) w.Write([]byte(SID)) } func (api *MyHandler) Logout(w http.ResponseWriter, r *http.Request) { session, err := r.Cookie("session_id") if err == http.ErrNoCookie { http.Error(w, `no sess`, 401) return } if _, ok := api.sessions[session.Value]; !ok { http.Error(w, `no sess`, 401) return } delete(api.sessions, session.Value) session.Expires = time.Now().AddDate(0, 0, -1) http.SetCookie(w, session) } func (api *MyHandler) Root(w http.ResponseWriter, r *http.Request) { authorized := false session, err := r.Cookie("session_id") if err == nil && session != nil { _, authorized = api.sessions[session.Value] } if authorized { w.Write([]byte("autrorized")) } else { w.Write([]byte("not autrorized")) } } func main() { r := mux.NewRouter() api := NewMyHandler() r.HandleFunc("/", api.Root) r.HandleFunc("/login", api.Login) r.HandleFunc("/logout", api.Logout) http.ListenAndServe(":8080", r) } ================================================ FILE: 4-api/6_jwt/main.go ================================================ package main import ( "fmt" "net/http" jwt "github.com/dgrijalva/jwt-go" ) var SECRET = []byte("myawesomesecret") // http://127.0.0.1:8080/login?username=rvasily func main() { http.HandleFunc("/login", func(w http.ResponseWriter, r *http.Request) { // if r.Method != http.MethodPost { // w.WriteHeader(http.StatusBadRequest) // return // } token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{ "username": r.FormValue("username"), }) str, err := token.SignedString(SECRET) if err != nil { w.Write([]byte("=(" + err.Error())) return } cookie := &http.Cookie{ Name: "session_id", Value: str, } http.SetCookie(w, cookie) w.Write([]byte(str)) }) http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { cookie, err := r.Cookie("session_id") if err != nil { w.Write([]byte("=(")) return } token, err := jwt.Parse(cookie.Value, func(token *jwt.Token) (interface{}, error) { if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok { return nil, fmt.Errorf("Unexpected signing method: %v", token.Header["alg"]) } return SECRET, nil }) if claims, ok := token.Claims.(jwt.MapClaims); ok && token.Valid { w.Write([]byte("hello " + claims["username"].(string))) return } w.Write([]byte("not authorized")) fmt.Println(err) }) http.ListenAndServe(":8080", nil) } ================================================ FILE: 4-api/7_oauth/main.go ================================================ package main import ( "encoding/json" "fmt" "io/ioutil" "log" "net/http" "golang.org/x/oauth2" "golang.org/x/oauth2/vk" ) const ( APP_ID = "7065390" APP_KEY = "cQZe3Vvo4mHotmetUdXK" APP_SECRET = "1bbf49951bbf49951bbf49953b1bd486bb11bbf1bbf4995468b3d76e2cb2114610654e0" API_URL = "https://api.vk.com/method/users.get?fields=email,photo_50&access_token=%s&v=5.131" ) type Response struct { Response []struct { FirstName string `json:"first_name"` Photo string `json:"photo_50"` } } // https://oauth.vk.com/authorize?client_id=7065390&redirect_uri=http://localhost:8080/&response_type=code&scope=email func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { ctx := r.Context() code := r.FormValue("code") conf := oauth2.Config{ ClientID: APP_ID, ClientSecret: APP_KEY, RedirectURL: "http://localhost:8080/", Endpoint: vk.Endpoint, } token, err := conf.Exchange(ctx, code) if err != nil { log.Println("cannot exchange", err) w.Write([]byte("=(")) return } client := conf.Client(ctx, token) resp, err := client.Get(fmt.Sprintf(API_URL, token.AccessToken)) if err != nil { log.Println("cannot request data", err) w.Write([]byte("=(")) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { log.Println("cannot read buffer", err) w.Write([]byte("=(")) return } data := &Response{} json.Unmarshal(body, data) w.Write([]byte(`
` + data.Response[0].FirstName + `
`)) }) http.ListenAndServe(":8080", nil) } ================================================ FILE: 5-architecture/0_bad_example/api.go ================================================ package main import ( "encoding/json" "fmt" "io/ioutil" "log" "math/rand" "net/http" ) type User struct { Login string `json:"login"` Password string `json:"password"` } type TODO struct { Text string `json:"text"` } var ( userDB = map[string]User{ "predefined": { Login: "predefined", Password: "123", }, } sessionDB = map[string]string{ "predefined": "predefined", } todoDB = map[string][]TODO{ "predefined": {{Text: "first thing"}, {Text: "second thing"}}, } ) func genRequestID() string { return fmt.Sprintf("%016x", rand.Int())[:10] } func createUserHandler(w http.ResponseWriter, r *http.Request) { defer func() { if err := recover(); err != nil { log.Printf("panic during request: %s", err) w.WriteHeader(http.StatusInternalServerError) w.Write([]byte("internal error")) } }() requestID := genRequestID() log.Printf("incoming request [rid=%s] %s %q", requestID, r.Method, r.URL) switch r.Method { // curl 'http://127.0.0.1:8080/user' --cookie "session=78629a0f5f3f164f" case http.MethodGet: sessionCookie, err := r.Cookie("session") if err != nil { w.WriteHeader(http.StatusUnauthorized) w.Write([]byte("unauthorized")) return } username := sessionDB[sessionCookie.Value] user, ok := userDB[username] if !ok { panic("user not exists") } res, _ := json.Marshal(user) w.WriteHeader(http.StatusOK) w.Write(res) // curl 'http://127.0.0.1:8080/user' -X POST -v -d '{"login": "user", "password": "123"}' case http.MethodPost: body, err := ioutil.ReadAll(r.Body) if err != nil { panic("request body read failure") } var user User err = json.Unmarshal(body, &user) if err != nil { log.Printf("[rid=%s] unmarshal failure: %s", requestID, err) w.WriteHeader(http.StatusBadRequest) w.Write([]byte("bad body")) return } userDB[user.Login] = user sessionID := fmt.Sprintf("%016x", rand.Int()) sessionDB[sessionID] = user.Login http.SetCookie(w, &http.Cookie{ Name: "session", Value: sessionID, Path: "/", }) w.WriteHeader(200) default: w.WriteHeader(http.StatusNotFound) } } func allUsersHandler(w http.ResponseWriter, r *http.Request) { defer func() { if err := recover(); err != nil { log.Printf("panic during request: %s", err) w.WriteHeader(http.StatusInternalServerError) w.Write([]byte("internal error")) } }() requestID := genRequestID() log.Printf("incoming request [rid=%s] %s %q", requestID, r.Method, r.URL) switch r.Method { case http.MethodGet: response, err := json.Marshal(userDB) if err != nil { panic(err) } w.WriteHeader(200) w.Write(response) default: w.WriteHeader(http.StatusNotFound) } } func todoHandler(w http.ResponseWriter, r *http.Request) { defer func() { if err := recover(); err != nil { log.Printf("panic during request: %s", err) w.WriteHeader(http.StatusInternalServerError) w.Write([]byte("internal error")) } }() requestID := genRequestID() log.Printf("incoming request [rid=%s] %s %q", requestID, r.Method, r.URL) sessionCookie, err := r.Cookie("session") if err != nil { w.WriteHeader(http.StatusUnauthorized) w.Write([]byte("unauthorized")) return } username := sessionDB[sessionCookie.Value] switch r.Method { case http.MethodGet: todos, _ := json.Marshal(todoDB[username]) w.WriteHeader(http.StatusOK) w.Write(todos) case http.MethodPost: body, err := ioutil.ReadAll(r.Body) if err != nil { panic("request body read failure") } var todo TODO json.Unmarshal(body, &todo) todoDB[username] = append(todoDB[username], todo) w.WriteHeader(200) w.Write([]byte("ok")) default: w.WriteHeader(404) w.Write([]byte("not exists")) } } func main() { userMux := http.NewServeMux() userMux.HandleFunc("/user", createUserHandler) userMux.HandleFunc("/users", allUsersHandler) userMux.HandleFunc("/todo", todoHandler) log.Println("listening on 127.0.0.1:8080") log.Fatal(http.ListenAndServe("127.0.0.1:8080", userMux)) } ================================================ FILE: 5-architecture/10_crudapp/cmd/crudapp/main.go ================================================ package main import ( "html/template" "net/http" "crudapp/internal/crudapp/middleware" items_delivery "crudapp/internal/pkg/items/delivery" items_repo "crudapp/internal/pkg/items/repository" "crudapp/internal/pkg/session" user_delivery "crudapp/internal/pkg/user/delivery" user_repo "crudapp/internal/pkg/user/repository" "github.com/gorilla/mux" "go.uber.org/zap" ) func main() { templates := template.Must(template.ParseGlob("./templates/*")) sm := session.NewSessionsMem() zapLogger, _ := zap.NewProduction() defer zapLogger.Sync() // flushes buffer, if any logger := zapLogger.Sugar() userRepo := user_repo.NewUserRepo() itemsRepo := items_repo.NewRepo() userHandler := &user_delivery.UserHandler{ Tmpl: templates, UserRepo: userRepo, Logger: logger, Sessions: sm, } handlers := &items_delivery.ItemsHandler{ Tmpl: templates, Logger: logger, ItemsRepo: itemsRepo, } r := mux.NewRouter() r.HandleFunc("/", userHandler.Index).Methods("GET") r.HandleFunc("/login", userHandler.Login).Methods("POST") r.HandleFunc("/logout", userHandler.Logout).Methods("POST") r.HandleFunc("/items", handlers.List).Methods("GET") r.HandleFunc("/items/new", handlers.AddForm).Methods("GET") r.HandleFunc("/items/new", handlers.Add).Methods("POST") r.HandleFunc("/items/{id}", handlers.Edit).Methods("GET") r.HandleFunc("/items/{id}", handlers.Update).Methods("POST") r.HandleFunc("/items/{id}", handlers.Delete).Methods("DELETE") mux := middleware.Auth(sm, r) mux = middleware.AccessLog(logger, mux) mux = middleware.Panic(mux) addr := ":8080" logger.Infow("starting server", "type", "START", "addr", addr, ) http.ListenAndServe(addr, mux) } ================================================ FILE: 5-architecture/10_crudapp/file_tree.txt ================================================ ? tree . ├── bin crudapp_auth crudapp ├── cmd │ └── crudapp │ └── main.go ├── go.mod ├── go.sum ├── pkg │ ├── handlers │ │ ├── items.go │ │ └── user.go │ ├── items │ │ ├── item.go │ │ └── repo.go │ ├── middleware │ │ ├── accesslog.go │ │ ├── auth.go │ │ └── panic.go │ ├── session │ │ ├── manager.go │ │ └── session.go │ └── user │ ├── user.go │ └── repo.go ├── readme.md └── templates ├── create.html ├── edit.html ├── index.html └── login.html 10 directories, 18 files ================================================ FILE: 5-architecture/10_crudapp/go.mod ================================================ module crudapp go 1.13 require ( github.com/golang/mock v1.4.4 github.com/gorilla/mux v1.7.3 github.com/gorilla/schema v1.1.0 github.com/stretchr/testify v1.4.0 go.uber.org/zap v1.12.0 ) ================================================ FILE: 5-architecture/10_crudapp/go.sum ================================================ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/schema v1.1.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.12.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= ================================================ FILE: 5-architecture/10_crudapp/internal/crudapp/middleware/accesslog.go ================================================ package middleware import ( "fmt" "net/http" "time" "go.uber.org/zap" ) func AccessLog(logger *zap.SugaredLogger, next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Println("access log middleware") start := time.Now() next.ServeHTTP(w, r) logger.Infow("New request", "method", r.Method, "remote_addr", r.RemoteAddr, "url", r.URL.Path, "time", time.Since(start), ) }) } ================================================ FILE: 5-architecture/10_crudapp/internal/crudapp/middleware/auth.go ================================================ package middleware import ( "context" "fmt" "net/http" "crudapp/internal/pkg/models" "crudapp/internal/pkg/session" ) var ( noAuthUrls = map[string]struct{}{ "/login": struct{}{}, } noSessUrls = map[string]struct{}{ "/": struct{}{}, } ) func Auth(sm *session.SessionsManager, next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Println("auth middleware") if _, ok := noAuthUrls[r.URL.Path]; ok { next.ServeHTTP(w, r) return } sess, err := sm.Check(r) _, canbeWithouthSess := noSessUrls[r.URL.Path] if err != nil && !canbeWithouthSess { fmt.Println("no auth") http.Redirect(w, r, "/", 302) return } ctx := context.WithValue(r.Context(), models.SessionKey, sess) next.ServeHTTP(w, r.WithContext(ctx)) }) } ================================================ FILE: 5-architecture/10_crudapp/internal/crudapp/middleware/panic.go ================================================ package middleware import ( "fmt" "net/http" ) func Panic(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Println("panicMiddleware", r.URL.Path) defer func() { if err := recover(); err != nil { fmt.Println("recovered", err) http.Error(w, "Internal server error", 500) } }() next.ServeHTTP(w, r) }) } ================================================ FILE: 5-architecture/10_crudapp/internal/pkg/items/delivery/items.go ================================================ package delivery import ( "crudapp/internal/pkg/items" "encoding/json" "html/template" "net/http" "strconv" "crudapp/internal/pkg/models" "github.com/gorilla/mux" "github.com/gorilla/schema" "go.uber.org/zap" ) type ItemsHandler struct { Tmpl *template.Template ItemsRepo items.Repository Logger *zap.SugaredLogger } func (h *ItemsHandler) List(w http.ResponseWriter, r *http.Request) { elems, err := h.ItemsRepo.GetAll() if err != nil { http.Error(w, `DB err`, http.StatusInternalServerError) return } err = h.Tmpl.ExecuteTemplate(w, "index.html", struct { Items []*models.Item }{ Items: elems, }) if err != nil { http.Error(w, `Template errror`, http.StatusInternalServerError) return } } func (h *ItemsHandler) AddForm(w http.ResponseWriter, r *http.Request) { err := h.Tmpl.ExecuteTemplate(w, "create.html", nil) if err != nil { http.Error(w, `Template errror`, http.StatusInternalServerError) return } } func (h *ItemsHandler) Add(w http.ResponseWriter, r *http.Request) { r.ParseForm() item := new(models.Item) decoder := schema.NewDecoder() decoder.IgnoreUnknownKeys(true) err := decoder.Decode(item, r.PostForm) if err != nil { http.Error(w, `Bad form`, http.StatusBadRequest) return } sess, _ := models.SessionFromContext(r.Context()) item.CreatedBy = sess.UserID lastID, err := h.ItemsRepo.Add(item) if err != nil { http.Error(w, `DB err`, http.StatusInternalServerError) return } h.Logger.Infof("Insert with id LastInsertId: %v", lastID) http.Redirect(w, r, "/", http.StatusFound) } func (h *ItemsHandler) Edit(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) id, err := strconv.Atoi(vars["id"]) if err != nil { http.Error(w, `{"error": "bad id"}`, http.StatusBadGateway) return } item, err := h.ItemsRepo.GetByID(uint32(id)) if err != nil { http.Error(w, `DB err`, http.StatusInternalServerError) return } if item == nil { http.Error(w, `no item`, http.StatusNotFound) return } err = h.Tmpl.ExecuteTemplate(w, "edit.html", item) if err != nil { http.Error(w, `Template errror`, http.StatusInternalServerError) return } } func (h *ItemsHandler) Update(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) id, err := strconv.Atoi(vars["id"]) if err != nil { http.Error(w, `Bad id`, http.StatusBadRequest) return } r.ParseForm() item := new(models.Item) decoder := schema.NewDecoder() decoder.IgnoreUnknownKeys(true) err = decoder.Decode(item, r.PostForm) if err != nil { http.Error(w, `Bad form`, http.StatusBadRequest) return } item.ID = uint32(id) ok, err := h.ItemsRepo.Update(item) if err != nil { http.Error(w, `db error`, http.StatusInternalServerError) return } h.Logger.Infof("update: %v %v", item, ok) http.Redirect(w, r, "/", http.StatusFound) } func (h *ItemsHandler) Delete(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) id, err := strconv.Atoi(vars["id"]) if err != nil { http.Error(w, `{"error": "bad id"}`, http.StatusBadGateway) return } ok, err := h.ItemsRepo.Delete(uint32(id)) if err != nil { http.Error(w, `{"error": "db error"}`, http.StatusInternalServerError) return } w.Header().Set("Content-type", "application/json") respJSON, _ := json.Marshal(map[string]bool{ "success": ok, }) w.Write(respJSON) } ================================================ FILE: 5-architecture/10_crudapp/internal/pkg/items/items.go ================================================ package items import "crudapp/internal/pkg/models" type Repository interface { GetAll() ([]*models.Item, error) GetByID(id uint32) (*models.Item, error) Add(item *models.Item) (uint32, error) Update(newItem *models.Item) (bool, error) Delete(id uint32) (bool, error) } ================================================ FILE: 5-architecture/10_crudapp/internal/pkg/items/repository/repo.go ================================================ package repository import "crudapp/internal/pkg/models" // WARNING! completly unsafe in multi-goroutine use, need add mutexes type itemsRepo struct { lastID uint32 data []*models.Item } func NewRepo() *itemsRepo { return &itemsRepo{ data: make([]*models.Item, 0, 10), } } func (repo *itemsRepo) GetAll() ([]*models.Item, error) { return repo.data, nil } func (repo *itemsRepo) GetByID(id uint32) (*models.Item, error) { for _, item := range repo.data { if item.ID == id { return item, nil } } return nil, nil } func (repo *itemsRepo) Add(item *models.Item) (uint32, error) { repo.lastID++ item.ID = repo.lastID repo.data = append(repo.data, item) return repo.lastID, nil } func (repo *itemsRepo) Update(newItem *models.Item) (bool, error) { for _, item := range repo.data { if item.ID != newItem.ID { continue } item.Title = newItem.Title item.Description = newItem.Description return true, nil } return false, nil } func (repo *itemsRepo) Delete(id uint32) (bool, error) { i := -1 for idx, item := range repo.data { if item.ID != id { continue } i = idx } if i < 0 { return false, nil } if i < len(repo.data)-1 { copy(repo.data[i:], repo.data[i+1:]) } repo.data[len(repo.data)-1] = nil // or the zero value of T repo.data = repo.data[:len(repo.data)-1] return true, nil } ================================================ FILE: 5-architecture/10_crudapp/internal/pkg/models/item.go ================================================ package models type Item struct { ID uint32 `schema:"-"` Title string `schema:"title,required"` Description string `schema:"description,required"` CreatedBy uint32 `schema:"-"` } ================================================ FILE: 5-architecture/10_crudapp/internal/pkg/models/session.go ================================================ package models import ( "context" "crypto/rand" "errors" "fmt" ) type Session struct { ID string UserID uint32 } func NewSession(userID uint32) *Session { // лучше генерировать из заданного алфавита, но так писать меньше и для учебного примера ОК randID := make([]byte, 16) rand.Read(randID) return &Session{ ID: fmt.Sprintf("%x", randID), UserID: userID, } } var ( ErrNoAuth = errors.New("No session found") ) type sessKey string var SessionKey sessKey = "sessionKey" func SessionFromContext(ctx context.Context) (*Session, error) { sess, ok := ctx.Value(SessionKey).(*Session) if !ok || sess == nil { return nil, ErrNoAuth } return sess, nil } ================================================ FILE: 5-architecture/10_crudapp/internal/pkg/models/user.go ================================================ package models import "errors" type User struct { ID uint32 Login string Password string } var ( ErrNoUser = errors.New("no user found") ErrBadPass = errors.New("invalid password") ) ================================================ FILE: 5-architecture/10_crudapp/internal/pkg/session/manager.go ================================================ package session import ( "crudapp/internal/pkg/models" "net/http" "sync" "time" ) type SessionsManager struct { data map[string]*models.Session mu *sync.RWMutex } func NewSessionsMem() *SessionsManager { return &SessionsManager{ data: make(map[string]*models.Session, 10), mu: &sync.RWMutex{}, } } func (sm *SessionsManager) Check(r *http.Request) (*models.Session, error) { sessionCookie, err := r.Cookie("session_id") if err == http.ErrNoCookie { return nil, models.ErrNoAuth } sm.mu.RLock() sess, ok := sm.data[sessionCookie.Value] sm.mu.RUnlock() if !ok { return nil, models.ErrNoAuth } return sess, nil } func (sm *SessionsManager) Create(w http.ResponseWriter, userID uint32) (*models.Session, error) { sess := models.NewSession(userID) sm.mu.Lock() sm.data[sess.ID] = sess sm.mu.Unlock() cookie := &http.Cookie{ Name: "session_id", Value: sess.ID, Expires: time.Now().Add(90 * 24 * time.Hour), Path: "/", } http.SetCookie(w, cookie) return sess, nil } func (sm *SessionsManager) DestroyCurrent(w http.ResponseWriter, r *http.Request) error { sess, err := models.SessionFromContext(r.Context()) if err != nil { return err } sm.mu.Lock() delete(sm.data, sess.ID) sm.mu.Unlock() cookie := http.Cookie{ Name: "session_id", Expires: time.Now().AddDate(0, 0, -1), Path: "/", } http.SetCookie(w, &cookie) return nil } ================================================ FILE: 5-architecture/10_crudapp/internal/pkg/user/delivery/user.go ================================================ package delivery import ( "crudapp/internal/pkg/models" "crudapp/internal/pkg/user" "errors" "html/template" "net/http" "crudapp/internal/pkg/session" "go.uber.org/zap" ) type UserHandler struct { Tmpl *template.Template Logger *zap.SugaredLogger UserRepo user.Repository Sessions *session.SessionsManager } func (h *UserHandler) Index(w http.ResponseWriter, r *http.Request) { _, err := models.SessionFromContext(r.Context()) if err == nil { http.Redirect(w, r, "/items", 302) return } err = h.Tmpl.ExecuteTemplate(w, "login.html", nil) if err != nil { http.Error(w, `Template errror`, http.StatusInternalServerError) return } } func (h *UserHandler) Login(w http.ResponseWriter, r *http.Request) { u, err := h.UserRepo.Authorize(r.FormValue("login"), r.FormValue("password")) if err == models.ErrNoUser { http.Error(w, `no user`, http.StatusBadRequest) return } if err == models.ErrBadPass { http.Error(w, `bad pass`, http.StatusBadRequest) return } sess, _ := h.Sessions.Create(w, u.ID) h.Logger.Infof("created session for %v", sess.UserID) http.Redirect(w, r, "/", 302) } func (h *UserHandler) Logout(w http.ResponseWriter, r *http.Request) { h.Sessions.DestroyCurrent(w, r) http.Redirect(w, r, "/", 302) } func (h *UserHandler) GetUserByID(login string) (*models.User, error) { if login == "" { return nil, errors.New("login is empty") } return h.UserRepo.GetByLogin(login) } ================================================ FILE: 5-architecture/10_crudapp/internal/pkg/user/delivery/user_test.go ================================================ package delivery import ( "crudapp/internal/pkg/models" "crudapp/internal/pkg/user/mock" "testing" "github.com/stretchr/testify/require" "github.com/golang/mock/gomock" ) func TestGetByID(t *testing.T) { login := "somelogin" retModel := &models.User{ ID: 0, Login: login, Password: "password", } ctrl := gomock.NewController(t) defer ctrl.Finish() mock := mock.NewMockRepository(ctrl) mock.EXPECT().GetByLogin(login).Times(1).Return(retModel, nil) uh := UserHandler{ UserRepo: mock, } models, err := uh.GetUserByID(login) require.NoError(t, err) require.Equal(t, models, retModel) } ================================================ FILE: 5-architecture/10_crudapp/internal/pkg/user/mock/mock_repo.go ================================================ // Code generated by MockGen. DO NOT EDIT. // Source: crudapp/internal/pkg/user (interfaces: Repository) // Package mock is a generated GoMock package. package mock import ( models "crudapp/internal/pkg/models" gomock "github.com/golang/mock/gomock" reflect "reflect" ) // MockRepository is a mock of Repository interface type MockRepository struct { ctrl *gomock.Controller recorder *MockRepositoryMockRecorder } // MockRepositoryMockRecorder is the mock recorder for MockRepository type MockRepositoryMockRecorder struct { mock *MockRepository } // NewMockRepository creates a new mock instance func NewMockRepository(ctrl *gomock.Controller) *MockRepository { mock := &MockRepository{ctrl: ctrl} mock.recorder = &MockRepositoryMockRecorder{mock} return mock } // EXPECT returns an object that allows the caller to indicate expected use func (m *MockRepository) EXPECT() *MockRepositoryMockRecorder { return m.recorder } // Authorize mocks base method func (m *MockRepository) Authorize(arg0, arg1 string) (*models.User, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Authorize", arg0, arg1) ret0, _ := ret[0].(*models.User) ret1, _ := ret[1].(error) return ret0, ret1 } // Authorize indicates an expected call of Authorize func (mr *MockRepositoryMockRecorder) Authorize(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Authorize", reflect.TypeOf((*MockRepository)(nil).Authorize), arg0, arg1) } // GetByLogin mocks base method func (m *MockRepository) GetByLogin(arg0 string) (*models.User, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetByLogin", arg0) ret0, _ := ret[0].(*models.User) ret1, _ := ret[1].(error) return ret0, ret1 } // GetByLogin indicates an expected call of GetByLogin func (mr *MockRepositoryMockRecorder) GetByLogin(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByLogin", reflect.TypeOf((*MockRepository)(nil).GetByLogin), arg0) } ================================================ FILE: 5-architecture/10_crudapp/internal/pkg/user/repository/user.go ================================================ package repository import ( "crudapp/internal/pkg/models" ) type UserRepo struct { data map[string]*models.User } func NewUserRepo() *UserRepo { return &UserRepo{ data: map[string]*models.User{ "rvasily": { ID: 1, Login: "rvasily", Password: "love", }, }, } } func (repo *UserRepo) Authorize(login, pass string) (*models.User, error) { u, ok := repo.data[login] if !ok { return nil, models.ErrNoUser } // dont do this un production :) if u.Password != pass { return nil, models.ErrBadPass } return u, nil } ================================================ FILE: 5-architecture/10_crudapp/internal/pkg/user/user.go ================================================ package user import "crudapp/internal/pkg/models" //go:generate mockgen -destination=./mock/mock_repo.go -package=mock crudapp/internal/pkg/user Repository type Repository interface { GetByLogin(login string) (*models.User, error) Authorize(login, pass string) (*models.User, error) } ================================================ FILE: 5-architecture/10_crudapp/readme.md ================================================ ``` bash go mod init crudapp # go mod init github.com/rvasily/crudapp go build go mod download go mod verify go mod tidy go build -o ./bin/crudapp ./cmd/crudapp go test -v -coverpkg=./... ./... go mod vendor go build -mod=vendor -o ./bin/myapp ./cmd/myapp go test -v -mod=vendor -coverpkg=./... ./... ``` ================================================ FILE: 5-architecture/10_crudapp/templates/create.html ================================================

Edit item

================================================ FILE: 5-architecture/10_crudapp/templates/edit.html ================================================

Edit item

================================================ FILE: 5-architecture/10_crudapp/templates/index.html ================================================

Posts

{{range .Items}} {{end}} ================================================ FILE: 5-architecture/10_crudapp/templates/login.html ================================================

CrudAPP login

================================================ FILE: 5-architecture/1_routers/0_httprouter/0_httprouter.go ================================================ package main import ( "fmt" "log" "net/http" "github.com/julienschmidt/httprouter" ) func List(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { fmt.Fprint(w, "You see user list\n") } func Get(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { fmt.Fprintf(w, "you try to see user %s\n", ps.ByName("id")) } /* curl -v -X PUT -H "Content-Type: application/json" -d '{"login":"rvasily"}' http://localhost:8080/users */ func Create(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { fmt.Fprintf(w, "you try to create new user\n") } /* curl -v -X POST -H "Content-Type: application/json" -d '{"name":"Vasily Romanov"}' http://localhost:8080/users/rvasily */ func Update(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { fmt.Fprintf(w, "you try to update %s\n", ps.ByName("login")) } func main() { router := httprouter.New() router.GET("/", List) router.GET("/users", List) router.PUT("/users", Create) router.GET("/users/:id", Get) router.POST("/users/:login", Update) fmt.Println("starting server at :8080") log.Fatal(http.ListenAndServe(":8080", router)) } ================================================ FILE: 5-architecture/1_routers/1_fasthttp/1_fasthttp.go ================================================ package main import ( "encoding/json" "fmt" "log" "github.com/buaazp/fasthttprouter" "github.com/valyala/fasthttp" ) func Index(ctx *fasthttp.RequestCtx) { ctx.SetContentType("application/json") ctx.SetStatusCode(fasthttp.StatusOK) users := []string{"rvasily"} body, _ := json.Marshal(users) ctx.SetBody(body) } func GetUser(ctx *fasthttp.RequestCtx) { fmt.Fprintf(ctx, "you try to see user %s\n", ctx.UserValue("id")) } func main() { router := fasthttprouter.New() router.GET("/", Index) // /users/123 router.GET("/users/:id", GetUser) fmt.Println("starting server at :8080") log.Fatal(fasthttp.ListenAndServe(":8080", router.Handler)) } ================================================ FILE: 5-architecture/1_routers/2_gorilla/2_gorilla.go ================================================ package main import ( "fmt" "log" "net/http" "github.com/gorilla/mux" ) func List(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "You see user list\n") } func Get(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) fmt.Fprintf(w, "you try to see user %s\n", vars["id"]) } /* curl -v -X PUT -H "Content-Type: application/json" -d '{"login":"rvasily"}' http://localhost:8080/users */ func Create(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "you try to create new user\n") } /* curl -v -X POST -H "Content-Type: application/json" -H "X-Auth: test" -d '{"name":"Vasily Romanov"}' http://localhost:8080/users/rvasily */ func Update(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) fmt.Fprintf(w, "you try to update %s\n", vars["login"]) } func main() { r := mux.NewRouter() r.HandleFunc("/", List) r.HandleFunc("/users", List). Host("localhost") r.HandleFunc("/users", Update). Methods("PUT") r.HandleFunc("/users/{id:[0-9]+}", Get) r.HandleFunc("/users/{login}", Create). Methods("POST"). Headers("X-Auth", "test") fmt.Println("starting server at :8080") log.Fatal(http.ListenAndServe(":8080", r)) } ================================================ FILE: 5-architecture/1_routers/3_multiple/3_multiple.go ================================================ package main import ( "fmt" "log" "net/http" "github.com/gorilla/mux" "github.com/julienschmidt/httprouter" ) func RegularRequest(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "Request with averange amout of logic\n") } func FastRequest(w http.ResponseWriter, r *http.Request, params httprouter.Params) { fmt.Fprint(w, "Request with high hitrate\n") } func ComplexRequest(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "Request with complex routing logic\n") } func main() { fastApiHandler := httprouter.New() fastApiHandler.GET("/fast/:id", FastRequest) complexApiHandler := mux.NewRouter() complexApiHandler.HandleFunc("/complex/", ComplexRequest). Headers("X-Requested-With", "XMLHttpRequest") // ajax stdApiHandler := http.NewServeMux() stdApiHandler.HandleFunc("/std/", RegularRequest) siteMux := http.NewServeMux() siteMux.Handle("/fast/", fastApiHandler) siteMux.Handle("/complex/", complexApiHandler) siteMux.Handle("/std/", stdApiHandler) fmt.Println("starting server at :8080") log.Fatal(http.ListenAndServe(":8080", siteMux)) } ================================================ FILE: 5-architecture/2_middleware/1_middleware/1_middleware.go ================================================ package main import ( "fmt" "net/http" "time" ) func mainPage(w http.ResponseWriter, r *http.Request) { session, err := r.Cookie("session_id") // учебный пример! это не проверка авторизации! loggedIn := (err != http.ErrNoCookie) if loggedIn { fmt.Fprintln(w, `logout`) fmt.Fprintln(w, "Welcome, "+session.Value) } else { fmt.Fprintln(w, `login`) fmt.Fprintln(w, "You need to login") } } func loginPage(w http.ResponseWriter, r *http.Request) { expiration := time.Now().Add(10 * time.Hour) cookie := http.Cookie{ Name: "session_id", Value: "Dmitry", Expires: expiration, } http.SetCookie(w, &cookie) http.Redirect(w, r, "/", http.StatusFound) } func logoutPage(w http.ResponseWriter, r *http.Request) { session, err := r.Cookie("session_id") if err == http.ErrNoCookie { http.Redirect(w, r, "/", http.StatusFound) return } session.Expires = time.Now().AddDate(0, 0, -1) http.SetCookie(w, session) http.Redirect(w, r, "/", http.StatusFound) } // ----------- func adminIndex(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, `site index`) fmt.Fprintln(w, "Admin main page") } func panicPage(w http.ResponseWriter, r *http.Request) { panic("this must me recovered") } // ----------- func pageWithAllChecks(w http.ResponseWriter, r *http.Request) { defer func() { if err := recover(); err != nil { fmt.Println("recovered", err) http.Error(w, "Internal server error", 500) } }() defer func(start time.Time) { fmt.Printf("[%s] %s, %s %s\n", r.Method, r.RemoteAddr, r.URL.Path, time.Since(start)) }(time.Now()) _, err := r.Cookie("session_id") // учебный пример! это не проверка авторизации! if err != nil { fmt.Println("no auth at", r.URL.Path) http.Redirect(w, r, "/", http.StatusFound) return } // your logic } // ----------- func adminAuthMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Println("adminAuthMiddleware", r.URL.Path) _, err := r.Cookie("session_id") // учебный пример! это не проверка авторизации! if err != nil { fmt.Println("no auth at", r.URL.Path) http.Redirect(w, r, "/", http.StatusFound) return } next.ServeHTTP(w, r) }) } func accessLogMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Println("accessLogMiddleware", r.URL.Path) start := time.Now() next.ServeHTTP(w, r) fmt.Printf("[%s] %s, %s %s\n", r.Method, r.RemoteAddr, r.URL.Path, time.Since(start)) }) } func panicMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Println("panicMiddleware", r.URL.Path) defer func() { if err := recover(); err != nil { fmt.Println("recovered", err) http.Error(w, "Internal server error", 500) } }() next.ServeHTTP(w, r) }) } // ----------- func main() { adminMux := http.NewServeMux() adminMux.HandleFunc("/admin/", adminIndex) adminMux.HandleFunc("/admin/panic", panicPage) // set middleware adminHandler := adminAuthMiddleware(adminMux) siteMux := http.NewServeMux() siteMux.Handle("/admin/", adminHandler) siteMux.HandleFunc("/login", loginPage) siteMux.HandleFunc("/logout", logoutPage) siteMux.HandleFunc("/", mainPage) // set middleware siteHandler := accessLogMiddleware(siteMux) siteHandler = panicMiddleware(siteHandler) fmt.Println("starting server at http://127.0.0.1:8080") http.ListenAndServe(":8080", siteHandler) } ================================================ FILE: 5-architecture/2_middleware/2_context_value/2_context_value.go ================================================ package main import ( "bytes" "context" "fmt" "math/rand" "net/http" "sync" "time" ) // сколько в среднем спим при эмуляции работы const AvgSleep = 50 func trackContextTimings(ctx context.Context, metricName string, start time.Time) { // получаем тайминги из контекста // поскольку там пустой интерфейс, то нам надо преобразовать к нужному типу timings, ok := ctx.Value(timingsKey).(*ctxTimings) if !ok { return } elapsed := time.Since(start) // лочимся на случай конкурентной записи в мапку timings.Lock() defer timings.Unlock() // если меткри ещё нет - мы её создадим, если есть - допишем в существующую if metric, metricExist := timings.Data[metricName]; !metricExist { timings.Data[metricName] = &Timing{ Count: 1, Duration: elapsed, } } else { metric.Count++ metric.Duration += elapsed } } type Timing struct { Count int Duration time.Duration } type ctxTimings struct { sync.Mutex Data map[string]*Timing } // линтер ругается если используем базовые типы в Value контекста // типа так безопаснее разграничивать type key int const timingsKey key = 1 func logContextTimings(ctx context.Context, path string, start time.Time) { // получаем тайминги из контекста // поскольку там пустой интерфейс, то нам надо преобразовать к нужному типу timings, ok := ctx.Value(timingsKey).(*ctxTimings) if !ok { return } totalReal := time.Since(start) buf := bytes.NewBufferString(path) var total time.Duration for timing, value := range timings.Data { total += value.Duration buf.WriteString(fmt.Sprintf("\n\t%s(%d): %s", timing, value.Count, value.Duration)) } buf.WriteString(fmt.Sprintf("\n\ttotal: %s", totalReal)) buf.WriteString(fmt.Sprintf("\n\ttracked: %s", total)) buf.WriteString(fmt.Sprintf("\n\tunkn: %s", totalReal-total)) fmt.Println(buf.String()) } func timingMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ctx := r.Context() ctx = context.WithValue(ctx, timingsKey, &ctxTimings{ Data: make(map[string]*Timing), }) defer logContextTimings(ctx, r.URL.Path, time.Now()) next.ServeHTTP(w, r.WithContext(ctx)) }) } func emulateWork(ctx context.Context, workName string) { defer trackContextTimings(ctx, workName, time.Now()) rnd := time.Duration(rand.Intn(AvgSleep)) time.Sleep(time.Millisecond * rnd) } func loadPostsHandle(w http.ResponseWriter, req *http.Request) { ctx := req.Context() emulateWork(ctx, "checkCache") emulateWork(ctx, "loadPosts") emulateWork(ctx, "loadPosts") emulateWork(ctx, "loadPosts") time.Sleep(10 * time.Millisecond) emulateWork(ctx, "loadSidebar") emulateWork(ctx, "loadComments") fmt.Fprintln(w, "Request done") } func main() { rand.Seed(time.Now().UTC().UnixNano()) siteMux := http.NewServeMux() siteMux.HandleFunc("/", loadPostsHandle) siteHandler := timingMiddleware(siteMux) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", siteHandler) } ================================================ FILE: 5-architecture/3_errors/1_basic_err/1_basic_err.go ================================================ package main import ( "fmt" "net/http" "time" ) var ( client = http.Client{Timeout: time.Duration(time.Millisecond)} ) func getRemoteResource() error { url := "http://127.0.0.1:9999/pages?id=123" _, err := client.Get(url) if err != nil { // вернётся `timed out`. и что? // return err // будет `res error: time out`. а где? // return fmt.Errof("getRemoteResource: %+v", err) return fmt.Errorf("getRemoteResource: %s at %s", err, url) } return nil } func handler(w http.ResponseWriter, r *http.Request) { err := getRemoteResource() if err != nil { fmt.Printf("error happend: %+v\n", err) http.Error(w, "internal error", 500) return } w.Write([]byte("all is OK")) } func main() { http.HandleFunc("/", handler) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } ================================================ FILE: 5-architecture/3_errors/2_named_err/2_named_err.go ================================================ package main import ( "errors" "fmt" "net/http" "time" ) var ( client = http.Client{Timeout: time.Duration(time.Millisecond)} ErrResource = errors.New("resource error") ) func getRemoteResource() error { url := "http://127.0.0.1:9999/pages?id=123" _, err := client.Get(url) if err != nil { return ErrResource } return nil } func handler(w http.ResponseWriter, r *http.Request) { err := getRemoteResource() if err != nil { fmt.Printf("error happend: %+v\n", err) switch err { case ErrResource: http.Error(w, "remote resource error", 500) default: http.Error(w, "internal error", 500) } return } w.Write([]byte("all is OK")) } func main() { http.HandleFunc("/", handler) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } ================================================ FILE: 5-architecture/3_errors/3_pkg_err/3_pkg_err.go ================================================ package main import ( "fmt" "net/http" "net/url" "time" "github.com/pkg/errors" ) var ( client = http.Client{Timeout: time.Duration(time.Millisecond)} ) func getRemoteResource() error { url := "http://127.0.0.1:9999/pages?id=123" _, err := client.Get(url) if err != nil { return errors.Wrap(err, "resource error") // resource error: timeout } return nil } func handler(w http.ResponseWriter, r *http.Request) { err := getRemoteResource() if err != nil { fmt.Printf("full err: %+v\n", err) switch err := errors.Cause(err).(type) { case *url.Error: fmt.Printf("resource %s err: %+v\n", err.URL, err.Err) http.Error(w, "remote resource error", 422) default: fmt.Printf("%+v\n", err) http.Error(w, "parsing error", 500) } return } w.Write([]byte("all is OK")) } func main() { http.HandleFunc("/", handler) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } ================================================ FILE: 5-architecture/3_errors/4_own_err/4_own_err.go ================================================ package main import ( "fmt" "net/http" "time" ) var ( client = http.Client{Timeout: time.Duration(time.Millisecond)} ) type HTTPError struct { Code int } var e error = &ResourceError{} type ResourceError struct { URL string Err error Code int } func (re *ResourceError) Error() string { return fmt.Sprintf( "Resource error: URL: %s, err: %v", re.URL, re.Err, ) } func getRemoteResource() error { url := "http://127.0.0.1:9999/pages?id=123" _, err := client.Get(url) if err != nil { return &ResourceError{URL: url, Err: err} } return nil } func handler(w http.ResponseWriter, r *http.Request) { err := getRemoteResource() if err != nil { switch err.(type) { case *ResourceError: err := err.(*ResourceError) fmt.Printf("resource %s err: %s\n", err.URL, err.Err) http.Error(w, "remote resource error", 500) default: fmt.Printf("internal error: %+v\n", err) http.Error(w, "internal error", 500) } return } w.Write([]byte("all is OK")) } func main() { http.HandleFunc("/", handler) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } ================================================ FILE: 5-architecture/3_errors/5_new_errors/5_new_errors.go ================================================ package main import ( "fmt" "log" "math/rand" "time" "github.com/pkg/errors" ) type MyOwnError struct { Reason string Code int } func (e MyOwnError) Error() string { return fmt.Sprintf("error with code %d happened: %s", e.Code, e.Reason) } var ( ownError1 error = MyOwnError{ Reason: "really bad things happened", Code: 42, } ) func someJob() error { if rand.Intn(100) > 50 { return ownError1 } if randomInt := rand.Intn(100); randomInt > 50 { return MyOwnError{ Reason: "random was above 50", Code: randomInt, } } return nil } func jobWrapper() error { err := someJob() return errors.Wrap(err, "failed to do some job") } func main() { rand.Seed(time.Now().UnixNano()) err := someJob() // if err == ownError1 // WRONG if errors.Is(err, ownError1) { log.Println("found ownError1") return } var myOwnError MyOwnError if ok := errors.As(err, &myOwnError); ok { log.Println("found my own error sturct") return } if err != nil { log.Println("well, that was unexpected") return } log.Println("error is nil") } ================================================ FILE: 5-architecture/4_validation/validation.go ================================================ package main import ( "fmt" "net/http" // валидатор "github.com/asaskevich/govalidator" // парсинг параметров в структуру "github.com/gorilla/schema" ) // http://127.0.0.1:8080/?to=v.romanov@corp.mail.ru&priority=low&subject=Hello!&inner=ignored&id=12&flag=23 type SendMessage struct { Id int `valid:",optional"` Priority string `valid:"in(low|normal|high)"` Recipient string `schema:"to" valid:"email"` Subject string `valid:"msgSubject"` Inner string `schema:"-" valid:"-"` flag int } func handler(w http.ResponseWriter, r *http.Request) { w.Write([]byte("request " + r.URL.String() + "\n\n")) msg := &SendMessage{} decoder := schema.NewDecoder() decoder.IgnoreUnknownKeys(true) err := decoder.Decode(msg, r.URL.Query()) if err != nil { fmt.Println(err) http.Error(w, "internal", 500) return } w.Write([]byte(fmt.Sprintf("Msg: %#v\n\n", msg))) _, err = govalidator.ValidateStruct(msg) if err != nil { if allErrs, ok := err.(govalidator.Errors); ok { for _, fld := range allErrs.Errors() { data := []byte(fmt.Sprintf("field: %#v\n\n", fld)) w.Write(data) } } w.Write([]byte(fmt.Sprintf("error: %s\n\n", err))) } else { w.Write([]byte(fmt.Sprintf("msg is correct\n\n"))) } } func main() { http.HandleFunc("/", handler) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } func init() { govalidator.CustomTypeTagMap.Set( "msgSubject", govalidator.CustomTypeValidator(func(i interface{}, o interface{}) bool { subject, ok := i.(string) if !ok { return false } if len(subject) == 0 || len(subject) > 10 { return false } return true }), ) } ================================================ FILE: 5-architecture/5_logging/main.go ================================================ package main import ( "fmt" "log" "net/http" "os" "time" "github.com/sirupsen/logrus" "go.uber.org/zap" ) func mainPage(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, "hello world") } type AccessLogger struct { StdLogger *log.Logger ZapLogger *zap.SugaredLogger LogrusLogger *logrus.Entry } func (ac *AccessLogger) accessLogMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { start := time.Now() next.ServeHTTP(w, r) fmt.Printf("FMT [%s] %s, %s %s\n", r.Method, r.RemoteAddr, r.URL.Path, time.Since(start)) log.Printf("LOG [%s] %s, %s %s\n", r.Method, r.RemoteAddr, r.URL.Path, time.Since(start)) ac.StdLogger.Printf("[%s] %s, %s %s\n", r.Method, r.RemoteAddr, r.URL.Path, time.Since(start)) ac.ZapLogger.Info(r.URL.Path, zap.String("method", r.Method), zap.String("remote_addr", r.RemoteAddr), zap.String("url", r.URL.Path), zap.Duration("work_time", time.Since(start)), ) ac.LogrusLogger.WithFields(logrus.Fields{ "method": r.Method, "remote_addr": r.RemoteAddr, "work_time": time.Since(start), }).Info(r.URL.Path) }) } // ----------- func main() { addr := "localhost" port := 8080 // std fmt.Printf("STD starting server at %s:%d\n", addr, port) // std log.Printf("STD starting server at %s:%d\n", addr, port) // zap // у zap-а нет логгера по-умолчанию zapLogger, _ := zap.NewProduction() defer zapLogger.Sync() zapLogger.Info("starting server", zap.String("logger", "ZAP"), zap.String("host", addr), zap.Int("port", port), ) // logrus logrus.SetFormatter(&logrus.TextFormatter{DisableColors: true}) logrus.WithFields(logrus.Fields{ "logger": "LOGRUS", "host": addr, "port": port, }).Info("Starting server") AccessLogOut := new(AccessLogger) // std AccessLogOut.StdLogger = log.New(os.Stdout, "STD ", log.LUTC|log.Lshortfile) // zap sugar := zapLogger.Sugar().With( zap.String("mode", "[access_log]"), zap.String("logger", "ZAP"), ) AccessLogOut.ZapLogger = sugar // logrus contextLogger := logrus.WithFields(logrus.Fields{ "mode": "[access_log]", "logger": "LOGRUS", }) logrus.SetFormatter(&logrus.JSONFormatter{}) AccessLogOut.LogrusLogger = contextLogger // server stuff siteMux := http.NewServeMux() siteMux.HandleFunc("/", mainPage) siteHandler := AccessLogOut.accessLogMiddleware(siteMux) http.ListenAndServe(":8080", siteHandler) } ================================================ FILE: 5-architecture/6_websockets/index.html ================================================ Inbox

Messages

================================================ FILE: 5-architecture/6_websockets/main.go ================================================ package main import ( "encoding/json" "fmt" "html/template" "log" "net/http" "time" "github.com/gorilla/websocket" "github.com/icrowley/fake" ) var upgrader = websocket.Upgrader{ ReadBufferSize: 1024, WriteBufferSize: 1024, CheckOrigin: func(r *http.Request) bool { return true }, } func sendNewMsgNotifications(client *websocket.Conn) { ticker := time.NewTicker(3 * time.Second) for { w, err := client.NextWriter(websocket.TextMessage) if err != nil { ticker.Stop() break } msg := newMessage() w.Write(msg) w.Close() <-ticker.C } } func main() { tmpl := template.Must(template.ParseFiles("index.html")) http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { tmpl.Execute(w, nil) }) http.HandleFunc("/notifications", func(w http.ResponseWriter, r *http.Request) { log.Println("ws upgrade") ws, err := upgrader.Upgrade(w, r, nil) if err != nil { log.Fatal(err) } go sendNewMsgNotifications(ws) }) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } func newMessage() []byte { data, _ := json.Marshal(map[string]string{ "email": fake.EmailAddress(), "name": fake.FirstName() + " " + fake.LastName(), "subject": fake.Product() + " " + fake.Model(), }) return data } ================================================ FILE: 5-architecture/7_frameworks/echo/main.go ================================================ package main import ( "github.com/go-park-mail-ru/lectures/5-architecture/7_frameworks/echo/middleware" userhttp "github.com/go-park-mail-ru/lectures/5-architecture/7_frameworks/echo/user/delivery/http" "github.com/go-park-mail-ru/lectures/5-architecture/7_frameworks/echo/user/repository" "github.com/go-park-mail-ru/lectures/5-architecture/7_frameworks/echo/user/usecase" "github.com/labstack/echo" echomiddleware "github.com/labstack/echo/middleware" ) const listenAddr = "127.0.0.1:8080" func main() { e := echo.New() e.Use(middleware.RequestIDMiddleware) e.Use(echomiddleware.Logger()) e.Use(middleware.PanicMiddleware) e.HTTPErrorHandler = middleware.ErrorHandler userhttp.NewUserHandler(e, usecase.NewUserUsecase(repository.NewUserMemoryRepository())) e.Logger.Warnf("start listening on %s", listenAddr) err := e.Start("127.0.0.1:8080") if err != nil { e.Logger.Errorf("server error: %s", err) } e.Logger.Warnf("shutdown") } ================================================ FILE: 5-architecture/7_frameworks/echo/middleware/error.go ================================================ package middleware import ( "net/http" "github.com/pkg/errors" "github.com/labstack/echo" ) func ErrorHandler(err error, ctx echo.Context) { ctx.Logger().Errorf("error happened while processing request: %s", err) switch err := errors.Cause(err); err.(type) { case *echo.HTTPError: ctx.JSON(err.(*echo.HTTPError).Code, struct { Body string }{Body: "internal"}) default: ctx.JSON(500, struct { Body string }{Body: "internal"}) } err = ctx.HTML(http.StatusInternalServerError, "internal") if err != nil { ctx.Logger().Errorf("failed to write 500 internal after error: %s", err) } } ================================================ FILE: 5-architecture/7_frameworks/echo/middleware/panic.go ================================================ package middleware import ( "fmt" "github.com/labstack/echo" ) func PanicMiddleware(next echo.HandlerFunc) echo.HandlerFunc { return func(ctx echo.Context) error { defer func() { if err := recover(); err != nil { ctx.Error(fmt.Errorf("%s", err)) } }() return next(ctx) } } ================================================ FILE: 5-architecture/7_frameworks/echo/middleware/request_id.go ================================================ package middleware import ( "fmt" "math/rand" "github.com/labstack/echo" ) func RequestIDMiddleware(next echo.HandlerFunc) echo.HandlerFunc { return func(ctx echo.Context) error { requestID := fmt.Sprintf("%016x", rand.Int())[:10] ctx.Logger().SetPrefix(fmt.Sprintf("%s rid=%s", ctx.Logger().Prefix(), requestID)) return next(ctx) } } ================================================ FILE: 5-architecture/7_frameworks/echo/middleware/session.go ================================================ package middleware ================================================ FILE: 5-architecture/7_frameworks/echo/model/user.go ================================================ package model type User struct { Username string Password string `json:"-"` } ================================================ FILE: 5-architecture/7_frameworks/echo/user/delivery/http/hander_test.go ================================================ package http import ( "io/ioutil" "net/http" "net/http/httptest" "strings" "testing" "github.com/go-park-mail-ru/lectures/5-architecture/7_frameworks/echo/model" "github.com/go-park-mail-ru/lectures/5-architecture/7_frameworks/echo/user" "github.com/golang/mock/gomock" "github.com/labstack/echo" ) func TestGetUser(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() usecase := user.NewMockUsecase(ctrl) usecase.EXPECT().GetUser(gomock.Eq("ivan")).Return(model.User{ Username: "Ivan", }, nil) handler := userHandler{usecase: usecase} e := echo.New() req := httptest.NewRequest(http.MethodGet, "/user/ivan", nil) rec := httptest.NewRecorder() c := e.NewContext(req, rec) c.SetPath("/user/:username") c.SetParamNames("username") c.SetParamValues("ivan") err := handler.GetUser(c) if err != nil { t.Errorf("err is not nil: %s", err) } body, _ := ioutil.ReadAll(rec.Body) if strings.Trim(string(body), "\n") != `{"Username":"Ivan"}` { t.Errorf("Expected: %s, got: %s", `{"Username":"Ivan"}`, string(body)) } } ================================================ FILE: 5-architecture/7_frameworks/echo/user/delivery/http/handler.go ================================================ package http import ( "errors" "github.com/go-park-mail-ru/lectures/5-architecture/7_frameworks/echo/middleware" "github.com/go-park-mail-ru/lectures/5-architecture/7_frameworks/echo/user" "github.com/labstack/echo" ) type userHandler struct { usecase user.Usecase } func NewUserHandler(e *echo.Echo, us user.Usecase) { handler := userHandler{usecase: us} e.GET("/user", handler.GetUser, middleware.PanicMiddleware) e.POST("/user", handler.CreateUser) e.GET("/users", handler.GetAllUsers) } func (h *userHandler) GetUser(ctx echo.Context) error { ctx.Error(errors.New("some error")) } func (h *userHandler) GetAllUsers(ctx echo.Context) error { return nil } func (h *userHandler) CreateUser(ctx echo.Context) error { return nil } ================================================ FILE: 5-architecture/7_frameworks/echo/user/repository/memory.go ================================================ package repository import ( "sync" "github.com/go-park-mail-ru/lectures/5-architecture/7_frameworks/echo/model" "github.com/go-park-mail-ru/lectures/5-architecture/7_frameworks/echo/user" ) func NewUserMemoryRepository() user.Repository { return &UserMemoryRepository{ storage: map[string]model.User{}, } } type UserMemoryRepository struct { mu sync.RWMutex storage map[string]model.User } func (db *UserMemoryRepository) GetUser(username string) (model.User, error) { panic("implement me") } func (db *UserMemoryRepository) GetAllUsers() ([]model.User, error) { db.mu.RLock() defer db.mu.RUnlock() ret := make([]model.User, 0, len(db.storage)) for _, u := range db.storage { ret = append(ret, u) } return ret, nil } func (db *UserMemoryRepository) InsertUser(u model.User) error { db.mu.Lock() defer db.mu.Unlock() if _, ok := db.storage[u.Username]; ok { return user.ErrUserExists } db.storage[u.Username] = u return nil } ================================================ FILE: 5-architecture/7_frameworks/echo/user/repository.go ================================================ package user import ( "errors" "github.com/go-park-mail-ru/lectures/5-architecture/7_frameworks/echo/model" ) var ErrUserExists = errors.New("user exists") type Repository interface { GetUser(username string) (model.User, error) GetAllUsers() ([]model.User, error) InsertUser(user model.User) error } ================================================ FILE: 5-architecture/7_frameworks/echo/user/usecase/usecase.go ================================================ package usecase import ( "github.com/go-park-mail-ru/lectures/5-architecture/7_frameworks/echo/model" "github.com/go-park-mail-ru/lectures/5-architecture/7_frameworks/echo/user" ) func NewUserUsecase(userRepo user.Repository) user.Usecase { return userUsecase{repo: userRepo} } type userUsecase struct { repo user.Repository } func (u userUsecase) GetUser(username string) (model.User, error) { return u.repo.GetUser(username) } func (u userUsecase) GetAllUsers() ([]model.User, error) { return u.repo.GetAllUsers() } func (u userUsecase) CreateUser(user model.User) error { return u.repo.InsertUser(user) } ================================================ FILE: 5-architecture/7_frameworks/echo/user/usecase.go ================================================ package user import "github.com/go-park-mail-ru/lectures/5-architecture/7_frameworks/echo/model" type Usecase interface { GetUser(username string) (model.User, error) GetAllUsers() ([]model.User, error) CreateUser(user model.User) error } ================================================ FILE: 5-architecture/7_frameworks/echo/user/usecase_mock.go ================================================ // Code generated by MockGen. DO NOT EDIT. // Source: user/usecase.go // Package user is a generated GoMock package. package user import ( model "github.com/go-park-mail-ru/lectures/5-architecture/7_frameworks/echo/model" gomock "github.com/golang/mock/gomock" reflect "reflect" ) // MockUsecase is a mock of Usecase interface type MockUsecase struct { ctrl *gomock.Controller recorder *MockUsecaseMockRecorder } // MockUsecaseMockRecorder is the mock recorder for MockUsecase type MockUsecaseMockRecorder struct { mock *MockUsecase } // NewMockUsecase creates a new mock instance func NewMockUsecase(ctrl *gomock.Controller) *MockUsecase { mock := &MockUsecase{ctrl: ctrl} mock.recorder = &MockUsecaseMockRecorder{mock} return mock } // EXPECT returns an object that allows the caller to indicate expected use func (m *MockUsecase) EXPECT() *MockUsecaseMockRecorder { return m.recorder } // GetUser mocks base method func (m *MockUsecase) GetUser(username string) (model.User, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetUser", username) ret0, _ := ret[0].(model.User) ret1, _ := ret[1].(error) return ret0, ret1 } // GetUser indicates an expected call of GetUser func (mr *MockUsecaseMockRecorder) GetUser(username interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUser", reflect.TypeOf((*MockUsecase)(nil).GetUser), username) } // GetAllUsers mocks base method func (m *MockUsecase) GetAllUsers() ([]model.User, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAllUsers") ret0, _ := ret[0].([]model.User) ret1, _ := ret[1].(error) return ret0, ret1 } // GetAllUsers indicates an expected call of GetAllUsers func (mr *MockUsecaseMockRecorder) GetAllUsers() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllUsers", reflect.TypeOf((*MockUsecase)(nil).GetAllUsers)) } // CreateUser mocks base method func (m *MockUsecase) CreateUser(user model.User) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateUser", user) ret0, _ := ret[0].(error) return ret0 } // CreateUser indicates an expected call of CreateUser func (mr *MockUsecaseMockRecorder) CreateUser(user interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateUser", reflect.TypeOf((*MockUsecase)(nil).CreateUser), user) } ================================================ FILE: 5-architecture/readings_5.md ================================================ # Репозиторий, архитектура, либы Layout'ы репозиториев: * https://github.com/golang-standards/project-layout - стандартный layout репозитория сервиса на гошке * https://github.com/bxcodec/go-clean-arch - layout репозитория с чистой архитектурой Основная и самая важная ссылка, касательно компонентов: * https://github.com/avelino/awesome-go Шаблоны: * https://github.com/SlinSo/goTemplateBenchmark Роутеры: * https://github.com/gorilla/mux - один из компонентов gorillatoolkit, из которых можно собрать себе полноценный фреймворк * https://github.com/julienschmidt/httprouter * https://github.com/valyala/fasthttp * https://github.com/julienschmidt/go-http-routing-benchmark Фреймворки: * https://github.com/labstack/echo * https://github.com/gin-gonic/gin * https://github.com/gramework/gramework - быстрый веб-ферймворк на основе fasthttp Логирование: * https://github.com/uber-go/zap * https://github.com/sirupsen/logrus * https://www.youtube.com/watch?v=c_MPDg2C9tg - видео по структурному логирования * https://habrahabr.ru/company/badoo/blog/328722/ Веб-сокеты: * https://github.com/gorilla/websocket * https://github.com/gobwas/ws - библиотека для низкоуровневой работы в веб-сокетами от Mail.ru, которая позволяет существенно сэкономить на памяти сервера * https://github.com/olahol/melody Безопасность: * https://github.com/Checkmarx/Go-SCP ================================================ FILE: 6-databases/00_databases/_kafka/setup.sh ================================================ #!/bin/sh /opt/bitnami/kafka/bin/kafka-topics.sh --create --topic cool_topic --bootstrap-server localhost:9092 /opt/bitnami/kafka/bin/kafka-topics.sh --describe --topic cool_topic --bootstrap-server localhost:9092 ================================================ FILE: 6-databases/00_databases/_mysql/injection_db.sql ================================================ DROP TABLE IF EXISTS `users`; CREATE TABLE `users` ( `id` int(11) NOT NULL, `login` varchar(200) NOT NULL, `name` varchar(200) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO `users` (`id`, `login`, `name`) VALUES (1, 'user', ''), (2, 'admin', ''); ================================================ FILE: 6-databases/00_databases/_mysql/items.sql ================================================ SET NAMES utf8; SET time_zone = '+00:00'; SET foreign_key_checks = 0; SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; DROP TABLE IF EXISTS `items`; CREATE TABLE `items` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(255) NOT NULL, `description` text NOT NULL, `updated` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO `items` (`id`, `title`, `description`, `updated`) VALUES (1, 'database/sql', 'Рассказать про базы данных', 'rvasily'), (2, 'memcache', 'Рассказать про мемкеш с примером использования', NULL); ================================================ FILE: 6-databases/00_databases/_postgres/items.sql ================================================ SET TIME ZONE '+00:00'; DROP TABLE IF EXISTS items; CREATE TABLE items ( id SERIAL PRIMARY KEY, title VARCHAR(255) NOT NULL, description TEXT NOT NULL, updated VARCHAR(255) ); INSERT INTO items (id, title, description, updated) VALUES (1, 'database/sql', 'Рассказать про базы данных', 'rvasily'), (2, 'memcache', 'Рассказать про мемкеш с примером использования', NULL); SELECT setval(pg_get_serial_sequence('items', 'id'), MAX(id)) FROM items; ================================================ FILE: 6-databases/00_databases/docker-compose.yml ================================================ version: '3' # docker-compose up -d # docker-compose down # docker rm $(docker ps -a -q) && docker volume prune -f services: mysql: image: mysql:8 command: --mysql-native-password=ON environment: MYSQL_ROOT_PASSWORD: "love" MYSQL_DATABASE: golang ports: - '3306:3306' volumes: - './_mysql/:/docker-entrypoint-initdb.d/' postgres: image: postgres:13.2 restart: always environment: POSTGRES_USER: postgres_user POSTGRES_PASSWORD: postgres_password POSTGRES_DB: golang ports: - '5432:5432' volumes: - './_postgres/:/docker-entrypoint-initdb.d/' mongodb: image: mongo:5 environment: - MONGO_INITDB_DATABASE=vkbmstu ports: - '27017-27019:27017-27019' adminer: image: adminer restart: always links: - "mysql:mysql" - "postgres:postgres" ports: - '8090:8080' memcached: image: 'memcached:latest' ports: - '11211:11211' redis: image: 'redis' ports: - '6379:6379' rabbitmq: image: 'rabbitmq' ports: - '5672:5672' kafka: image: bitnami/kafka:3.2.1 ports: - '9092:9092' environment: KAFKA_ENABLE_KRAFT: yes KAFKA_CFG_PROCESS_ROLES: broker,controller KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER KAFKA_CFG_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093 KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://127.0.0.1:9092 KAFKA_BROKER_ID: 1 KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 1@127.0.0.1:9093 ALLOW_PLAINTEXT_LISTENER: yes volumes: - ./_kafka:/scripts tarantool: build: ../13_tarantool_simple restart: always ports: - '3301:3301' ================================================ FILE: 6-databases/01_mysql/main.go ================================================ package main import ( "database/sql" "fmt" "html/template" "net/http" "strconv" "github.com/gorilla/mux" _ "github.com/go-sql-driver/mysql" ) type Item struct { Id int Title string Description string Updated sql.NullString } type Handler struct { DB *sql.DB Tmpl *template.Template } func (h *Handler) List(w http.ResponseWriter, r *http.Request) { items := []*Item{} // Не надо так: SELECT * FROM items rows, err := h.DB.QueryContext(r.Context(), "SELECT id, title, updated FROM items") panicOnErr(err) // Надо закрывать соединение, иначе будет течь defer rows.Close() for rows.Next() { post := &Item{} err = rows.Scan(&post.Id, &post.Title, &post.Updated) panicOnErr(err) items = append(items, post) } err = h.Tmpl.ExecuteTemplate(w, "index.html", struct { Items []*Item }{ Items: items, }) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } } func (h *Handler) AddForm(w http.ResponseWriter, r *http.Request) { err := h.Tmpl.ExecuteTemplate(w, "create.html", nil) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } } func (h *Handler) Add(w http.ResponseWriter, r *http.Request) { // В целях упрощения примера пропущена валидация result, err := h.DB.Exec( "INSERT INTO items (`title`, `description`) VALUES (?, ?)", r.FormValue("title"), r.FormValue("description"), ) panicOnErr(err) affected, err := result.RowsAffected() panicOnErr(err) lastID, err := result.LastInsertId() panicOnErr(err) fmt.Println("Insert - RowsAffected", affected, "LastInsertId: ", lastID) http.Redirect(w, r, "/", http.StatusFound) } func (h *Handler) Edit(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) id, err := strconv.Atoi(vars["id"]) panicOnErr(err) post := &Item{} row := h.DB.QueryRow("SELECT id, title, updated, description FROM items WHERE id = ?", id) // Scan сам закрывает коннект err = row.Scan(&post.Id, &post.Title, &post.Updated, &post.Description) panicOnErr(err) err = h.Tmpl.ExecuteTemplate(w, "edit.html", post) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } } func (h *Handler) Update(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) id, err := strconv.Atoi(vars["id"]) panicOnErr(err) // В целях упрощения примера пропущена валидация result, err := h.DB.Exec( "UPDATE items SET `title` = ?, `description` = ?, `updated` = ? WHERE id = ?", r.FormValue("title"), r.FormValue("description"), "user", id, ) panicOnErr(err) affected, err := result.RowsAffected() panicOnErr(err) fmt.Println("Update - RowsAffected", affected) http.Redirect(w, r, "/", http.StatusFound) } func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) id, err := strconv.Atoi(vars["id"]) panicOnErr(err) result, err := h.DB.Exec( "DELETE FROM items WHERE id = ?", id, ) panicOnErr(err) affected, err := result.RowsAffected() panicOnErr(err) fmt.Println("Delete - RowsAffected", affected) w.Header().Set("Content-type", "application/json") resp := `{"affected": ` + strconv.Itoa(int(affected)) + `}` w.Write([]byte(resp)) } func main() { // основные настройки к базе dsn := "root:love@tcp(localhost:3306)/golang?" // указываем кодировку dsn += "&charset=utf8" // отказываемся от prepared statements // параметры подставляются сразу dsn += "&interpolateParams=true" db, err := sql.Open("mysql", dsn) panicOnErr(err) db.SetMaxOpenConns(10) err = db.Ping() // Тут будет первое подключение к базе panicOnErr(err) handlers := &Handler{ DB: db, Tmpl: template.Must(template.ParseGlob("templates/*")), } // В целях упрощения примера пропущена авторизация и csrf r := mux.NewRouter() r.HandleFunc("/", handlers.List).Methods("GET") r.HandleFunc("/items", handlers.List).Methods("GET") r.HandleFunc("/items/new", handlers.AddForm).Methods("GET") r.HandleFunc("/items/new", handlers.Add).Methods("POST") r.HandleFunc("/items/{id}", handlers.Edit).Methods("GET") r.HandleFunc("/items/{id}", handlers.Update).Methods("POST") r.HandleFunc("/items/{id}", handlers.Delete).Methods("DELETE") fmt.Println("starting server at :8080") fmt.Println(http.ListenAndServe(":8080", r)) } // Не используйте такой код в продакшене // Ошибка должна всегда явно обрабатываться func panicOnErr(err error) { if err != nil { panic(err) } } ================================================ FILE: 6-databases/01_mysql/templates/create.html ================================================

Edit item

================================================ FILE: 6-databases/01_mysql/templates/edit.html ================================================

Edit item

{{if .Updated.Valid}}
{{end}}
================================================ FILE: 6-databases/01_mysql/templates/index.html ================================================

Posts

# Title New
{{.ID}} {{.Title}} Edit Del
{{range .Items}} {{end}} ================================================ FILE: 6-databases/02_postgresql/main.go ================================================ package main import ( "database/sql" "fmt" "html/template" "net/http" "strconv" "github.com/gorilla/mux" _ "github.com/jackc/pgx/v5/stdlib" ) type Item struct { Id int Title string Description string Updated sql.NullString } type Handler struct { DB *sql.DB Tmpl *template.Template } func (h *Handler) List(w http.ResponseWriter, r *http.Request) { items := []*Item{} // Не надо так: SELECT * FROM items rows, err := h.DB.QueryContext(r.Context(), "SELECT id, title, updated FROM items") panicOnErr(err) // Надо закрывать соединение, иначе будет течь defer rows.Close() for rows.Next() { post := &Item{} err = rows.Scan(&post.Id, &post.Title, &post.Updated) panicOnErr(err) items = append(items, post) } err = h.Tmpl.ExecuteTemplate(w, "index.html", struct { Items []*Item }{ Items: items, }) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } } func (h *Handler) AddForm(w http.ResponseWriter, r *http.Request) { err := h.Tmpl.ExecuteTemplate(w, "create.html", nil) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } } func (h *Handler) Add(w http.ResponseWriter, r *http.Request) { // В целях упрощения примера пропущена валидация var insertedID int err := h.DB.QueryRow( "INSERT INTO items (title, description) VALUES ($1, $2) RETURNING id", r.FormValue("title"), r.FormValue("description"), ).Scan(&insertedID) panicOnErr(err) fmt.Println("Insert - InsertedId: ", insertedID) http.Redirect(w, r, "/", http.StatusFound) } func (h *Handler) Edit(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) id, err := strconv.Atoi(vars["id"]) panicOnErr(err) post := &Item{} row := h.DB.QueryRow("SELECT id, title, updated, description FROM items WHERE id = $1", id) // Scan сам закрывает коннект err = row.Scan(&post.Id, &post.Title, &post.Updated, &post.Description) panicOnErr(err) err = h.Tmpl.ExecuteTemplate(w, "edit.html", post) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } } func (h *Handler) Update(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) id, err := strconv.Atoi(vars["id"]) panicOnErr(err) // В целях упрощения примера пропущена валидация result, err := h.DB.Exec( "UPDATE items SET title = $1, description = $2, updated = $3 WHERE id = $4", r.FormValue("title"), r.FormValue("description"), "user", id, ) panicOnErr(err) affected, err := result.RowsAffected() panicOnErr(err) fmt.Println("Update - RowsAffected", affected) http.Redirect(w, r, "/", http.StatusFound) } func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) id, err := strconv.Atoi(vars["id"]) panicOnErr(err) result, err := h.DB.Exec( "DELETE FROM items WHERE id = $1", id, ) panicOnErr(err) affected, err := result.RowsAffected() panicOnErr(err) fmt.Println("Delete - RowsAffected", affected) w.Header().Set("Content-type", "application/json") resp := `{"affected": ` + strconv.Itoa(int(affected)) + `}` w.Write([]byte(resp)) } func main() { // Основные настройки подключения к базе dsn := "postgres://postgres_user:postgres_password@localhost:5432/golang?" // Отключаем использование SSL dsn += "sslmode=disable" db, err := sql.Open("pgx", dsn) panicOnErr(err) db.SetMaxOpenConns(10) err = db.Ping() // Тут будет первое подключение к базе if err != nil { panic(err) } handlers := &Handler{ DB: db, Tmpl: template.Must(template.ParseGlob("templates/*")), } // В целях упрощения примера пропущена авторизация и csrf r := mux.NewRouter() r.HandleFunc("/", handlers.List).Methods("GET") r.HandleFunc("/items", handlers.List).Methods("GET") r.HandleFunc("/items/new", handlers.AddForm).Methods("GET") r.HandleFunc("/items/new", handlers.Add).Methods("POST") r.HandleFunc("/items/{id}", handlers.Edit).Methods("GET") r.HandleFunc("/items/{id}", handlers.Update).Methods("POST") r.HandleFunc("/items/{id}", handlers.Delete).Methods("DELETE") fmt.Println("starting server at :8080") fmt.Println(http.ListenAndServe(":8080", r)) } // Не используйте такой код в продакшене // Ошибка должна всегда явно обрабатываться func panicOnErr(err error) { if err != nil { panic(err) } } ================================================ FILE: 6-databases/02_postgresql/templates/create.html ================================================

Edit item

================================================ FILE: 6-databases/02_postgresql/templates/edit.html ================================================

Edit item

{{if .Updated.Valid}}
{{end}}
================================================ FILE: 6-databases/02_postgresql/templates/index.html ================================================

Posts

# Title Edited New
{{.Id}} {{.Title}} {{if .Updated.Valid}}{{.Updated.String}}{{end}} Edit Del
{{range .Items}} {{end}} ================================================ FILE: 6-databases/03_mysql_sql_injection/main.go ================================================ package main import ( "database/sql" "errors" "fmt" "net/http" _ "github.com/go-sql-driver/mysql" ) var loginFormTmpl = ` Login: Password: ` func main() { // Основные настройки подключения к базе dsn := "root:love@tcp(localhost:3306)/golang?" // Указываем кодировку dsn += "&charset=utf8" // Отказываемся от prepared statements // Параметры подставляются сразу dsn += "&interpolateParams=true" var err error // Создаём структуру базы // Но соединение происходит только при первом запросе db, err := sql.Open("mysql", dsn) PanicOnErr(err) err = db.Ping() // Тут будет первое подключение к базе PanicOnErr(err) http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte(loginFormTmpl)) }) http.HandleFunc("/login", func(w http.ResponseWriter, r *http.Request) { var ( id int login, body string ) inputLogin := r.FormValue("login") body += fmt.Sprintln("inputLogin:", inputLogin) // ПЛОХО! НЕ ДЕЛАЙТЕ ТАК! // Параметры не экранированы должным образом // Мы подставляем в запрос параметр как есть query := fmt.Sprintf("SELECT id, login FROM users WHERE login = '%s' LIMIT 1", inputLogin) // SELECT id, login FROM users WHERE login = '' OR '1'<>'2' LIMIT 1 //query := fmt.Sprintf("SELECT id, login FROM users WHERE (login = '%s' AND login <> 'admin') LIMIT 1", inputLogin) // SELECT id, login FROM users WHERE (login = 'admin') #' AND login <> 'admin') LIMIT 1 body += fmt.Sprintln("Sprint query:", query) row := db.QueryRow(query) err := row.Scan(&id, &login) if errors.Is(err, sql.ErrNoRows) { body += fmt.Sprintln("Sprint case: NOT FOUND") } else { PanicOnErr(err) body += fmt.Sprintln("Sprint case: id:", id, "login:", login) } // ПРАВИЛЬНО // Мы используем плейсхолдеры, там параметры будет экранирован должным образом row = db.QueryRow("SELECT id, login FROM users WHERE login = ? LIMIT 1", inputLogin) err = row.Scan(&id, &login) if errors.Is(err, sql.ErrNoRows) { body += fmt.Sprintln("Placeholders case: NOT FOUND") } else { PanicOnErr(err) body += fmt.Sprintln("Placeholders id:", id, "login:", login) } w.Write([]byte(body)) }) fmt.Println("starting server at :8080") PanicOnErr(http.ListenAndServe(":8080", nil)) } // PanicOnErr panics on error func PanicOnErr(err error) { if err != nil { panic(err) } } ================================================ FILE: 6-databases/04_mysql_sqlmock/item_repo.go ================================================ package main import ( "database/sql" ) type Item struct { ID int64 Title string Description string Updated sql.NullString } type ItemRepository struct { DB *sql.DB } func (repo *ItemRepository) ListAll() ([]*Item, error) { items := []*Item{} rows, err := repo.DB.Query("SELECT id, title, updated FROM items") if err != nil { return nil, err } defer rows.Close() // надо закрывать соединение, иначе будет течь for rows.Next() { post := &Item{} err = rows.Scan(&post.ID, &post.Title, &post.Updated) if err != nil { return nil, err } items = append(items, post) } return items, nil } func (repo *ItemRepository) SelectByID(id int64) (*Item, error) { post := &Item{} // QueryRow сам закрывает коннект err := repo.DB. QueryRow("SELECT id, title, updated, description FROM items WHERE id = ?", id). Scan(&post.ID, &post.Title, &post.Updated, &post.Description) if err != nil { return nil, err } return post, nil } func (repo *ItemRepository) Create(elem *Item) (int64, error) { result, err := repo.DB.Exec( "INSERT INTO items (`title`, `description`) VALUES (?, ?)", elem.Title, elem.Description, ) if err != nil { return 0, err } return result.LastInsertId() } func (repo *ItemRepository) Update(elem *Item) (int64, error) { result, err := repo.DB.Exec( "UPDATE items SET"+ "`title` = ?"+ ",`description` = ?"+ ",`updated` = ?"+ "WHERE id = ?", elem.Title, elem.Description, "rvasily", elem.ID, ) if err != nil { return 0, err } return result.RowsAffected() } func (repo *ItemRepository) Delete(id int64) (int64, error) { result, err := repo.DB.Exec( "DELETE FROM items WHERE id = ?", id, ) if err != nil { return 0, err } return result.RowsAffected() } ================================================ FILE: 6-databases/04_mysql_sqlmock/item_repo_test.go ================================================ package main import ( "database/sql" "fmt" "testing" "github.com/DATA-DOG/go-sqlmock" "github.com/stretchr/testify/require" ) // go test -coverprofile=cover.out && go tool cover -html=cover.out -o cover.html func TestSelectByID(t *testing.T) { db, mock, err := sqlmock.New() if err != nil { t.Fatalf("cant create mock: %s", err) } defer db.Close() var elemID int64 = 1 // good query rows := sqlmock. NewRows([]string{"id", "title", "updated", "description"}) expect := []*Item{ {elemID, "title", "desct", sql.NullString{}}, } for _, item := range expect { rows = rows.AddRow(item.ID, item.Title, nil, item.Description) } mock. ExpectQuery("SELECT id, title, updated, description FROM items WHERE"). WithArgs(elemID). WillReturnRows(rows) repo := &ItemRepository{ DB: db, } item, err := repo.SelectByID(elemID) if err != nil { t.Errorf("unexpected err: %s", err) return } if err := mock.ExpectationsWereMet(); err != nil { t.Errorf("there were unfulfilled expectations: %s", err) return } require.Equalf(t, item, expect[0], "results not match, want %v, have %v", expect[0], item) // query error mock. ExpectQuery("SELECT id, title, updated, description FROM items WHERE"). WithArgs(elemID). WillReturnError(fmt.Errorf("db_error")) _, err = repo.SelectByID(elemID) if err := mock.ExpectationsWereMet(); err != nil { t.Errorf("there were unfulfilled expectations: %s", err) return } if err == nil { t.Errorf("expected error, got nil") return } // row scan error rows = sqlmock.NewRows([]string{"id", "title"}). AddRow(1, "title") mock. ExpectQuery("SELECT id, title, updated, description FROM items WHERE"). WithArgs(elemID). WillReturnRows(rows) _, err = repo.SelectByID(elemID) if err := mock.ExpectationsWereMet(); err != nil { t.Errorf("there were unfulfilled expectations: %s", err) return } if err == nil { t.Errorf("expected error, got nil") return } } func TestCreate(t *testing.T) { db, mock, err := sqlmock.New() if err != nil { t.Fatalf("cant create mock: %s", err) } defer db.Close() repo := &ItemRepository{ DB: db, } title := "title" descr := "description" testItem := &Item{ Title: title, Description: descr, } //ok query mock. ExpectExec(`INSERT INTO items`). WithArgs(title, descr). WillReturnResult(sqlmock.NewResult(1, 1)) id, err := repo.Create(testItem) if err != nil { t.Errorf("unexpected err: %s", err) return } if id != 1 { t.Errorf("bad id: want %v, have %v", id, 1) return } if err := mock.ExpectationsWereMet(); err != nil { t.Errorf("there were unfulfilled expectations: %s", err) } // query error mock. ExpectExec(`INSERT INTO items`). WithArgs(title, descr). WillReturnError(fmt.Errorf("bad query")) _, err = repo.Create(testItem) if err == nil { t.Errorf("expected error, got nil") return } if err := mock.ExpectationsWereMet(); err != nil { t.Errorf("there were unfulfilled expectations: %s", err) } // result error mock. ExpectExec(`INSERT INTO items`). WithArgs(title, descr). WillReturnResult(sqlmock.NewErrorResult(fmt.Errorf("bad_result"))) _, err = repo.Create(testItem) if err == nil { t.Errorf("expected error, got nil") return } if err := mock.ExpectationsWereMet(); err != nil { t.Errorf("there were unfulfilled expectations: %s", err) } // // last id error // mock. // ExpectExec(`INSERT INTO items`). // WithArgs(title, descr). // WillReturnResult(sqlmock.NewResult(0, 0)) // _, err = repo.Create(testItem) // if err == nil { // t.Errorf("expected error, got nil") // return // } // if err := mock.ExpectationsWereMet(); err != nil { // t.Errorf("there were unfulfilled expectations: %s", err) // } } ================================================ FILE: 6-databases/04_mysql_sqlmock/main.go ================================================ package main import ( "database/sql" "fmt" "html/template" "log" "net/http" "strconv" "github.com/gorilla/mux" _ "github.com/go-sql-driver/mysql" ) type ItemCRUD interface { ListAll() ([]*Item, error) SelectByID(int64) (*Item, error) Create(*Item) (int64, error) Update(*Item) (int64, error) Delete(int64) (int64, error) } type Handler struct { Items ItemCRUD Tmpl *template.Template } func (h *Handler) List(w http.ResponseWriter, r *http.Request) { items, err := h.Items.ListAll() if err != nil { log.Println("Items.ListAll err:", err) http.Error(w, "db err", 500) return } err = h.Tmpl.ExecuteTemplate(w, "index.html", struct { Items []*Item }{ Items: items, }) if err != nil { log.Println("Tmpl.ExecuteTemplate err:", err) http.Error(w, "template expand err", 500) return } } func (h *Handler) AddForm(w http.ResponseWriter, r *http.Request) { err := h.Tmpl.ExecuteTemplate(w, "create.html", nil) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } } func (h *Handler) Add(w http.ResponseWriter, r *http.Request) { elem := &Item{ Title: r.FormValue("title"), Description: r.FormValue("description"), } lastID, err := h.Items.Create(elem) if err != nil { log.Println("Items.Create err:", err) http.Error(w, "db err", 500) return } fmt.Println("LastInsertId: ", lastID) http.Redirect(w, r, "/", http.StatusFound) } func (h *Handler) Edit(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) id, err := strconv.Atoi(vars["id"]) if err != nil || id == 0 { log.Println("bad id:", id, err) http.Error(w, "bad request", 400) return } post, err := h.Items.SelectByID(int64(id)) if err != nil { log.Println("Items.SelectByID err:", err) http.Error(w, "db err", 500) return } err = h.Tmpl.ExecuteTemplate(w, "edit.html", post) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } } func (h *Handler) Update(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) id, err := strconv.Atoi(vars["id"]) panicOnErr(err) elem := &Item{ ID: int64(id), Title: r.FormValue("title"), Description: r.FormValue("description"), } affected, err := h.Items.Update(elem) if err != nil { log.Println("Items.Update err:", err) http.Error(w, "db err", 500) return } fmt.Println("Update - RowsAffected", affected) http.Redirect(w, r, "/", http.StatusFound) } func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) id, err := strconv.Atoi(vars["id"]) panicOnErr(err) affected, err := h.Items.Delete(int64(id)) fmt.Println("Delete - RowsAffected", affected, err) w.Header().Set("Content-type", "application/json") resp := `{"affected": ` + strconv.Itoa(int(affected)) + `}` w.Write([]byte(resp)) } func main() { // основные настройки к базе dsn := "root:love@tcp(localhost:3306)/golang?" // указываем кодировку dsn += "&charset=utf8" // отказываемся от prapared statements // параметры подставляются сразу dsn += "&interpolateParams=true" db, err := sql.Open("mysql", dsn) panicOnErr(err) db.SetMaxOpenConns(10) err = db.Ping() // Тут будет первое подключение к базе if err != nil { panic(err) } itemsRepo := &ItemRepository{ DB: db, } handlers := &Handler{ Items: itemsRepo, Tmpl: template.Must(template.ParseGlob("./templates/*")), } // В целях упрощения примера пропущена авторизация и csrf r := mux.NewRouter() r.HandleFunc("/", handlers.List).Methods("GET") r.HandleFunc("/items", handlers.List).Methods("GET") r.HandleFunc("/items/new", handlers.AddForm).Methods("GET") r.HandleFunc("/items/new", handlers.Add).Methods("POST") r.HandleFunc("/items/{id}", handlers.Edit).Methods("GET") r.HandleFunc("/items/{id}", handlers.Update).Methods("POST") r.HandleFunc("/items/{id}", handlers.Delete).Methods("DELETE") fmt.Println("starting server at :8080") http.ListenAndServe(":8080", r) } // Не используйте такой код в продакшене. // Ошибка должна всегда явно обрабатываться func panicOnErr(err error) { if err != nil { panic(err) } } ================================================ FILE: 6-databases/04_mysql_sqlmock/templates/create.html ================================================

Edit item

================================================ FILE: 6-databases/04_mysql_sqlmock/templates/edit.html ================================================

Edit item

{{if .Updated.Valid}}
{{end}}
================================================ FILE: 6-databases/04_mysql_sqlmock/templates/index.html ================================================

Posts

# Title Edited New
{{.Id}} {{.Title}} {{if .Updated.Valid}}{{.Updated.String}}{{end}} Edit Del
{{range .Items}} {{end}} ================================================ FILE: 6-databases/05_gorm/main.go ================================================ package main import ( "errors" "fmt" "html/template" "net/http" "strconv" "github.com/gorilla/mux" "github.com/jinzhu/gorm" _ "github.com/go-sql-driver/mysql" ) type Item struct { Id int `sql:"AUTO_INCREMENT" gorm:"primary_key"` Title string Description string Updated string `sql:"null"` } func (Item) TableName() string { return "items" } func (Item) BeforeSave() (err error) { fmt.Println("trigger on before save") return } // see also https://github.com/doug-martin/goqu type Handler struct { DB *gorm.DB Tmpl *template.Template } func (h *Handler) List(w http.ResponseWriter, r *http.Request) { items := []*Item{} db := h.DB.Find(&items) err := db.Error __err_panic(err) err = h.Tmpl.ExecuteTemplate(w, "index.html", struct { Items []*Item }{ Items: items, }) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } } func (h *Handler) AddForm(w http.ResponseWriter, r *http.Request) { err := h.Tmpl.ExecuteTemplate(w, "create.html", nil) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } } func (h *Handler) Add(w http.ResponseWriter, r *http.Request) { newItem := &Item{ Title: r.FormValue("title"), Description: r.FormValue("description"), } db := h.DB.Create(&newItem) err := db.Error __err_panic(err) affected := db.RowsAffected fmt.Println("Insert - RowsAffected", affected, "LastInsertId: ", newItem.Id) http.Redirect(w, r, "/", http.StatusFound) } func (h *Handler) Edit(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) id, err := strconv.Atoi(vars["id"]) __err_panic(err) post := &Item{ Id: id, } db := h.DB.Find(post) err = db.Error if errors.Is(err, gorm.ErrRecordNotFound) { fmt.Println("Record not found", id) } else { __err_panic(err) } err = h.Tmpl.ExecuteTemplate(w, "edit.html", post) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } } func (h *Handler) Update(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) id, err := strconv.Atoi(vars["id"]) __err_panic(err) post := &Item{} h.DB.Find(post, id) post.Title = r.FormValue("title") post.Description = r.FormValue("description") post.Updated = "rvasily" db := h.DB.Save(post) err = db.Error __err_panic(err) affected := db.RowsAffected fmt.Println("Update - RowsAffected", affected) http.Redirect(w, r, "/", http.StatusFound) } func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) id, err := strconv.Atoi(vars["id"]) __err_panic(err) db := h.DB.Delete(&Item{Id: id}) err = db.Error __err_panic(err) affected := db.RowsAffected fmt.Println("Delete - RowsAffected", affected) w.Header().Set("Content-type", "application/json") resp := `{"affected": ` + strconv.Itoa(int(affected)) + `}` w.Write([]byte(resp)) } func main() { // основные настройки к базе dsn := "root:love@tcp(localhost:3306)/golang?" // указываем кодировку dsn += "&charset=utf8" // отказываемся от prapared statements // параметры подставляются сразу dsn += "&interpolateParams=true" db, err := gorm.Open("mysql", dsn) db.DB() db.DB().Ping() __err_panic(err) handlers := &Handler{ DB: db, Tmpl: template.Must(template.ParseGlob("templates/*")), } // в целям упрощения примера пропущена авторизация и csrf r := mux.NewRouter() r.HandleFunc("/", handlers.List).Methods("GET") r.HandleFunc("/items", handlers.List).Methods("GET") r.HandleFunc("/items/new", handlers.AddForm).Methods("GET") r.HandleFunc("/items/new", handlers.Add).Methods("POST") r.HandleFunc("/items/{id}", handlers.Edit).Methods("GET") r.HandleFunc("/items/{id}", handlers.Update).Methods("POST") r.HandleFunc("/items/{id}", handlers.Delete).Methods("DELETE") fmt.Println("starting server at :8080") fmt.Println(http.ListenAndServe(":8080", r)) } // не используйте такой код в прошакшене // ошибка должна всегда явно обрабатываться func __err_panic(err error) { if err != nil { panic(err) } } ================================================ FILE: 6-databases/05_gorm/templates/create.html ================================================

Edit item

================================================ FILE: 6-databases/05_gorm/templates/edit.html ================================================

Edit item

================================================ FILE: 6-databases/05_gorm/templates/index.html ================================================

Posts

# Title Edited New
{{.Id}} {{.Title}} {{if .Updated.Valid}}{{.Updated.String}}{{end}} Edit Del
{{range .Items}} {{end}} ================================================ FILE: 6-databases/06_crudapp_db_tests/cmd/crudapp/main.go ================================================ package main import ( "database/sql" "html/template" "log" "net/http" _ "github.com/go-sql-driver/mysql" _ "github.com/jackc/pgx/stdlib" "github.com/jmoiron/sqlx" "gorm.io/driver/mysql" "gorm.io/gorm" "github.com/go-park-mail-ru/lectures/6-databases/06_crudapp_db_tests/pkg/handlers" "github.com/go-park-mail-ru/lectures/6-databases/06_crudapp_db_tests/pkg/items" "github.com/go-park-mail-ru/lectures/6-databases/06_crudapp_db_tests/pkg/middleware" "github.com/go-park-mail-ru/lectures/6-databases/06_crudapp_db_tests/pkg/session" "github.com/go-park-mail-ru/lectures/6-databases/06_crudapp_db_tests/pkg/user" "github.com/gorilla/mux" "go.uber.org/zap" ) func getMysql() *sql.DB { dsn := "root:love@tcp(localhost:3306)/golang?&charset=utf8&interpolateParams=true" db, err := sql.Open("mysql", dsn) err = db.Ping() // вот тут будет первое подключение к базе if err != nil { log.Fatalln(err) } db.SetMaxOpenConns(10) return db } func getPostgres() *sql.DB { dsn := "user=postgres_user dbname=golang password=postgres_password host=127.0.0.1 port=5432 sslmode=disable" db, err := sql.Open("pgx", dsn) if err != nil { log.Fatalln("cant parse config", err) } err = db.Ping() // вот тут будет первое подключение к базе if err != nil { log.Fatalln(err) } db.SetMaxOpenConns(10) return db } // http://jmoiron.github.io/sqlx/ func getSqlx() *sqlx.DB { return sqlx.NewDb(getMysql(), "mysql") } // https://gorm.io/ func getGorm() *gorm.DB { db, err := gorm.Open(mysql.New(mysql.Config{ Conn: getMysql(), }), &gorm.Config{}) if err != nil { log.Fatalln(err) } return db } func main() { // ----- templates := template.Must(template.ParseGlob("./templates/*")) sm := session.NewSessionsMem() zapLogger, _ := zap.NewProduction() defer zapLogger.Sync() // flushes buffer, if any logger := zapLogger.Sugar() // dbMSSQL := sql.Open(...) userRepo := user.NewUserRepo() // itemsRepo := items.NewMysqlRepository(getMysql()) // itemsRepo := items.NewSqlxRepository(getSqlx()) itemsRepo := items.NewGormRepository(getGorm()) // itemsRepo := items.NewPgxRepository(getPostgres()) userHandler := &handlers.UserHandler{ Tmpl: templates, UserRepo: userRepo, Logger: logger, Sessions: sm, } handlers := &handlers.ItemsHandler{ Tmpl: templates, Logger: logger, ItemsRepo: itemsRepo, } r := mux.NewRouter() r.HandleFunc("/", userHandler.Index).Methods("GET") r.HandleFunc("/login", userHandler.Login).Methods("POST") r.HandleFunc("/logout", userHandler.Logout).Methods("POST") r.HandleFunc("/items", handlers.List).Methods("GET") r.HandleFunc("/items/new", handlers.AddForm).Methods("GET") r.HandleFunc("/items/new", handlers.Add).Methods("POST") r.HandleFunc("/items/{id}", handlers.Edit).Methods("GET") r.HandleFunc("/items/{id}", handlers.Update).Methods("POST") r.HandleFunc("/items/{id}", handlers.Delete).Methods("DELETE") mux := middleware.Auth(sm, r) mux = middleware.AccessLog(logger, mux) mux = middleware.Panic(mux) addr := ":8080" logger.Infow("starting server", "type", "START", "addr", addr, ) http.ListenAndServe(addr, mux) } ================================================ FILE: 6-databases/06_crudapp_db_tests/pkg/handlers/handler.html ================================================ handlers: Go Coverage Report
not tracked not covered covered
================================================ FILE: 6-databases/06_crudapp_db_tests/pkg/handlers/items.go ================================================ package handlers import ( "encoding/json" "html/template" "net/http" "strconv" "github.com/go-park-mail-ru/lectures/6-databases/06_crudapp_db_tests/pkg/items" "github.com/go-park-mail-ru/lectures/6-databases/06_crudapp_db_tests/pkg/session" "github.com/gorilla/mux" "github.com/gorilla/schema" "go.uber.org/zap" ) //go:generate mockgen -source=items.go -destination=items_mock.go -package=handlers ItemRepositoryInterface type ItemRepositoryInterface interface { GetAll() ([]*items.Item, error) GetByID(int64) (*items.Item, error) Add(*items.Item) (int64, error) Update(*items.Item) (int64, error) Delete(int64) (int64, error) } type ItemsHandler struct { Tmpl *template.Template ItemsRepo ItemRepositoryInterface Logger *zap.SugaredLogger } func (h *ItemsHandler) List(w http.ResponseWriter, r *http.Request) { elems, err := h.ItemsRepo.GetAll() if err != nil { h.Logger.Error("GetAll err", err) http.Error(w, `DB err`, http.StatusInternalServerError) return } err = h.Tmpl.ExecuteTemplate(w, "index.html", struct { Items []*items.Item }{ Items: elems, }) if err != nil { h.Logger.Error("ExecuteTemplate err", err) http.Error(w, `Template errror`, http.StatusInternalServerError) return } } func (h *ItemsHandler) AddForm(w http.ResponseWriter, r *http.Request) { err := h.Tmpl.ExecuteTemplate(w, "create.html", nil) if err != nil { h.Logger.Error("ExecuteTemplate err", err) http.Error(w, `Template errror`, http.StatusInternalServerError) return } } // type ItemsAddInput struct { // } func (h *ItemsHandler) Add(w http.ResponseWriter, r *http.Request) { r.ParseForm() item := new(items.Item) decoder := schema.NewDecoder() decoder.IgnoreUnknownKeys(true) err := decoder.Decode(item, r.PostForm) if err != nil { h.Logger.Error("Form err", err) http.Error(w, `Bad form`, http.StatusBadRequest) return } sess, _ := session.SessionFromContext(r.Context()) // item.UserID = sess.UserID lastID, err := h.ItemsRepo.Add(item) if err != nil { h.Logger.Error("Db err", err) http.Error(w, `DB err`, http.StatusInternalServerError) return } h.Logger.Infof("Insert with id LastInsertId: %v %v", lastID, sess) http.Redirect(w, r, "/", http.StatusFound) } func (h *ItemsHandler) Edit(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) id, err := strconv.Atoi(vars["id"]) if err != nil { http.Error(w, `{"error": "bad id"}`, http.StatusBadGateway) return } item, err := h.ItemsRepo.GetByID(int64(id)) if err != nil { h.Logger.Error("Db err", err) http.Error(w, `DB err`, http.StatusInternalServerError) return } if item == nil { http.Error(w, `no item`, http.StatusNotFound) return } err = h.Tmpl.ExecuteTemplate(w, "edit.html", item) if err != nil { h.Logger.Error("ExecuteTemplate err", err) http.Error(w, `Template errror`, http.StatusInternalServerError) return } } func (h *ItemsHandler) Update(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) id, err := strconv.Atoi(vars["id"]) if err != nil { http.Error(w, `Bad id`, http.StatusBadRequest) return } r.ParseForm() item := new(items.Item) decoder := schema.NewDecoder() decoder.IgnoreUnknownKeys(true) err = decoder.Decode(item, r.PostForm) if err != nil { h.Logger.Error("Form err", err) http.Error(w, `Bad form`, http.StatusBadRequest) return } item.ID = uint32(id) sess, _ := session.SessionFromContext(r.Context()) item.SetUpdated(sess.UserID) ok, err := h.ItemsRepo.Update(item) if err != nil { h.Logger.Error("Db err", err) http.Error(w, `db error`, http.StatusInternalServerError) return } h.Logger.Infof("update: %v %v", item, ok) http.Redirect(w, r, "/", http.StatusFound) } func (h *ItemsHandler) Delete(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) id, err := strconv.Atoi(vars["id"]) if err != nil { http.Error(w, `{"error": "bad id"}`, http.StatusBadGateway) return } affected, err := h.ItemsRepo.Delete(int64(id)) if err != nil { h.Logger.Error("Db err", err) http.Error(w, `{"error": "db error"}`, http.StatusInternalServerError) return } w.Header().Set("Content-type", "application/json") respJSON, _ := json.Marshal(map[string]int64{ "updated": affected, }) w.Write(respJSON) } ================================================ FILE: 6-databases/06_crudapp_db_tests/pkg/handlers/items_mock.go ================================================ // Code generated by MockGen. DO NOT EDIT. // Source: items.go // // Generated by this command: // // mockgen -source=items.go -destination=items_mock.go -package=handlers ItemRepositoryInterface // // Package handlers is a generated GoMock package. package handlers import ( reflect "reflect" items "github.com/go-park-mail-ru/lectures/6-databases/06_crudapp_db_tests/pkg/items" gomock "go.uber.org/mock/gomock" ) // MockItemRepositoryInterface is a mock of ItemRepositoryInterface interface. type MockItemRepositoryInterface struct { ctrl *gomock.Controller recorder *MockItemRepositoryInterfaceMockRecorder isgomock struct{} } // MockItemRepositoryInterfaceMockRecorder is the mock recorder for MockItemRepositoryInterface. type MockItemRepositoryInterfaceMockRecorder struct { mock *MockItemRepositoryInterface } // NewMockItemRepositoryInterface creates a new mock instance. func NewMockItemRepositoryInterface(ctrl *gomock.Controller) *MockItemRepositoryInterface { mock := &MockItemRepositoryInterface{ctrl: ctrl} mock.recorder = &MockItemRepositoryInterfaceMockRecorder{mock} return mock } // EXPECT returns an object that allows the caller to indicate expected use. func (m *MockItemRepositoryInterface) EXPECT() *MockItemRepositoryInterfaceMockRecorder { return m.recorder } // Add mocks base method. func (m *MockItemRepositoryInterface) Add(arg0 *items.Item) (int64, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Add", arg0) ret0, _ := ret[0].(int64) ret1, _ := ret[1].(error) return ret0, ret1 } // Add indicates an expected call of Add. func (mr *MockItemRepositoryInterfaceMockRecorder) Add(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Add", reflect.TypeOf((*MockItemRepositoryInterface)(nil).Add), arg0) } // Delete mocks base method. func (m *MockItemRepositoryInterface) Delete(arg0 int64) (int64, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Delete", arg0) ret0, _ := ret[0].(int64) ret1, _ := ret[1].(error) return ret0, ret1 } // Delete indicates an expected call of Delete. func (mr *MockItemRepositoryInterfaceMockRecorder) Delete(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockItemRepositoryInterface)(nil).Delete), arg0) } // GetAll mocks base method. func (m *MockItemRepositoryInterface) GetAll() ([]*items.Item, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAll") ret0, _ := ret[0].([]*items.Item) ret1, _ := ret[1].(error) return ret0, ret1 } // GetAll indicates an expected call of GetAll. func (mr *MockItemRepositoryInterfaceMockRecorder) GetAll() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAll", reflect.TypeOf((*MockItemRepositoryInterface)(nil).GetAll)) } // GetByID mocks base method. func (m *MockItemRepositoryInterface) GetByID(arg0 int64) (*items.Item, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetByID", arg0) ret0, _ := ret[0].(*items.Item) ret1, _ := ret[1].(error) return ret0, ret1 } // GetByID indicates an expected call of GetByID. func (mr *MockItemRepositoryInterfaceMockRecorder) GetByID(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByID", reflect.TypeOf((*MockItemRepositoryInterface)(nil).GetByID), arg0) } // Update mocks base method. func (m *MockItemRepositoryInterface) Update(arg0 *items.Item) (int64, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Update", arg0) ret0, _ := ret[0].(int64) ret1, _ := ret[1].(error) return ret0, ret1 } // Update indicates an expected call of Update. func (mr *MockItemRepositoryInterfaceMockRecorder) Update(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockItemRepositoryInterface)(nil).Update), arg0) } ================================================ FILE: 6-databases/06_crudapp_db_tests/pkg/handlers/items_test.go ================================================ package handlers import ( "bytes" "fmt" "html/template" "io/ioutil" "net/http/httptest" "testing" "github.com/go-park-mail-ru/lectures/6-databases/06_crudapp_db_tests/pkg/items" "go.uber.org/mock/gomock" "go.uber.org/zap" ) /* repo db -> mock handler repo -> mock */ func TestItemsHandlerList(t *testing.T) { // мы передаём t сюда, это надо чтобы получить корректное сообщение если тесты не пройдут ctrl := gomock.NewController(t) // Finish сравнит последовательсноть вызовов и выведет ошибку если последовательность другая defer ctrl.Finish() st := NewMockItemRepositoryInterface(ctrl) service := &ItemsHandler{ ItemsRepo: st, Logger: zap.NewNop().Sugar(), // не пишет логи Tmpl: template.Must(template.ParseGlob("../../templates/*")), } resultItems := []*items.Item{ {ID: 1, Title: "database/sql"}, } // тут мы записываем последовтаельность вызовов и результат st.EXPECT().GetAll().Return(resultItems, nil) req := httptest.NewRequest("GET", "/", nil) w := httptest.NewRecorder() service.List(w, req) resp := w.Result() body, _ := ioutil.ReadAll(resp.Body) img := `database/sql` if !bytes.Contains(body, []byte(img)) { t.Errorf("no text found") return } // GetPhotos error // тут мы записываем последовтаельность вызовов и результат st.EXPECT().GetAll().Return(nil, fmt.Errorf("no results")) req = httptest.NewRequest("GET", "/", nil) w = httptest.NewRecorder() service.List(w, req) resp = w.Result() if resp.StatusCode != 500 { t.Errorf("expected resp status 500, got %d", resp.StatusCode) return } // template expand error service.Tmpl, _ = template.New("tmplError").Parse("{{.NotExist}}") st.EXPECT().GetAll().Return(resultItems, nil) req = httptest.NewRequest("GET", "/", nil) w = httptest.NewRecorder() service.List(w, req) resp = w.Result() if resp.StatusCode != 500 { t.Errorf("expected resp status 500, got %d", resp.StatusCode) return } } ================================================ FILE: 6-databases/06_crudapp_db_tests/pkg/handlers/user.go ================================================ package handlers import ( "html/template" "net/http" "github.com/go-park-mail-ru/lectures/6-databases/06_crudapp_db_tests/pkg/session" "github.com/go-park-mail-ru/lectures/6-databases/06_crudapp_db_tests/pkg/user" "go.uber.org/zap" ) type UserHandler struct { Tmpl *template.Template Logger *zap.SugaredLogger UserRepo *user.UserRepo Sessions *session.SessionsManager } func (h *UserHandler) Index(w http.ResponseWriter, r *http.Request) { _, err := session.SessionFromContext(r.Context()) if err == nil { http.Redirect(w, r, "/items", 302) return } err = h.Tmpl.ExecuteTemplate(w, "login.html", nil) if err != nil { http.Error(w, `Template errror`, http.StatusInternalServerError) return } } func (h *UserHandler) Login(w http.ResponseWriter, r *http.Request) { u, err := h.UserRepo.Authorize(r.FormValue("login"), r.FormValue("password")) if err == user.ErrNoUser { http.Error(w, `no user`, http.StatusBadRequest) return } if err == user.ErrBadPass { http.Error(w, `bad pass`, http.StatusBadRequest) return } sess, _ := h.Sessions.Create(w, u.ID) h.Logger.Infof("created session for %v", sess.UserID) http.Redirect(w, r, "/", 302) } func (h *UserHandler) Logout(w http.ResponseWriter, r *http.Request) { h.Sessions.DestroyCurrent(w, r) http.Redirect(w, r, "/", 302) } ================================================ FILE: 6-databases/06_crudapp_db_tests/pkg/items/item.go ================================================ package items import ( "database/sql" "fmt" "strconv" "gorm.io/gorm" ) type ItemZero struct { ID uint32 Title string Description string Updated sql.NullString } type Item struct { ID uint32 `sql:"AUTO_INCREMENT" gorm:"primary_key"` Title string Description string Updated sql.NullString `sql:"null"` } // позволяет items handlers не импортировать sql func (it *Item) SetUpdated(val uint32) { it.Updated = sql.NullString{String: strconv.Itoa(int(val))} } /* https://gorm.io/docs/models.html */ func (i *Item) TableName() string { return "items" } func (i *Item) BeforeSave(*gorm.DB) (err error) { fmt.Println("trigger on before save") return } type Item0 struct { gorm.Model ID uint32 `sql:"AUTO_INCREMENT" gorm:"primary_key"` Title string Description string Updated string `sql:"null"` } ================================================ FILE: 6-databases/06_crudapp_db_tests/pkg/items/item_repo_test.go ================================================ package items import ( "database/sql" "fmt" "reflect" "testing" sqlmock "github.com/DATA-DOG/go-sqlmock" ) // go test -coverprofile=cover.out && go tool cover -html=cover.out -o cover.html /* handlers repo -> mock repo db -> mock */ func TestGetByID(t *testing.T) { db, mock, err := sqlmock.New() if err != nil { t.Fatalf("cant create mock: %s", err) } defer db.Close() repo := &RepoMysql{ DB: db, } var elemID int64 = 1 // good query rows := sqlmock. NewRows([]string{"id", "title", "updated", "description"}) expect := []*Item{ {uint32(elemID), "title", "desct", sql.NullString{}}, } for _, item := range expect { rows = rows.AddRow(item.ID, item.Title, nil, item.Description) } mock. ExpectQuery("SELECT id, title, updated, description"). WithArgs(elemID). WillReturnRows(rows) item, err := repo.GetByID(elemID) if err != nil { t.Errorf("unexpected err: %s", err) return } if err := mock.ExpectationsWereMet(); err != nil { t.Errorf("there were unfulfilled expectations: %s", err) return } if !reflect.DeepEqual(item, expect[0]) { t.Errorf("results not match, want %v, have %v", expect[0], item) return } // query error mock. ExpectQuery("SELECT id, title, updated, description FROM items WHERE"). WithArgs(elemID). WillReturnError(fmt.Errorf("db_error")) _, err = repo.GetByID(elemID) if err := mock.ExpectationsWereMet(); err != nil { t.Errorf("there were unfulfilled expectations: %s", err) return } if err == nil { t.Errorf("expected error, got nil") return } // row scan error rows = sqlmock.NewRows([]string{"id", "title"}). AddRow(1, "title") mock. ExpectQuery("SELECT id, title, updated, description FROM items WHERE"). WithArgs(elemID). WillReturnRows(rows) _, err = repo.GetByID(elemID) if err := mock.ExpectationsWereMet(); err != nil { t.Errorf("there were unfulfilled expectations: %s", err) return } if err == nil { t.Errorf("expected error, got nil") return } } func TestCreate(t *testing.T) { db, mock, err := sqlmock.New() if err != nil { t.Fatalf("cant create mock: %s", err) } defer db.Close() repo := &RepoMysql{ DB: db, } title := "title" descr := "description" testItem := &Item{ Title: title, Description: descr, } //ok query mock. ExpectExec(`INSERT INTO items`). WithArgs(title, descr). WillReturnResult(sqlmock.NewResult(1, 1)) id, err := repo.Add(testItem) if err != nil { t.Errorf("unexpected err: %s", err) return } if id != 1 { t.Errorf("bad id: want %v, have %v", id, 1) return } if err := mock.ExpectationsWereMet(); err != nil { t.Errorf("there were unfulfilled expectations: %s", err) } // query error mock. ExpectExec(`INSERT INTO items`). WithArgs(title, descr). WillReturnError(fmt.Errorf("bad query")) // mock.ExpectClose() _, err = repo.Add(testItem) if err == nil { t.Errorf("expected error, got nil") return } if err := mock.ExpectationsWereMet(); err != nil { t.Errorf("there were unfulfilled expectations: %s", err) } // result error mock. ExpectExec(`INSERT INTO items`). WithArgs(title, descr). WillReturnResult(sqlmock.NewErrorResult(fmt.Errorf("bad_result"))) _, err = repo.Add(testItem) if err == nil { t.Errorf("expected error, got nil") return } if err := mock.ExpectationsWereMet(); err != nil { t.Errorf("there were unfulfilled expectations: %s", err) } // // last id error // mock. // ExpectExec(`INSERT INTO items`). // WithArgs(title, descr). // WillReturnResult(sqlmock.NewResult(0, 0)) // _, err = repo.Add(testItem) // if err == nil { // t.Errorf("expected error, got nil") // return // } // if err := mock.ExpectationsWereMet(); err != nil { // t.Errorf("there were unfulfilled expectations: %s", err) // } } ================================================ FILE: 6-databases/06_crudapp_db_tests/pkg/items/repo_gorm.go ================================================ package items import ( "log" "gorm.io/gorm" ) type RepoGorm struct { DB *gorm.DB } func NewGormRepository(db *gorm.DB) *RepoGorm { return &RepoGorm{DB: db} } func (repo *RepoGorm) GetAll() ([]*Item, error) { // https://gorm.io/docs/query.html items := make([]*Item, 0, 10) err := repo.DB.Find(&items).Error if err != nil { return nil, err } return items, nil } func (repo *RepoGorm) GetByID(id int64) (*Item, error) { post := &Item{} err := repo.DB.First(&post, "id = ?", id).Error if err != nil { return nil, err } return post, nil } func (repo *RepoGorm) Add(elem *Item) (int64, error) { err := repo.DB.Create(elem).Error log.Println("created elem id:", elem.ID) if err != nil { return 0, err } return int64(elem.ID), nil } func (repo *RepoGorm) Update(elem *Item) (int64, error) { res := repo.DB.Model(&elem).Updates(map[string]interface{}{ "title": elem.Title, "description": elem.Description, "updated": "rvasily", }) if res.Error != nil { return 0, res.Error } return res.RowsAffected, nil } func (repo *RepoGorm) Delete(id int64) (int64, error) { res := repo.DB.Delete(&Item{}, id) if res.Error != nil { return 0, res.Error } return res.RowsAffected, nil } ================================================ FILE: 6-databases/06_crudapp_db_tests/pkg/items/repo_mysql.go ================================================ package items import ( "database/sql" ) type RepoMysql struct { DB *sql.DB } func NewMysqlRepository(db *sql.DB) *RepoMysql { return &RepoMysql{DB: db} } func (repo *RepoMysql) GetAll(limit int) ([]*Item, error) { items := make([]*Item, 0, limit) rows, err := repo.DB.Query("SELECT id, title, updated FROM items") if err != nil { return nil, err } defer rows.Close() // надо закрывать соединение, иначе будет течь for rows.Next() { post := &Item{} err = rows.Scan(&post.ID, &post.Title, &post.Updated) if err != nil { return nil, err } items = append(items, post) } return items, nil } /* dsn += "&interpolateParams=false" (или нет параметра) QueryRow("SELECT * FROM items WHERE id = ?", id). -> smtp := db.PrepareStatement("SELECT * FROM items WHERE id = ?") row := smtp.Execute(smtp, 1) dsn += "&interpolateParams=true" smtp := db.QueryRaw("SELECT * FROM items WHERE id = 1") params := make([]string, 0, len(manyIds)) values := make([]interface{}, 0, len(manyIds)) for _, val := manyIds { params = append(params, "?") values = append(values, val) } q := fmt.Sprintf(`where id in(%s)`, string.Join(params, `,`)) db.Query(q, values...) */ func (repo *RepoMysql) GetByID(id int64) (*Item, error) { post := &Item{} // QueryRow сам закрывает коннект err := repo.DB. QueryRow(`SELECT id, title, updated, description FROM items WHERE id = ?`, id). Scan(&post.ID, &post.Title, &post.Updated, &post.Description) // если запись не найден - вернется sql.ErrNoRows if err != nil { return nil, err } return post, nil } func (repo *RepoMysql) Add(elem *Item) (int64, error) { result, err := repo.DB.Exec( "INSERT INTO items (`title`, `description`) VALUES (?, ?)", elem.Title, elem.Description, ) if err != nil { return 0, err } return result.LastInsertId() } func (repo *RepoMysql) Update(elem *Item) (int64, error) { result, err := repo.DB.Exec( "UPDATE items SET"+ "`title` = ?"+ ",`description` = ?"+ ",`updated` = ?"+ "WHERE id = ?", elem.Title, elem.Description, "rvasily", elem.ID, ) if err != nil { return 0, err } return result.RowsAffected() } func (repo *RepoMysql) Delete(id int64) (int64, error) { result, err := repo.DB.Exec( "DELETE FROM items WHERE id = ?", id, ) if err != nil { return 0, err } return result.RowsAffected() } ================================================ FILE: 6-databases/06_crudapp_db_tests/pkg/items/repo_pgx.go ================================================ package items import ( "database/sql" ) type RepoPgx struct { DB *sql.DB } func NewPgxRepository(db *sql.DB) *RepoPgx { return &RepoPgx{DB: db} } func (repo *RepoPgx) GetAll() ([]*Item, error) { items := []*Item{} rows, err := repo.DB.Query("SELECT id, title, updated FROM items") if err != nil { return nil, err } defer rows.Close() // надо закрывать соединение, иначе будет течь for rows.Next() { post := &Item{} err = rows.Scan(&post.ID, &post.Title, &post.Updated) if err != nil { return nil, err } items = append(items, post) } /* func tx(db *sq.DB, fb func(tx *sql.Tx) error) error { tx := repo.DB.Begin() err := fb(tx) if err != nil { tx.Rollback() return err } tx.Commit() return nil } tx(repo.DB, func(tx *sql.Tx) error { tx.Query("select") if err != nil { return err } tx.Exec("update") return nil }) */ return items, nil } func (repo *RepoPgx) GetByID(id int64) (*Item, error) { post := &Item{} // QueryRow сам закрывает коннект err := repo.DB. QueryRow(`SELECT id, title, updated, description FROM items WHERE id = $1`, id). Scan(&post.ID, &post.Title, &post.Updated, &post.Description) if err != nil { return nil, err } return post, nil } func (repo *RepoPgx) Add(elem *Item) (int64, error) { var lastInsertId int64 err := repo.DB.QueryRow( `INSERT INTO items ("title", "description") VALUES ($1, $2) RETURNING id`, elem.Title, elem.Description, ).Scan(&lastInsertId) if err != nil { return 0, err } return lastInsertId, nil } func (repo *RepoPgx) Update(elem *Item) (int64, error) { result, err := repo.DB.Exec( `UPDATE items SET "title" = $1`+ `,"description" = $2`+ `,"updated" = $3`+ `WHERE id = $4`, elem.Title, elem.Description, "rvasily", elem.ID, ) if err != nil { return 0, err } return result.RowsAffected() } func (repo *RepoPgx) Delete(id int64) (int64, error) { result, err := repo.DB.Exec( "DELETE FROM items WHERE id = $1", id, ) if err != nil { return 0, err } return result.RowsAffected() } ================================================ FILE: 6-databases/06_crudapp_db_tests/pkg/items/repo_sqlx.go ================================================ package items import ( // "database/sql" "github.com/jmoiron/sqlx" ) type RepoSqlx struct { DB *sqlx.DB } func NewSqlxRepository(db *sqlx.DB) *RepoSqlx { return &RepoSqlx{DB: db} } func (repo *RepoSqlx) GetAll() ([]*Item, error) { items := make([]*Item, 0, 10) err := repo.DB.Select(&items, "SELECT id, title, updated FROM items") if err != nil { return nil, err } return items, nil } func (repo *RepoSqlx) GetAll_0() ([]*Item, error) { items := make([]*Item, 0, 10) rows, err := repo.DB.Queryx("SELECT id, title, updated FROM items") if err != nil { return nil, err } for rows.Next() { item := &Item{} // MapScan, SliceScan err := rows.StructScan(&item) if err != nil { return nil, err } items = append(items, item) } return items, nil } func (repo *RepoSqlx) GetByID(id int64) (*Item, error) { post := &Item{} err := repo.DB.Get(post, `SELECT id, title, updated, description FROM items WHERE id = ?`, id) if err != nil { return nil, err } return post, nil } func (repo *RepoSqlx) Add(elem *Item) (int64, error) { result, err := repo.DB.NamedExec( `INSERT INTO person (first_name,last_name,email) VALUES (:title, :description)`, map[string]interface{}{ "title": elem.Title, "description": elem.Description, }) if err != nil { return 0, err } return result.LastInsertId() } func (repo *RepoSqlx) Update(elem *Item) (int64, error) { result, err := repo.DB.Exec( "UPDATE items SET"+ "`title` = ?"+ ",`description` = ?"+ ",`updated` = ?"+ "WHERE id = ?", elem.Title, elem.Description, "rvasily", elem.ID, ) if err != nil { return 0, err } return result.RowsAffected() } func (repo *RepoSqlx) Delete(id int64) (int64, error) { result, err := repo.DB.Exec( "DELETE FROM items WHERE id = ?", id, ) if err != nil { return 0, err } return result.RowsAffected() } ================================================ FILE: 6-databases/06_crudapp_db_tests/pkg/middleware/accesslog.go ================================================ package middleware import ( // "fmt" "net/http" "time" "go.uber.org/zap" ) func AccessLog(logger *zap.SugaredLogger, next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // fmt.Println("access log middleware") start := time.Now() next.ServeHTTP(w, r) logger.Infow("New request", "method", r.Method, "remote_addr", r.RemoteAddr, "url", r.URL.Path, "time", time.Since(start), ) }) } ================================================ FILE: 6-databases/06_crudapp_db_tests/pkg/middleware/auth.go ================================================ package middleware import ( "context" // "fmt" "net/http" "github.com/go-park-mail-ru/lectures/6-databases/06_crudapp_db_tests/pkg/session" ) var ( noAuthUrls = map[string]struct{}{ "/login": struct{}{}, } noSessUrls = map[string]struct{}{ "/": struct{}{}, } ) func Auth(sm *session.SessionsManager, next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // fmt.Println("auth middleware") if _, ok := noAuthUrls[r.URL.Path]; ok { next.ServeHTTP(w, r) return } sess, err := sm.Check(r) _, canbeWithouthSess := noSessUrls[r.URL.Path] if err != nil && !canbeWithouthSess { // fmt.Println("no auth") http.Redirect(w, r, "/", 302) return } ctx := context.WithValue(r.Context(), session.SessionKey, sess) next.ServeHTTP(w, r.WithContext(ctx)) }) } ================================================ FILE: 6-databases/06_crudapp_db_tests/pkg/middleware/panic.go ================================================ package middleware import ( "net/http" ) func Panic(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // fmt.Println("panicMiddleware", r.URL.Path) defer func() { if err := recover(); err != nil { // fmt.Println("recovered", err) http.Error(w, "Internal server error", 500) } }() next.ServeHTTP(w, r) }) } ================================================ FILE: 6-databases/06_crudapp_db_tests/pkg/session/manager.go ================================================ package session import ( "net/http" "sync" "time" ) type SessionsManager struct { data map[string]*Session mu *sync.RWMutex } func NewSessionsMem() *SessionsManager { return &SessionsManager{ data: make(map[string]*Session, 10), mu: &sync.RWMutex{}, } } func (sm *SessionsManager) Check(r *http.Request) (*Session, error) { sessionCookie, err := r.Cookie("session_id") if err == http.ErrNoCookie { return nil, ErrNoAuth } sm.mu.RLock() sess, ok := sm.data[sessionCookie.Value] sm.mu.RUnlock() if !ok { return nil, ErrNoAuth } return sess, nil } func (sm *SessionsManager) Create(w http.ResponseWriter, userID uint32) (*Session, error) { sess := NewSession(userID) sm.mu.Lock() sm.data[sess.ID] = sess sm.mu.Unlock() cookie := &http.Cookie{ Name: "session_id", Value: sess.ID, Expires: time.Now().Add(90 * 24 * time.Hour), Path: "/", } http.SetCookie(w, cookie) return sess, nil } func (sm *SessionsManager) DestroyCurrent(w http.ResponseWriter, r *http.Request) error { sess, err := SessionFromContext(r.Context()) if err != nil { return err } sm.mu.Lock() delete(sm.data, sess.ID) sm.mu.Unlock() cookie := http.Cookie{ Name: "session_id", Expires: time.Now().AddDate(0, 0, -1), Path: "/", } http.SetCookie(w, &cookie) return nil } ================================================ FILE: 6-databases/06_crudapp_db_tests/pkg/session/session.go ================================================ package session import ( "context" "crypto/rand" "errors" "fmt" ) type Session struct { ID string UserID uint32 } func NewSession(userID uint32) *Session { // лучше генерировать из заданного алфавита, но так писать меньше и для учебного примера ОК randID := make([]byte, 16) rand.Read(randID) return &Session{ ID: fmt.Sprintf("%x", randID), UserID: userID, } } var ( ErrNoAuth = errors.New("No session found") ) type sessKey string var SessionKey sessKey = "sessionKey" func SessionFromContext(ctx context.Context) (*Session, error) { sess, ok := ctx.Value(SessionKey).(*Session) if !ok || sess == nil { return nil, ErrNoAuth } return sess, nil } ================================================ FILE: 6-databases/06_crudapp_db_tests/pkg/user/user.go ================================================ package user import "errors" type User struct { ID uint32 Login string password string } type UserRepo struct { data map[string]*User } func NewUserRepo() *UserRepo { return &UserRepo{ data: map[string]*User{ "rvasily": &User{ ID: 1, Login: "rvasily", password: "love", }, }, } } var ( ErrNoUser = errors.New("No user found") ErrBadPass = errors.New("Invald password") ) func (repo *UserRepo) Authorize(login, pass string) (*User, error) { u, ok := repo.data[login] if !ok { return nil, ErrNoUser } // dont do this un production :) if u.password != pass { return nil, ErrBadPass } return u, nil } ================================================ FILE: 6-databases/06_crudapp_db_tests/readme.md ================================================ go mod init crudapp # go mod init github.com/rvasily/crudapp go build go mod download go mod verify go mod tidy go build -o ./bin/crudapp ./cmd/crudapp go test -v -coverpkg=./... ./... go mod vendor go build -mod=vendor -o ./bin/myapp ./cmd/myapp go test -v -mod=vendor -coverpkg=./... ./... ---- docker-compose up go test -v -coverprofile=cover.out -coverpkg=./... ./... go tool cover -html=cover.out -o cover.html ----- находять в папке pkg/handlers mockgen -source=items.go -destination=items_mock.go -package=handlers ItemRepositoryInterface go test -v -run Handler -coverprofile=handler.out && go tool cover -html=handler.out -o handler.html && rm handler.out ================================================ FILE: 6-databases/06_crudapp_db_tests/templates/create.html ================================================

Edit item

================================================ FILE: 6-databases/06_crudapp_db_tests/templates/edit.html ================================================

Edit item

{{if .Updated.Valid}}
{{end}}
================================================ FILE: 6-databases/06_crudapp_db_tests/templates/index.html ================================================

Posts

# Title Edited New
{{.Id}} {{.Title}} {{.Updated}} Edit Del
{{range .Items}} {{end}} ================================================ FILE: 6-databases/06_crudapp_db_tests/templates/login.html ================================================

CrudAPP login

================================================ FILE: 6-databases/07_mongodb/main.go ================================================ package main import ( "context" "fmt" "html/template" "net/http" "strconv" // https://www.mongodb.com/blog/post/quick-start-golang--mongodb--modeling-documents-with-go-data-structures "github.com/gorilla/mux" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" ) type Item struct { Id primitive.ObjectID `json:"id" bson:"_id"` Title string `json:"title" bson:"title"` Description string `json:"description" bson:"description"` Updated string `json:"updated" bson:"updated"` } type Handler struct { Sess *mongo.Client Items *mongo.Collection Tmpl *template.Template } func (h *Handler) List(w http.ResponseWriter, r *http.Request) { items := []*Item{} // bson.M{} - это типа условия для поиска c, err := h.Items.Find(r.Context(), bson.M{}) panicOnError(err) err = c.All(r.Context(), &items) panicOnError(err) err = h.Tmpl.ExecuteTemplate(w, "index.html", struct { Items []*Item }{ Items: items, }) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } } func (h *Handler) AddForm(w http.ResponseWriter, r *http.Request) { err := h.Tmpl.ExecuteTemplate(w, "create.html", nil) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } } func (h *Handler) Add(w http.ResponseWriter, r *http.Request) { newItem := bson.M{ "_id": primitive.NewObjectID(), "title": r.FormValue("title"), "description": r.FormValue("description"), "some_filed": 123, } _, err := h.Items.InsertOne(r.Context(), newItem) panicOnError(err) fmt.Println("Insert - LastInsertId:", newItem["_id"]) http.Redirect(w, r, "/", http.StatusFound) } func (h *Handler) Edit(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) if !primitive.IsValidObjectID(vars["id"]) { http.Error(w, "bad id", 500) return } id, err := primitive.ObjectIDFromHex(vars["id"]) if err != nil { http.Error(w, err.Error(), 500) return } post := &Item{} err = h.Items.FindOne(r.Context(), bson.M{"_id": id}).Decode(post) panicOnError(err) err = h.Tmpl.ExecuteTemplate(w, "edit.html", post) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } } func (h *Handler) Update(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) if !primitive.IsValidObjectID(vars["id"]) { http.Error(w, "bad id", 500) return } id, err := primitive.ObjectIDFromHex(vars["id"]) if err != nil { http.Error(w, err.Error(), 500) return } post := &Item{} err = h.Items.FindOne(r.Context(), bson.M{"_id": id}).Decode(&post) panicOnError(err) post.Title = r.FormValue("title") post.Description = r.FormValue("description") post.Updated = "rvasily" res, err := h.Items.UpdateOne( r.Context(), bson.M{"_id": id}, // про другие операторы помимо $set можно почитать тут // https://www.mongodb.com/docs/manual/reference/operator/update/ bson.M{"$set": bson.M{ "title": r.FormValue("title"), "description": r.FormValue("description"), "updated": "rvasily", "newField": 123, }}, ) affected := 1 if err != nil { panicOnError(err) } else if res.ModifiedCount == 0 { affected = 0 } fmt.Println("Update - RowsAffected", affected) http.Redirect(w, r, "/", http.StatusFound) } func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) if !primitive.IsValidObjectID(vars["id"]) { http.Error(w, "bad id", 500) return } id, err := primitive.ObjectIDFromHex(vars["id"]) if err != nil { http.Error(w, err.Error(), 500) return } res, err := h.Items.DeleteOne(r.Context(), bson.M{"_id": id}) affected := 1 if err != nil { panicOnError(err) } else if res.DeletedCount == 0 { affected = 0 } w.Header().Set("Content-type", "application/json") resp := `{"affected": ` + strconv.Itoa(int(affected)) + `}` w.Write([]byte(resp)) } func main() { ctx := context.Background() sess, err := mongo.Connect(ctx, options.Client().ApplyURI("mongodb://localhost")) panicOnError(err) collection := sess.Database("golang").Collection("items") // если коллекции не будет, то она создасться автоматически // для монги нет такого красивого дампа SQL, так что я вставляю демо-запись если коллекция пуста if n, _ := collection.CountDocuments(ctx, bson.M{}); n == 0 { collection.InsertOne(ctx, &Item{ Id: primitive.NewObjectID(), Title: "mongodb", Description: "Рассказать про монгу", Updated: "", }) collection.InsertOne(ctx, &Item{ Id: primitive.NewObjectID(), Title: "redis", Description: "Рассказать про redis", Updated: "rvasily", }) } handlers := &Handler{ Items: collection, Tmpl: template.Must(template.ParseGlob("./templates/*")), } // В целях упрощения примера пропущена авторизация и csrf r := mux.NewRouter() r.HandleFunc("/", handlers.List).Methods("GET") r.HandleFunc("/items", handlers.List).Methods("GET") r.HandleFunc("/items/new", handlers.AddForm).Methods("GET") r.HandleFunc("/items/new", handlers.Add).Methods("POST") r.HandleFunc("/items/{id}", handlers.Edit).Methods("GET") r.HandleFunc("/items/{id}", handlers.Update).Methods("POST") r.HandleFunc("/items/{id}", handlers.Delete).Methods("DELETE") fmt.Println("starting server at :8080") err = http.ListenAndServe(":8080", r) panicOnError(err) } // Не используйте такой код в продакшене. // Ошибка должна всегда явно обрабатываться func panicOnError(err error) { if err != nil { panic(err) } } ================================================ FILE: 6-databases/07_mongodb/templates/create.html ================================================

Edit item

================================================ FILE: 6-databases/07_mongodb/templates/edit.html ================================================

Edit item

================================================ FILE: 6-databases/07_mongodb/templates/index.html ================================================

Posts

# Title Updated New
{{.ID}} {{.Title}} {{if .Updated.Valid}}{{.Updated.String}}{{end}} Edit Del
{{range .Items}} {{end}} ================================================ FILE: 6-databases/08_memcache/memcache.go ================================================ package main import ( "errors" "fmt" "github.com/bradfitz/gomemcache/memcache" ) func main() { MemcachedAddresses := []string{"127.0.0.1:11211"} memcacheClient := memcache.New(MemcachedAddresses...) mkey := "tech" memcacheClient.Set(&memcache.Item{ Key: mkey, Value: []byte("1"), Expiration: 3, }) memcacheClient.Increment("habrTag", 1) item, err := memcacheClient.Get(mkey) if err != nil && !errors.Is(err, memcache.ErrCacheMiss) { fmt.Println("MC error", err) } fmt.Printf("mc value %#v\n", item) memcacheClient.Delete(mkey) item, err = memcacheClient.Get(mkey) if errors.Is(err, memcache.ErrCacheMiss) { fmt.Println("record not found in MC") } } ================================================ FILE: 6-databases/09_redis_simple/cmds.go ================================================ package main import ( "errors" "fmt" "time" "github.com/gomodule/redigo/redis" ) var ( c redis.Conn ) func getRecord(mkey string) (string, error) { println("get", mkey) // получает запись, https://redis.io/commands/get data, err := c.Do("GET", mkey) item, err := redis.String(data, err) // если записи нет, то для этого есть специальная ошибка, её надо обрабатывать отдеьно, это почти штатная ситуация, а не что-то страшное if errors.Is(err, redis.ErrNil) { fmt.Println("Record not found in redis (return value is nil)") return "", redis.ErrNil } else if err != nil { return "", err } return item, nil } func main() { var err error // соединение c, err = redis.DialURL("redis://user:@localhost:6379/0") // c, err = redis.DialURL(os.Getenv("REDIS_URL")) PanicOnErr(err) defer c.Close() mkey := "record_21" item, err := getRecord(mkey) fmt.Printf("first get %+v\n", item) ttl := 5 // добавляет запись, https://redis.io/commands/set result, err := redis.String(c.Do("SET", mkey, 1, "EX", ttl)) PanicOnErr(err) if result != "OK" { panic("result not ok: " + result) } time.Sleep(time.Microsecond) // time.Sleep(7 * time.Second) item, err = getRecord(mkey) if err != nil { PanicOnErr(err) } fmt.Printf("second get %+v\n", item) // https://redis.io/commands/incrby // https://redis.io/commands/incr - тут хорошо описан рейтилимитер n, _ := redis.Int(c.Do("INCRBY", mkey, 2)) fmt.Println("INCRBY by 2 ", mkey, "is", n) // https://redis.io/commands/decrby n, _ = redis.Int(c.Do("DECRBY", mkey, 1)) fmt.Println("DECRY by 1 ", mkey, "is", n) // если записи не было - редис создаст n, err = redis.Int(c.Do("INCR", mkey+"_not_exist")) fmt.Println("INCR (default by 1) ", mkey+"_not_exist", "is", n) PanicOnErr(err) keys := []interface{}{mkey, mkey + "_not_exist", "sure_not_exist"} // https://redis.io/commands/mget reply, err := redis.Strings(c.Do("MGET", keys...)) PanicOnErr(err) fmt.Println(reply) } // PanicOnErr panics on error func PanicOnErr(err error) { if err != nil { panic(err) } } ================================================ FILE: 6-databases/10_redis/main.go ================================================ package main import ( "errors" "flag" "fmt" "log" "net/http" "time" "github.com/gomodule/redigo/redis" ) var ( redisAddr = flag.String("addr", "redis://user:@localhost:6379/0", "redis addr") sessManager *SessionManager users = map[string]string{ "dmitrydorofeev": "test", "romanov.vasily": "100500", } ) func checkSession(r *http.Request) (*Session, error) { cookieSessionID, err := r.Cookie("session_id") if errors.Is(err, http.ErrNoCookie) { return nil, nil } else if err != nil { return nil, err } sess := sessManager.Check(&SessionID{ ID: cookieSessionID.Value, }) return sess, nil } func innerPage(w http.ResponseWriter, r *http.Request) { sess, err := checkSession(r) if err != nil { w.WriteHeader(http.StatusInternalServerError) return } if sess == nil { w.Write(loginFormTmpl) return } w.Header().Set("Content-Type", "text/html") fmt.Fprintln(w, "Welcome, "+sess.Login+"
") fmt.Fprintln(w, "Session ua: "+sess.Useragent+"
") fmt.Fprintln(w, `logout`) } func loginPage(w http.ResponseWriter, r *http.Request) { inputLogin := r.FormValue("login") inputPass := r.FormValue("password") expiration := time.Now().Add(24 * time.Hour) pass, exist := users[inputLogin] if !exist || pass != inputPass { w.WriteHeader(http.StatusUnauthorized) return } sess, err := sessManager.Create(&Session{ Login: inputLogin, Useragent: r.UserAgent(), }) if err != nil { log.Println("cant create session:", err) w.WriteHeader(http.StatusInternalServerError) return } cookie := http.Cookie{ Name: "session_id", Value: sess.ID, Expires: expiration, } http.SetCookie(w, &cookie) http.Redirect(w, r, "/", http.StatusFound) } func main() { flag.Parse() var err error redisConn, err := redis.DialURL(*redisAddr) if err != nil { log.Fatalf("cant connect to redis") } sessManager = NewSessionManager(redisConn) http.HandleFunc("/", innerPage) http.HandleFunc("/login", loginPage) http.HandleFunc("/logout", logoutPage) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } func logoutPage(w http.ResponseWriter, r *http.Request) { session, err := r.Cookie("session_id") if errors.Is(err, http.ErrNoCookie) { http.Redirect(w, r, "/", http.StatusFound) return } else if err != nil { w.WriteHeader(http.StatusInternalServerError) return } sessManager.Delete(&SessionID{ ID: session.Value, }) session.Expires = time.Now().AddDate(0, 0, -1) http.SetCookie(w, session) http.Redirect(w, r, "/", http.StatusFound) } var loginFormTmpl = []byte(` Login: Password: `) ================================================ FILE: 6-databases/10_redis/session.go ================================================ package main import ( "encoding/json" "fmt" "log" "math/rand" "github.com/gomodule/redigo/redis" ) type Session struct { Login string Useragent string } type SessionID struct { ID string } const sessKeyLen = 10 type SessionManager struct { redisConn redis.Conn } func NewSessionManager(conn redis.Conn) *SessionManager { return &SessionManager{ redisConn: conn, } } func (sm *SessionManager) Create(in *Session) (*SessionID, error) { id := SessionID{RandStringRunes(sessKeyLen)} dataSerialized, _ := json.Marshal(in) mkey := "sessions:" + id.ID result, err := redis.String(sm.redisConn.Do("SET", mkey, dataSerialized, "EX", 86400)) if err != nil { return nil, err } if result != "OK" { return nil, fmt.Errorf("result not OK") } return &id, nil } func (sm *SessionManager) Check(in *SessionID) *Session { mkey := "sessions:" + in.ID data, err := redis.Bytes(sm.redisConn.Do("GET", mkey)) if err != nil { log.Println("cant get data:", err) return nil } sess := &Session{} err = json.Unmarshal(data, sess) if err != nil { log.Println("cant unpack session data:", err) return nil } return sess } func (sm *SessionManager) Delete(in *SessionID) { mkey := "sessions:" + in.ID _, err := redis.Int(sm.redisConn.Do("DEL", mkey)) if err != nil { log.Println("redis error:", err) } } var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") func RandStringRunes(n int) string { b := make([]rune, n) for i := range b { b[i] = letterRunes[rand.Intn(len(letterRunes))] } return string(b) } ================================================ FILE: 6-databases/11_rabbit/form/form.go ================================================ package main import ( "crypto/md5" "encoding/hex" "encoding/json" "flag" "fmt" "io" "math/rand" "net/http" "os" "github.com/streadway/amqp" ) var uploadFormTmpl = []byte(` Image: `) type ImgResizeTask struct { Name string MD5 string } func mainPage(w http.ResponseWriter, r *http.Request) { w.Write(uploadFormTmpl) } func uploadPage(w http.ResponseWriter, r *http.Request) { uploadData, handler, err := r.FormFile("my_file") if err != nil { fmt.Println(err) return } defer uploadData.Close() fmt.Fprintf(w, "handler.Filename %v\n", handler.Filename) fmt.Fprintf(w, "handler.Header %#v\n", handler.Header) tmpName := RandStringRunes(32) tmpFile := "./images/" + tmpName + ".jpg" newFile, err := os.Create(tmpFile) if err != nil { http.Error(w, "cant open file: "+err.Error(), http.StatusInternalServerError) return } hasher := md5.New() writtenBytes, err := io.Copy(newFile, io.TeeReader(uploadData, hasher)) if err != nil { http.Error(w, "cant save file: "+err.Error(), http.StatusInternalServerError) return } newFile.Sync() newFile.Close() md5Sum := hex.EncodeToString(hasher.Sum(nil)) realFile := "./images/" + md5Sum + ".jpg" err = os.Rename(tmpFile, realFile) if err != nil { http.Error(w, "cant rename file: "+err.Error(), http.StatusInternalServerError) return } data, _ := json.Marshal(ImgResizeTask{handler.Filename, md5Sum}) fmt.Println("put task ", string(data)) err = rabbitChan.Publish( "", // exchange ImageResizeQueueName, // routing key false, // mandatory false, // immediate amqp.Publishing{ DeliveryMode: amqp.Persistent, ContentType: "text/plain", Body: data, }, ) panicOnError("cant publish task", err) fmt.Fprintf(w, "Upload %d bytes successful\n", writtenBytes) } const ( ImageResizeQueueName = "image_resize" ) var ( rabbitAddr = flag.String("addr", "amqp://guest:guest@127.0.0.1:5672/", "rabbit addr") rabbitConn *amqp.Connection rabbitChan *amqp.Channel ) func main() { err := os.Mkdir("./images", 0777) if err != nil && !os.IsExist(err) { fmt.Println(err) return } flag.Parse() rabbitConn, err = amqp.Dial(*rabbitAddr) panicOnError("cant connect to rabbit", err) rabbitChan, err = rabbitConn.Channel() panicOnError("cant open chan", err) defer rabbitChan.Close() q, err := rabbitChan.QueueDeclare( ImageResizeQueueName, // name true, // durable false, // delete when unused false, // exclusive false, // no-wait nil, // arguments ) panicOnError("cant init queue", err) fmt.Printf("queue %s have %d msg and %d consumers\n", q.Name, q.Messages, q.Consumers) http.HandleFunc("/", mainPage) http.HandleFunc("/upload", uploadPage) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } // Никогда так не делайте! func panicOnError(msg string, err error) { if err != nil { panic(msg + " " + err.Error()) } } var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") func RandStringRunes(n int) string { b := make([]rune, n) for i := range b { b[i] = letterRunes[rand.Intn(len(letterRunes))] } return string(b) } ================================================ FILE: 6-databases/11_rabbit/resizer/resize_worker.go ================================================ package main import ( "encoding/json" "flag" "fmt" "image/jpeg" "os" "sync" "time" "github.com/nfnt/resize" "github.com/streadway/amqp" ) type ImgResizeTask struct { Name string MD5 string } const ( ImageResizeQueueName = "image_resize" ) var ( rabbitAddr = flag.String("addr", "amqp://guest:guest@127.0.0.1:5672/", "rabbit addr") rabbitConn *amqp.Connection rabbitChan *amqp.Channel ) func main() { flag.Parse() var err error rabbitConn, err = amqp.Dial(*rabbitAddr) panicOnError("cant connect to rabbit", err) rabbitChan, err = rabbitConn.Channel() panicOnError("cant open chan", err) defer rabbitChan.Close() _, err = rabbitChan.QueueDeclare( ImageResizeQueueName, // name true, // durable false, // delete when unused false, // exclusive false, // no-wait nil, // arguments ) panicOnError("cant init queue", err) err = rabbitChan.Qos( 1, // prefetch count 0, // prefetch size false, // global ) panicOnError("cant set QoS", err) tasks, err := rabbitChan.Consume( ImageResizeQueueName, // queue "", // consumer false, // auto-ack false, // exclusive false, // no-local false, // no-wait nil, // args ) panicOnError("cant register consumer", err) wg := &sync.WaitGroup{} wg.Add(1) go ResizeWorker(tasks) fmt.Println("worker started") wg.Wait() } var ( sizes = []uint{80, 160, 320} ) func ResizeWorker(tasks <-chan amqp.Delivery) { for taskItem := range tasks { fmt.Printf("incoming task %+v\n", taskItem) task := &ImgResizeTask{} err := json.Unmarshal(taskItem.Body, task) if err != nil { fmt.Println("cant unpack json", err) taskItem.Ack(false) continue } originalPath := fmt.Sprintf("./images/%s.jpg", task.MD5) for _, size := range sizes { resizedPath := fmt.Sprintf("./images/%s_%d.jpg", task.MD5, size) err := ResizeImage(originalPath, resizedPath, size) if err != nil { fmt.Println("resize failed", err) continue } fmt.Println("resize success") time.Sleep(3 * time.Second) } taskItem.Ack(false) } } func ResizeImage(originalPath string, resizedPath string, size uint) error { file, err := os.Open(originalPath) if err != nil { return fmt.Errorf("cant open file %s: %s", originalPath, err) } img, err := jpeg.Decode(file) if err != nil { return fmt.Errorf("cant jpeg decode file %s", err) } file.Close() resizeImage := resize.Resize(size, 0, img, resize.Lanczos3) out, err := os.Create(resizedPath) if err != nil { return fmt.Errorf("cant create file %s: %s", resizedPath, err) } defer out.Close() jpeg.Encode(out, resizeImage, nil) return nil } // Никогда так не делайте! func panicOnError(msg string, err error) { if err != nil { panic(msg + " " + err.Error()) } } ================================================ FILE: 6-databases/12_kafka/form/form.go ================================================ package main import ( "crypto/md5" "encoding/hex" "encoding/json" "flag" "fmt" "io" "math/rand" "net/http" "os" "github.com/IBM/sarama" ) var uploadFormTmpl = []byte(` Image: `) type ImgResizeTask struct { Name string MD5 string } func mainPage(w http.ResponseWriter, r *http.Request) { w.Write(uploadFormTmpl) } func uploadPage(w http.ResponseWriter, r *http.Request) { uploadData, handler, err := r.FormFile("my_file") if err != nil { fmt.Println(err) return } defer uploadData.Close() fmt.Fprintf(w, "handler.Filename %v\n", handler.Filename) fmt.Fprintf(w, "handler.Header %#v\n", handler.Header) tmpName := RandStringRunes(32) tmpFile := "./images/" + tmpName + ".jpg" newFile, err := os.Create(tmpFile) if err != nil { http.Error(w, "cant open file: "+err.Error(), http.StatusInternalServerError) return } hasher := md5.New() writtenBytes, err := io.Copy(newFile, io.TeeReader(uploadData, hasher)) if err != nil { http.Error(w, "cant save file: "+err.Error(), http.StatusInternalServerError) return } newFile.Sync() newFile.Close() md5Sum := hex.EncodeToString(hasher.Sum(nil)) realFile := "./images/" + md5Sum + ".jpg" err = os.Rename(tmpFile, realFile) if err != nil { http.Error(w, "cant rename file: "+err.Error(), http.StatusInternalServerError) return } data, _ := json.Marshal(ImgResizeTask{handler.Filename, md5Sum}) fmt.Println("put task ", string(data)) // Kafka publish via sarama msg := &sarama.ProducerMessage{ Topic: ImageResizeTopicName, Key: sarama.StringEncoder(md5Sum), Value: sarama.ByteEncoder(data), } kafkaAsyncP.Input() <- msg fmt.Fprintf(w, "Upload %d bytes successful\n", writtenBytes) } const ( ImageResizeTopicName = "cool_topic" ) var ( kafkaAddr = flag.String("addr", "localhost:9092", "kafka broker address") kafkaAsyncP sarama.AsyncProducer ) func main() { err := os.Mkdir("./images", 0777) if err != nil && !os.IsExist(err) { fmt.Println(err) return } flag.Parse() config := sarama.NewConfig() config.Producer.Return.Successes = false config.Producer.Return.Errors = true kafkaAsyncP, err = sarama.NewAsyncProducer([]string{*kafkaAddr}, config) panicOnError("cant create kafka producer", err) defer kafkaAsyncP.Close() // Отдельная горутина для ошибок продюсера go func() { for err := range kafkaAsyncP.Errors() { fmt.Println("Failed to produce message", err) } }() http.HandleFunc("/", mainPage) http.HandleFunc("/upload", uploadPage) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } // Никогда так не делайте! func panicOnError(msg string, err error) { if err != nil { panic(msg + " " + err.Error()) } } var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") func RandStringRunes(n int) string { b := make([]rune, n) for i := range b { b[i] = letterRunes[rand.Intn(len(letterRunes))] } return string(b) } ================================================ FILE: 6-databases/12_kafka/resizer/resize_worker.go ================================================ package main import ( "context" "encoding/json" "flag" "fmt" "image/jpeg" "os" "os/signal" "sync" "syscall" "time" "github.com/IBM/sarama" "github.com/nfnt/resize" ) type ImgResizeTask struct { Name string MD5 string } const ( ImageResizeTopicName = "cool_topic" ) var ( kafkaAddr = flag.String("addr", "localhost:9092", "kafka broker address") groupID = flag.String("group", "resizer-group", "kafka consumer group") ) var ( sizes = []uint{80, 160, 320} ) type Consumer struct { ready chan bool } func (c *Consumer) Setup(sarama.ConsumerGroupSession) error { close(c.ready) return nil } func (c *Consumer) Cleanup(sarama.ConsumerGroupSession) error { return nil } func (c *Consumer) ConsumeClaim(sess sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error { for msg := range claim.Messages() { fmt.Printf("incoming task %s\n", string(msg.Value)) task := &ImgResizeTask{} err := json.Unmarshal(msg.Value, task) if err != nil { fmt.Println("cant unpack json", err) sess.MarkMessage(msg, "") continue } originalPath := fmt.Sprintf("./images/%s.jpg", task.MD5) for _, size := range sizes { resizedPath := fmt.Sprintf("./images/%s_%d.jpg", task.MD5, size) err := ResizeImage(originalPath, resizedPath, size) if err != nil { fmt.Println("resize failed", err) continue } fmt.Println("resize success") time.Sleep(3 * time.Second) } sess.MarkMessage(msg, "") } return nil } func main() { flag.Parse() config := sarama.NewConfig() config.Version = sarama.V2_1_0_0 config.Consumer.Return.Errors = true config.Consumer.Offsets.Initial = sarama.OffsetOldest consumer := Consumer{ ready: make(chan bool), } client, err := sarama.NewConsumerGroup([]string{*kafkaAddr}, *groupID, config) panicOnError("cant create consumer group", err) defer client.Close() c := make(chan os.Signal, 1) signal.Notify(c, syscall.SIGINT, syscall.SIGTERM) wg := &sync.WaitGroup{} wg.Add(1) ctx, cancel := context.WithCancel(context.Background()) go func() { <-c cancel() }() go func() { defer wg.Done() for { if err := client.Consume(ctx, []string{ImageResizeTopicName}, &consumer); err != nil { fmt.Println("Error from consumer:", err) time.Sleep(time.Second) } consumer.ready = make(chan bool) // Check if context was cancelled, signaling that the consumer should stop select { case <-ctx.Done(): return default: } } }() <-consumer.ready fmt.Println("worker started") <-ctx.Done() fmt.Println("worker stopped") wg.Wait() } func ResizeImage(originalPath string, resizedPath string, size uint) error { file, err := os.Open(originalPath) if err != nil { return fmt.Errorf("cant open file %s: %s", originalPath, err) } defer file.Close() img, err := jpeg.Decode(file) if err != nil { return fmt.Errorf("cant jpeg decode file %s", err) } resizeImage := resize.Resize(size, 0, img, resize.Lanczos3) out, err := os.Create(resizedPath) if err != nil { return fmt.Errorf("cant create file %s: %s", resizedPath, err) } defer out.Close() jpeg.Encode(out, resizeImage, nil) return nil } // Никогда так не делайте! func panicOnError(msg string, err error) { if err != nil { panic(msg + " " + err.Error()) } } ================================================ FILE: 6-databases/13_tarantool_simple/Dockerfile ================================================ FROM tarantool/tarantool:2.10.8 COPY app.lua /opt/tarantool CMD ["tarantool", "/opt/tarantool/app.lua"] ================================================ FILE: 6-databases/13_tarantool_simple/app.lua ================================================ #!/usr/bin/env tarantool -- Настроить базу данных box.cfg { listen = 3301 } -- При поднятии БД создаем спейсы и индексы box.once('init', function() box.schema.space.create('users') box.space.users:create_index('primary', { type = 'TREE', parts = {1, 'unsigned'}}) box.schema.space.create('sessions') box.space.sessions:create_index('primary', { type = 'HASH', parts = {1, 'string'}}) print('Hello, world!') end) -- Можем определять свои функции и вызывать их из кода function test() print('test') return 'test' end -- Например ID сессии генерируется здесь function new_session(user_data) print('received data', user_data) local random_number local session_id session_id = "" for x = 1,64,1 do random_number = math.random(65, 90) session_id = session_id .. string.char(random_number) end box.space.sessions:insert{session_id, user_data} return session_id end function check_session(session_id) local session_id = box.space.sessions:select{session_id}[1] print('found session', session_id) return session_id end ================================================ FILE: 6-databases/13_tarantool_simple/main.go ================================================ package main import ( "context" "fmt" "math/rand" "github.com/tarantool/go-tarantool/v2" ) /* s = box.schema.space.create('users') s:format({{name = 'id', type = 'unsigned'},{name = 'name', type = 'string'},{name = 'age', type = 'unsigned'}}) s:create_index('primary', {type = 'hash', parts = {'id'}}) */ func main() { ctx := context.Background() dialer := tarantool.NetDialer{Address: "127.0.0.1:3301", User: "guest"} conn, err := tarantool.Connect(ctx, dialer, tarantool.Opts{}) if err != nil { fmt.Println("baa: Connection refused:", err) return } resp, err := conn.Do( tarantool.NewInsertRequest("users").Tuple([]any{rand.Int(), fmt.Sprintf("user%d", rand.Int()), 2019}), ).Get() if err != nil { fmt.Println("Error", err) } items := make([]any, 0) err = conn.Do( tarantool.NewSelectRequest("users").Index("primary").Offset(0).Limit(100).Iterator(tarantool.IterAll).Key([]any{uint(1)}), ).GetTyped(&items) if err != nil { fmt.Println("Error", err) return } for _, item := range items { fmt.Println(item) } resp, err = conn.Do( tarantool.NewEvalRequest("return test()"), ).Get() if err != nil { fmt.Println("Error", err) return } fmt.Println(resp) } ================================================ FILE: 6-databases/14_tarantool/main.go ================================================ package main import ( "context" "errors" "flag" "fmt" "log" "net/http" "time" "github.com/tarantool/go-tarantool/v2" ) var ( tarantoolAddr = flag.String("addr", "127.0.0.1:3301", "tarantool addr") sessManager *SessionManager users = map[string]string{ "a.sulaev": "golang", "dmitrydorofeev": "test", "romanov.vasily": "100500", "anton.chumakov": "amogus", } ) func checkSession(r *http.Request) (*Session, error) { cookieSessionID, err := r.Cookie("session_id") if errors.Is(err, http.ErrNoCookie) { return nil, nil } else if err != nil { return nil, err } sess, err := sessManager.Check(&SessionID{ ID: cookieSessionID.Value, }) if err != nil { return nil, err } return sess, nil } func innerPage(w http.ResponseWriter, r *http.Request) { sess, err := checkSession(r) if err != nil { log.Println(err) w.WriteHeader(http.StatusInternalServerError) return } if sess == nil { w.Write(loginFormTmpl) return } w.Header().Set("Content-Type", "text/html") fmt.Fprintln(w, "Welcome, "+sess.Login+"
") fmt.Fprintln(w, "Session ua: "+sess.Useragent+"
") fmt.Fprintln(w, `logout`) } func loginPage(w http.ResponseWriter, r *http.Request) { inputLogin := r.FormValue("login") inputPass := r.FormValue("password") expiration := time.Now().Add(24 * time.Hour) pass, exist := users[inputLogin] if !exist || pass != inputPass { w.WriteHeader(http.StatusUnauthorized) w.Write([]byte("wrong credentials")) return } sess, err := sessManager.Create(&Session{ Login: inputLogin, Useragent: r.UserAgent(), }) if err != nil { log.Printf("cannot create session: %s", err) w.WriteHeader(http.StatusInternalServerError) return } cookie := http.Cookie{ Name: "session_id", Value: sess.ID, Expires: expiration, } http.SetCookie(w, &cookie) http.Redirect(w, r, "/", http.StatusFound) } func main() { flag.Parse() var err error ctx := context.Background() dialer := tarantool.NetDialer{Address: *tarantoolAddr, User: "guest"} tConn, err := tarantool.Connect(ctx, dialer, tarantool.Opts{}) if err != nil { log.Fatalf("cant connect to tarantool: %s\n", err) } sessManager = NewSessionManager(tConn) http.HandleFunc("/", innerPage) http.HandleFunc("/login", loginPage) http.HandleFunc("/logout", logoutPage) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } func logoutPage(w http.ResponseWriter, r *http.Request) { session, err := r.Cookie("session_id") if errors.Is(err, http.ErrNoCookie) { http.Redirect(w, r, "/", http.StatusFound) return } else if err != nil { w.WriteHeader(http.StatusInternalServerError) return } sessManager.Delete(&SessionID{ ID: session.Value, }) session.Expires = time.Now().AddDate(0, 0, -1) http.SetCookie(w, session) http.Redirect(w, r, "/", http.StatusFound) } var loginFormTmpl = []byte(` Login: Password: `) ================================================ FILE: 6-databases/14_tarantool/session.go ================================================ package main import ( "encoding/json" "fmt" "log" "github.com/tarantool/go-tarantool/v2" ) type Session struct { Login string Useragent string } type SessionID struct { ID string } type SessionManager struct { tConn *tarantool.Connection } func NewSessionManager(conn *tarantool.Connection) *SessionManager { return &SessionManager{ tConn: conn, } } func (sm *SessionManager) Create(in *Session) (*SessionID, error) { dataSerialized, err := json.Marshal(in) if err != nil { return nil, fmt.Errorf("data serialization failed: %s", err) } dataStr := string(dataSerialized) log.Printf("try to save data: %s", dataStr) resp, err := sm.tConn.Do( tarantool.NewEvalRequest("return new_session(...)").Args([]interface{}{dataStr}), ).Get() if err != nil { return nil, fmt.Errorf("error while calling function: %s", err) } data := resp[0] if id, ok := data.(string); ok { return &SessionID{id}, nil } return nil, fmt.Errorf("cannot cast into int") } func (sm *SessionManager) Check(in *SessionID) (*Session, error) { resp, err := sm.tConn.Do( tarantool.NewCallRequest("check_session").Args([]interface{}{in.ID}), ).Get() if err != nil { fmt.Println("cannot check session", err) return nil, err } data := resp[0] if data == nil { return &Session{}, nil } sessionDataSlice, ok := data.([]interface{}) if !ok { return nil, fmt.Errorf("cannot cast data: %v", sessionDataSlice) } if sessionDataSlice[1] == nil { return nil, nil } sessionData, ok := sessionDataSlice[1].(string) if !ok { return nil, fmt.Errorf("cannot cast data: %v", sessionDataSlice[1]) } sess := &Session{} err = json.Unmarshal([]byte(sessionData), sess) if err != nil { log.Printf("cant unpack session data(%s): %v\n", sessionData, err) return nil, nil } return sess, nil } func (sm *SessionManager) Delete(in *SessionID) { // mkey := "sessions:" + in.ID // _, err := redis.Int(sm.redisConn.Do("DEL", mkey)) // if err != nil { // log.Println("redis error:", err) // } } ================================================ FILE: 6-databases/crudapp_mongo/cmd/crudapp/main.go ================================================ package main import ( "context" "html/template" "log" "net/http" "time" "github.com/go-park-mail-ru/lectures/6-databases/crudapp_mongo/pkg/handlers" "github.com/go-park-mail-ru/lectures/6-databases/crudapp_mongo/pkg/items" "github.com/go-park-mail-ru/lectures/6-databases/crudapp_mongo/pkg/middleware" "github.com/go-park-mail-ru/lectures/6-databases/crudapp_mongo/pkg/session" "github.com/go-park-mail-ru/lectures/6-databases/crudapp_mongo/pkg/user" "github.com/gorilla/mux" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/readpref" "go.uber.org/zap" ) func getMongo(cfg string) *mongo.Client { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() client, err := mongo.Connect(ctx, options.Client().ApplyURI(cfg)) if err != nil { log.Fatalln("cant connect to mongo", err) } err = client.Ping(ctx, readpref.Primary()) if err != nil { log.Fatalln("cant ping mongo", err) } return client } func main() { // ----- templates := template.Must(template.ParseGlob("./templates/*")) sm := session.NewSessionsMem() zapLogger, _ := zap.NewProduction() defer zapLogger.Sync() // flushes buffer, if any logger := zapLogger.Sugar() // dbMSSQL := sql.Open(...) userRepo := user.NewUserRepo() mongoClient := getMongo("mongodb://localhost:27017") itemsRepo := items.NewMongoRepository(mongoClient.Database("vkbmstu").Collection("items")) userHandler := &handlers.UserHandler{ Tmpl: templates, UserRepo: userRepo, Logger: logger, Sessions: sm, } handlers := &handlers.ItemsHandler{ Tmpl: templates, Logger: logger, ItemsRepo: itemsRepo, } r := mux.NewRouter() r.HandleFunc("/", userHandler.Index).Methods("GET") r.HandleFunc("/login", userHandler.Login).Methods("POST") r.HandleFunc("/logout", userHandler.Logout).Methods("POST") r.HandleFunc("/items", handlers.List).Methods("GET") r.HandleFunc("/items/new", handlers.AddForm).Methods("GET") r.HandleFunc("/items/new", handlers.Add).Methods("POST") r.HandleFunc("/items/{id}", handlers.Edit).Methods("GET") r.HandleFunc("/items/{id}", handlers.Update).Methods("POST") r.HandleFunc("/items/{id}", handlers.Delete).Methods("DELETE") mux := middleware.Auth(sm, r) mux = middleware.AccessLog(logger, mux) mux = middleware.Panic(mux) addr := ":8080" logger.Infow("starting server", "type", "START", "addr", addr, ) http.ListenAndServe(addr, mux) } ================================================ FILE: 6-databases/crudapp_mongo/file_tree.txt ================================================ . ├── bin ├── cmd │   └── crudapp │   └── main.go ├── cover.html ├── cover.out ├── file_tree.txt ├── go.mod ├── go.sum ├── pkg │   ├── handlers │   │   ├── cover.out │   │   ├── handler.html │   │   ├── items.go │   │   ├── items_mock.go │   │   ├── items_test.go │   │   └── user.go │   ├── items │   │   ├── item.go │   │   ├── item_repo_test.go │   │   ├── repo_gorm.go │   │   ├── repo_mysql.go │   │   ├── repo_pgx.go │   │   └── repo_sqlx.go │   ├── middleware │   │   ├── accesslog.go │   │   ├── auth.go │   │   └── panic.go │   ├── session │   │   ├── manager.go │   │   └── session.go │   └── user │   └── user.go ├── readme.md └── templates ├── create.html ├── edit.html ├── index.html └── login.html 10 directories, 29 files ================================================ FILE: 6-databases/crudapp_mongo/pkg/handlers/items.go ================================================ package handlers import ( "context" "encoding/json" "html/template" "net/http" "github.com/go-park-mail-ru/lectures/6-databases/crudapp_mongo/pkg/items" "github.com/go-park-mail-ru/lectures/6-databases/crudapp_mongo/pkg/session" "github.com/gorilla/mux" "github.com/gorilla/schema" "go.mongodb.org/mongo-driver/bson/primitive" "go.uber.org/zap" ) type ItemRepositoryInterface interface { GetAll() ([]*items.Item, error) GetByID(string) (*items.Item, error) Add(context.Context, *items.Item) (string, error) Update(*items.Item) (int64, error) Delete(string) (int64, error) } type ItemsHandler struct { Tmpl *template.Template ItemsRepo ItemRepositoryInterface Logger *zap.SugaredLogger } func (h *ItemsHandler) List(w http.ResponseWriter, r *http.Request) { elems, err := h.ItemsRepo.GetAll() if err != nil { h.Logger.Error("GetAll err", err) http.Error(w, `DB err`, http.StatusInternalServerError) return } err = h.Tmpl.ExecuteTemplate(w, "index.html", struct { Items []*items.Item }{ Items: elems, }) if err != nil { h.Logger.Error("ExecuteTemplate err", err) http.Error(w, `Template errror`, http.StatusInternalServerError) return } } func (h *ItemsHandler) AddForm(w http.ResponseWriter, r *http.Request) { err := h.Tmpl.ExecuteTemplate(w, "create.html", nil) if err != nil { h.Logger.Error("ExecuteTemplate err", err) http.Error(w, `Template errror`, http.StatusInternalServerError) return } } // type ItemsAddInput struct { // } func (h *ItemsHandler) Add(w http.ResponseWriter, r *http.Request) { r.ParseForm() item := new(items.Item) decoder := schema.NewDecoder() decoder.IgnoreUnknownKeys(true) err := decoder.Decode(item, r.PostForm) if err != nil { h.Logger.Error("Form err", err) http.Error(w, `Bad form`, http.StatusBadRequest) return } ctx := r.Context() sess, _ := session.SessionFromContext(ctx) // item.UserID = sess.UserID lastID, err := h.ItemsRepo.Add(ctx, item) if err != nil { h.Logger.Error("Db err", err) http.Error(w, `DB err`, http.StatusInternalServerError) return } h.Logger.Infof("Insert with id LastInsertId: %v %v", lastID, sess) http.Redirect(w, r, "/", http.StatusFound) } func (h *ItemsHandler) Edit(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) id := vars["id"] if _, err := primitive.ObjectIDFromHex(id); err != nil { http.Error(w, `{"error": "bad id"}`, http.StatusBadGateway) return } item, err := h.ItemsRepo.GetByID(id) if err != nil { h.Logger.Error("Db err", err) http.Error(w, `DB err`, http.StatusInternalServerError) return } if item == nil { http.Error(w, `no item`, http.StatusNotFound) return } err = h.Tmpl.ExecuteTemplate(w, "edit.html", item) if err != nil { h.Logger.Error("ExecuteTemplate err", err) http.Error(w, `Template errror`, http.StatusInternalServerError) return } } func (h *ItemsHandler) Update(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) id, err := primitive.ObjectIDFromHex(vars["id"]) if err != nil { http.Error(w, `{"error": "bad id"}`, http.StatusBadGateway) return } r.ParseForm() item := new(items.Item) decoder := schema.NewDecoder() decoder.IgnoreUnknownKeys(true) err = decoder.Decode(item, r.PostForm) if err != nil { h.Logger.Error("Form err", err) http.Error(w, `Bad form`, http.StatusBadRequest) return } item.ID = id sess, _ := session.SessionFromContext(r.Context()) item.SetUpdated(sess.UserID) ok, err := h.ItemsRepo.Update(item) if err != nil { h.Logger.Error("Db err", err) http.Error(w, `db error`, http.StatusInternalServerError) return } h.Logger.Infof("update: %v %v", item, ok) http.Redirect(w, r, "/", http.StatusFound) } func (h *ItemsHandler) Delete(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) id := vars["id"] if _, err := primitive.ObjectIDFromHex(id); err != nil { http.Error(w, `{"error": "bad id"}`, http.StatusBadGateway) return } affected, err := h.ItemsRepo.Delete(id) if err != nil { h.Logger.Error("Db err", err) http.Error(w, `{"error": "db error"}`, http.StatusInternalServerError) return } w.Header().Set("Content-type", "application/json") respJSON, _ := json.Marshal(map[string]int64{ "updated": affected, }) w.Write(respJSON) } ================================================ FILE: 6-databases/crudapp_mongo/pkg/handlers/items_mock.go ================================================ // Code generated by MockGen. DO NOT EDIT. // Source: items.go // Package handlers is a generated GoMock package. package handlers import ( context "context" reflect "reflect" items "github.com/go-park-mail-ru/lectures/6-databases/crudapp_mongo/pkg/items" gomock "github.com/golang/mock/gomock" ) // MockItemRepositoryInterface is a mock of ItemRepositoryInterface interface. type MockItemRepositoryInterface struct { ctrl *gomock.Controller recorder *MockItemRepositoryInterfaceMockRecorder } // MockItemRepositoryInterfaceMockRecorder is the mock recorder for MockItemRepositoryInterface. type MockItemRepositoryInterfaceMockRecorder struct { mock *MockItemRepositoryInterface } // NewMockItemRepositoryInterface creates a new mock instance. func NewMockItemRepositoryInterface(ctrl *gomock.Controller) *MockItemRepositoryInterface { mock := &MockItemRepositoryInterface{ctrl: ctrl} mock.recorder = &MockItemRepositoryInterfaceMockRecorder{mock} return mock } // EXPECT returns an object that allows the caller to indicate expected use. func (m *MockItemRepositoryInterface) EXPECT() *MockItemRepositoryInterfaceMockRecorder { return m.recorder } // Add mocks base method. func (m *MockItemRepositoryInterface) Add(arg0 context.Context, arg1 *items.Item) (string, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Add", arg0, arg1) ret0, _ := ret[0].(string) ret1, _ := ret[1].(error) return ret0, ret1 } // Add indicates an expected call of Add. func (mr *MockItemRepositoryInterfaceMockRecorder) Add(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Add", reflect.TypeOf((*MockItemRepositoryInterface)(nil).Add), arg0, arg1) } // Delete mocks base method. func (m *MockItemRepositoryInterface) Delete(arg0 string) (int64, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Delete", arg0) ret0, _ := ret[0].(int64) ret1, _ := ret[1].(error) return ret0, ret1 } // Delete indicates an expected call of Delete. func (mr *MockItemRepositoryInterfaceMockRecorder) Delete(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockItemRepositoryInterface)(nil).Delete), arg0) } // GetAll mocks base method. func (m *MockItemRepositoryInterface) GetAll() ([]*items.Item, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAll") ret0, _ := ret[0].([]*items.Item) ret1, _ := ret[1].(error) return ret0, ret1 } // GetAll indicates an expected call of GetAll. func (mr *MockItemRepositoryInterfaceMockRecorder) GetAll() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAll", reflect.TypeOf((*MockItemRepositoryInterface)(nil).GetAll)) } // GetByID mocks base method. func (m *MockItemRepositoryInterface) GetByID(arg0 string) (*items.Item, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetByID", arg0) ret0, _ := ret[0].(*items.Item) ret1, _ := ret[1].(error) return ret0, ret1 } // GetByID indicates an expected call of GetByID. func (mr *MockItemRepositoryInterfaceMockRecorder) GetByID(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByID", reflect.TypeOf((*MockItemRepositoryInterface)(nil).GetByID), arg0) } // Update mocks base method. func (m *MockItemRepositoryInterface) Update(arg0 *items.Item) (int64, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Update", arg0) ret0, _ := ret[0].(int64) ret1, _ := ret[1].(error) return ret0, ret1 } // Update indicates an expected call of Update. func (mr *MockItemRepositoryInterfaceMockRecorder) Update(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockItemRepositoryInterface)(nil).Update), arg0) } ================================================ FILE: 6-databases/crudapp_mongo/pkg/handlers/items_test.go ================================================ package handlers import ( "bytes" "fmt" "html/template" "io/ioutil" "net/http/httptest" "testing" "github.com/go-park-mail-ru/lectures/6-databases/crudapp_mongo/pkg/items" "go.mongodb.org/mongo-driver/bson/primitive" "github.com/golang/mock/gomock" "go.uber.org/zap" ) /* repo db -> mock handler repo -> mock */ func TestItemsHandlerList(t *testing.T) { // мы передаём t сюда, это надо чтобы получить корректное сообщение если тесты не пройдут ctrl := gomock.NewController(t) // Finish сравнит последовательсноть вызовов и выведет ошибку если последовательность другая defer ctrl.Finish() st := NewMockItemRepositoryInterface(ctrl) service := &ItemsHandler{ ItemsRepo: st, Logger: zap.NewNop().Sugar(), // не пишет логи Tmpl: template.Must(template.ParseGlob("../../templates/*")), } resultItems := []*items.Item{ {ID: primitive.NewObjectID(), Title: "database/sql"}, } // тут мы записываем последовтаельность вызовов и результат st.EXPECT().GetAll().Return(resultItems, nil) req := httptest.NewRequest("GET", "/", nil) w := httptest.NewRecorder() service.List(w, req) resp := w.Result() body, _ := ioutil.ReadAll(resp.Body) img := `database/sql` if !bytes.Contains(body, []byte(img)) { t.Errorf("no text found") return } // GetPhotos error // тут мы записываем последовтаельность вызовов и результат st.EXPECT().GetAll().Return(nil, fmt.Errorf("no results")) req = httptest.NewRequest("GET", "/", nil) w = httptest.NewRecorder() service.List(w, req) resp = w.Result() if resp.StatusCode != 500 { t.Errorf("expected resp status 500, got %d", resp.StatusCode) return } // template expand error service.Tmpl, _ = template.New("tmplError").Parse("{{.NotExist}}") st.EXPECT().GetAll().Return(resultItems, nil) req = httptest.NewRequest("GET", "/", nil) w = httptest.NewRecorder() service.List(w, req) resp = w.Result() if resp.StatusCode != 500 { t.Errorf("expected resp status 500, got %d", resp.StatusCode) return } } ================================================ FILE: 6-databases/crudapp_mongo/pkg/handlers/user.go ================================================ package handlers import ( "html/template" "net/http" "github.com/go-park-mail-ru/lectures/6-databases/crudapp_mongo/pkg/session" "github.com/go-park-mail-ru/lectures/6-databases/crudapp_mongo/pkg/user" "go.uber.org/zap" ) type UserHandler struct { Tmpl *template.Template Logger *zap.SugaredLogger UserRepo *user.UserRepo Sessions *session.SessionsManager } func (h *UserHandler) Index(w http.ResponseWriter, r *http.Request) { _, err := session.SessionFromContext(r.Context()) if err == nil { http.Redirect(w, r, "/items", 302) return } err = h.Tmpl.ExecuteTemplate(w, "login.html", nil) if err != nil { http.Error(w, `Template errror`, http.StatusInternalServerError) return } } func (h *UserHandler) Login(w http.ResponseWriter, r *http.Request) { u, err := h.UserRepo.Authorize(r.FormValue("login"), r.FormValue("password")) if err == user.ErrNoUser { http.Error(w, `no user`, http.StatusBadRequest) return } if err == user.ErrBadPass { http.Error(w, `bad pass`, http.StatusBadRequest) return } sess, _ := h.Sessions.Create(w, u.ID) h.Logger.Infof("created session for %v", sess.UserID) http.Redirect(w, r, "/", 302) } func (h *UserHandler) Logout(w http.ResponseWriter, r *http.Request) { h.Sessions.DestroyCurrent(w, r) http.Redirect(w, r, "/", 302) } ================================================ FILE: 6-databases/crudapp_mongo/pkg/items/item.go ================================================ package items import ( "strconv" "go.mongodb.org/mongo-driver/bson/primitive" ) type Item struct { ID primitive.ObjectID `json:"id" bson:"_id"` Title string `json:"title" bson:"title"` Description string `json:"description" bson:"description"` Updated string `json:"updated" bson:"updated"` } // позволяет items handlers не импортировать sql func (it *Item) SetUpdated(val uint32) { it.Updated = strconv.Itoa(int(val)) } ================================================ FILE: 6-databases/crudapp_mongo/pkg/items/repo_mongo.go ================================================ package items import ( "context" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" ) type RepoMongo struct { Coll *mongo.Collection } func NewMongoRepository(coll *mongo.Collection) *RepoMongo { return &RepoMongo{Coll: coll} } func (repo *RepoMongo) GetAll() ([]*Item, error) { items := make([]*Item, 0, 10) res, err := repo.Coll.Find(context.Background(), bson.M{}) err = res.All(context.Background(), &items) if err != nil { return nil, err } return items, nil } func (repo *RepoMongo) GetByID(id string) (*Item, error) { post := &Item{} oid, _ := primitive.ObjectIDFromHex(id) err := repo.Coll.FindOne(context.Background(), bson.M{"_id": oid}).Decode(&post) if err != nil { return nil, err } return post, nil } func (repo *RepoMongo) Add(ctx context.Context, elem *Item) (string, error) { elem.ID = primitive.NewObjectID() _, err := repo.Coll.InsertOne(ctx, elem) if err != nil { return "", err } // log.Println(res, elem) return elem.ID.Hex(), nil } func (repo *RepoMongo) Update(elem *Item) (int64, error) { res, err := repo.Coll.UpdateOne(context.Background(), bson.M{"_id": elem.ID}, bson.M{ "$set": bson.M{ "title": elem.Title, "description": elem.Description, "updated": "rvasily", }, }, ) if err != nil { return 0, err } return res.ModifiedCount, nil } func (repo *RepoMongo) Delete(id string) (int64, error) { oid, _ := primitive.ObjectIDFromHex(id) res, err := repo.Coll.DeleteOne(context.Background(), bson.M{"_id": oid}) if err != nil { return 0, err } return res.DeletedCount, nil } ================================================ FILE: 6-databases/crudapp_mongo/pkg/middleware/accesslog.go ================================================ package middleware import ( // "fmt" "net/http" "time" "go.uber.org/zap" ) func AccessLog(logger *zap.SugaredLogger, next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // fmt.Println("access log middleware") start := time.Now() next.ServeHTTP(w, r) logger.Infow("New request", "method", r.Method, "remote_addr", r.RemoteAddr, "url", r.URL.Path, "time", time.Since(start), ) }) } ================================================ FILE: 6-databases/crudapp_mongo/pkg/middleware/auth.go ================================================ package middleware import ( "context" // "fmt" "net/http" "github.com/go-park-mail-ru/lectures/6-databases/crudapp_mongo/pkg/session" ) var ( noAuthUrls = map[string]struct{}{ "/login": struct{}{}, } noSessUrls = map[string]struct{}{ "/": struct{}{}, } ) func Auth(sm *session.SessionsManager, next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // fmt.Println("auth middleware") if _, ok := noAuthUrls[r.URL.Path]; ok { next.ServeHTTP(w, r) return } sess, err := sm.Check(r) _, canbeWithouthSess := noSessUrls[r.URL.Path] if err != nil && !canbeWithouthSess { // fmt.Println("no auth") http.Redirect(w, r, "/", 302) return } ctx := context.WithValue(r.Context(), session.SessionKey, sess) next.ServeHTTP(w, r.WithContext(ctx)) }) } ================================================ FILE: 6-databases/crudapp_mongo/pkg/middleware/panic.go ================================================ package middleware import ( "net/http" ) func Panic(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // fmt.Println("panicMiddleware", r.URL.Path) defer func() { if err := recover(); err != nil { // fmt.Println("recovered", err) http.Error(w, "Internal server error", 500) } }() next.ServeHTTP(w, r) }) } ================================================ FILE: 6-databases/crudapp_mongo/pkg/session/manager.go ================================================ package session import ( "net/http" "sync" "time" ) type SessionsManager struct { data map[string]*Session mu *sync.RWMutex } func NewSessionsMem() *SessionsManager { return &SessionsManager{ data: make(map[string]*Session, 10), mu: &sync.RWMutex{}, } } func (sm *SessionsManager) Check(r *http.Request) (*Session, error) { sessionCookie, err := r.Cookie("session_id") if err == http.ErrNoCookie { return nil, ErrNoAuth } sm.mu.RLock() sess, ok := sm.data[sessionCookie.Value] sm.mu.RUnlock() if !ok { return nil, ErrNoAuth } return sess, nil } func (sm *SessionsManager) Create(w http.ResponseWriter, userID uint32) (*Session, error) { sess := NewSession(userID) sm.mu.Lock() sm.data[sess.ID] = sess sm.mu.Unlock() cookie := &http.Cookie{ Name: "session_id", Value: sess.ID, Expires: time.Now().Add(90 * 24 * time.Hour), Path: "/", } http.SetCookie(w, cookie) return sess, nil } func (sm *SessionsManager) DestroyCurrent(w http.ResponseWriter, r *http.Request) error { sess, err := SessionFromContext(r.Context()) if err != nil { return err } sm.mu.Lock() delete(sm.data, sess.ID) sm.mu.Unlock() cookie := http.Cookie{ Name: "session_id", Expires: time.Now().AddDate(0, 0, -1), Path: "/", } http.SetCookie(w, &cookie) return nil } ================================================ FILE: 6-databases/crudapp_mongo/pkg/session/session.go ================================================ package session import ( "context" "crypto/rand" "errors" "fmt" ) type Session struct { ID string UserID uint32 } func NewSession(userID uint32) *Session { // лучше генерировать из заданного алфавита, но так писать меньше и для учебного примера ОК randID := make([]byte, 16) rand.Read(randID) return &Session{ ID: fmt.Sprintf("%x", randID), UserID: userID, } } var ( ErrNoAuth = errors.New("No session found") ) type sessKey string var SessionKey sessKey = "sessionKey" func SessionFromContext(ctx context.Context) (*Session, error) { sess, ok := ctx.Value(SessionKey).(*Session) if !ok || sess == nil { return nil, ErrNoAuth } return sess, nil } ================================================ FILE: 6-databases/crudapp_mongo/pkg/user/user.go ================================================ package user import "errors" type User struct { ID uint32 Login string password string } type UserRepo struct { data map[string]*User } func NewUserRepo() *UserRepo { return &UserRepo{ data: map[string]*User{ "rvasily": &User{ ID: 1, Login: "rvasily", password: "love", }, }, } } var ( ErrNoUser = errors.New("No user found") ErrBadPass = errors.New("Invald password") ) func (repo *UserRepo) Authorize(login, pass string) (*User, error) { u, ok := repo.data[login] if !ok { return nil, ErrNoUser } // dont do this un production :) if u.password != pass { return nil, ErrBadPass } return u, nil } ================================================ FILE: 6-databases/crudapp_mongo/readme.md ================================================ go mod init crudapp # go mod init github.com/rvasily/crudapp go build go mod download go mod verify go mod tidy go build -o ./bin/crudapp ./cmd/crudapp go test -v -coverpkg=./... ./... go mod vendor go build -mod=vendor -o ./bin/myapp ./cmd/myapp go test -v -mod=vendor -coverpkg=./... ./... ---- docker-compose up go test -v -coverprofile=cover.out -coverpkg=./... ./... go tool cover -html=cover.out -o cover.html ----- находять в папке pkg/handlers mockgen -source=items.go -destination=items_mock.go -package=handlers ItemRepositoryInterface go test -v -run Handler -coverprofile=handler.out && go tool cover -html=handler.out -o handler.html && rm handler.out ================================================ FILE: 6-databases/crudapp_mongo/templates/create.html ================================================

Edit item

================================================ FILE: 6-databases/crudapp_mongo/templates/edit.html ================================================

Edit item

================================================ FILE: 6-databases/crudapp_mongo/templates/index.html ================================================

Posts

# Title Edited New
{{.Id.Hex}} {{.Title}} {{.Updated}} Edit Del
{{range .Items}} {{end}} ================================================ FILE: 6-databases/crudapp_mongo/templates/login.html ================================================

CrudAPP login

================================================ FILE: 6-databases/readings_6.md ================================================ * http://www.vividcortex.com/hubfs/eBooks/The_Ultimate_Guide_To_Building_Database-Driven_Apps_with_Go.pdf - в удобной форме информация по основным аспектам работы с database/sql * https://golang.org/pkg/database/sql/ - собственно сам интерфейс к базе * https://github.com/golang/go/wiki/SQLDrivers - список поддерживаемых баз * https://github.com/golang/go/wiki/SQLInterface * https://github.com/DATA-DOG/go-sqlmock * http://www.alexedwards.net/blog/configuring-sqldb * http://go-database-sql.org/ * https://astaxie.gitbooks.io/build-web-application-with-golang/ * https://github.com/thewhitetulip/web-dev-golang-anti-textbook/ * https://codegangsta.gitbooks.io/building-web-apps-with-go/content/ * https://godoc.org/github.com/go-sql-driver/mysql * https://godoc.org/github.com/lib/pq * https://godoc.org/github.com/bradfitz/gomemcache/memcache * https://godoc.org/github.com/garyburd/redigo/redis * https://godoc.org/gopkg.in/mgo.v2 * http://goinbigdata.com/how-to-build-microservice-with-mongodb-in-golang/ * http://gorm.io/ * http://motion-express.com/blog/gorm:-a-simple-guide-on-crud * https://godoc.org/github.com/jinzhu/gorm * https://habrahabr.ru/company/mailru/blog/266811/ - архи-полезная статья про устройство базы внутри * https://hackernoon.com/communicating-go-applications-through-redis-pub-sub-messaging-paradigm-df7317897b13 * https://medium.com/@shijuvar/introducing-nats-to-go-developers-3cfcb98c21d0 * https://medium.com/@shijuvar/building-distributed-systems-and-microservices-in-go-with-nats-streaming-d8b4baa633a2 ================================================ FILE: 6-databases/readme.md ================================================ docker run -p 3306:3306 --name some-mysql -e MYSQL_ROOT_PASSWORD=1234 -d mysql:5 docker run -p 6379:6379 --name some-redis -d redis docker run -p 11211:11211 --name my-memcache -d memcached docker run -p 5672:5672 -d --hostname my-rabbit --name some-rabbit rabbitmq:3 docker run -p 27017:27017 --name some-mongo -d mongo docker build --tag=mytnt . docker run --name mytnt-inst -p 3301:3301 -d mytnt docker exec -t -i mytnt-inst console ================================================ FILE: 6-databases/tcache/cache.go ================================================ package main import ( "encoding/json" "fmt" "reflect" "strconv" "time" "github.com/bradfitz/gomemcache/memcache" ) type CacheItem struct { Data json.RawMessage Tags map[string]int } type CacheItemStore struct { Data interface{} Tags map[string]int } type RebuildFunc func() (interface{}, []string, error) type TCache struct { *memcache.Client } func (tc *TCache) TGet( mkey string, ttl int32, in interface{}, rebuildCb RebuildFunc, ) (err error) { inKind := reflect.ValueOf(in).Kind() if inKind != reflect.Ptr { return fmt.Errorf("in must be ptr, got %s", inKind) } tc.checkLock(mkey) itemRaw, err := tc.Get(mkey) if err == memcache.ErrCacheMiss { fmt.Println("Record not found in memcache") return tc.rebuild(mkey, ttl, in, rebuildCb) } else if err != nil { return err } item := &CacheItem{} err = json.Unmarshal(itemRaw.Value, &item) if err != nil { return err } tagsValid, err := tc.isTagsValid(item.Tags) if err != nil { return fmt.Errorf("isTagsValid error %s", err) } if tagsValid { err = json.Unmarshal(item.Data, &in) return err } return tc.rebuild(mkey, ttl, in, rebuildCb) } func (tc *TCache) isTagsValid(itemTags map[string]int) (bool, error) { tags := make([]string, 0, len(itemTags)) for tagKey := range itemTags { tags = append(tags, tagKey) } curr, err := tc.GetMulti(tags) if err != nil { return false, err } currentTagsMap := make(map[string]int, len(curr)) for tagKey, tagItem := range curr { i, err := strconv.Atoi(string(tagItem.Value)) if err != nil { return false, err } currentTagsMap[tagKey] = i } return reflect.DeepEqual(itemTags, currentTagsMap), nil } func (tc *TCache) rebuild( mkey string, ttl int32, in interface{}, rebuildCb RebuildFunc, ) error { tc.lockRebuild(mkey) defer tc.unlockRebuild(mkey) result, tags, err := rebuildCb() // ожидаем и возвращаем одинаковые типы if reflect.TypeOf(result) != reflect.TypeOf(in) { return fmt.Errorf( "data type mismatch, expected %s, got %s", reflect.TypeOf(in), reflect.TypeOf(result), ) } currTags, err := tc.getCurrentItemTags(tags, ttl) if err != nil { return err } cacheData := CacheItemStore{result, currTags} rawData, err := json.Marshal(cacheData) if err != nil { return err } err = tc.Set(&memcache.Item{ Key: mkey, Value: rawData, Expiration: int32(ttl), }) inVal := reflect.ValueOf(in) resultVal := reflect.ValueOf(result) rv := reflect.Indirect(inVal) rvpresult := reflect.Indirect(resultVal) rv.Set(rvpresult) // *in = *result return nil } func (tc *TCache) checkLock(mkey string) error { for i := 0; i < 4; i++ { _, err := tc.Get("lock_" + mkey) if err == memcache.ErrCacheMiss { return nil } if err != nil { return err } time.Sleep(10 * time.Millisecond) } return nil } func (tc *TCache) lockRebuild(mkey string) (bool, error) { // пытаемся взять лок на перестроение кеша // чтобы все не ломанулись его перестраивать // параметры надо тюнить lockKey := "lock_" + mkey lockAccuired := false for i := 0; i < 4; i++ { // add добавляет запись если её ещё нету err := tc.Add(&memcache.Item{ Key: lockKey, Value: []byte("1"), Expiration: int32(3), }) if err == memcache.ErrNotStored { fmt.Println("get lock try", i) time.Sleep(time.Millisecond * 10) continue } else if err != nil { return false, err } lockAccuired = true break } if !lockAccuired { return false, fmt.Errorf("Can't get lock") } return true, nil } func (tc *TCache) unlockRebuild(mkey string) { tc.Delete("lock_" + mkey) } func (tc *TCache) getCurrentItemTags(tags []string, ttl int32) (map[string]int, error) { currTags, err := tc.GetMulti(tags) if err != nil { return nil, err } resultTags := make(map[string]int, len(tags)) now := int(time.Now().Unix()) nowBytes := []byte(fmt.Sprint(now)) for _, tagKey := range tags { tagItem, tagExist := currTags[tagKey] if !tagExist { err := tc.Set(&memcache.Item{ Key: tagKey, Value: nowBytes, Expiration: int32(ttl), }) if err != nil { return nil, err } resultTags[tagKey] = now } else { i, err := strconv.Atoi(string(tagItem.Value)) if err != nil { return nil, err } resultTags[tagKey] = i } } return resultTags, nil } ================================================ FILE: 6-databases/tcache/main.go ================================================ package main import ( "fmt" "github.com/bradfitz/gomemcache/memcache" ) /* type TCache struct { *memcache.Client } */ func main() { MemcachedAddresses := []string{"127.0.0.1:11211"} memcacheClient := memcache.New(MemcachedAddresses...) tc := &TCache{memcacheClient} mkey := "habrposts" tc.Delete(mkey) rebuild := func() (interface{}, []string, error) { habrPosts, err := GetHabrPosts() if err != nil { return nil, nil, err } return habrPosts, []string{"habrTag", "geektimes"}, nil } fmt.Println("\nTGet call #1") posts := RSS{} err := tc.TGet(mkey, 30, &posts, rebuild) fmt.Println("#1", len(posts.Items), "err:", err) fmt.Println("\nTGet call #2") posts = RSS{} err = tc.TGet(mkey, 30, &posts, rebuild) fmt.Println("#2", len(posts.Items), "err:", err) fmt.Println("\ninc tag habrTag") tc.Increment("habrTag", 1) go func() { // time.Sleep(time.Millisecond) fmt.Println("\nTGet call #async") posts = RSS{} err = tc.TGet(mkey, 30, &posts, rebuild) fmt.Println("#async", len(posts.Items), "err:", err) }() fmt.Println("\nTGet call #3") posts = RSS{} err = tc.TGet(mkey, 30, &posts, rebuild) fmt.Println("#3", len(posts.Items), "err:", err) } ================================================ FILE: 6-databases/tcache/posts.go ================================================ package main import ( "encoding/xml" "fmt" "io/ioutil" "net/http" ) type RSS struct { Items []Item `xml:"channel>item"` } type Item struct { URL string `xml:"guid"` Title string `xml:"title"` } func GetHabrPosts() (*RSS, error) { fmt.Println("fetching https://habrahabr.ru/rss/best/") resp, err := http.Get("https://habrahabr.ru/rss/best/") if err != nil { return nil, err } defer resp.Body.Close() body, _ := ioutil.ReadAll(resp.Body) rss := new(RSS) err = xml.Unmarshal(body, rss) if err != nil { return nil, err } return rss, nil } ================================================ FILE: 7-security/1_passwords/0_password.txt ================================================ john 1234 bob 12345 john 81dc9bdb52d04dc20036dbd8313ed055 bob 827ccb0eea8a706c4c34a16891f84e7b alice 81dc9bdb52d04dc20036dbd8313ed055 john 123_ad90103a6daa2d46f6ca32753f5bd8cd bob 234_876b13777d05743fca744018f8c82ef7 alice 789_0c01c17a759578ba5a956a18acd54c9b md5(salt + _ + password) -> reg password -> md5(salt + _ + password) -> db -> login password -> md5(salt + _ + password) <- db hash + salt ? == email - pass: k.kitsuragi@mail.ru - e10adc3949ba59abbe56e057f20f883e h.dubois@mail.ru - d8578edf8458ce06fbc5bb76a58c5ca4 ... ================================================ FILE: 7-security/1_passwords/1_salt.go ================================================ package main import ( "bytes" "crypto/rand" "fmt" "golang.org/x/crypto/argon2" ) func hashPass(salt []byte, plainPassword string) []byte { hashedPass := argon2.IDKey([]byte(plainPassword), []byte(salt), 1, 64*1024, 4, 32) return append(salt, hashedPass...) // [salt] + [pass_hash] } func checkPass(passHash []byte, plainPassword string) bool { salt := make([]byte, 8) copy(salt, passHash[:8]) userPassHash := hashPass(salt, plainPassword) return bytes.Equal(userPassHash, passHash) } func passExample() { pass := "love" // reg salt := make([]byte, 8) rand.Read(salt) fmt.Printf("salt: %x\n", salt) hashedPass := hashPass(salt, pass) fmt.Printf("hashedPass: %x\n", hashedPass) // login passValid := checkPass(hashedPass, pass) fmt.Printf("passValid: %v\n", passValid) } // func main() { // for i := 0; i < 3; i++ { // fmt.Println("\titeration", i) // passExample() // } // } ================================================ FILE: 7-security/1_passwords/2_pass.go ================================================ package main import ( "crypto/md5" "crypto/sha1" "fmt" "golang.org/x/crypto/argon2" "golang.org/x/crypto/bcrypt" "golang.org/x/crypto/pbkdf2" "golang.org/x/crypto/scrypt" ) var ( plainPassword = []byte("qwerty123456") // соль должна быть для каждого юзера своя, не используте в таком виде salt = []byte{0xd7, 0xc2, 0xf2, 0x51, 0xaa, 0x6a, 0x4e, 0x7b} ) // md5 - плохой вариант, подвержен брутфорс-атаке func PasswordMD5(plainPassword []byte) []byte { return md5.New().Sum(plainPassword) } // bcrypt where PBKDF2 or scrypt support is not available. func PasswordBcrypt(plainPassword []byte) []byte { passBcrypt, _ := bcrypt.GenerateFromPassword(plainPassword, 7) return passBcrypt } // PBKDF2 when FIPS certification or enterprise support on many platforms is required; func PasswordPBKDF2(plainPassword []byte) []byte { return pbkdf2.Key(plainPassword, salt, 4096, 32, sha1.New) } // scrypt where resisting any/all hardware accelerated attacks is necessary but support isn’t. func PasswordScrypt(plainPassword []byte) []byte { passScrypt, _ := scrypt.Key(plainPassword, salt, 1<<15, 8, 1, 32) return passScrypt } // Argon2 is the winner of the password hashing competition and should be considered as your first choice for new applications; func PasswordArgon2(plainPassword []byte) []byte { return argon2.IDKey(plainPassword, salt, 1, 64*1024, 4, 32) } // https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Password_Storage_Cheat_Sheet.md // https://cheatsheetseries.owasp.org func main() { fmt.Printf("PasswordMD5: %x\n", PasswordMD5(plainPassword)) fmt.Printf("PasswordBcrypt: %x\n", PasswordBcrypt(plainPassword)) fmt.Printf("PasswordBcrypt2: %x\n", PasswordBcrypt(plainPassword)) fmt.Printf("PasswordPBKDF2: %x\n", PasswordPBKDF2(plainPassword)) fmt.Printf("PasswordScrypt: %x\n", PasswordScrypt(plainPassword)) fmt.Printf("PasswordArgon2: %x\n", PasswordArgon2(plainPassword)) } ================================================ FILE: 7-security/1_passwords/2_pass_bench_test.go ================================================ package main import ( "testing" ) // go test -bench . -benchmem pass.go pass_bench_test.go func BenchmarkMD5(b *testing.B) { for i := 0; i < b.N; i++ { PasswordMD5(plainPassword) } } func BenchmarkBcrypt(b *testing.B) { for i := 0; i < b.N; i++ { PasswordBcrypt(plainPassword) } } func BenchmarkPBKDF2(b *testing.B) { for i := 0; i < b.N; i++ { PasswordPBKDF2(plainPassword) } } func BenchmarkScrypt(b *testing.B) { for i := 0; i < b.N; i++ { PasswordScrypt(plainPassword) } } func BenchmarkArgon2(b *testing.B) { for i := 0; i < b.N; i++ { PasswordArgon2(plainPassword) } } ================================================ FILE: 7-security/2_csrf/csrf.go ================================================ // CSRF - это выполнение какие-то действий на сайте от имени другого пользователя // данный пример ИСКУССТВЕННЫЙ, чтобы показать как проявляется CSRF // используйте пакет html/template // он автоматичски экранирует все входящие данные с учетом контекста // подрбонее https://golang.org/pkg/html/template/ package main import ( "net/http" // "html/template" "fmt" "math/rand" "strconv" "text/template" // надо заменить text/template на html/template чтобы по-умоллчанию было правильное экранирование "time" ) var sessions = map[string]string{} var cnt = 1 type Msg struct { ID int Message string Rating int } var messages = map[int]*Msg{} var loginFormTmplRaw = `
Login: Password: ` var messagesTmpl = ` <img src="/rate?id=1&vote=up">



{{range $idx, $var := .Messages}}
{{$var.Rating}}   {{$var.Message}}
{{end}} ` // https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html func main() { tmpl := template.New("main") tmpl, _ = tmpl.Parse(messagesTmpl) http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { if !checkSession(r) { w.Write([]byte(loginFormTmplRaw)) return } //выводим комментарии + форму отправки tmpl.Execute(w, struct { Messages map[int]*Msg }{ Messages: messages, }) }) // добавление комментария // добавим комментарий c текстом /* */ // это выведет на экран куки сайта. дальше с ними можно сделать всё что угодно - например отправить ан внешний сервис, который с сессией этого юзера будет слать спам пока может http.HandleFunc("/comment", func(w http.ResponseWriter, r *http.Request) { r.ParseForm() commentText := r.FormValue("comment") id := cnt messages[id] = &Msg{ ID: id, Message: commentText, Rating: 0, } cnt++ http.Redirect(w, r, "/", http.StatusFound) }) // функция для изменения рейтинга // тут происхрдит CSRF т.к. api.myproj.com/csrf -> referrer? -> jwt token front -> POST api.myproj.com/pay + token //-- front -> GET api.myproj.com/api/user -> Set-Cookie: csrf=kldjflckdhsfbilehroiw4hrkj34btf domain=.myproj.com expires=in 15 min -> POST api.myproj.com/pay X-CSRF-Token: getCookie('csrf') header == cookie ================================================ FILE: 7-security/3_csrf_token/csrf.go ================================================ // CSRF - это выполнение какие-то действий на сайте от имени другого пользователя // данный пример ИСКУССТВЕННЫЙ, чтобы показать как проявляется CSRF // используйте пакет html/template // он автоматичски экранирует все входящие данные с учетом контекста // подрбонее https://golang.org/pkg/html/template/ package main import ( "net/http" // "html/template" "fmt" "log" "math/rand" "strconv" "text/template" // надо заменить text/template на html/template чтобы по-умоллчанию было правильное экранирование "time" ) var sessions = map[string]*Session{} var cnt = 1 type Msg struct { ID int Message string Rating int } type Session struct { UserID uint32 ID string } var messages = map[int]*Msg{} var loginFormTmplRaw = `
Login: Password: ` var messagesTmpl = ` <img src="/rate?id=1&vote=up">



{{range $idx, $var := .Messages}}
{{$var.Rating}}   {{$var.Message}}
{{end}} ` func main() { tmpl := template.New("main") tmpl, _ = tmpl.Parse(messagesTmpl) // tokens, _ := NewHMACHashToken("golangcourse") //только хеш фиксированных данных // tokens, _ := NewAesCryptHashToken("qsRY2e4hcM5T7X984E9WQ5uZ8Nty7fxB") // можно еще че-то хранить и шифровать. без расшифровки не видно tokens, _ := NewJwtToken("qsRY2e4hcM5T7X984E9WQ5uZ8Nty7fxB") // можно так же че-то хранить и подписывать. видно, но нельзя подделать http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { sess, err := checkSession(r) if err != nil { w.Write([]byte(loginFormTmplRaw)) return } token, err := tokens.Create(sess, time.Now().Add(24*time.Hour).Unix()) if err != nil { log.Println("csrf token creation error:", err) http.Error(w, "internal error", http.StatusInternalServerError) return } //выводим комментарии + форму отправки tmpl.Execute(w, struct { Messages map[int]*Msg CSRFToken string }{ Messages: messages, CSRFToken: token, }) }) // добавление комментария // добавим комментарий c текстом /* */ // это выведет на экран куки сайта. дальше с ними можно сделать всё что угодно - например отправить ан внешний сервис, который с сессией этого юзера будет слать спам пока может http.HandleFunc("/comment", func(w http.ResponseWriter, r *http.Request) { r.ParseForm() sess, err := checkSession(r) if err != nil || r.Method == http.MethodGet { w.Write([]byte(loginFormTmplRaw)) return } CSRFToken := r.FormValue("csrf-token") _, err = tokens.Check(sess, CSRFToken) if err != nil { w.Write([]byte("{}")) return } commentText := r.FormValue("comment") id := cnt messages[id] = &Msg{ ID: id, Message: commentText, Rating: 0, } cnt++ http.Redirect(w, r, "/", http.StatusFound) }) // функция для изменения рейтинга // тут происхрдит CSRF т.к. payload.Exp { secret = key.Secret break } } if secret == "" { return nil, fmt.Errrof("no secret found") } return secret, nil } */ // https://specialistoff.net/page/902 ================================================ FILE: 7-security/3_csrf_token/tokjen_hash.go ================================================ package main import ( "crypto/hmac" "crypto/sha256" "encoding/hex" "fmt" "strconv" "strings" "time" ) // fbc1fd86ab53d52c3ffeb6529aea9676e14bc52b792414c32f5612b4eb2c9745:1567618546 // JSv5M7FZ5iPHnHiLXR1QbhnMcdoY/wvEae4a76KrGBxeHruFb1S90d4GkwsoQQU4R1zqEdSa0KMGflriF2dHj5XWm4Zp6OBxLp6BJFUhqpQxEBEr5yl4sxEHadgssvVWfWtDKe0bENU= // JSv5M7FZ5iPHnHiLXR1QbhnMcDAU/wvEae4a76KrGBxeHruFb1S90d4GkwsoQQU4R1zqEdSa0KMGflriF2dHj5XWm4Zp6OBxLp6BJFUhqpQxEBEr5yl4sxEHadgssvVWfWtDKe0bENU= // JSv5M7FZ5iPHnHiLXR1QbhnMcNEF/wvEae4a76KrGBxeHruFb1S90d4GkwsoQQU4R1zqEdSa0KMGflriF2dHj5XWm4Zp6OBxLp6BJFUhqpQxEBEr5yl4sxEHadgssvVWfWtDKe0bENU= type HashToken struct { Secret []byte } func NewHMACHashToken(secret string) (*HashToken, error) { return &HashToken{Secret: []byte(secret)}, nil } func (tk *HashToken) Create(s *Session, tokenExpTime int64) (string, error) { h := hmac.New(sha256.New, []byte(tk.Secret)) data := fmt.Sprintf("%s:%d:%d", s.ID, s.UserID, tokenExpTime) h.Write([]byte(data)) token := hex.EncodeToString(h.Sum(nil)) + ":" + strconv.FormatInt(tokenExpTime, 10) return token, nil } func (tk *HashToken) Check(s *Session, inputToken string) (bool, error) { tokenData := strings.Split(inputToken, ":") if len(tokenData) != 2 { return false, fmt.Errorf("bad token data") } tokenExp, err := strconv.ParseInt(tokenData[1], 10, 64) if err != nil { return false, fmt.Errorf("bad token time") } if tokenExp < time.Now().Unix() { return false, fmt.Errorf("token expired") } h := hmac.New(sha256.New, []byte(tk.Secret)) data := fmt.Sprintf("%s:%d:%d", s.ID, s.UserID, tokenExp) h.Write([]byte(data)) expectedMAC := h.Sum(nil) messageMAC, err := hex.DecodeString(tokenData[0]) if err != nil { return false, fmt.Errorf("cand hex decode token") } return hmac.Equal(messageMAC, expectedMAC), nil } ================================================ FILE: 7-security/4_xss/xss.go ================================================ // XSS - это внедрение вредоносного кода там где мы не ожидаем // например в комменте пишем JS, который будет выполняться для всех пользователей, читающих его // опасность заключается в том, что злоумышленник может вызывать от имени юзера какие-то методы // например отправка спама от его имени или кража сессии // лечится правильным экранированием всех внешних входных данных по отношению к сайту (в первую очередь - пользовательского ввода) // данный пример ИСКУССТВЕННЫЙ, чтобы показать как проявляется XSS // используйте пакет html/template // он автоматичски экранирует все входящие данные с учетом контекста // подрбонее https://golang.org/pkg/html/template/ package main import ( "fmt" "html/template" "math/rand" "net/http" // "text/template" "time" ) var sessions = map[string]string{} var messages = []string{"Hello World"} var loginFormTmplRaw = `
Login: Password: ` var messagesTmpl = ` <script>alert(document.cookie)</script>



{{range .Messages}}
{{.}}
{{end}} ` func checkSession(r *http.Request) bool { // обработка сессии // не используйте этот подход в продакшене sessionID, err := r.Cookie("session_id") if err == http.ErrNoCookie { return false } else if err != nil { PanicOnErr(err) } _, ok := sessions[sessionID.Value] if !ok { return false } return true } func main() { tmpl := template.New("main") tmpl, _ = tmpl.Parse(messagesTmpl) http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { if !checkSession(r) { w.Write([]byte(loginFormTmplRaw)) return } // для отключения экранирования в html/template newMsgs := []template.HTML{} for _, v := range messages { newMsgs = append(newMsgs, template.HTML(v)) } //выводим комментарии + форму отправки tmpl.Execute(w, struct { Messages []template.HTML }{ Messages: newMsgs, }) }) // добавление комментария // добавим комментарий c текстом /* */ // это выведет на экран куки сайта. дальше с ними можно сделать всё что угодно - например отправить на внешний сервис, который с сессией этого юзера будет слать спам пока может http.HandleFunc("/comment", func(w http.ResponseWriter, r *http.Request) { if !checkSession(r) { w.Write([]byte(loginFormTmplRaw)) return } r.ParseForm() commentText := r.FormValue("comment") messages = append(messages, commentText) http.Redirect(w, r, "/", http.StatusFound) }) // сервисный метод для очистки комментариев http.HandleFunc("/clear_comments", func(w http.ResponseWriter, r *http.Request) { if !checkSession(r) { w.Write([]byte(loginFormTmplRaw)) return } messages = []string{} http.Redirect(w, r, "/", http.StatusFound) }) // создаём сессию // не используйте этот подход в продакшене http.HandleFunc("/login", func(w http.ResponseWriter, r *http.Request) { r.ParseForm() inputLogin := r.Form["login"][0] expiration := time.Now().Add(365 * 24 * time.Hour) sessionID := RandStringRunes(32) sessions[sessionID] = inputLogin cookie := http.Cookie{Name: "session_id", Value: sessionID, Expires: expiration} http.SetCookie(w, &cookie) http.Redirect(w, r, "/", http.StatusFound) }) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } //PanicOnErr panics on error func PanicOnErr(err error) { if err != nil { panic(err) } } var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") func RandStringRunes(n int) string { b := make([]rune, n) for i := range b { b[i] = letterRunes[rand.Intn(len(letterRunes))] } return string(b) } ================================================ FILE: 7-security/5_xss_clean/login.txt ================================================ Здравствуйте, , спасибо за регу -> Регаете в сервисе юзера с email d.dorofeev@corp.mail.ru, ставите имя скачайте бесплатно и без смс ================================================ FILE: 7-security/5_xss_clean/xss_clean.go ================================================ package main import ( "encoding/json" "fmt" "github.com/microcosm-cc/bluemonday" "net/http" ) // для санитайзинга на сторое фронта используйте https://github.com/cure53/DOMPurify func main() { sanitizer := bluemonday.UGCPolicy() http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { comment := `Mail.ru` comment = sanitizer.Sanitize(comment) resp, _ := json.Marshal(map[string]interface{}{ "comment": comment, }) w.Write(resp) }) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } ================================================ FILE: 7-security/6_acl/acl_rbac.txt ================================================ ACL: Access Control List кто что и что делает? alice /menu write bob /menu read /admin/user/edit userid=1 userid=2 userid=3 /admin/user/moderate userid=1 ------- userid=1 /admin/user/edit /admin/user/moderate userid=2 /admin/user/edit userid=3 /admin/user/edit ------------------------------- RBAC: Role Based Access Control client /menu read /order write owner /menu read /menu write /orders read user_id; role 1; user 2; moderator 3; admin /admin/user/edit moderator admin /admin/user/moderate admin ------- admin /admin/user/edit /admin/user/moderate ------ https://github.com/casbin/casbin type Session struct { ID string UserID string Role string } ================================================ FILE: 7-security/6_acl/casbin/basic_model.conf ================================================ [request_definition] r = sub, obj, act [policy_definition] p = sub, obj, act [policy_effect] e = some(where (p.eft == allow)) [matchers] m = r.sub == p.sub && keyMatch(r.obj, p.obj) && (r.act == p.act || p.act == "*") ================================================ FILE: 7-security/6_acl/casbin/basic_policy.csv ================================================ p, admin, /*, * p, anonymous, /, * p, anonymous, /login, POST p, member, /, * p, member, /member/*, * p, member, /logout, * ================================================ FILE: 7-security/6_acl/casbin/rbac.go ================================================ package main import ( "log" "net/http" "net/url" "github.com/casbin/casbin" ) // https://casbin.org/en/editor func main() { ur := &UsersRepo{ db: map[string]*User{ "admin@mail.ru": {1, "admin", "555"}, "user@mail.ru": {2, "member", "123"}, }, } e, err := casbin.NewEnforcerSafe("basic_model.conf", "basic_policy.csv") if err != nil { panic(err) } r := http.NewServeMux() r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("root page")) }) r.HandleFunc("/login", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("you just logged int")) }) r.HandleFunc("/logout", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("you just logged out")) }) r.HandleFunc("/member/profile", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("here is your profile")) }) r.HandleFunc("/member/profiles", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("here is your profile")) }) r.HandleFunc("/admin/user", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("user edditing")) }) r.HandleFunc("/admin/users", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("users list")) }) mux := PermissionsMiddleware(e, ur, r) http.ListenAndServe(":8080", mux) } func PermissionsMiddleware(e *casbin.Enforcer, ur *UsersRepo, next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { v, _ := url.ParseQuery(r.URL.RawQuery) email := v.Get("email") // check auth and cookie/token ... role := "anonymous" user := ur.GetUser(email) if user != nil { role = user.Role } res, _ := e.EnforceSafe(role, r.URL.Path, r.Method) log.Printf("path=%s role=%s access=%v", r.URL.Path, role, res) if res { next.ServeHTTP(w, r) } else { http.Error(w, "forbidden", http.StatusForbidden) return } }) } type User struct { UserID int Role string Password string } type UsersRepo struct { db map[string]*User } func (ur *UsersRepo) GetUser(email string) *User { return ur.db[email] } ================================================ FILE: 7-security/7_docker/.dockerignore ================================================ *.exe .git .DS_Store .gitignore ================================================ FILE: 7-security/7_docker/Dockerfile ================================================ FROM golang:1.19-alpine COPY ./code /go/src/my_super_app WORKDIR /go/src/my_super_app RUN go install . EXPOSE 8080/tcp CMD [ "my_super_app" ] ================================================ FILE: 7-security/7_docker/Dockerfile.Multistage ================================================ # 1 шаг - сборки FROM golang:1.19-alpine AS build_stage COPY ./code /go/src/my_super_app WORKDIR /go/src/my_super_app RUN go install . # 2 шаг FROM alpine AS run_stage WORKDIR /app_binary COPY --from=build_stage /go/bin/my_super_app /app_binary/ RUN chmod +x ./my_super_app EXPOSE 8080/tcp ENTRYPOINT ./my_super_app ================================================ FILE: 7-security/7_docker/code/go.mod ================================================ module my_super_app go 1.19 ================================================ FILE: 7-security/7_docker/code/main.go ================================================ package main import ( "fmt" "net/http" "net/url" "strconv" "strings" ) var privateAlbums = map[string]struct{}{ "selfies": struct{}{}, "nudes": struct{}{}, } var privateAlbumsACL = map[string]map[int]struct{}{ "selfies": map[int]struct{}{ 1: struct{}{}, 2: struct{}{}, 3: struct{}{}, }, "nudes": map[int]struct{}{ 2: struct{}{}, }, } func checkACL(albumName string, uid int) bool { if _, ok := privateAlbums[albumName]; !ok { return true } allowedUsers, ok := privateAlbumsACL[albumName] if !ok { return true } _, ok = allowedUsers[uid] return ok } func getSession(r string) int { uid, _ := strconv.Atoi(r) return uid } func main() { http.HandleFunc("/auth", func(w http.ResponseWriter, r *http.Request) { fmt.Println("AUTH request", r) // fmt.Println("X-Original-URI", r.Header.Get("X-Original-URI")) req, _ := url.Parse(r.Header.Get("X-Original-URI")) // fmt.Println("X-User-ID", req, err) // fmt.Println("Req Data", req.Path, " -- ", req.Query().Get("user_id")) uid := getSession(req.Query().Get("user_id")) str := req.Path albumName := strings.ReplaceAll(str, "/albums/", "") fmt.Println("PARAMS", albumName, uid) if !checkACL(albumName, uid) { fmt.Println("ACL failed", albumName, uid) http.Error(w, "", 403) } w.Header().Set("WWW-Authenticate", req.Query().Get("user_id")) fmt.Println("ACL OK", albumName, uid) http.Error(w, "", 200) }) http.HandleFunc("/albums/", func(w http.ResponseWriter, r *http.Request) { fmt.Println("incoming request", r) fmt.Fprintln(w, "hi", r.Header.Get("WWW-Authenticate")) }) http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { fmt.Println("ROOT incoming request", r) fmt.Fprintln(w, "hi", r.Header.Get("WWW-Authenticate")) }) fmt.Println("start server at :8080") http.ListenAndServe(":8080", nil) } ================================================ FILE: 7-security/7_docker/docker-compose.yml ================================================ version: '3' services: dockergo: image: docker-golang-image:latest nginx: image: nginx:1.15.3 links: - dockergo:dockergo volumes: - ./nginx:/etc/nginx/conf.d ports: - 8080:80 ================================================ FILE: 7-security/7_docker/nginx/nginx.conf ================================================ server { listen 80; location / { proxy_pass http://dockergo:8080/; } location /albums/ { auth_request /auth; proxy_pass http://dockergo:8080/; } location = /auth { proxy_pass http://dockergo:8080/auth; proxy_pass_request_body off; proxy_set_header Content-Length ""; # proxy_set_header X-User-ID $arg_user_id; proxy_set_header X-Original-URI $request_uri; } } ================================================ FILE: 7-security/7_docker/readme.md ================================================ docker build -f Dockerfile -t docker-golang-image . docker build -f Dockerfile.Multistage -t docker-golang-image . docker-compose up docker run --rm -p 8080:8080 docker-golang-image ================================================ FILE: 8-microservices/0_service/1_step/main.go ================================================ package main import ( "fmt" "net/http" "time" ) var loginFormTmpl = []byte(`
Login: Password: `) func checkSession(r *http.Request) (*Session, error) { cookieSessionID, err := r.Cookie("session_id") if err == http.ErrNoCookie { return nil, nil } else if err != nil { return nil, err } sess := AuthCheckSession(&SessionID{ ID: cookieSessionID.Value, }) return sess, nil } func innerPage(w http.ResponseWriter, r *http.Request) { sess, err := checkSession(r) if err != nil { w.WriteHeader(http.StatusInternalServerError) return } if sess == nil { w.Write(loginFormTmpl) return } w.Header().Set("Content-Type", "text/html") fmt.Fprintln(w, "Welcome, "+sess.Login+"
") fmt.Fprintln(w, "Session ua: "+sess.Useragent+"
") fmt.Fprintln(w, `logout`) } func loginPage(w http.ResponseWriter, r *http.Request) { inputLogin := r.FormValue("login") expiration := time.Now().Add(365 * 24 * time.Hour) sess, err := AuthCreateSession(&Session{ Login: inputLogin, Useragent: r.UserAgent(), }) if err != nil { w.WriteHeader(http.StatusInternalServerError) return } cookie := http.Cookie{ Name: "session_id", Value: sess.ID, Expires: expiration, } http.SetCookie(w, &cookie) http.Redirect(w, r, "/", http.StatusFound) } func logoutPage(w http.ResponseWriter, r *http.Request) { session, err := r.Cookie("session_id") if err == http.ErrNoCookie { http.Redirect(w, r, "/", http.StatusFound) return } else if err != nil { w.WriteHeader(http.StatusInternalServerError) return } AuthSessionDelete(&SessionID{ ID: session.Value, }) session.Expires = time.Now().AddDate(0, 0, -1) http.SetCookie(w, session) http.Redirect(w, r, "/", http.StatusFound) } func main() { http.HandleFunc("/", innerPage) http.HandleFunc("/login", loginPage) http.HandleFunc("/logout", logoutPage) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } ================================================ FILE: 8-microservices/0_service/1_step/run_test.go ================================================ package main import ( "testing" ) func TestExample(t *testing.T) { // создаем сессию sessId, err := AuthCreateSession( &Session{ Login: "anton", Useragent: "safari", }) t.Log("sessId", sessId, err) // проеряем сессию sess := AuthCheckSession( &SessionID{ ID: sessId.ID, }) t.Log("sess", sess) // удаляем сессию AuthSessionDelete( &SessionID{ ID: sessId.ID, }) // проверяем еще раз sess = AuthCheckSession( &SessionID{ ID: sessId.ID, }) t.Log("sess", sess) t.Fail() } ================================================ FILE: 8-microservices/0_service/1_step/session.go ================================================ package main import ( "math/rand" "sync" ) type Session struct { Login string Useragent string } type SessionID struct { ID string } const sessKeyLen = 10 var ( sessions = map[SessionID]*Session{} mu = &sync.RWMutex{} ) func AuthCreateSession(in *Session) (*SessionID, error) { mu.Lock() id := SessionID{RandStringRunes(sessKeyLen)} mu.Unlock() sessions[id] = in return &id, nil } func AuthCheckSession(in *SessionID) *Session { mu.RLock() defer mu.RUnlock() if sess, ok := sessions[*in]; ok { return sess } return nil } func AuthSessionDelete(in *SessionID) { mu.Lock() defer mu.Unlock() delete(sessions, *in) } var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") func RandStringRunes(n int) string { b := make([]rune, n) for i := range b { b[i] = letterRunes[rand.Intn(len(letterRunes))] } return string(b) } ================================================ FILE: 8-microservices/0_service/2_step/main.go ================================================ package main import ( "fmt" "net/http" "time" ) var loginFormTmpl = []byte(`
Login: Password: `) var ( sessManager SessionManagerInterface ) func checkSession(r *http.Request) (*Session, error) { cookieSessionID, err := r.Cookie("session_id") if err == http.ErrNoCookie { return nil, nil } else if err != nil { return nil, err } sess := sessManager.Check(&SessionID{ ID: cookieSessionID.Value, }) return sess, nil } func innerPage(w http.ResponseWriter, r *http.Request) { sess, err := checkSession(r) if err != nil { w.WriteHeader(http.StatusInternalServerError) return } if sess == nil { w.Write(loginFormTmpl) return } w.Header().Set("Content-Type", "text/html") fmt.Fprintln(w, "Welcome, "+sess.Login+"
") fmt.Fprintln(w, "Session ua: "+sess.Useragent+"
") fmt.Fprintln(w, `logout`) } func loginPage(w http.ResponseWriter, r *http.Request) { inputLogin := r.FormValue("login") expiration := time.Now().Add(365 * 24 * time.Hour) sess, err := sessManager.Create(&Session{ Login: inputLogin, Useragent: r.UserAgent(), }) if err != nil { w.WriteHeader(http.StatusInternalServerError) return } cookie := http.Cookie{ Name: "session_id", Value: sess.ID, Expires: expiration, } http.SetCookie(w, &cookie) http.Redirect(w, r, "/", http.StatusFound) } func main() { sessManager = NewSessionManager() http.HandleFunc("/", innerPage) http.HandleFunc("/login", loginPage) http.HandleFunc("/logout", logoutPage) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } func logoutPage(w http.ResponseWriter, r *http.Request) { session, err := r.Cookie("session_id") if err == http.ErrNoCookie { http.Redirect(w, r, "/", http.StatusFound) return } else if err != nil { w.WriteHeader(http.StatusInternalServerError) return } sessManager.Delete(&SessionID{ ID: session.Value, }) session.Expires = time.Now().AddDate(0, 0, -1) http.SetCookie(w, session) http.Redirect(w, r, "/", http.StatusFound) } ================================================ FILE: 8-microservices/0_service/2_step/run_test.go ================================================ package main import ( "testing" ) func TestExample(t *testing.T) { sessManager = NewSessionManager() // создаем сессию sessId, err := sessManager.Create( &Session{ Login: "anton", Useragent: "safari", }) t.Log("sessId", sessId, err) // проеряем сессию sess := sessManager.Check( &SessionID{ ID: sessId.ID, }) t.Log("sess", sess) // удаляем сессию sessManager.Delete( &SessionID{ ID: sessId.ID, }) // проверяем еще раз sess = sessManager.Check( &SessionID{ ID: sessId.ID, }) t.Log("sess", sess) t.Fail() } ================================================ FILE: 8-microservices/0_service/2_step/session.go ================================================ package main import ( "math/rand" "sync" ) type Session struct { Login string Useragent string } type SessionID struct { ID string } const sessKeyLen = 10 type SessionManagerInterface interface { Create(in *Session) (*SessionID, error) Check(in *SessionID) *Session Delete(in *SessionID) } type SessionManager struct { mu sync.RWMutex sessions map[SessionID]*Session } func NewSessionManager() *SessionManager { return &SessionManager{ mu: sync.RWMutex{}, sessions: map[SessionID]*Session{}, } } func (sm *SessionManager) Create(in *Session) (*SessionID, error) { sm.mu.Lock() id := SessionID{RandStringRunes(sessKeyLen)} sm.mu.Unlock() sm.sessions[id] = in return &id, nil } func (sm *SessionManager) Check(in *SessionID) *Session { sm.mu.RLock() defer sm.mu.RUnlock() if sess, ok := sm.sessions[*in]; ok { return sess } return nil } func (sm *SessionManager) Delete(in *SessionID) { sm.mu.Lock() defer sm.mu.Unlock() delete(sm.sessions, *in) } var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") func RandStringRunes(n int) string { b := make([]rune, n) for i := range b { b[i] = letterRunes[rand.Intn(len(letterRunes))] } return string(b) } ================================================ FILE: 8-microservices/1_net-rpc/client/client.go ================================================ package main import ( "fmt" "net/http" "time" ) var loginFormTmpl = []byte(`
Login: Password: `) var ( sessManager *SessionManager ) func checkSession(r *http.Request) (*Session, error) { cookieSessionID, err := r.Cookie("session_id") if err == http.ErrNoCookie { return nil, nil } else if err != nil { return nil, err } sess := sessManager.Check(&SessionID{ ID: cookieSessionID.Value, }) return sess, nil } func innerPage(w http.ResponseWriter, r *http.Request) { sess, err := checkSession(r) if err != nil { w.WriteHeader(http.StatusInternalServerError) return } if sess == nil { w.Write(loginFormTmpl) return } w.Header().Set("Content-Type", "text/html") fmt.Fprintln(w, "Welcome, "+sess.Login+"
") fmt.Fprintln(w, "Session ua: "+sess.Useragent+"
") fmt.Fprintln(w, `logout`) } func loginPage(w http.ResponseWriter, r *http.Request) { inputLogin := r.FormValue("login") expiration := time.Now().Add(365 * 24 * time.Hour) sess, err := sessManager.Create(&Session{ Login: inputLogin, Useragent: r.UserAgent(), }) if err != nil { w.WriteHeader(http.StatusInternalServerError) return } cookie := http.Cookie{ Name: "session_id", Value: sess.ID, Expires: expiration, } http.SetCookie(w, &cookie) http.Redirect(w, r, "/", http.StatusFound) } func main() { sessManager = NewSessionManager() http.HandleFunc("/", innerPage) http.HandleFunc("/login", loginPage) http.HandleFunc("/logout", logoutPage) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } func logoutPage(w http.ResponseWriter, r *http.Request) { session, err := r.Cookie("session_id") if err == http.ErrNoCookie { http.Redirect(w, r, "/", http.StatusFound) return } else if err != nil { w.WriteHeader(http.StatusInternalServerError) return } sessManager.Delete(&SessionID{ ID: session.Value, }) session.Expires = time.Now().AddDate(0, 0, -1) http.SetCookie(w, session) http.Redirect(w, r, "/", http.StatusFound) } ================================================ FILE: 8-microservices/1_net-rpc/client/run_test.go ================================================ package main import ( "testing" ) func TestRun(t *testing.T) { sessManager = NewSessionManager() // создаем сессию sessId, err := sessManager.Create( &Session{ Login: "anton", Useragent: "safari", }) t.Log("sessId", sessId, err) // проеряем сессию sess := sessManager.Check( &SessionID{ ID: sessId.ID, }) t.Log("sess", sess) // удаляем сессию sessManager.Delete( &SessionID{ ID: sessId.ID, }) // проверяем еще раз sess = sessManager.Check( &SessionID{ ID: sessId.ID, }) t.Log("sess", sess) t.Fail() } ================================================ FILE: 8-microservices/1_net-rpc/client/session.go ================================================ package main import ( "fmt" "log" "net/rpc" ) type Session struct { Login string Useragent string } type SessionID struct { ID string } type SessionManagerI interface { Create(*Session) (*SessionID, error) Check(*SessionID) *Session Delete(*SessionID) } type SessionManager struct { client *rpc.Client } func NewSessionManager() *SessionManager { client, err := rpc.DialHTTP("tcp", "localhost:8081") if err != nil { log.Fatal("dialing:", err) } return &SessionManager{ client: client, } } func (sm *SessionManager) Create(in *Session) (*SessionID, error) { id := new(SessionID) err := sm.client.Call("SessionManager.Create", in, id) if err != nil { fmt.Println("SessionManager.Create error:", err) return nil, nil } return id, nil } func (sm *SessionManager) Check(in *SessionID) *Session { sess := new(Session) err := sm.client.Call("SessionManager.Check", in, sess) if err != nil { fmt.Println("SessionManager.Check error:", err) return nil } return sess } func (sm *SessionManager) Delete(in *SessionID) { var reply int err := sm.client.Call("SessionManager.Delete", in, &reply) if err != nil { fmt.Println("SessionManager.Delete error:", err) } } ================================================ FILE: 8-microservices/1_net-rpc/server/server.go ================================================ package main import ( "fmt" "log" "net" "net/http" "net/rpc" ) func main() { sessManager := NewSessManager() rpc.Register(sessManager) rpc.HandleHTTP() l, e := net.Listen("tcp", ":8081") if e != nil { log.Fatal("listen error:", e) } fmt.Println("starting server at :8081") http.Serve(l, nil) } ================================================ FILE: 8-microservices/1_net-rpc/server/session.go ================================================ package main import ( "fmt" "math/rand" "sync" ) type Session struct { Login string Useragent string } type SessionID struct { ID string } const sessKeyLen = 10 type SessionManager struct { mu sync.RWMutex sessions map[SessionID]*Session } func NewSessManager() *SessionManager { return &SessionManager{ mu: sync.RWMutex{}, sessions: map[SessionID]*Session{}, } } // func (sm *SessionManager) Create(in *Session) (*SessionID, error) { func (sm *SessionManager) Create(in *Session, out *SessionID) error { fmt.Println("call Create", in) id := &SessionID{RandStringRunes(sessKeyLen)} sm.mu.Lock() sm.sessions[*id] = in sm.mu.Unlock() *out = *id return nil } func (sm *SessionManager) Check(in *SessionID, out *Session) error { fmt.Println("call Check", in) sm.mu.RLock() defer sm.mu.RUnlock() if sess, ok := sm.sessions[*in]; ok { *out = *sess } return nil } func (sm *SessionManager) Delete(in *SessionID, out *int) error { fmt.Println("call Delete", in) sm.mu.Lock() defer sm.mu.Unlock() delete(sm.sessions, *in) *out = 1 return nil } var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") func RandStringRunes(n int) string { b := make([]rune, n) for i := range b { b[i] = letterRunes[rand.Intn(len(letterRunes))] } return string(b) } ================================================ FILE: 8-microservices/2_json-rpc/client/client.go ================================================ package main import ( "fmt" "net/http" "time" ) var loginFormTmpl = []byte(`
Login: Password: `) var ( sessManager *SessionManager ) func checkSession(r *http.Request) (*Session, error) { cookieSessionID, err := r.Cookie("session_id") if err == http.ErrNoCookie { return nil, nil } else if err != nil { return nil, err } sess := sessManager.Check(&SessionID{ ID: cookieSessionID.Value, }) return sess, nil } func innerPage(w http.ResponseWriter, r *http.Request) { sess, err := checkSession(r) if err != nil { w.WriteHeader(http.StatusInternalServerError) return } if sess == nil { w.Write(loginFormTmpl) return } w.Header().Set("Content-Type", "text/html") fmt.Fprintln(w, "Welcome, "+sess.Login+"
") fmt.Fprintln(w, "Session ua: "+sess.Useragent+"
") fmt.Fprintln(w, `logout`) } func loginPage(w http.ResponseWriter, r *http.Request) { inputLogin := r.FormValue("login") expiration := time.Now().Add(365 * 24 * time.Hour) sess, err := sessManager.Create(&Session{ Login: inputLogin, Useragent: r.UserAgent(), }) if err != nil { w.WriteHeader(http.StatusInternalServerError) return } cookie := http.Cookie{ Name: "session_id", Value: sess.ID, Expires: expiration, } http.SetCookie(w, &cookie) http.Redirect(w, r, "/", http.StatusFound) } func main() { sessManager = NewSessionManager() http.HandleFunc("/", innerPage) http.HandleFunc("/login", loginPage) http.HandleFunc("/logout", logoutPage) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } func logoutPage(w http.ResponseWriter, r *http.Request) { session, err := r.Cookie("session_id") if err == http.ErrNoCookie { http.Redirect(w, r, "/", http.StatusFound) return } else if err != nil { w.WriteHeader(http.StatusInternalServerError) return } sessManager.Delete(&SessionID{ ID: session.Value, }) session.Expires = time.Now().AddDate(0, 0, -1) http.SetCookie(w, session) http.Redirect(w, r, "/", http.StatusFound) } ================================================ FILE: 8-microservices/2_json-rpc/client/run_test.go ================================================ package main import ( "testing" ) func TestRun(t *testing.T) { sessManager = NewSessionManager() // создаем сессию sessId, err := sessManager.Create( &Session{ Login: "anton", Useragent: "safari", }) t.Log("sessId", sessId, err) // проеряем сессию sess := sessManager.Check( &SessionID{ ID: sessId.ID, }) t.Log("sess", sess) // удаляем сессию sessManager.Delete( &SessionID{ ID: sessId.ID, }) // проверяем еще раз sess = sessManager.Check( &SessionID{ ID: sessId.ID, }) t.Log("sess", sess) t.Fail() } ================================================ FILE: 8-microservices/2_json-rpc/client/session.go ================================================ package main import ( "fmt" jsonrpc "github.com/ybbus/jsonrpc/v2" ) type Session struct { Login string Useragent string } type SessionID struct { ID string } type SessionManagerI interface { Create(*Session) (*SessionID, error) Check(*SessionID) *Session Delete(*SessionID) } type SessionManager struct { client jsonrpc.RPCClient } func NewSessionManager() *SessionManager { client := jsonrpc.NewClient("http://localhost:8081/rpc") return &SessionManager{ client: client, } } func (sm *SessionManager) Create(in *Session) (*SessionID, error) { id := new(SessionID) _, err := sm.client.Call("SessionManager.Create", in, id) if err != nil { fmt.Println("SessionManager.Create error:", err) return nil, nil } return id, nil } func (sm *SessionManager) Check(in *SessionID) *Session { sess := new(Session) _, err := sm.client.Call("SessionManager.Check", in, sess) if err != nil { fmt.Println("SessionManager.Check error:", err) return nil } return sess } func (sm *SessionManager) Delete(in *SessionID) { var reply int _, err := sm.client.Call("SessionManager.Delete", in, &reply) if err != nil { fmt.Println("SessionManager.Delete error:", err) } } ================================================ FILE: 8-microservices/2_json-rpc/server/server.go ================================================ package main import ( "fmt" "io" "log" "net/http" "net/rpc" "net/rpc/jsonrpc" ) type HttpConn struct { in io.Reader out io.Writer } func (c *HttpConn) Read(p []byte) (n int, err error) { return c.in.Read(p) } func (c *HttpConn) Write(d []byte) (n int, err error) { return c.out.Write(d) } func (c *HttpConn) Close() error { return nil } /* { "jsonrpc":"2.0", "id":1, "method":"SessionManager.Create", "params":[ { "login":"rvasily", "useragent":"chrome" } ] } */ /* curl -v -X POST -H "Content-Type: application/json" -H "X-Auth: 123" -d '{"jsonrpc":"2.0", "id": 1, "method": "SessionManager.Create", "params": [{"login":"rvasily", "useragent": "chrome"}]}' http://localhost:8081/rpc curl -v -X POST -H "Content-Type: application/json" -H "X-Auth: 123" -d '{"jsonrpc":"2.0", "id": 2, "method": "SessionManager.Check", "params": [{"id":"XVlBzgbaiC"}]}' http://localhost:8081/rpc */ type Handler struct { rpcServer *rpc.Server } func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { fmt.Println("rpc auth: ", r.Header.Get("X-Auth")) serverCodec := jsonrpc.NewServerCodec(&HttpConn{ in: r.Body, out: w, }) w.Header().Set("Content-type", "application/json") err := h.rpcServer.ServeRequest(serverCodec) if err != nil { log.Printf("Error while serving JSON request: %v", err) http.Error(w, `{"error":"cant serve request"}`, 500) } else { w.WriteHeader(200) } } func main() { sessManager := NewSessManager() server := rpc.NewServer() server.Register(sessManager) sessionHandler := &Handler{ rpcServer: server, } http.Handle("/rpc", sessionHandler) fmt.Println("starting server at :8081") http.ListenAndServe(":8081", nil) } ================================================ FILE: 8-microservices/2_json-rpc/server/session.go ================================================ package main import ( "fmt" "math/rand" "sync" ) type Session struct { Login string Useragent string } type SessionID struct { ID string } const sessKeyLen = 10 type SessionManager struct { mu sync.RWMutex sessions map[SessionID]*Session } func NewSessManager() *SessionManager { return &SessionManager{ mu: sync.RWMutex{}, sessions: map[SessionID]*Session{}, } } func (sm *SessionManager) Create(in *Session, out *SessionID) error { fmt.Println("call Create", in) id := &SessionID{RandStringRunes(sessKeyLen)} sm.mu.Lock() sm.sessions[*id] = in sm.mu.Unlock() *out = *id return nil } func (sm *SessionManager) Check(in *SessionID, out *Session) error { fmt.Println("call Check", in) sm.mu.RLock() defer sm.mu.RUnlock() if sess, ok := sm.sessions[*in]; ok { *out = *sess } return nil } func (sm *SessionManager) Delete(in *SessionID, out *int) error { fmt.Println("call Delete", in) sm.mu.Lock() defer sm.mu.Unlock() delete(sm.sessions, *in) *out = 1 return nil } var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") func RandStringRunes(n int) string { b := make([]rune, n) for i := range b { b[i] = letterRunes[rand.Intn(len(letterRunes))] } return string(b) } ================================================ FILE: 8-microservices/3_protobuf/main.go ================================================ package main import ( "encoding/json" "fmt" "github.com/golang/protobuf/proto" "gopkg.in/vmihailenco/msgpack.v2" ) // protoc --go_out=. *.proto func main() { sess := &Session{ Login: "vasiliy", Useragent: "Chrome", } dataJson, _ := json.Marshal(sess) fmt.Printf("dataJson: %s\n", string(dataJson)) fmt.Printf("dataJson\nlen %d\n%v\n", len(dataJson), dataJson) /* 39 байт {"login":"dmitry","useragent":"Chrome"} */ dataPb, _ := proto.Marshal(sess) fmt.Printf("dataPb\nlen %d\n%v\n", len(dataPb), dataPb) /* 17 байт [10 7 114 118 97 115 105 108 121 18 6 67 104 114 111 109 101] 10 // номер поля + тип 7 // длина данных 114 118 97 115 105 108 121 18 // номер поля + тип 6 // длина данных 67 104 114 111 109 101 */ dataMsgPack, _ := msgpack.Marshal(sess) fmt.Printf("dataMsgPack\nlen %d\n%v\n", len(dataMsgPack), dataMsgPack) } ================================================ FILE: 8-microservices/3_protobuf/session.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.26.0 // protoc v3.17.3 // source: session.proto package main import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) 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 SessionID struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"` } func (x *SessionID) Reset() { *x = SessionID{} if protoimpl.UnsafeEnabled { mi := &file_session_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } func (x *SessionID) String() string { return protoimpl.X.MessageStringOf(x) } func (*SessionID) ProtoMessage() {} func (x *SessionID) ProtoReflect() protoreflect.Message { mi := &file_session_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 SessionID.ProtoReflect.Descriptor instead. func (*SessionID) Descriptor() ([]byte, []int) { return file_session_proto_rawDescGZIP(), []int{0} } func (x *SessionID) GetID() string { if x != nil { return x.ID } return "" } type Session struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Login string `protobuf:"bytes,1,opt,name=login,proto3" json:"login,omitempty"` Useragent string `protobuf:"bytes,2,opt,name=useragent,proto3" json:"useragent,omitempty"` } func (x *Session) Reset() { *x = Session{} if protoimpl.UnsafeEnabled { mi := &file_session_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } func (x *Session) String() string { return protoimpl.X.MessageStringOf(x) } func (*Session) ProtoMessage() {} func (x *Session) ProtoReflect() protoreflect.Message { mi := &file_session_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 Session.ProtoReflect.Descriptor instead. func (*Session) Descriptor() ([]byte, []int) { return file_session_proto_rawDescGZIP(), []int{1} } func (x *Session) GetLogin() string { if x != nil { return x.Login } return "" } func (x *Session) GetUseragent() string { if x != nil { return x.Useragent } return "" } var File_session_proto protoreflect.FileDescriptor var file_session_proto_rawDesc = []byte{ 0x0a, 0x0d, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x6d, 0x61, 0x69, 0x6e, 0x22, 0x1b, 0x0a, 0x09, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x44, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x44, 0x22, 0x3d, 0x0a, 0x07, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x75, 0x73, 0x65, 0x72, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x2f, 0x3b, 0x6d, 0x61, 0x69, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_session_proto_rawDescOnce sync.Once file_session_proto_rawDescData = file_session_proto_rawDesc ) func file_session_proto_rawDescGZIP() []byte { file_session_proto_rawDescOnce.Do(func() { file_session_proto_rawDescData = protoimpl.X.CompressGZIP(file_session_proto_rawDescData) }) return file_session_proto_rawDescData } var file_session_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_session_proto_goTypes = []interface{}{ (*SessionID)(nil), // 0: main.SessionID (*Session)(nil), // 1: main.Session } var file_session_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type 0, // [0:0] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name } func init() { file_session_proto_init() } func file_session_proto_init() { if File_session_proto != nil { return } if !protoimpl.UnsafeEnabled { file_session_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*SessionID); i { case 0: return &v.state case 1: return &v.sizeCache case 2: return &v.unknownFields default: return nil } } file_session_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Session); i { case 0: return &v.state case 1: return &v.sizeCache case 2: return &v.unknownFields default: return nil } } } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_session_proto_rawDesc, NumEnums: 0, NumMessages: 2, NumExtensions: 0, NumServices: 0, }, GoTypes: file_session_proto_goTypes, DependencyIndexes: file_session_proto_depIdxs, MessageInfos: file_session_proto_msgTypes, }.Build() File_session_proto = out.File file_session_proto_rawDesc = nil file_session_proto_goTypes = nil file_session_proto_depIdxs = nil } ================================================ FILE: 8-microservices/3_protobuf/session.proto ================================================ syntax = "proto3"; option go_package = "./;main"; // protoc --go_out=. *.proto package main; message SessionID { string ID = 1; } message Session { string login = 1; string useragent = 2; } ================================================ FILE: 8-microservices/4_grpc/client/main.go ================================================ package main import ( "context" "fmt" "log" "net/http" "time" "google.golang.org/grpc" "github.com/go-park-mail-ru/lectures/8-microservices/4_grpc/session" ) var loginFormTmpl = []byte(`
Login: Password: `) var ( sessManager session.AuthCheckerClient ) func checkSession(r *http.Request) (*session.Session, error) { cookieSessionID, err := r.Cookie("session_id") if err == http.ErrNoCookie { return nil, nil } else if err != nil { return nil, err } sess, err := sessManager.Check( context.Background(), &session.SessionID{ ID: cookieSessionID.Value, }) if err != nil { return nil, err } return sess, nil } func innerPage(w http.ResponseWriter, r *http.Request) { sess, err := checkSession(r) if err != nil { w.Write(loginFormTmpl) return } if sess == nil { w.Write(loginFormTmpl) return } w.Header().Set("Content-Type", "text/html") fmt.Fprintln(w, "Welcome, "+sess.Login+"
") fmt.Fprintln(w, "Session ua: "+sess.Useragent+"
") fmt.Fprintln(w, `logout`) } func loginPage(w http.ResponseWriter, r *http.Request) { inputLogin := r.FormValue("login") expiration := time.Now().Add(365 * 24 * time.Hour) sess, err := sessManager.Create( context.Background(), &session.Session{ Login: inputLogin, Useragent: r.UserAgent(), }) if err != nil { w.WriteHeader(http.StatusInternalServerError) return } cookie := http.Cookie{ Name: "session_id", Value: sess.ID, Expires: expiration, } http.SetCookie(w, &cookie) http.Redirect(w, r, "/", http.StatusFound) } func main() { grcpConn, err := grpc.Dial( "127.0.0.1:8081", grpc.WithInsecure(), ) if err != nil { log.Fatalf("cant connect to grpc") } defer grcpConn.Close() sessManager = session.NewAuthCheckerClient(grcpConn) http.HandleFunc("/", innerPage) http.HandleFunc("/login", loginPage) http.HandleFunc("/logout", logoutPage) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } func logoutPage(w http.ResponseWriter, r *http.Request) { cookieSessionID, err := r.Cookie("session_id") if err == http.ErrNoCookie { http.Redirect(w, r, "/", http.StatusFound) return } else if err != nil { w.WriteHeader(http.StatusInternalServerError) return } sessManager.Delete( context.Background(), &session.SessionID{ ID: cookieSessionID.Value, }) cookieSessionID.Expires = time.Now().AddDate(0, 0, -1) http.SetCookie(w, cookieSessionID) http.Redirect(w, r, "/", http.StatusFound) } ================================================ FILE: 8-microservices/4_grpc/client/run_test.go ================================================ package main import ( "context" "log" "testing" "github.com/go-park-mail-ru/lectures/8-microservices/4_grpc/session" "google.golang.org/grpc" ) func TestRun(t *testing.T) { grcpConn, err := grpc.Dial( "127.0.0.1:8081", grpc.WithInsecure(), ) if err != nil { log.Fatalf("cant connect to grpc") } defer grcpConn.Close() sessManager := session.NewAuthCheckerClient(grcpConn) ctx := context.Background() // создаем сессию sessId, err := sessManager.Create(ctx, &session.Session{ Login: "rvasily", Useragent: "chrome", }) log.Println("sessId", sessId, err) // проеряем сессию sess, err := sessManager.Check(ctx, &session.SessionID{ ID: sessId.ID, }) log.Println("sess", sess, err) // удаляем сессию _, err = sessManager.Delete(ctx, &session.SessionID{ ID: sessId.ID, }) // проверяем еще раз sess, err = sessManager.Check(ctx, &session.SessionID{ ID: sessId.ID, }) log.Println("sess", sess, err) t.Fail() } ================================================ FILE: 8-microservices/4_grpc/readme.md ================================================ пример с микросервисом авторизации смысл: * проверяем авторизацию в 1 месте из разных сервисов, можем горизонатльно масштабироваться (увеличивать количество серверов) * скрываем детали реализации хранения - теперь это может быть мапка в памяти, мемкеш, таранутл, файлы, база, libastral # 1 старый способ генерации. он deprecated, но может еще работать 1. надо скачать protoc () 2. go get -u github.com/golang/protobuf/{proto,protoc-gen-go} 3. go get -u google.golang.org/grpc 4. go get -u golang.org/x/net/context Генерация кода: * находясь в папке session сгенерируем код для го `protoc --go_out=plugins=grpc:. *.proto` * подобной командой так же генерируется нужная обвязка для других поддерживаемых языков * go_out означает что мы хотим сгенерировать код в этой папке для языка go * plugins=grpc созначает что мы хотим использовать ещё плагин для генерации grpc-сервиса дополнительная документация * * * windows: Download protoc-win32.zip from Unzip and add location of the protoc.exe to your PATH environment variable Run `protoc --version` from command prompt to verify Verify the your GOPATH environment variable is set Run `go get -u github.com/golang/protobuf/protoc-gen-go` from command prompt. This should install the binary to %GOPATH%/bin Add `%GOPATH%/bin` to your PATH environment variable Open a new command prompt, navigate to your .proto file, run `protoc --go_out=. *.proto` если ругается - надо читобы были доступны protoc.exe и protoc-gen-go.exe - прописать в PATH путь до них # 2 способ генерации. лучше им и пользоваться * ставим тулзу для генерации - protoc (это можно нагуглить) * ставим модуль go для protoc `go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26` * ставим модуль grpc для protoc `go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1` * генерим (на выходе получаем 2 файла. это ок): `protoc --go_out=. --go-grpc_out=. --go-grpc_opt=paths=source_relative --go_opt=paths=source_relative *.proto` ================================================ FILE: 8-microservices/4_grpc/server/server.go ================================================ package main import ( "fmt" "log" "net" "github.com/go-park-mail-ru/lectures/8-microservices/4_grpc/session" "google.golang.org/grpc" ) func main() { lis, err := net.Listen("tcp", ":8081") if err != nil { log.Fatalln("cant listet port", err) } server := grpc.NewServer() session.RegisterAuthCheckerServer(server, NewSessionManager()) fmt.Println("starting server at :8081") server.Serve(lis) } ================================================ FILE: 8-microservices/4_grpc/server/session.go ================================================ package main import ( "fmt" "math/rand" "sync" "github.com/go-park-mail-ru/lectures/8-microservices/4_grpc/session" "google.golang.org/grpc" "google.golang.org/grpc/codes" "context" ) const sessKeyLen = 10 type SessionManager struct { session.UnimplementedAuthCheckerServer mu sync.RWMutex sessions map[string]*session.Session } func NewSessionManager() *SessionManager { return &SessionManager{ mu: sync.RWMutex{}, sessions: map[string]*session.Session{}, } } func (sm *SessionManager) Create(ctx context.Context, in *session.Session) (*session.SessionID, error) { fmt.Println("call Create", in) id := &session.SessionID{ ID: RandStringRunes(sessKeyLen), } sm.mu.Lock() sm.sessions[id.ID] = in sm.mu.Unlock() return id, nil } func (sm *SessionManager) Check(ctx context.Context, in *session.SessionID) (*session.Session, error) { fmt.Println("call Check", in) sm.mu.RLock() defer sm.mu.RUnlock() if sess, ok := sm.sessions[in.ID]; ok { return sess, nil } return nil, grpc.Errorf(codes.NotFound, "session not found") } func (sm *SessionManager) Delete(ctx context.Context, in *session.SessionID) (*session.Nothing, error) { fmt.Println("call Delete", in) sm.mu.Lock() defer sm.mu.Unlock() delete(sm.sessions, in.ID) return &session.Nothing{Dummy: true}, nil } var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") func RandStringRunes(n int) string { b := make([]rune, n) for i := range b { b[i] = letterRunes[rand.Intn(len(letterRunes))] } return string(b) } ================================================ FILE: 8-microservices/4_grpc/session/session.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.26.0 // protoc v3.17.3 // source: session.proto package session import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) 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 SessionID struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"` } func (x *SessionID) Reset() { *x = SessionID{} if protoimpl.UnsafeEnabled { mi := &file_session_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } func (x *SessionID) String() string { return protoimpl.X.MessageStringOf(x) } func (*SessionID) ProtoMessage() {} func (x *SessionID) ProtoReflect() protoreflect.Message { mi := &file_session_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 SessionID.ProtoReflect.Descriptor instead. func (*SessionID) Descriptor() ([]byte, []int) { return file_session_proto_rawDescGZIP(), []int{0} } func (x *SessionID) GetID() string { if x != nil { return x.ID } return "" } type Session struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Login string `protobuf:"bytes,1,opt,name=login,proto3" json:"login,omitempty"` Useragent string `protobuf:"bytes,2,opt,name=useragent,proto3" json:"useragent,omitempty"` } func (x *Session) Reset() { *x = Session{} if protoimpl.UnsafeEnabled { mi := &file_session_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } func (x *Session) String() string { return protoimpl.X.MessageStringOf(x) } func (*Session) ProtoMessage() {} func (x *Session) ProtoReflect() protoreflect.Message { mi := &file_session_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 Session.ProtoReflect.Descriptor instead. func (*Session) Descriptor() ([]byte, []int) { return file_session_proto_rawDescGZIP(), []int{1} } func (x *Session) GetLogin() string { if x != nil { return x.Login } return "" } func (x *Session) GetUseragent() string { if x != nil { return x.Useragent } return "" } type Nothing struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Dummy bool `protobuf:"varint,1,opt,name=dummy,proto3" json:"dummy,omitempty"` } func (x *Nothing) Reset() { *x = Nothing{} if protoimpl.UnsafeEnabled { mi := &file_session_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } func (x *Nothing) String() string { return protoimpl.X.MessageStringOf(x) } func (*Nothing) ProtoMessage() {} func (x *Nothing) ProtoReflect() protoreflect.Message { mi := &file_session_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 Nothing.ProtoReflect.Descriptor instead. func (*Nothing) Descriptor() ([]byte, []int) { return file_session_proto_rawDescGZIP(), []int{2} } func (x *Nothing) GetDummy() bool { if x != nil { return x.Dummy } return false } var File_session_proto protoreflect.FileDescriptor var file_session_proto_rawDesc = []byte{ 0x0a, 0x0d, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x1b, 0x0a, 0x09, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x44, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x44, 0x22, 0x3d, 0x0a, 0x07, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x75, 0x73, 0x65, 0x72, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x22, 0x1f, 0x0a, 0x07, 0x4e, 0x6f, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x12, 0x14, 0x0a, 0x05, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x32, 0xa2, 0x01, 0x0a, 0x0b, 0x41, 0x75, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x72, 0x12, 0x30, 0x0a, 0x06, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x10, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x1a, 0x12, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x44, 0x22, 0x00, 0x12, 0x2f, 0x0a, 0x05, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x12, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x44, 0x1a, 0x10, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x00, 0x12, 0x30, 0x0a, 0x06, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x12, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x44, 0x1a, 0x10, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x4e, 0x6f, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x22, 0x00, 0x42, 0x0c, 0x5a, 0x0a, 0x2e, 0x2f, 0x3b, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_session_proto_rawDescOnce sync.Once file_session_proto_rawDescData = file_session_proto_rawDesc ) func file_session_proto_rawDescGZIP() []byte { file_session_proto_rawDescOnce.Do(func() { file_session_proto_rawDescData = protoimpl.X.CompressGZIP(file_session_proto_rawDescData) }) return file_session_proto_rawDescData } var file_session_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_session_proto_goTypes = []interface{}{ (*SessionID)(nil), // 0: session.SessionID (*Session)(nil), // 1: session.Session (*Nothing)(nil), // 2: session.Nothing } var file_session_proto_depIdxs = []int32{ 1, // 0: session.AuthChecker.Create:input_type -> session.Session 0, // 1: session.AuthChecker.Check:input_type -> session.SessionID 0, // 2: session.AuthChecker.Delete:input_type -> session.SessionID 0, // 3: session.AuthChecker.Create:output_type -> session.SessionID 1, // 4: session.AuthChecker.Check:output_type -> session.Session 2, // 5: session.AuthChecker.Delete:output_type -> session.Nothing 3, // [3:6] is the sub-list for method output_type 0, // [0:3] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name } func init() { file_session_proto_init() } func file_session_proto_init() { if File_session_proto != nil { return } if !protoimpl.UnsafeEnabled { file_session_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*SessionID); i { case 0: return &v.state case 1: return &v.sizeCache case 2: return &v.unknownFields default: return nil } } file_session_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Session); i { case 0: return &v.state case 1: return &v.sizeCache case 2: return &v.unknownFields default: return nil } } file_session_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Nothing); i { case 0: return &v.state case 1: return &v.sizeCache case 2: return &v.unknownFields default: return nil } } } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_session_proto_rawDesc, NumEnums: 0, NumMessages: 3, NumExtensions: 0, NumServices: 1, }, GoTypes: file_session_proto_goTypes, DependencyIndexes: file_session_proto_depIdxs, MessageInfos: file_session_proto_msgTypes, }.Build() File_session_proto = out.File file_session_proto_rawDesc = nil file_session_proto_goTypes = nil file_session_proto_depIdxs = nil } ================================================ FILE: 8-microservices/4_grpc/session/session.proto ================================================ syntax = "proto3"; // protoc --go_out=. --go-grpc_out=. --go-grpc_opt=paths=source_relative --go_opt=paths=source_relative *.proto option go_package = "./;session"; package session; message SessionID { string ID = 1; } message Session { string login = 1; string useragent = 2; } message Nothing { bool dummy = 1; } // grpc-сервис проверки авторизации service AuthChecker { rpc Create (Session) returns (SessionID) {} rpc Check (SessionID) returns (Session) {} rpc Delete (SessionID) returns (Nothing) {} } ================================================ FILE: 8-microservices/4_grpc/session/session_grpc.pb.go ================================================ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. package session import ( context "context" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 // AuthCheckerClient is the client API for AuthChecker service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type AuthCheckerClient interface { Create(ctx context.Context, in *Session, opts ...grpc.CallOption) (*SessionID, error) Check(ctx context.Context, in *SessionID, opts ...grpc.CallOption) (*Session, error) Delete(ctx context.Context, in *SessionID, opts ...grpc.CallOption) (*Nothing, error) } type authCheckerClient struct { cc grpc.ClientConnInterface } func NewAuthCheckerClient(cc grpc.ClientConnInterface) AuthCheckerClient { return &authCheckerClient{cc} } func (c *authCheckerClient) Create(ctx context.Context, in *Session, opts ...grpc.CallOption) (*SessionID, error) { out := new(SessionID) err := c.cc.Invoke(ctx, "/session.AuthChecker/Create", in, out, opts...) if err != nil { return nil, err } return out, nil } func (c *authCheckerClient) Check(ctx context.Context, in *SessionID, opts ...grpc.CallOption) (*Session, error) { out := new(Session) err := c.cc.Invoke(ctx, "/session.AuthChecker/Check", in, out, opts...) if err != nil { return nil, err } return out, nil } func (c *authCheckerClient) Delete(ctx context.Context, in *SessionID, opts ...grpc.CallOption) (*Nothing, error) { out := new(Nothing) err := c.cc.Invoke(ctx, "/session.AuthChecker/Delete", in, out, opts...) if err != nil { return nil, err } return out, nil } // AuthCheckerServer is the server API for AuthChecker service. // All implementations must embed UnimplementedAuthCheckerServer // for forward compatibility type AuthCheckerServer interface { Create(context.Context, *Session) (*SessionID, error) Check(context.Context, *SessionID) (*Session, error) Delete(context.Context, *SessionID) (*Nothing, error) mustEmbedUnimplementedAuthCheckerServer() } // UnimplementedAuthCheckerServer must be embedded to have forward compatible implementations. type UnimplementedAuthCheckerServer struct { } func (UnimplementedAuthCheckerServer) Create(context.Context, *Session) (*SessionID, error) { return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") } func (UnimplementedAuthCheckerServer) Check(context.Context, *SessionID) (*Session, error) { return nil, status.Errorf(codes.Unimplemented, "method Check not implemented") } func (UnimplementedAuthCheckerServer) Delete(context.Context, *SessionID) (*Nothing, error) { return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented") } func (UnimplementedAuthCheckerServer) mustEmbedUnimplementedAuthCheckerServer() {} // UnsafeAuthCheckerServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to AuthCheckerServer will // result in compilation errors. type UnsafeAuthCheckerServer interface { mustEmbedUnimplementedAuthCheckerServer() } func RegisterAuthCheckerServer(s grpc.ServiceRegistrar, srv AuthCheckerServer) { s.RegisterService(&AuthChecker_ServiceDesc, srv) } func _AuthChecker_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(Session) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(AuthCheckerServer).Create(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: "/session.AuthChecker/Create", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(AuthCheckerServer).Create(ctx, req.(*Session)) } return interceptor(ctx, in, info, handler) } func _AuthChecker_Check_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SessionID) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(AuthCheckerServer).Check(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: "/session.AuthChecker/Check", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(AuthCheckerServer).Check(ctx, req.(*SessionID)) } return interceptor(ctx, in, info, handler) } func _AuthChecker_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SessionID) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(AuthCheckerServer).Delete(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: "/session.AuthChecker/Delete", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(AuthCheckerServer).Delete(ctx, req.(*SessionID)) } return interceptor(ctx, in, info, handler) } // AuthChecker_ServiceDesc is the grpc.ServiceDesc for AuthChecker service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var AuthChecker_ServiceDesc = grpc.ServiceDesc{ ServiceName: "session.AuthChecker", HandlerType: (*AuthCheckerServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Create", Handler: _AuthChecker_Create_Handler, }, { MethodName: "Check", Handler: _AuthChecker_Check_Handler, }, { MethodName: "Delete", Handler: _AuthChecker_Delete_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "session.proto", } ================================================ FILE: 8-microservices/5_grpc_features/client/client.go ================================================ package main import ( "fmt" "log" "time" "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/metadata" "github.com/go-park-mail-ru/lectures/8-microservices/4_grpc/session" ) // {Interceprtor} | serialization | -> request func timingInterceptor( ctx context.Context, method string, req interface{}, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption, ) error { start := time.Now() err := invoker(ctx, method, req, reply, cc, opts...) fmt.Printf(`-- call=%v req=%#v reply=%#v time=%v err=%v `, method, req, reply, time.Since(start), err) return err } type tokenAuth struct { Token string } func (t *tokenAuth) GetRequestMetadata(context.Context, ...string) (map[string]string, error) { return map[string]string{ "access-token": t.Token, }, nil } func (c *tokenAuth) RequireTransportSecurity() bool { return false } func main() { grcpConn, err := grpc.Dial( "127.0.0.1:8081", grpc.WithUnaryInterceptor(timingInterceptor), grpc.WithPerRPCCredentials(&tokenAuth{"100500"}), grpc.WithInsecure(), ) if err != nil { log.Fatalf("cant connect to grpc") } defer grcpConn.Close() sessManager := session.NewAuthCheckerClient(grcpConn) ctx := context.Background() md := metadata.Pairs( "api-req-id", "123", "subsystem", "cli", ) ctx = metadata.NewOutgoingContext(ctx, md) var header, trailer metadata.MD // создаем сессию sessId, err := sessManager.Create(ctx, &session.Session{ Login: "rvasily", Useragent: "chrome", }, grpc.Header(&header), grpc.Trailer(&trailer), ) fmt.Println("sessId", sessId, err) fmt.Println("header", header) fmt.Println("trailer", trailer) // проеряем сессию sess, err := sessManager.Check(ctx, &session.SessionID{ ID: sessId.ID, }) fmt.Println("sess", sess, err) // удаляем сессию _, err = sessManager.Delete(ctx, &session.SessionID{ ID: sessId.ID, }) // проверяем еще раз sess, err = sessManager.Check(ctx, &session.SessionID{ ID: sessId.ID, }) fmt.Println("sess", sess, err) } ================================================ FILE: 8-microservices/5_grpc_features/server/server.go ================================================ package main import ( "fmt" "log" "net" "time" "github.com/go-park-mail-ru/lectures/8-microservices/4_grpc/session" "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/metadata" "google.golang.org/grpc/tap" ) // request -> {InTapHandle} | parsing | -> {Interceprtor} | handling | ... func authInterceptor( ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler, ) (interface{}, error) { start := time.Now() md, _ := metadata.FromIncomingContext(ctx) // ... auth logic reply, err := handler(ctx, req) fmt.Printf(`-- after incoming call=%v req=%#v reply=%#v time=%v md=%v err=%v `, info.FullMethod, req, reply, time.Since(start), md, err) return reply, err } func rateLimiter(ctx context.Context, info *tap.Info) (context.Context, error) { fmt.Printf("--\ncheck ratelim for %s\n", info.FullMethodName) // ... rate limit logic return ctx, nil } func main() { lis, err := net.Listen("tcp", ":8081") if err != nil { log.Fatalln("cant listet port", err) } server := grpc.NewServer( grpc.UnaryInterceptor(authInterceptor), grpc.InTapHandle(rateLimiter), ) session.RegisterAuthCheckerServer(server, NewSessionManager()) fmt.Println("starting server at :8081") server.Serve(lis) } ================================================ FILE: 8-microservices/5_grpc_features/server/session.go ================================================ package main import ( "fmt" "math/rand" "sync" "github.com/go-park-mail-ru/lectures/8-microservices/4_grpc/session" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/metadata" "golang.org/x/net/context" ) const sessKeyLen = 10 type SessionManager struct { session.UnimplementedAuthCheckerServer mu sync.RWMutex sessions map[string]*session.Session } func NewSessionManager() *SessionManager { return &SessionManager{ mu: sync.RWMutex{}, sessions: map[string]*session.Session{}, } } func (sm *SessionManager) Create(ctx context.Context, in *session.Session) (*session.SessionID, error) { fmt.Println("call Create", in) header := metadata.Pairs("header-key", "42") grpc.SendHeader(ctx, header) trailer := metadata.Pairs("trailer-key", "3.14") grpc.SetTrailer(ctx, trailer) id := &session.SessionID{ID: RandStringRunes(sessKeyLen)} sm.mu.Lock() sm.sessions[id.ID] = in sm.mu.Unlock() return id, nil } func (sm *SessionManager) Check(ctx context.Context, in *session.SessionID) (*session.Session, error) { fmt.Println("call Check", in) sm.mu.RLock() defer sm.mu.RUnlock() if sess, ok := sm.sessions[in.ID]; ok { return sess, nil } return nil, grpc.Errorf(codes.NotFound, "session not found") } func (sm *SessionManager) Delete(ctx context.Context, in *session.SessionID) (*session.Nothing, error) { fmt.Println("call Delete", in) sm.mu.Lock() defer sm.mu.Unlock() delete(sm.sessions, in.ID) return &session.Nothing{Dummy: true}, nil } var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") func RandStringRunes(n int) string { b := make([]rune, n) for i := range b { b[i] = letterRunes[rand.Intn(len(letterRunes))] } return string(b) } ================================================ FILE: 8-microservices/6_grpc_stream/client/client.go ================================================ package main import ( "bufio" "context" "fmt" "io" "log" "os" "sync" "google.golang.org/grpc" "github.com/go-park-mail-ru/lectures/8-microservices/6_grpc_stream/translit" ) func main() { grcpConn, err := grpc.Dial( "127.0.0.1:8081", grpc.WithInsecure(), ) if err != nil { log.Fatalf("cant connect to grpc") } defer grcpConn.Close() tr := translit.NewTransliterationClient(grcpConn) ctx := context.Background() stream, err := tr.EnRu(ctx) if err != nil { println(err) } wg := &sync.WaitGroup{} wg.Add(1) go func(wg *sync.WaitGroup) { defer wg.Done() for { outWord, err := stream.Recv() if err == io.EOF { fmt.Println("\tstream closed") return } else if err != nil { fmt.Println("\terror happed", err) return } fmt.Println(" <-", outWord.Word) } }(wg) scanner := bufio.NewScanner(os.Stdin) for scanner.Scan() { errSend := stream.Send(&translit.Word{ Word: scanner.Text(), }) if err != nil { println(errSend) } } stream.CloseSend() wg.Wait() } ================================================ FILE: 8-microservices/6_grpc_stream/client/run_test.go ================================================ package main import ( "context" "io" "log" "sync" "testing" "github.com/go-park-mail-ru/lectures/8-microservices/6_grpc_stream/translit" "google.golang.org/grpc" ) func Test(t *testing.T) { grcpConn, err := grpc.Dial( "127.0.0.1:8081", grpc.WithInsecure(), ) if err != nil { log.Fatalf("cant connect to grpc") } defer grcpConn.Close() tr := translit.NewTransliterationClient(grcpConn) ctx := context.Background() stream, _ := tr.EnRu(ctx) wg := &sync.WaitGroup{} wg.Add(2) go func(wg *sync.WaitGroup) { defer wg.Done() for { outWord, err := stream.Recv() if err == io.EOF { log.Println("\tstream closed") return } else if err != nil { log.Println("\terror happed", err) return } log.Println(" <-", outWord.Word) } }(wg) go func(wg *sync.WaitGroup) { defer wg.Done() words := []string{"privet", "kak", "dela"} for _, w := range words { log.Println("-> ", w) stream.Send(&translit.Word{ Word: w, }) //time.Sleep(2 * time.Second) } stream.CloseSend() log.Println("\tsend done") }(wg) wg.Wait() t.Fail() } ================================================ FILE: 8-microservices/6_grpc_stream/server/main.go ================================================ package main ================================================ FILE: 8-microservices/6_grpc_stream/server/server.go ================================================ package main import ( "fmt" "log" "net" "github.com/go-park-mail-ru/lectures/8-microservices/6_grpc_stream/translit" "google.golang.org/grpc" ) func main() { lis, err := net.Listen("tcp", ":8081") if err != nil { log.Fatalln("cant listet port", err) } server := grpc.NewServer() clientsWriter := []func(string){} tr := NewTr() tr.SetSendCallback = func(f func(string)) { clientsWriter = append(clientsWriter, f) } translit.RegisterTransliterationServer(server, tr) fmt.Println("starting server at :8081") server.Serve(lis) // for { // for _, f := range clientsWriter { // time.Sleep(time.Second) // f("123") // } // } } ================================================ FILE: 8-microservices/6_grpc_stream/server/translit.go ================================================ package main import ( "fmt" "io" tr "github.com/gen1us2k/go-translit" "github.com/go-park-mail-ru/lectures/8-microservices/6_grpc_stream/translit" ) type TrServer struct { translit.UnimplementedTransliterationServer SetSendCallback func(func(string)) } func (srv *TrServer) EnRu(inStream translit.Transliteration_EnRuServer) error { srv.SetSendCallback(func(s string) { out := &translit.Word{ Word: s, } inStream.Send(out) }) // return nil // go func() { // for { // inStream.Send(&translit.Word{ // Word: "stat", // }) // time.Sleep(time.Second) // } // }() for { // time.Sleep(1 * time.Second) inWord, err := inStream.Recv() if err == io.EOF { return nil } if err != nil { return err } out := &translit.Word{ Word: tr.Translit(inWord.Word), } fmt.Println(inWord.Word, "->", out.Word) inStream.Send(out) } } func NewTr() *TrServer { return &TrServer{} } ================================================ FILE: 8-microservices/6_grpc_stream/translit/translit.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.26.0 // protoc v3.17.3 // source: translit.proto package translit import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) 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 Word struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Word string `protobuf:"bytes,1,opt,name=Word,proto3" json:"Word,omitempty"` } func (x *Word) Reset() { *x = Word{} if protoimpl.UnsafeEnabled { mi := &file_translit_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } func (x *Word) String() string { return protoimpl.X.MessageStringOf(x) } func (*Word) ProtoMessage() {} func (x *Word) ProtoReflect() protoreflect.Message { mi := &file_translit_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 Word.ProtoReflect.Descriptor instead. func (*Word) Descriptor() ([]byte, []int) { return file_translit_proto_rawDescGZIP(), []int{0} } func (x *Word) GetWord() string { if x != nil { return x.Word } return "" } var File_translit_proto protoreflect.FileDescriptor var file_translit_proto_rawDesc = []byte{ 0x0a, 0x0e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6c, 0x69, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6c, 0x69, 0x74, 0x22, 0x1a, 0x0a, 0x04, 0x57, 0x6f, 0x72, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x57, 0x6f, 0x72, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x57, 0x6f, 0x72, 0x64, 0x32, 0x3f, 0x0a, 0x0f, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x6c, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2c, 0x0a, 0x04, 0x45, 0x6e, 0x52, 0x75, 0x12, 0x0e, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6c, 0x69, 0x74, 0x2e, 0x57, 0x6f, 0x72, 0x64, 0x1a, 0x0e, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6c, 0x69, 0x74, 0x2e, 0x57, 0x6f, 0x72, 0x64, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x42, 0x0d, 0x5a, 0x0b, 0x2e, 0x2f, 0x3b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6c, 0x69, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_translit_proto_rawDescOnce sync.Once file_translit_proto_rawDescData = file_translit_proto_rawDesc ) func file_translit_proto_rawDescGZIP() []byte { file_translit_proto_rawDescOnce.Do(func() { file_translit_proto_rawDescData = protoimpl.X.CompressGZIP(file_translit_proto_rawDescData) }) return file_translit_proto_rawDescData } var file_translit_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_translit_proto_goTypes = []interface{}{ (*Word)(nil), // 0: translit.Word } var file_translit_proto_depIdxs = []int32{ 0, // 0: translit.Transliteration.EnRu:input_type -> translit.Word 0, // 1: translit.Transliteration.EnRu:output_type -> translit.Word 1, // [1:2] is the sub-list for method output_type 0, // [0:1] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name } func init() { file_translit_proto_init() } func file_translit_proto_init() { if File_translit_proto != nil { return } if !protoimpl.UnsafeEnabled { file_translit_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Word); i { case 0: return &v.state case 1: return &v.sizeCache case 2: return &v.unknownFields default: return nil } } } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_translit_proto_rawDesc, NumEnums: 0, NumMessages: 1, NumExtensions: 0, NumServices: 1, }, GoTypes: file_translit_proto_goTypes, DependencyIndexes: file_translit_proto_depIdxs, MessageInfos: file_translit_proto_msgTypes, }.Build() File_translit_proto = out.File file_translit_proto_rawDesc = nil file_translit_proto_goTypes = nil file_translit_proto_depIdxs = nil } ================================================ FILE: 8-microservices/6_grpc_stream/translit/translit.proto ================================================ syntax = "proto3"; // protoc --go_out=. --go-grpc_out=. --go-grpc_opt=paths=source_relative --go_opt=paths=source_relative *.proto option go_package = "./;translit"; package translit; message Word { string Word = 1; } // grpc-сервис транслитерации service Transliteration { rpc EnRu (stream Word) returns (stream Word) {} } ================================================ FILE: 8-microservices/6_grpc_stream/translit/translit_grpc.pb.go ================================================ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. package translit import ( context "context" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 // TransliterationClient is the client API for Transliteration service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type TransliterationClient interface { EnRu(ctx context.Context, opts ...grpc.CallOption) (Transliteration_EnRuClient, error) } type transliterationClient struct { cc grpc.ClientConnInterface } func NewTransliterationClient(cc grpc.ClientConnInterface) TransliterationClient { return &transliterationClient{cc} } func (c *transliterationClient) EnRu(ctx context.Context, opts ...grpc.CallOption) (Transliteration_EnRuClient, error) { stream, err := c.cc.NewStream(ctx, &Transliteration_ServiceDesc.Streams[0], "/translit.Transliteration/EnRu", opts...) if err != nil { return nil, err } x := &transliterationEnRuClient{stream} return x, nil } type Transliteration_EnRuClient interface { Send(*Word) error Recv() (*Word, error) grpc.ClientStream } type transliterationEnRuClient struct { grpc.ClientStream } func (x *transliterationEnRuClient) Send(m *Word) error { return x.ClientStream.SendMsg(m) } func (x *transliterationEnRuClient) Recv() (*Word, error) { m := new(Word) if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err } return m, nil } // TransliterationServer is the server API for Transliteration service. // All implementations must embed UnimplementedTransliterationServer // for forward compatibility type TransliterationServer interface { EnRu(Transliteration_EnRuServer) error mustEmbedUnimplementedTransliterationServer() } // UnimplementedTransliterationServer must be embedded to have forward compatible implementations. type UnimplementedTransliterationServer struct { } func (UnimplementedTransliterationServer) EnRu(Transliteration_EnRuServer) error { return status.Errorf(codes.Unimplemented, "method EnRu not implemented") } func (UnimplementedTransliterationServer) mustEmbedUnimplementedTransliterationServer() {} // UnsafeTransliterationServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to TransliterationServer will // result in compilation errors. type UnsafeTransliterationServer interface { mustEmbedUnimplementedTransliterationServer() } func RegisterTransliterationServer(s grpc.ServiceRegistrar, srv TransliterationServer) { s.RegisterService(&Transliteration_ServiceDesc, srv) } func _Transliteration_EnRu_Handler(srv interface{}, stream grpc.ServerStream) error { return srv.(TransliterationServer).EnRu(&transliterationEnRuServer{stream}) } type Transliteration_EnRuServer interface { Send(*Word) error Recv() (*Word, error) grpc.ServerStream } type transliterationEnRuServer struct { grpc.ServerStream } func (x *transliterationEnRuServer) Send(m *Word) error { return x.ServerStream.SendMsg(m) } func (x *transliterationEnRuServer) Recv() (*Word, error) { m := new(Word) if err := x.ServerStream.RecvMsg(m); err != nil { return nil, err } return m, nil } // Transliteration_ServiceDesc is the grpc.ServiceDesc for Transliteration service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var Transliteration_ServiceDesc = grpc.ServiceDesc{ ServiceName: "translit.Transliteration", HandlerType: (*TransliterationServer)(nil), Methods: []grpc.MethodDesc{}, Streams: []grpc.StreamDesc{ { StreamName: "EnRu", Handler: _Transliteration_EnRu_Handler, ServerStreams: true, ClientStreams: true, }, }, Metadata: "translit.proto", } ================================================ FILE: 8-microservices/7_grpc_loadbalance/client/main.go ================================================ package main import ( "context" "flag" "fmt" "log" "strconv" "time" "google.golang.org/grpc" "google.golang.org/grpc/resolver" "google.golang.org/grpc/resolver/manual" "github.com/go-park-mail-ru/lectures/8-microservices/4_grpc/session" consulapi "github.com/hashicorp/consul/api" ) var ( consulAddr = flag.String("addr", "127.0.0.1:8500", "consul addr (8500 in original consul)") ) var ( consul *consulapi.Client ) func main() { flag.Parse() var err error config := consulapi.DefaultConfig() config.Address = *consulAddr consul, err = consulapi.NewClient(config) health, _, err := consul.Health().Service("session-api", "", false, nil) if err != nil { log.Fatalf("cant get alive services") } servers := make([]resolver.Address, 0, len(health)) for _, item := range health { addr := item.Service.Address + ":" + strconv.Itoa(item.Service.Port) servers = append(servers, resolver.Address{Addr: addr}) } if len(servers) == 0 { panic("no alive session-api servers") } nameResolver := manual.NewBuilderWithScheme("myservice") nameResolver.InitialState(resolver.State{Addresses: servers}) // grpclog.SetLogger(log.New(os.Stdout, "", log.LstdFlags)) // add logging grpcConn, err := grpc.Dial( nameResolver.Scheme()+":///", grpc.WithDefaultServiceConfig(`{"loadBalancingConfig": [{"round_robin":{}}]}`), grpc.WithResolvers(nameResolver), grpc.WithInsecure(), grpc.WithBlock(), grpc.WithTimeout(time.Second), ) if err != nil { log.Fatalf("cant connect to grpc: %v", err) } defer grpcConn.Close() sessManager := session.NewAuthCheckerClient(grpcConn) // тут мы будем периодически опрашивать консул на предмет изменений go runOnlineServiceDiscovery(nameResolver) ctx := context.Background() step := 1 for { // проверяем несуществуюущую сессию // потому что сейчас между сервисами нет общения // получаем загшулку sess, err := sessManager.Check(ctx, &session.SessionID{ ID: "not_exist_" + strconv.Itoa(step), }) fmt.Println("get sess", step, sess, err) time.Sleep(500 * time.Millisecond) step++ } } func runOnlineServiceDiscovery(nameResolver *manual.Resolver) { ticker := time.Tick(5 * time.Second) for _ = range ticker { health, _, err := consul.Health().Service("session-api", "", false, nil) if err != nil { log.Fatalf("cant get alive services") } servers := make([]resolver.Address, 0, len(health)) for _, item := range health { addr := item.Service.Address + ":" + strconv.Itoa(item.Service.Port) servers = append(servers, resolver.Address{Addr: addr}) } nameResolver.CC.NewAddress(servers) } } ================================================ FILE: 8-microservices/7_grpc_loadbalance/docker-compose.yml ================================================ version: "3" services: consul: image: consul ports: - "8500:8500" ================================================ FILE: 8-microservices/7_grpc_loadbalance/readme.md ================================================ пример с балансировкой нагрузки и service discovery для микросервиса на grpc в качестве service discovery используется consul (в видео поднят отдельно в докере) это учебный пример, не используйте это как есть в продакшене без понимани всего что там происходит ================================================ FILE: 8-microservices/7_grpc_loadbalance/server/server.go ================================================ package main import ( "flag" "fmt" "log" "net" "strconv" "github.com/go-park-mail-ru/lectures/8-microservices/4_grpc/session" "google.golang.org/grpc" consulapi "github.com/hashicorp/consul/api" ) var ( grpcPort = flag.Int("grpc", 8081, "listen addr") consulAddr = flag.String("consul", "127.0.0.1:8500", "consul addr (8500 in original consul)") ) /* go run *.go --grpc="8081" go run *.go --grpc="8082" */ func main() { flag.Parse() port := strconv.Itoa(*grpcPort) lis, err := net.Listen("tcp", ":"+port) if err != nil { log.Fatalln("cant listen port", err) } server := grpc.NewServer() session.RegisterAuthCheckerServer(server, NewSessionManager(port)) config := consulapi.DefaultConfig() config.Address = *consulAddr consul, err := consulapi.NewClient(config) serviceID := "SAPI_127.0.0.1:" + port err = consul.Agent().ServiceRegister(&consulapi.AgentServiceRegistration{ ID: serviceID, Name: "session-api", Port: *grpcPort, Address: "127.0.0.1", }) if err != nil { fmt.Println("cant add service to consul", err) return } fmt.Println("registered in consul", serviceID) defer func() { err := consul.Agent().ServiceDeregister(serviceID) if err != nil { fmt.Println("cant delete service from consul", err) return } fmt.Println("deregistered in consul", serviceID) }() fmt.Println("starting server at " + port) go server.Serve(lis) fmt.Println("Press any key to exit") fmt.Scanln() } ================================================ FILE: 8-microservices/7_grpc_loadbalance/server/session.go ================================================ package main import ( "fmt" "math/rand" "sync" "github.com/go-park-mail-ru/lectures/8-microservices/4_grpc/session" "golang.org/x/net/context" ) const sessKeyLen = 10 type SessionManager struct { session.UnimplementedAuthCheckerServer mu sync.RWMutex sessions map[string]*session.Session host string } func NewSessionManager(port string) *SessionManager { return &SessionManager{ mu: sync.RWMutex{}, sessions: map[string]*session.Session{}, host: port, } } func (sm *SessionManager) Create(ctx context.Context, in *session.Session) (*session.SessionID, error) { fmt.Println("call Create", in) id := &session.SessionID{ID: RandStringRunes(sessKeyLen)} sm.mu.Lock() sm.sessions[id.ID] = in sm.mu.Unlock() return id, nil } func (sm *SessionManager) Check(ctx context.Context, in *session.SessionID) (*session.Session, error) { fmt.Println("call Check", in) // между сервисами нет общения, возвращаем заглушку fakeLogin := sm.host + " " + in.GetID() return &session.Session{Login: fakeLogin}, nil } func (sm *SessionManager) Delete(ctx context.Context, in *session.SessionID) (*session.Nothing, error) { fmt.Println("call Delete", in) sm.mu.Lock() defer sm.mu.Unlock() delete(sm.sessions, in.ID) return &session.Nothing{Dummy: true}, nil } var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") func RandStringRunes(n int) string { b := make([]rune, n) for i := range b { b[i] = letterRunes[rand.Intn(len(letterRunes))] } return string(b) } ================================================ FILE: 9-monitoring/0_services/alertmanager/alertmanager.yml ================================================ global: resolve_timeout: 5m smtp_from: park.alerting@mail.ru smtp_hello: mail.ru smtp_smarthost: smtp.mail.ru:465 smtp_auth_username: park.alerting@mail.ru smtp_auth_password: gb=D>zTa8)uLkndj@peE smtp_require_tls: false route: group_by: - 'alertname' group_wait: 30s group_interval: 10s repeat_interval: 20s receiver: 'email' routes: - receiver: alertmananger-bot continue: true - receiver: email receivers: - name: 'alertmananger-bot' webhook_configs: - url: 'http://alertmanager-bot:8080' - name: email email_configs: - send_resolved: false to: park.alerting@mail.ru headers: From: park.alerting@mail.ru Subject: '{{ template "email.default.subject" . }}' To: park.alerting@mail.ru html: '{{ template "email.default.html" . }}' inhibit_rules: - source_match: severity: 'critical' target_match: severity: 'warning' equal: [ 'alertname', 'instance' ] ================================================ FILE: 9-monitoring/0_services/alertmanager-bot/templates/default.tmpl ================================================ {{ define "telegram.default" }} {{ range .Alerts }} {{ if eq .Status "firing"}}🔥 {{ .Status | toUpper }} 🔥{{ else }}{{ .Status | toUpper }}{{ end }} {{ .Labels.alertname }} {{ if .Annotations.message }} {{ .Annotations.message }} {{ end }} {{ if .Annotations.summary }} {{ .Annotations.summary }} {{ end }} {{ if .Annotations.description }} {{ .Annotations.description }} {{ end }} Duration: {{ duration .StartsAt .EndsAt }}{{ if ne .Status "firing"}} Ended: {{ .EndsAt | since }}{{ end }} {{ end }} {{ end }} ================================================ FILE: 9-monitoring/0_services/docker-compose.yml ================================================ version: "3" services: consul: image: hashicorp/consul ports: - "8500:8500" vault: image: hashicorp/vault environment: VAULT_DEV_ROOT_TOKEN_ID: 123 ports: - "8200:8200" prometheus: image: prom/prometheus ports: - "9090:9090" volumes: - "./prometheus:/etc/prometheus" alertmanager: image: prom/alertmanager ports: - "9093:9093" command: - '--config.file=/etc/alertmanager/alertmanager.yml' volumes: - "./alertmanager:/etc/alertmanager" alertmanager-bot: image: metalmatze/alertmanager-bot command: - "--listen.addr=0.0.0.0:8080" environment: ALERTMANAGER_URL: http://alertmanager:9093 BOLT_PATH: /data/bot.db STORE: bolt TEMPLATE_PATHS: /templates/default.tmpl TELEGRAM_ADMIN: 164626023 TELEGRAM_TOKEN: 997404236:AAGB0453GmnqkD2vhFmz6I8Iq0YRlOut8HE volumes: - "./alertmanager-bot/templates:/templates" jaeger: image: jaegertracing/all-in-one ports: - "6831:6831/udp" - "16686:16686" grafana: image: grafana/grafana ports: - "3000:3000" ================================================ FILE: 9-monitoring/0_services/prometheus/alerts.yml ================================================ groups: - name: default rules: - alert: InternalServerError expr: increase(hits{status="500"}[1m]) > 0 for: 1s labels: severity: critical annotations: summary: "path {{ $labels.path }} returned status 500" description: "{{ $labels.path }} of job {{ $labels.job }} returned status {{ $labels.status }}" ================================================ FILE: 9-monitoring/0_services/prometheus/prometheus.yml ================================================ global: scrape_interval: 10s evaluation_interval: 10s scrape_configs: - job_name: 'golang' static_configs: - targets: ['docker.for.mac.localhost:8080'] - job_name: 'system' static_configs: - targets: ['docker.for.mac.localhost:9100'] rule_files: - 'alerts.yml' alerting: alertmanagers: - static_configs: - targets: - alertmanager:9093 ================================================ FILE: 9-monitoring/1_config/1_flag/flag.go ================================================ package main import ( "flag" "fmt" "net" "strings" ) var ( commentsEnabled = flag.Bool("comments", false, "Enable comments after post") commentsLimit = flag.Int("limit", 10, "Comments number per page") commentsServices = &AddrList{} ) // go run flag.go --comments=true --servers="127.0.0.1:8081,127.0.0.1:8082" func init() { flag.Var(commentsServices, "servers", "Addresses") } func main() { flag.Parse() if *commentsEnabled { fmt.Println("Comments per page", *commentsLimit) fmt.Println("Comments services", *commentsServices) } else { fmt.Println("Comments disabled") } } type AddrList []string func (v *AddrList) String() string { return fmt.Sprint(*v) } func (v *AddrList) Set(in string) error { for _, addr := range strings.Split(in, ",") { ipRaw, _, err := net.SplitHostPort(addr) if err != nil { return fmt.Errorf("bad addr %v", addr) } ip := net.ParseIP(ipRaw) if ip.To4() == nil { return fmt.Errorf("invalid ipv4 addr %v", addr) } *v = append(*v, addr) } return nil } ================================================ FILE: 9-monitoring/1_config/2_json/config.json ================================================ { "comments": true, "servers": ["127.0.0.1:8081", "127.0.0.1:8082"] } ================================================ FILE: 9-monitoring/1_config/2_json/json_config.go ================================================ package main import ( "encoding/json" "fmt" "io/ioutil" "log" ) type Config struct { Comments bool `json:"comments"` Limit int Servers []string } var ( config = &Config{} ) func main() { data, err := ioutil.ReadFile("./config.json") if err != nil { log.Fatalln("cant read config file:", err) } err = json.Unmarshal(data, config) if err != nil { log.Fatalln("cant parse config:", err) } if config.Comments { fmt.Println("Comments per page", config.Limit) fmt.Println("Comments services", config.Servers) } else { fmt.Println("Comments disabled") } } ================================================ FILE: 9-monitoring/1_config/3_ldflags/ldflags.go ================================================ package main import ( "fmt" ) /* go run -ldflags="-X 'main.Version=$(git rev-parse HEAD)' -X 'main.Branch=$(git rev-parse --abbrev-ref HEAD)'" ldflags.go */ var ( Version = "" Branch = "" ) func main() { fmt.Println("[start] starting version ", Version, Branch) } ================================================ FILE: 9-monitoring/1_config/4_viper/config.yml ================================================ port: 8080 db: host: 127.0.0.1 port: 5432 username: root password: guest ================================================ FILE: 9-monitoring/1_config/4_viper/main.go ================================================ package main import ( "log" "github.com/spf13/viper" ) func main() { viper.AddConfigPath(".") viper.SetConfigName("config") if err := viper.ReadInConfig(); err != nil { log.Fatal(err) } port := viper.GetString("port") host := viper.GetStringMap("db") log.Println(port, host) } ================================================ FILE: 9-monitoring/1_config/5_consul/consul_config.go ================================================ package main import ( "context" "flag" "fmt" "net/http" "strings" "sync" "time" consulapi "github.com/hashicorp/consul/api" ) var ( consulAddr = flag.String("addr", "127.0.0.1:8500", "consul addr (8500 in original consul)") consul *consulapi.Client consulLastIndex uint64 = 0 globalCfg = make(map[string]string) globalCfgMu = &sync.RWMutex{} cfgPrefix = "myapi/" prefixStripper = strings.NewReplacer(cfgPrefix, "") ) // линтер ругается если используем базовые типы в Value контекста // типа так безопаснее разграничивать type key string const configKey key = "configKey" func configMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ctx := r.Context() globalCfgMu.RLock() localCfg := globalCfg globalCfgMu.RUnlock() ctx = context.WithValue(ctx, configKey, localCfg) next.ServeHTTP(w, r.WithContext(ctx)) }) } func ConfigFromContext(ctx context.Context) (map[string]string, error) { cfg, ok := ctx.Value(configKey).(map[string]string) if !ok { return nil, fmt.Errorf("config not found") } return cfg, nil } func loadPostsHandle(w http.ResponseWriter, req *http.Request) { ctx := req.Context() localCfg, err := ConfigFromContext(ctx) if err != nil { http.Error(w, "no config!", 500) return } fmt.Fprintf(w, "localCfg version %v\n%#v\n", consulLastIndex, localCfg) fmt.Fprintln(w, "Request done") } func main() { flag.Parse() var err error config := consulapi.DefaultConfig() config.Address = *consulAddr consul, err = consulapi.NewClient(config) if err != nil { fmt.Println("consul error", err) return } loadConfig() go runConfigUpdater() siteMux := http.NewServeMux() siteMux.HandleFunc("/", loadPostsHandle) siteHandler := configMiddleware(siteMux) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", siteHandler) } func runConfigUpdater() { ticker := time.Tick(3 * time.Second) for _ = range ticker { loadConfig() } } func loadConfig() { qo := &consulapi.QueryOptions{ WaitIndex: consulLastIndex, } kvPairs, qm, err := consul.KV().List(cfgPrefix, qo) if err != nil { fmt.Println(err) return } fmt.Println("remote consulLastIndex", qm.LastIndex) if consulLastIndex == qm.LastIndex { fmt.Println("consulLastIndex not changed") return } newConfig := make(map[string]string) for idx, item := range kvPairs { if item.Key == cfgPrefix { continue } fmt.Printf("item[%d] %#v\n", idx, item) key := prefixStripper.Replace(item.Key) newConfig[key] = string(item.Value) } globalCfgMu.Lock() globalCfg = newConfig consulLastIndex = qm.LastIndex globalCfgMu.Unlock() fmt.Printf("config updated to version %v\n\t%#v\n\n", consulLastIndex, newConfig) } ================================================ FILE: 9-monitoring/2_vault/main.go ================================================ package main import ( "fmt" "log" "os" "github.com/hashicorp/vault/api" ) func main() { client, err := api.NewClient(&api.Config{ Address: "http://127.0.0.1:8200", }) if err != nil { log.Fatal(err) } token := os.Getenv("token") client.SetToken(token) secretValues, err := client.Logical().Read("secret/data/postgres") if err != nil { log.Println(err) } fmt.Printf("secret %s -> %+v", "postgres", secretValues.Data) } ================================================ FILE: 9-monitoring/2_vault/readme.md ================================================ docker run -p 8200:8200 -v $(pwd):/vault/config -d vault Unseal Key: o8BS/qgI/YWpn95eaaHt60AFnV/yYOOXrqFDq+lVXQg= Root Token: s.yrEcqEeuKv85biCHpBa8TqCH ================================================ FILE: 9-monitoring/3_monitoring/expvars/expvars.go ================================================ package main import ( "expvar" "fmt" "net/http" ) var ( hits = expvar.NewMap("hits") i = 0 ) func handler(w http.ResponseWriter, r *http.Request) { hits.Add(r.URL.String(), 1) fmt.Println("hit to" + r.URL.String()) w.Write([]byte("expvar increased")) i++ } func main() { http.HandleFunc("/", handler) expvar.Publish("mystat", expvar.Func(func() interface{} { return map[string]int{ "test": 100500, "value": i, } })) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } ================================================ FILE: 9-monitoring/3_monitoring/metrics/context_monitoring.go ================================================ package main import ( "context" "flag" "fmt" "log" "math/rand" "net/http" "strings" "sync" "time" "gopkg.in/alexcesaro/statsd.v2" ) // сколько в среднем спим при эмуляции работы const AvgSleep = 50 func trackContextTimings(ctx context.Context, metricName string, start time.Time) { // получаем тайминги из контекста // поскольку там пустой интерфейс, то нам надо преобразовать к нужному типу timings, ok := ctx.Value(timingsKey).(*ctxTimings) if !ok { return } elapsed := time.Since(start) // лочимся на случай конкурентной записи в мапку timings.Lock() defer timings.Unlock() // если меткри ещё нет - мы её создадим, если есть - допишем в существующую if metric, metricExist := timings.Data[metricName]; !metricExist { timings.Data[metricName] = &Timing{ Count: 1, Duration: elapsed, } } else { metric.Count++ metric.Duration += elapsed } } type Timing struct { Count int Duration time.Duration } type ctxTimings struct { sync.Mutex Data map[string]*Timing } // линтер ругается если используем базовые типы в Value контекста // типа так безопаснее разграничивать type key int const timingsKey key = 1 type TimingMiddleware struct { sync.Mutex StatsReciever *statsd.Client Metrics map[string]int } func NewTimingMiddleware(st *statsd.Client) *TimingMiddleware { tm := &TimingMiddleware{ StatsReciever: st, Metrics: make(map[string]int), } return tm } func (tm *TimingMiddleware) TrackRequestTimings(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ctx := r.Context() ctx = context.WithValue(ctx, timingsKey, &ctxTimings{ Data: make(map[string]*Timing), }) defer tm.logContextTimings(ctx, r.URL.Path, time.Now()) next.ServeHTTP(w, r.WithContext(ctx)) }) } func (tm *TimingMiddleware) logContextTimings(ctx context.Context, path string, start time.Time) { // получаем тайминги из контекста // поскольку там пустой интерфейс, то нам надо преобразовать к нужному типу timings, ok := ctx.Value(timingsKey).(*ctxTimings) if !ok { return } totalReal := time.Since(start) path = strings.Replace(path, "/", "-", -1) prefix := "requests." + path + "." // buf := bytes.NewBufferString(path) var total time.Duration for timing, value := range timings.Data { metric := prefix + "timings." + timing tm.StatsReciever.Increment(metric) tm.StatsReciever.Timing(metric+"_time", uint64(value.Duration/time.Millisecond)) total += value.Duration } tm.StatsReciever.Increment(prefix + "hits") tm.StatsReciever.Timing(prefix+"tracked", uint64(totalReal/time.Millisecond)) tm.StatsReciever.Timing(prefix+"real_time", uint64(total/time.Millisecond)) log.Println(prefix+"real_time", uint64(total/time.Millisecond)) } func emulateWork(ctx context.Context, workName string) { defer trackContextTimings(ctx, workName, time.Now()) rnd := time.Duration(rand.Intn(AvgSleep)) time.Sleep(time.Millisecond * rnd) } func loadPostsHandle(w http.ResponseWriter, req *http.Request) { ctx := req.Context() emulateWork(ctx, "checkCache") emulateWork(ctx, "loadPosts") emulateWork(ctx, "loadPosts") emulateWork(ctx, "loadPosts") time.Sleep(10 * time.Millisecond) emulateWork(ctx, "loadSidebar") emulateWork(ctx, "loadComments") fmt.Fprintln(w, "Request done") } var ( statsdAddr = flag.String("addr", "127.0.0.1:8125", "statsd addr") ) func main() { flag.Parse() rand.Seed(time.Now().UTC().UnixNano()) siteMux := http.NewServeMux() siteMux.HandleFunc("/", loadPostsHandle) statsd, err := statsd.New( statsd.Prefix("prod"), statsd.Address(*statsdAddr), statsd.ErrorHandler(func(err error) { log.Print(err) }), ) if err != nil { log.Print(err) } tm := NewTimingMiddleware(statsd) siteHandler := tm.TrackRequestTimings(siteMux) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", siteHandler) } ================================================ FILE: 9-monitoring/3_monitoring/prometheus/alertmanager/alertmanager.yml ================================================ global: resolve_timeout: 5m smtp_from: park.alerting@mail.ru smtp_hello: mail.ru smtp_smarthost: smtp.mail.ru:465 smtp_auth_username: park.alerting@mail.ru smtp_auth_password: gb=D>zTa8)uLkndj@peE smtp_require_tls: false route: group_by: ['alertname'] group_wait: 30s group_interval: 10s repeat_interval: 20s receiver: 'email' receivers: - name: 'alertmananger-bot' webhook_configs: - url: 'http://alertmanager-bot:8080' - name: email email_configs: - send_resolved: false to: park.alerting@mail.ru headers: From: park.alerting@mail.ru Subject: '{{ template "email.default.subject" . }}' To: park.alerting@mail.ru html: '{{ template "email.default.html" . }}' inhibit_rules: - source_match: severity: 'critical' target_match: severity: 'warning' equal: ['alertname', 'instance'] ================================================ FILE: 9-monitoring/3_monitoring/prometheus/main.go ================================================ package main import ( "fmt" "log" "net/http" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" ) var fooCount = prometheus.NewCounter(prometheus.CounterOpts{ Name: "foo_total", Help: "Number of foo successfully processed.", }) var hits = prometheus.NewCounterVec(prometheus.CounterOpts{ Name: "hits", }, []string{"status", "path"}) func main() { prometheus.MustRegister(fooCount, hits) http.Handle("/metrics", promhttp.Handler()) http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { hits.WithLabelValues("200", r.URL.String()).Inc() fooCount.Add(1) fmt.Fprintf(w, "foo_total increased") }) http.HandleFunc("/500", func(w http.ResponseWriter, r *http.Request) { hits.WithLabelValues("500", r.URL.String()).Inc() w.WriteHeader(http.StatusInternalServerError) w.Write([]byte("error")) }) log.Fatal(http.ListenAndServe(":8080", nil)) } ================================================ FILE: 9-monitoring/3_monitoring/prometheus/prometheus/alerts.yml ================================================ groups: - name: default rules: - alert: InternalServerError expr: increase(hits{status="500"}[1m]) > 0 for: 1s labels: severity: critical annotations: summary: "path {{ $labels.path }} returned status 500" description: "{{ $labels.path }} of job {{ $labels.job }} returned status {{ $labels.status }}" ================================================ FILE: 9-monitoring/3_monitoring/prometheus/prometheus/prometheus.yml ================================================ global: scrape_interval: 10s evaluation_interval: 10s scrape_configs: - job_name: 'golang' static_configs: - targets: ['docker.for.mac.localhost:8080'] - job_name: 'system' static_configs: - targets: ['docker.for.mac.localhost:9100'] rule_files: - 'alerts.yml' alerting: alertmanagers: - static_configs: - targets: - alertmanager:9093 ================================================ FILE: 9-monitoring/3_monitoring/prometheus/readme.md ================================================ #Run prometheus ``` docker run -p 9090:9090 -d --name prometheus --network monitoring -v $(pwd)/prometheus:/etc/config prom/prometheus --config.file=/etc/config/prometheus.yml ``` ``` docker run -p 9090:9090 -it --name prometheus --network monitoring -v $(pwd)/prometheus:/etc/config prom/prometheus --config.file=/etc/config/prometheus.yml ``` # Run alert manager ``` docker run -d -p 9093:9093 -v $(pwd)/alertmanager:/etc/config --network monitoring --name alertmanager prom/alertmanager --config.file=/etc/config/alertmanager.yml ``` # Telegram bot for alerting ``` docker run -d \ -e 'ALERTMANAGER_URL=http://alertmanager:9093' \ -e 'BOLT_PATH=/data/bot.db' \ -e 'STORE=bolt' \ -e 'TEMPLATE_PATHS=/templates/default.tmpl' \ -e 'TELEGRAM_ADMIN=164626023' \ -e 'TELEGRAM_TOKEN=686312965:AAFf0goR98-8uVxGM8tRVxhafHyyQ_KIynk' \ -v $(pwd)/alertmanager-bot:/data \ -v $(pwd)/alertmanager-bot:/templates \ --network monitoring \ --name alertmanager-bot \ metalmatze/alertmanager-bot:0.4.0 --listen.addr 0.0.0.0:8080 ``` ================================================ FILE: 9-monitoring/3_monitoring/sentry/echo/main.go ================================================ package main import ( "fmt" "net/http" "github.com/getsentry/sentry-go" sentryecho "github.com/getsentry/sentry-go/echo" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" ) func main() { _ = sentry.Init(sentry.ClientOptions{ Dsn: "https://73eda8ec507b464caeb9d8fd331bc9ce@o427877.ingest.sentry.io/5372588", BeforeSend: func(event *sentry.Event, hint *sentry.EventHint) *sentry.Event { fmt.Println(event) return event }, Debug: true, AttachStacktrace: true, }) app := echo.New() app.Use(middleware.Logger()) app.Use(middleware.Recover()) app.Use(sentryecho.New(sentryecho.Options{ Repanic: true, })) app.Use(func(next echo.HandlerFunc) echo.HandlerFunc { return func(ctx echo.Context) error { if hub := sentryecho.GetHubFromContext(ctx); hub != nil { hub.Scope().SetTag("someRandomTag", "maybeYouNeedIt") } return next(ctx) } }) app.GET("/", func(ctx echo.Context) error { if hub := sentryecho.GetHubFromContext(ctx); hub != nil { hub.WithScope(func(scope *sentry.Scope) { scope.SetExtra("unwantedQuery", "someQueryDataMaybe") hub.CaptureMessage("User provided unwanted query string, but we recovered just fine") }) } return ctx.String(http.StatusOK, "Hello, World!") }) app.GET("/foo", func(ctx echo.Context) error { panic("y tho") }) app.Logger.Fatal(app.Start(":8080")) } ================================================ FILE: 9-monitoring/3_monitoring/sentry/simple/main.go ================================================ package main import ( "github.com/pkg/errors" "log" "net/http" "time" "github.com/getsentry/sentry-go" ) func firstError() error { return errors.New("error") } func returnError() error { return errors.Wrap(firstError(), "failed to do something") } func main() { err := sentry.Init(sentry.ClientOptions{ Dsn: "https://73eda8ec507b464caeb9d8fd331bc9ce@o427877.ingest.sentry.io/5372588", Debug: true, }) if err != nil { log.Fatalf("sentry.Init: %s", err) } defer sentry.Flush(2 * time.Second) http.HandleFunc( "/500", func(writer http.ResponseWriter, request *http.Request) { sentry.CaptureException(returnError()) }, ) http.ListenAndServe(":8080", nil) } ================================================ FILE: 9-monitoring/4_tracing/jaeger_grpc/client/main.go ================================================ package main import ( "context" "fmt" "log" "net/http" "time" traceutils "github.com/opentracing-contrib/go-grpc" "github.com/opentracing/opentracing-go" "github.com/uber/jaeger-client-go" jaegercfg "github.com/uber/jaeger-client-go/config" jaegerlog "github.com/uber/jaeger-client-go/log" "github.com/uber/jaeger-lib/metrics" "google.golang.org/grpc" "github.com/go-park-mail-ru/lectures/9-monitoring/4_tracing/jaeger_grpc/session" ) var loginFormTmpl = []byte(`
Login: Password: `) var ( sessManager session.AuthCheckerClient ) func checkSession(r *http.Request) (*session.Session, error) { cookieSessionID, err := r.Cookie("session_id") if err == http.ErrNoCookie { return nil, nil } else if err != nil { return nil, err } sess, err := sessManager.Check( context.Background(), &session.SessionID{ ID: cookieSessionID.Value, }) if err != nil { return nil, err } return sess, nil } func innerPage(w http.ResponseWriter, r *http.Request) { sess, err := checkSession(r) if err != nil || sess == nil { w.Write(loginFormTmpl) return } w.Header().Set("Content-Type", "text/html") fmt.Fprintln(w, "Welcome, "+sess.Login+"
") fmt.Fprintln(w, "Session ua: "+sess.Useragent+"
") fmt.Fprintln(w, `logout`) } func loginPage(w http.ResponseWriter, r *http.Request) { inputLogin := r.FormValue("login") expiration := time.Now().Add(365 * 24 * time.Hour) sess, err := sessManager.Create( context.Background(), &session.Session{ Login: inputLogin, Useragent: r.UserAgent(), }) if err != nil { w.WriteHeader(http.StatusInternalServerError) return } cookie := http.Cookie{ Name: "session_id", Value: sess.ID, Expires: expiration, } http.SetCookie(w, &cookie) http.Redirect(w, r, "/", http.StatusFound) } func main() { jaegerCfgInstance := jaegercfg.Configuration{ ServiceName: "client", Sampler: &jaegercfg.SamplerConfig{ Type: jaeger.SamplerTypeConst, Param: 1, }, Reporter: &jaegercfg.ReporterConfig{ LogSpans: true, LocalAgentHostPort: "localhost:6831", }, } tracer, closer, err := jaegerCfgInstance.NewTracer( jaegercfg.Logger(jaegerlog.StdLogger), jaegercfg.Metrics(metrics.NullFactory), ) if err != nil { log.Fatal("cannot create tracer", err) } opentracing.SetGlobalTracer(tracer) defer closer.Close() grcpConn, err := grpc.Dial( "127.0.0.1:8081", grpc.WithInsecure(), grpc.WithUnaryInterceptor(traceutils.OpenTracingClientInterceptor(tracer)), ) if err != nil { log.Fatalf("cant connect to grpc") } defer grcpConn.Close() sessManager = session.NewAuthCheckerClient(grcpConn) http.HandleFunc("/", innerPage) http.HandleFunc("/login", loginPage) http.HandleFunc("/logout", logoutPage) fmt.Println("starting server at :8080") http.ListenAndServe(":8080", nil) } func logoutPage(w http.ResponseWriter, r *http.Request) { cookieSessionID, err := r.Cookie("session_id") if err == http.ErrNoCookie { http.Redirect(w, r, "/", http.StatusFound) return } else if err != nil { w.WriteHeader(http.StatusInternalServerError) return } sessManager.Delete( context.Background(), &session.SessionID{ ID: cookieSessionID.Value, }) cookieSessionID.Expires = time.Now().AddDate(0, 0, -1) http.SetCookie(w, cookieSessionID) http.Redirect(w, r, "/", http.StatusFound) } ================================================ FILE: 9-monitoring/4_tracing/jaeger_grpc/readme.md ================================================ docker run \ --rm \ --name jaeger \ -p6831:6831/udp \ -p16686:16686 \ jaegertracing/all-in-one:latest ================================================ FILE: 9-monitoring/4_tracing/jaeger_grpc/server/server.go ================================================ package main import ( "fmt" "log" "net" "github.com/go-park-mail-ru/lectures/9-monitoring/4_tracing/jaeger_grpc/session" traceutils "github.com/opentracing-contrib/go-grpc" opentracing "github.com/opentracing/opentracing-go" "github.com/uber/jaeger-client-go" jaegercfg "github.com/uber/jaeger-client-go/config" jaegerlog "github.com/uber/jaeger-client-go/log" "github.com/uber/jaeger-lib/metrics" "google.golang.org/grpc" ) func main() { jaegerCfgInstance := jaegercfg.Configuration{ ServiceName: "session", Sampler: &jaegercfg.SamplerConfig{ Type: jaeger.SamplerTypeConst, Param: 1, }, Reporter: &jaegercfg.ReporterConfig{ LogSpans: true, LocalAgentHostPort: "localhost:6831", }, } tracer, closer, err := jaegerCfgInstance.NewTracer( jaegercfg.Logger(jaegerlog.StdLogger), jaegercfg.Metrics(metrics.NullFactory), ) if err != nil { log.Fatal("cannot create tracer", err) } opentracing.SetGlobalTracer(tracer) defer closer.Close() lis, err := net.Listen("tcp", ":8081") if err != nil { log.Fatalln("cant listet port", err) } server := grpc.NewServer(grpc.UnaryInterceptor(traceutils.OpenTracingServerInterceptor(tracer))) session.RegisterAuthCheckerServer(server, NewSessionManager()) fmt.Println("starting server at :8081") server.Serve(lis) } ================================================ FILE: 9-monitoring/4_tracing/jaeger_grpc/server/session.go ================================================ package main import ( "fmt" "math/rand" "sync" "github.com/go-park-mail-ru/lectures/9-monitoring/4_tracing/jaeger_grpc/session" "google.golang.org/grpc" "google.golang.org/grpc/codes" "golang.org/x/net/context" ) const sessKeyLen = 10 type SessionManager struct { mu sync.RWMutex sessions map[session.SessionID]*session.Session } func NewSessionManager() *SessionManager { return &SessionManager{ mu: sync.RWMutex{}, sessions: map[session.SessionID]*session.Session{}, } } func (sm *SessionManager) Create(ctx context.Context, in *session.Session) (*session.SessionID, error) { fmt.Println("call Create", in) id := &session.SessionID{RandStringRunes(sessKeyLen)} sm.mu.Lock() sm.sessions[*id] = in sm.mu.Unlock() return id, nil } func (sm *SessionManager) Check(ctx context.Context, in *session.SessionID) (*session.Session, error) { fmt.Println("call Check", in) sm.mu.RLock() defer sm.mu.RUnlock() if sess, ok := sm.sessions[*in]; ok { return sess, nil } return nil, grpc.Errorf(codes.NotFound, "session not found") } func (sm *SessionManager) Delete(ctx context.Context, in *session.SessionID) (*session.Nothing, error) { fmt.Println("call Delete", in) sm.mu.Lock() defer sm.mu.Unlock() delete(sm.sessions, *in) return &session.Nothing{Dummy: true}, nil } var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") func RandStringRunes(n int) string { b := make([]rune, n) for i := range b { b[i] = letterRunes[rand.Intn(len(letterRunes))] } return string(b) } ================================================ FILE: 9-monitoring/4_tracing/jaeger_grpc/session/session.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // source: session.proto /* Package session is a generated protocol buffer package. It is generated from these files: session.proto It has these top-level messages: SessionID Session Nothing */ package session import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" import ( context "golang.org/x/net/context" grpc "google.golang.org/grpc" ) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. // A compilation error at this line likely means your copy of the // proto package needs to be updated. const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package type SessionID struct { ID string `protobuf:"bytes,1,opt,name=ID" json:"ID,omitempty"` } func (m *SessionID) Reset() { *m = SessionID{} } func (m *SessionID) String() string { return proto.CompactTextString(m) } func (*SessionID) ProtoMessage() {} func (*SessionID) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } func (m *SessionID) GetID() string { if m != nil { return m.ID } return "" } type Session struct { Login string `protobuf:"bytes,1,opt,name=login" json:"login,omitempty"` Useragent string `protobuf:"bytes,2,opt,name=useragent" json:"useragent,omitempty"` } func (m *Session) Reset() { *m = Session{} } func (m *Session) String() string { return proto.CompactTextString(m) } func (*Session) ProtoMessage() {} func (*Session) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } func (m *Session) GetLogin() string { if m != nil { return m.Login } return "" } func (m *Session) GetUseragent() string { if m != nil { return m.Useragent } return "" } type Nothing struct { Dummy bool `protobuf:"varint,1,opt,name=dummy" json:"dummy,omitempty"` } func (m *Nothing) Reset() { *m = Nothing{} } func (m *Nothing) String() string { return proto.CompactTextString(m) } func (*Nothing) ProtoMessage() {} func (*Nothing) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } func (m *Nothing) GetDummy() bool { if m != nil { return m.Dummy } return false } func init() { proto.RegisterType((*SessionID)(nil), "session.SessionID") proto.RegisterType((*Session)(nil), "session.Session") proto.RegisterType((*Nothing)(nil), "session.Nothing") } // Reference imports to suppress errors if they are not otherwise used. var _ context.Context var _ grpc.ClientConn // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. const _ = grpc.SupportPackageIsVersion4 // Client API for AuthChecker service type AuthCheckerClient interface { Create(ctx context.Context, in *Session, opts ...grpc.CallOption) (*SessionID, error) Check(ctx context.Context, in *SessionID, opts ...grpc.CallOption) (*Session, error) Delete(ctx context.Context, in *SessionID, opts ...grpc.CallOption) (*Nothing, error) } type authCheckerClient struct { cc *grpc.ClientConn } func NewAuthCheckerClient(cc *grpc.ClientConn) AuthCheckerClient { return &authCheckerClient{cc} } func (c *authCheckerClient) Create(ctx context.Context, in *Session, opts ...grpc.CallOption) (*SessionID, error) { out := new(SessionID) err := grpc.Invoke(ctx, "/session.AuthChecker/Create", in, out, c.cc, opts...) if err != nil { return nil, err } return out, nil } func (c *authCheckerClient) Check(ctx context.Context, in *SessionID, opts ...grpc.CallOption) (*Session, error) { out := new(Session) err := grpc.Invoke(ctx, "/session.AuthChecker/Check", in, out, c.cc, opts...) if err != nil { return nil, err } return out, nil } func (c *authCheckerClient) Delete(ctx context.Context, in *SessionID, opts ...grpc.CallOption) (*Nothing, error) { out := new(Nothing) err := grpc.Invoke(ctx, "/session.AuthChecker/Delete", in, out, c.cc, opts...) if err != nil { return nil, err } return out, nil } // Server API for AuthChecker service type AuthCheckerServer interface { Create(context.Context, *Session) (*SessionID, error) Check(context.Context, *SessionID) (*Session, error) Delete(context.Context, *SessionID) (*Nothing, error) } func RegisterAuthCheckerServer(s *grpc.Server, srv AuthCheckerServer) { s.RegisterService(&_AuthChecker_serviceDesc, srv) } func _AuthChecker_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(Session) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(AuthCheckerServer).Create(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: "/session.AuthChecker/Create", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(AuthCheckerServer).Create(ctx, req.(*Session)) } return interceptor(ctx, in, info, handler) } func _AuthChecker_Check_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SessionID) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(AuthCheckerServer).Check(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: "/session.AuthChecker/Check", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(AuthCheckerServer).Check(ctx, req.(*SessionID)) } return interceptor(ctx, in, info, handler) } func _AuthChecker_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SessionID) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(AuthCheckerServer).Delete(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: "/session.AuthChecker/Delete", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(AuthCheckerServer).Delete(ctx, req.(*SessionID)) } return interceptor(ctx, in, info, handler) } var _AuthChecker_serviceDesc = grpc.ServiceDesc{ ServiceName: "session.AuthChecker", HandlerType: (*AuthCheckerServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Create", Handler: _AuthChecker_Create_Handler, }, { MethodName: "Check", Handler: _AuthChecker_Check_Handler, }, { MethodName: "Delete", Handler: _AuthChecker_Delete_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "session.proto", } func init() { proto.RegisterFile("session.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ // 205 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2d, 0x4e, 0x2d, 0x2e, 0xce, 0xcc, 0xcf, 0xd3, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x87, 0x72, 0x95, 0xa4, 0xb9, 0x38, 0x83, 0x21, 0x4c, 0x4f, 0x17, 0x21, 0x3e, 0x2e, 0x26, 0x4f, 0x17, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x26, 0x4f, 0x17, 0x25, 0x5b, 0x2e, 0x76, 0xa8, 0xa4, 0x90, 0x08, 0x17, 0x6b, 0x4e, 0x7e, 0x7a, 0x66, 0x1e, 0x54, 0x16, 0xc2, 0x11, 0x92, 0xe1, 0xe2, 0x2c, 0x2d, 0x4e, 0x2d, 0x4a, 0x4c, 0x4f, 0xcd, 0x2b, 0x91, 0x60, 0x02, 0xcb, 0x20, 0x04, 0x94, 0xe4, 0xb9, 0xd8, 0xfd, 0xf2, 0x4b, 0x32, 0x32, 0xf3, 0xd2, 0x41, 0xda, 0x53, 0x4a, 0x73, 0x73, 0x2b, 0xc1, 0xda, 0x39, 0x82, 0x20, 0x1c, 0xa3, 0x45, 0x8c, 0x5c, 0xdc, 0x8e, 0xa5, 0x25, 0x19, 0xce, 0x19, 0xa9, 0xc9, 0xd9, 0xa9, 0x45, 0x42, 0x06, 0x5c, 0x6c, 0xce, 0x45, 0xa9, 0x89, 0x25, 0xa9, 0x42, 0x02, 0x7a, 0x30, 0xf7, 0x42, 0x1d, 0x20, 0x25, 0x84, 0x2e, 0xe2, 0xe9, 0xa2, 0xc4, 0x20, 0xa4, 0xcf, 0xc5, 0x0a, 0xd6, 0x2c, 0x84, 0x45, 0x5a, 0x0a, 0xc3, 0x10, 0x25, 0x06, 0x90, 0x15, 0x2e, 0xa9, 0x39, 0xa9, 0x25, 0xa9, 0x04, 0x74, 0x40, 0x1d, 0xae, 0xc4, 0x90, 0xc4, 0x06, 0x0e, 0x31, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, 0x14, 0x16, 0x5c, 0x42, 0x01, 0x00, 0x00, } ================================================ FILE: 9-monitoring/4_tracing/jaeger_grpc/session/session.proto ================================================ syntax = "proto3"; // protoc --go_out=plugins=grpc:. *.proto package session; message SessionID { string ID = 1; } message Session { string login = 1; string useragent = 2; } message Nothing { bool dummy = 1; } // grpc-сервис проверки авторизации service AuthChecker { rpc Create (Session) returns (SessionID) {} rpc Check (SessionID) returns (Session) {} rpc Delete (SessionID) returns (Nothing) {} } ================================================ FILE: README.md ================================================ # lectures ================================================ FILE: go.mod ================================================ module github.com/go-park-mail-ru/lectures go 1.25.0 require ( github.com/99designs/gqlgen v0.11.1 github.com/DATA-DOG/go-sqlmock v1.3.3 github.com/IBM/sarama v1.47.0 github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d github.com/buaazp/fasthttprouter v0.1.1 github.com/casbin/casbin v1.9.1 github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/gen1us2k/go-translit v0.0.0-20160120121136-46f1a0be552c github.com/getsentry/sentry-go v0.13.0 github.com/go-sql-driver/mysql v1.6.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.2 github.com/gomodule/redigo v1.8.9 github.com/gorilla/mux v1.8.0 github.com/gorilla/schema v1.2.0 github.com/gorilla/websocket v1.5.0 github.com/graphql-go/graphql v0.8.0 github.com/hashicorp/consul/api v1.15.3 github.com/hashicorp/vault/api v1.8.2 github.com/icrowley/fake v0.0.0-20220625154756-3c7517006344 github.com/jackc/pgx v3.6.2+incompatible github.com/jackc/pgx/v5 v5.9.1 github.com/jinzhu/gorm v1.9.16 github.com/jmoiron/sqlx v1.3.5 github.com/julienschmidt/httprouter v1.3.0 github.com/labstack/echo v3.3.10+incompatible github.com/labstack/echo/v4 v4.9.0 github.com/mailru/easyjson v0.7.7 github.com/microcosm-cc/bluemonday v1.0.21 github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 github.com/opentracing-contrib/go-grpc v0.0.0-20210225150812-73cb765af46e github.com/opentracing/opentracing-go v1.2.0 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.12.1 github.com/sirupsen/logrus v1.9.0 github.com/spf13/viper v1.14.0 github.com/streadway/amqp v1.0.0 github.com/stretchr/testify v1.11.1 github.com/swaggo/http-swagger v1.3.3 github.com/swaggo/swag v1.8.5 github.com/tarantool/go-tarantool v1.12.2 github.com/tarantool/go-tarantool/v2 v2.4.2 github.com/uber/jaeger-client-go v2.30.0+incompatible github.com/uber/jaeger-lib v2.4.1+incompatible github.com/valyala/fasthttp v1.45.0 github.com/vektah/gqlparser v1.3.1 github.com/ybbus/jsonrpc/v2 v2.1.6 go.mongodb.org/mongo-driver v1.11.2 go.uber.org/mock v0.6.0 go.uber.org/zap v1.23.0 golang.org/x/crypto v0.48.0 golang.org/x/net v0.51.0 golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 golang.org/x/sync v0.19.0 google.golang.org/grpc v1.50.1 google.golang.org/protobuf v1.28.1 gopkg.in/alexcesaro/statsd.v2 v2.0.0 gopkg.in/vmihailenco/msgpack.v2 v2.9.2 gorm.io/driver/mysql v1.3.6 gorm.io/gorm v1.23.8 ) require ( github.com/HdrHistogram/hdrhistogram-go v1.1.2 // indirect github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect github.com/KyleBanks/depth v1.2.1 // indirect github.com/agnivade/levenshtein v1.0.3 // indirect github.com/andybalholm/brotli v1.0.5 // indirect github.com/armon/go-metrics v0.4.0 // indirect github.com/armon/go-radix v1.0.0 // indirect github.com/aymerick/douceur v0.2.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cenkalti/backoff/v3 v3.0.0 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/cockroachdb/apd v1.1.0 // indirect github.com/corpix/uarand v0.0.0-20170723150923-031be390f409 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/eapache/go-resiliency v1.7.0 // indirect github.com/eapache/queue v1.1.0 // indirect github.com/fatih/color v1.13.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/go-openapi/jsonpointer v0.19.5 // indirect github.com/go-openapi/jsonreference v0.20.0 // indirect github.com/go-openapi/spec v0.20.6 // indirect github.com/go-openapi/swag v0.19.15 // indirect github.com/gofrs/uuid v4.2.0+incompatible // indirect github.com/golang-jwt/jwt v3.2.2+incompatible // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/uuid v1.6.0 // indirect github.com/gorilla/css v1.0.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-hclog v1.2.0 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-plugin v1.4.5 // indirect github.com/hashicorp/go-retryablehttp v0.6.6 // indirect github.com/hashicorp/go-rootcerts v1.0.2 // indirect github.com/hashicorp/go-secure-stdlib/mlock v0.1.1 // indirect github.com/hashicorp/go-secure-stdlib/parseutil v0.1.6 // indirect github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect github.com/hashicorp/go-sockaddr v1.0.2 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/go-version v1.2.0 // indirect github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/serf v0.9.8 // indirect github.com/hashicorp/vault/sdk v0.6.0 // indirect github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect github.com/jackc/fake v0.0.0-20150926172116-812a484cc733 // 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/jcmturner/aescts/v2 v2.0.0 // indirect github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect github.com/jcmturner/gofork v1.7.6 // indirect github.com/jcmturner/gokrb5/v8 v8.4.4 // indirect github.com/jcmturner/rpc/v2 v2.0.3 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/klauspost/compress v1.18.4 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/labstack/gommon v0.3.1 // indirect github.com/magiconair/properties v1.8.6 // indirect github.com/mattn/go-colorable v0.1.12 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/mattn/go-pointer v0.0.1 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/mitchellh/copystructure v1.0.0 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.0.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/reflectwalk v1.0.0 // indirect github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect github.com/oklog/run v1.0.0 // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.5 // indirect github.com/pierrec/lz4 v2.5.2+incompatible // indirect github.com/pierrec/lz4/v4 v4.1.25 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.32.1 // indirect github.com/prometheus/procfs v0.7.3 // indirect github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 // indirect github.com/rogpeppe/go-internal v1.14.1 // indirect github.com/ryanuber/go-glob v1.0.0 // indirect github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect github.com/spf13/afero v1.9.2 // indirect github.com/spf13/cast v1.5.0 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.4.1 // indirect github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe // indirect github.com/tarantool/go-iproto v1.1.0 // indirect github.com/tarantool/go-openssl v0.0.8-0.20230307065445-720eeb389195 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.1 // indirect github.com/vektah/gqlparser/v2 v2.5.0 // indirect github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/scram v1.1.1 // indirect github.com/xdg-go/stringprep v1.0.3 // indirect github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 // indirect golang.org/x/sys v0.41.0 // indirect golang.org/x/text v0.34.0 // indirect golang.org/x/time v0.0.0-20220609170525-579cf78fd858 // indirect golang.org/x/tools v0.41.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/square/go-jose.v2 v2.5.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) ================================================ FILE: go.sum ================================================ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/99designs/gqlgen v0.11.1 h1:QoSL8/AAJ2T3UOeQbdnBR32JcG4pO08+P/g5jdbFkUg= github.com/99designs/gqlgen v0.11.1/go.mod h1:vjFOyBZ7NwDl+GdSD4PFn7BQn5Fy7ohJwXn7Vk8zz+c= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DATA-DOG/go-sqlmock v1.3.3 h1:CWUqKXe0s8A2z6qCgkP4Kru7wC11YoAnoupUKFDnH08= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/HdrHistogram/hdrhistogram-go v1.1.2 h1:5IcZpTvzydCQeHzK4Ef/D5rrSqwxob0t8PQPMybUNFM= github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= github.com/IBM/sarama v1.47.0 h1:GcQFEd12+KzfPYeLgN69Fh7vLCtYRhVIx0rO4TZO318= github.com/IBM/sarama v1.47.0/go.mod h1:7gLLIU97nznOmA6TX++Qds+DRxH89P2XICY2KAQUzAY= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible h1:1G1pk05UrOh0NlF1oeaaix1x8XzrfjIDK47TY0Zehcw= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/agnivade/levenshtein v1.0.3 h1:M5ZnqLOoZR8ygVq0FfkXsNOKzMCk0xRiow0R5+5VkQ0= github.com/agnivade/levenshtein v1.0.3/go.mod h1:4SFRZbbXWLF4MU1T9Qg0pGgH3Pjs+t6ie5efyrwRJXs= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= 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/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= 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/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-metrics v0.3.10/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= github.com/armon/go-metrics v0.4.0 h1:yCQqn7dwca4ITXb+CbubHmedzaQYHhNhrEXLYUeEe8Q= github.com/armon/go-metrics v0.4.0/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ= github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d h1:pVrfxiGfwelyab6n21ZBkbkmbevaf+WvMIiR7sr97hw= github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA= github.com/buaazp/fasthttprouter v0.1.1 h1:4oAnN0C3xZjylvZJdP35cxfclyn4TYkW6Y+DSvS+h8Q= github.com/buaazp/fasthttprouter v0.1.1/go.mod h1:h/Ap5oRVLeItGKTVBb+heQPks+HdIUtGmI4H5WCYijM= github.com/casbin/casbin v1.9.1 h1:ucjbS5zTrmSLtH4XogqOG920Poe6QatdXtz1FEbApeM= github.com/casbin/casbin v1.9.1/go.mod h1:z8uPsfBJGUsnkagrt3G8QvjgTKFMBJ32UP8HpZllfog= github.com/cenkalti/backoff/v3 v3.0.0 h1:ske+9nBpD9qZsTBoF41nW5L+AIuFBKMeze18XQ3eG1c= github.com/cenkalti/backoff/v3 v3.0.0/go.mod h1:cIeZDE3IrqwwJl6VUwCN6trj1oXrTS4rc0ij+ULvLYs= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/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/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= github.com/corpix/uarand v0.0.0-20170723150923-031be390f409 h1:9A+mfQmwzZ6KwUXPc8nHxFtKgn9VIvO3gXAOspIcE3s= github.com/corpix/uarand v0.0.0-20170723150923-031be390f409/go.mod h1:JSm890tOkDN+M1jqN8pUGDKnzJrsVbJwSMHBY4zwz7M= 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/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd h1:83Wprp6ROGeiHFAP8WJdI2RoxALQYgdllERc3N5N2DM= github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/trifles v0.0.0-20190318185328-a8d75aae118c h1:TUuUh0Xgj97tLMNtWtNvI9mIV6isjEb9lBMNv+77IGM= github.com/dgryski/trifles v0.0.0-20190318185328-a8d75aae118c/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= github.com/eapache/go-resiliency v1.7.0 h1:n3NRTnBn5N0Cbi/IeOHuQn9s2UwVUH7Ga0ZWcP+9JTA= github.com/eapache/go-resiliency v1.7.0/go.mod h1:5yPzW0MIvSe0JDsv0v+DvcjEv2FyD6iZYSs1ZI+iQho= github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y= github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/gen1us2k/go-translit v0.0.0-20160120121136-46f1a0be552c h1:J8HJ/lfhIBjmTPB0dZVRKciFaO60DJ+3n3ZXYU73CaQ= github.com/gen1us2k/go-translit v0.0.0-20160120121136-46f1a0be552c/go.mod h1:DCO0xCUjZ8eznOd/fx0E75c06B1hCrFHMTqXAQoYffk= github.com/getsentry/sentry-go v0.13.0 h1:20dgTiUSfxRB/EhMPtxcL9ZEbM1ZdR+W/7f7NWD+xWo= github.com/getsentry/sentry-go v0.13.0/go.mod h1:EOsfu5ZdvKPfeHYV6pTVQnsjfp30+XA7//UooKNumH0= github.com/go-chi/chi v3.3.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonreference v0.20.0 h1:MYlu0sBgChmCfJxxUKZ8g1cPWFOB37YSZqewK7OKeyA= github.com/go-openapi/jsonreference v0.20.0/go.mod h1:Ag74Ico3lPc+zR+qjn4XBUmXymS4zJbYVCZmcgkasdo= github.com/go-openapi/spec v0.20.6 h1:ich1RQ3WDbfoeTqTAb+5EIxNmpKVJZWBNah9RAT0jIQ= github.com/go-openapi/spec v0.20.6/go.mod h1:2OpW+JddWPrpXSCIX8eOx7lZ5iyuWj3RYR6VaaBKcWA= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM= github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-test/deep v1.0.2 h1:onZX1rnHT3Wv6cqNgYyFOOlgVKJrksuCMCRvJStbMYw= github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/gofrs/uuid v4.2.0+incompatible h1:yyYWMnhkhrKwwr8gAOcOCYxOOscHgDS9yZgBrnJfGa0= github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= 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.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/gomodule/redigo v1.8.9 h1:Sl3u+2BI/kk+VEatbj0scLdrFhjPmbxOc1myhDP41ws= github.com/gomodule/redigo v1.8.9/go.mod h1:7ArFNvsTjH8GMMzB4uy1snslv2BwmginuMs06a1uzZE= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= 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.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/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.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= 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/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY= github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c= github.com/gorilla/mux v1.6.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/schema v1.2.0 h1:YufUaxZYCKGFuAq3c96BOhjgd5nmXiOY9NGzF247Tsc= github.com/gorilla/schema v1.2.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= 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/graphql-go/graphql v0.8.0 h1:JHRQMeQjofwqVvGwYnr8JnPTY0AxgVy1HpHSGPLdH0I= github.com/graphql-go/graphql v0.8.0/go.mod h1:nKiHzRM0qopJEwCITUuIsxk9PlVlwIiiI8pnJEhordQ= github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645/go.mod h1:6iZfnjpejD4L/4DwD7NryNaJyCQdzwWwH2MWhCA90Kw= github.com/hashicorp/consul/api v1.15.3 h1:WYONYL2rxTXtlekAqblR2SCdJsizMDIj/uXb5wNy9zU= github.com/hashicorp/consul/api v1.15.3/go.mod h1:/g/qgcoBcEXALCNZgRRisyTW0nY86++L0KbeAMXYCeY= github.com/hashicorp/consul/sdk v0.11.0 h1:HRzj8YSCln2yGgCumN5CL8lYlD3gBurnervJRJAZyC4= github.com/hashicorp/consul/sdk v0.11.0/go.mod h1:yPkX5Q6CsxTFMjQQDJwzeNmUUF5NUGGbrDsv9wTb8cw= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-hclog v1.2.0 h1:La19f8d7WIlm4ogzNHB0JGqs5AUDAZ2UfCY4sJXcJdM= github.com/hashicorp/go-hclog v1.2.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-msgpack v0.5.5 h1:i9R9JSrqIz0QVLz3sz+i3YJdT7TTSLcfLLzJi9aZTuI= github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-plugin v1.4.5 h1:oTE/oQR4eghggRg8VY7PAz3dr++VwDNBGCcOfIvHpBo= github.com/hashicorp/go-plugin v1.4.5/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-retryablehttp v0.6.6 h1:HJunrbHTDDbBb/ay4kxa1n+dLmttUlnP3V9oNE4hmsM= github.com/hashicorp/go-retryablehttp v0.6.6/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc= github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-secure-stdlib/mlock v0.1.1 h1:cCRo8gK7oq6A2L6LICkUZ+/a5rLiRXFMf1Qd4xSwxTc= github.com/hashicorp/go-secure-stdlib/mlock v0.1.1/go.mod h1:zq93CJChV6L9QTfGKtfBxKqD7BqqXx5O04A/ns2p5+I= github.com/hashicorp/go-secure-stdlib/parseutil v0.1.6 h1:om4Al8Oy7kCm/B86rLCLah4Dt5Aa0Fr5rYBG60OzwHQ= github.com/hashicorp/go-secure-stdlib/parseutil v0.1.6/go.mod h1:QmrqtbKuxxSWTN3ETMPuB+VtEiBJ/A9XhoYGv8E1uD8= github.com/hashicorp/go-secure-stdlib/strutil v0.1.1/go.mod h1:gKOamz3EwoIoJq7mlMIRBpVTAUn8qPCrEclOKKWhD3U= github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 h1:kes8mmyCpxJsI7FTwtzRqEy9CdjCtrXrXGuOpxEA7Ts= github.com/hashicorp/go-secure-stdlib/strutil v0.1.2/go.mod h1:Gou2R9+il93BqX25LAKCLuM+y9U2T4hlwvT1yprcna4= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-sockaddr v1.0.2 h1:ztczhD1jLxIRjVejw8gFomI1BQZOe2WoVOu0SyteCQc= github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.2.0 h1:3vNe/fWF5CBgRIguda1meWhsZHy3m8gCJ5wx+dIzX/E= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= github.com/hashicorp/memberlist v0.3.1 h1:MXgUXLqva1QvpVEDQW1IQLG0wivQAtmFlHRQ+1vWZfM= github.com/hashicorp/memberlist v0.3.1/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= github.com/hashicorp/serf v0.9.7/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= github.com/hashicorp/serf v0.9.8 h1:JGklO/2Drf1QGa312EieQN3zhxQ+aJg6pG+aC3MFaVo= github.com/hashicorp/serf v0.9.8/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= github.com/hashicorp/vault/api v1.8.2 h1:C7OL9YtOtwQbTKI9ogB0A1wffRbCN+rH/LLCHO3d8HM= github.com/hashicorp/vault/api v1.8.2/go.mod h1:ML8aYzBIhY5m1MD1B2Q0JV89cC85YVH4t5kBaZiyVaE= github.com/hashicorp/vault/sdk v0.6.0 h1:6Z+In5DXHiUfZvIZdMx7e2loL1PPyDjA4bVh9ZTIAhs= github.com/hashicorp/vault/sdk v0.6.0/go.mod h1:+DRpzoXIdMvKc88R4qxr+edwy/RvH5QK8itmxLiDHLc= github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb h1:b5rjCoWHc7eqmAS4/qyk21ZsHyb6Mxv/jykxvNTkU4M= github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/icrowley/fake v0.0.0-20220625154756-3c7517006344 h1:gvlL0h+DFa2eX4rLg/lbtBV4z81p1qHGcvPIpWtlXn0= github.com/icrowley/fake v0.0.0-20220625154756-3c7517006344/go.mod h1:dQ6TM/OGAe+cMws81eTe4Btv1dKxfPZ2CX+YaAFAPN4= github.com/jackc/fake v0.0.0-20150926172116-812a484cc733 h1:vr3AYkKovP8uR8AvSGGUK1IDqRa5lAAvEkZG1LKaCRc= github.com/jackc/fake v0.0.0-20150926172116-812a484cc733/go.mod h1:WrMFNQdiFJ80sQsxDoMokWK1W5TQtxBFNpzWTD84ibQ= 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 v3.6.2+incompatible h1:2zP5OD7kiyR3xzRYMhOcXVvkDZsImVXfj+yIyTQf3/o= github.com/jackc/pgx v3.6.2+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGkVEFm4TeybAXq+I= github.com/jackc/pgx/v5 v5.9.1 h1:uwrxJXBnx76nyISkhr33kQLlUqjv7et7b9FjCen/tdc= github.com/jackc/pgx/v5 v5.9.1/go.mod h1:mal1tBGAFfLHvZzaYh77YS/eC6IX9OWbRV1QIIM0Jn4= 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/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8= github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs= github.com/jcmturner/dnsutils/v2 v2.0.0 h1:lltnkeZGL0wILNvrNiVCR6Ro5PGU/SeBvVO/8c/iPbo= github.com/jcmturner/dnsutils/v2 v2.0.0/go.mod h1:b0TnjGOvI/n42bZa+hmXL+kFJZsFT7G4t3HTlQ184QM= github.com/jcmturner/gofork v1.7.6 h1:QH0l3hzAU1tfT3rZCnW5zXl+orbkNMMRGJfdJjHVETg= github.com/jcmturner/gofork v1.7.6/go.mod h1:1622LH6i/EZqLloHfE7IeZ0uEJwMSUyQ/nDd82IeqRo= github.com/jcmturner/goidentity/v6 v6.0.1 h1:VKnZd2oEIMorCTsFBnJWbExfNN7yZr3EhJAxwOkZg6o= github.com/jcmturner/goidentity/v6 v6.0.1/go.mod h1:X1YW3bgtvwAXju7V3LCIMpY0Gbxyjn/mY9zx4tFonSg= github.com/jcmturner/gokrb5/v8 v8.4.4 h1:x1Sv4HaTpepFkXbt2IkL29DXRf8sOfZXo8eRKh687T8= github.com/jcmturner/gokrb5/v8 v8.4.4/go.mod h1:1btQEpgT6k+unzCwX1KdWMEwPPkkgBtP+F6aCACiMrs= github.com/jcmturner/rpc/v2 v2.0.3 h1:7FXXj8Ti1IaVFpSAziCZWNzbNuZmnvw/i6CqLNdWfZY= github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc= github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74= github.com/jinzhu/gorm v1.9.16 h1:+IyIjPEABKRpsu/F8OvDPy9fyQlgsg2luMV2ZIH5i5o= github.com/jinzhu/gorm v1.9.16/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBefADcs= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.18.4 h1:RPhnKRAQ4Fh8zU2FY/6ZFDwTVTxgJ/EMydqSTzE9a2c= github.com/klauspost/compress v1.18.4/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= 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/labstack/echo v3.3.10+incompatible h1:pGRcYk231ExFAyoAjAfD85kQzRJCRI8bbnE7CX5OEgg= github.com/labstack/echo v3.3.10+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s= github.com/labstack/echo/v4 v4.9.0 h1:wPOF1CE6gvt/kmbMR4dGzWvHMPT+sAEUJOwOTtvITVY= github.com/labstack/echo/v4 v4.9.0/go.mod h1:xkCDAdFCIf8jsFQ5NnbK7oqaF/yU1A1X20Ltm0OvSks= github.com/labstack/gommon v0.3.1 h1:OomWaJXm7xR6L1HmEtGyQf26TEn7V6X88mktX9kee9o= github.com/labstack/gommon v0.3.1/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/matryer/moq v0.0.0-20200106131100-75d0ddfc0007/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-pointer v0.0.1 h1:n+XhsuGeVO6MEAp7xyEukFINEa+Quek5psIR/ylA6o0= github.com/mattn/go-pointer v0.0.1/go.mod h1:2zXcozF6qYGgmsG+SeTZz3oAbFLdD3OWqnUbNvJZAlc= github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus= github.com/mattn/go-sqlite3 v1.14.6 h1:dNPt6NO46WmLVt2DLNpwczCmdV5boIZ6g/tlDrlRUbg= github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/microcosm-cc/bluemonday v1.0.21 h1:dNH3e4PSyE4vNX+KlRGHT5KrSvjeUkoNPwEORjffHJg= github.com/microcosm-cc/bluemonday v1.0.21/go.mod h1:ytNkv4RrDrLJ2pqlsSI46O6IVXmZOBBD4SaJyDwwTkM= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.41 h1:WMszZWJG0XmzbK9FEmzH2TVcqYzFesusSIB41b8KHxY= github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/opentracing-contrib/go-grpc v0.0.0-20210225150812-73cb765af46e h1:4cPxUYdgaGzZIT5/j0IfqOrrXmq6bG8AwvwisMXpdrg= github.com/opentracing-contrib/go-grpc v0.0.0-20210225150812-73cb765af46e/go.mod h1:DYR5Eij8rJl8h7gblRrOZ8g0kW1umSpKqYIBTgeDtLo= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml/v2 v2.0.5 h1:ipoSadvV8oGUjnUbMub59IDPPwfxF694nG/jwbMiyQg= github.com/pelletier/go-toml/v2 v2.0.5/go.mod h1:OMHamSCAODeSsVrwwvcJOaoN0LIUIaFVNZzmWyNfXas= github.com/pierrec/lz4 v2.5.2+incompatible h1:WCjObylUIOlKy/+7Abdn34TLIkXiA4UWUMhxq9m9ZXI= github.com/pierrec/lz4 v2.5.2+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pierrec/lz4/v4 v4.1.25 h1:kocOqRffaIbU5djlIBr7Wh+cx82C0vtFb0fOurZHqD0= github.com/pierrec/lz4/v4 v4.1.25/go.mod h1:EoQMVJgeeEOMsCqCzqFm2O0cJvljX2nGZjcRIPL34O4= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 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/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= 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/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= github.com/prometheus/client_golang v1.12.1 h1:ZiaPsmm9uiBeaSMRznKsCDNtPCS0T3JVDGF+06gjBzk= github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 h1:bsUq1dX0N8AOIL7EB/X911+m4EHsnWEHeJ0c+3TTBrg= github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk= github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 h1:RC6RW7j+1+HkWaX/Yh71Ee5ZHaHYt7ZP4sQgUrm6cDU= github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572/go.mod h1:w0SWMsp6j9O/dk4/ZpIhL+3CkG8ofA2vuv7k+ltqUMc= github.com/spf13/afero v1.9.2 h1:j49Hj62F0n+DaZ1dDCvhABaPNSGNkt32oRFxI33IEMw= github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.14.0 h1:Rg7d3Lo706X9tHsJMUjdiwMpHB7W8WnSVOssIY+JElU= github.com/spf13/viper v1.14.0/go.mod h1:WT//axPky3FdvXHzGw33dNdXXXfFQqmEalje+egj8As= github.com/streadway/amqp v1.0.0 h1:kuuDrUJFZL1QYL9hUNuCxNObNzB0bV/ZG5jV3RWAQgo= github.com/streadway/amqp v1.0.0/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/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/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.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.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs= github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe h1:K8pHPVoTgxFJt1lXuIzzOX7zZhZFldJQK/CgKx9BFIc= github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe/go.mod h1:lKJPbtWzJ9JhsTN1k1gZgleJWY/cqq0psdoMmaThG3w= github.com/swaggo/http-swagger v1.3.3 h1:Hu5Z0L9ssyBLofaama21iYaF2VbWyA8jdohaaCGpHsc= github.com/swaggo/http-swagger v1.3.3/go.mod h1:sE+4PjD89IxMPm77FnkDz0sdO+p5lbXzrVWT6OTVVGo= github.com/swaggo/swag v1.8.5 h1:7NgtfXsXE+jrcOwRyiftGKW7Ppydj7tZiVenuRf1fE4= github.com/swaggo/swag v1.8.5/go.mod h1:jMLeXOOmYyjk8PvHTsXBdrubsNd9gUJTTCzL5iBnseg= github.com/tarantool/go-iproto v1.1.0 h1:HULVOIHsiehI+FnHfM7wMDntuzUddO09DKqu2WnFQ5A= github.com/tarantool/go-iproto v1.1.0/go.mod h1:LNCtdyZxojUed8SbOiYHoc3v9NvaZTB7p96hUySMlIo= github.com/tarantool/go-openssl v0.0.8-0.20230307065445-720eeb389195 h1:/AN3eUPsTlvF6W+Ng/8ZjnSU6o7L0H4Wb9GMks6RkzU= github.com/tarantool/go-openssl v0.0.8-0.20230307065445-720eeb389195/go.mod h1:M7H4xYSbzqpW/ZRBMyH0eyqQBsnhAMfsYk5mv0yid7A= github.com/tarantool/go-tarantool v1.12.2 h1:u4g+gTOHNxbUDJv0EIUFkRurU/lTQSzWrz8o7bHVAqI= github.com/tarantool/go-tarantool v1.12.2/go.mod h1:QRiXv0jnxwgxHtr9ZmifSr/eRba76gTUBgp69pDMX1U= github.com/tarantool/go-tarantool/v2 v2.4.2 h1:rkzYtFhLJLA9RDIhjzN93MJBN5PBxHW4+soq+RB90gE= github.com/tarantool/go-tarantool/v2 v2.4.2/go.mod h1:MTbhdjFc3Jl63Lgi/UJr5D+QbT+QegqOzsNJGmaw7VM= github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/uber/jaeger-client-go v2.30.0+incompatible h1:D6wyKGCecFaSRUpo8lCVbaOOb6ThwMmTEbhRwtKR97o= github.com/uber/jaeger-client-go v2.30.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= github.com/uber/jaeger-lib v2.4.1+incompatible h1:td4jdvLcExb4cBISKIpHuGoVXh+dVKhn2Um6rjCsSsg= github.com/uber/jaeger-lib v2.4.1+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasthttp v1.45.0 h1:zPkkzpIn8tdHZUrVa6PzYd0i5verqiPSkgTd3bSUcpA= github.com/valyala/fasthttp v1.45.0/go.mod h1:k2zXd82h/7UZc3VOdJ2WaUqt1uZ/XpXAfE9i+HBC3lA= github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52WA1u4= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e/go.mod h1:/HUdMve7rvxZma+2ZELQeNh88+003LL7Pf/CZ089j8U= github.com/vektah/gqlparser v1.3.1 h1:8b0IcD3qZKWJQHSzynbDlrtP3IxVydZ2DZepCGofqfU= github.com/vektah/gqlparser v1.3.1/go.mod h1:bkVf0FX+Stjg/MHnm8mEyubuaArhNEqfQhF+OTiAL74= github.com/vektah/gqlparser/v2 v2.0.1/go.mod h1:SyUiHgLATUR8BiYURfTirrTcGpcE+4XkV2se04Px1Ms= github.com/vektah/gqlparser/v2 v2.5.0 h1:GwEwy7AJsqPWrey0bHnn+3JLaHLZVT66wY/+O+Tf9SU= github.com/vektah/gqlparser/v2 v2.5.0/go.mod h1:mPgqFBu/woKTVYWyNk8cO3kh4S/f4aRFZrvOnp3hmCs= github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8= github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= 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/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.1.1 h1:VOMT+81stJgXW3CpHyqHN3AXDYIMsx56mEFrB37Mb/E= github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= github.com/xdg-go/stringprep v1.0.3 h1:kdwGpVNwPFtjs98xCGkHjQtGKh86rDcRZN17QEMCOIs= github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= github.com/ybbus/jsonrpc/v2 v2.1.6 h1:++pboiaaD6TZ9FJ1JOBBRB/tPtR1njYzqz1iSZGv+3Y= github.com/ybbus/jsonrpc/v2 v2.1.6/go.mod h1:rIuG1+ORoiqocf9xs/v+ecaAVeo3zcZHQgInyKFMeg0= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.mongodb.org/mongo-driver v1.11.2 h1:+1v2rDQUWNcGW7/7E0Jvdz51V38XXxJfhzbV17aNHCw= go.mongodb.org/mongo-driver v1.11.2/go.mod h1:s7p5vEtfbeR1gYi6pnj3c3/urpbLv2T5Sfd6Rp2HBB8= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y= go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU= go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= go.uber.org/zap v1.23.0 h1:OjGQ5KQDEUawVHxNwQgPpiypGHOxo2mNZsOqTak4fFY= go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= golang.org/x/crypto v0.48.0 h1:/VRzVqiRSggnhY7gNRxPauEQ5Drw9haKdM0jqfcCFts= golang.org/x/crypto v0.48.0/go.mod h1:r0kV5h3qnFPlQnBSrULhlsRfryS2pmewsg+XfMgkVos= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c= golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU= golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190921015927-1a5e07d1ff72/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= 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.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= 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/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 h1:nt+Q6cXKz4MosCSpnbMtqiQ8Oz0pxTef2B4Vca2lvfk= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/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-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/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.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4= golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/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-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/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-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/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-20220715151400-c0bba94af5f8/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-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k= golang.org/x/sys v0.41.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.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk= golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20220609170525-579cf78fd858 h1:Dpdu/EMxGMFgq0CeYMh4fazTD2vtlZRYE7wyynxJb9U= golang.org/x/time v0.0.0-20220609170525-579cf78fd858/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.41.0 h1:a9b8iMweWG+S0OBnlU36rzLp20z1Rp10w+IY2czHTQc= golang.org/x/tools v0.41.0/go.mod h1:XSY6eDqxVNiYgezAVqqCeihT4j1U2CCsqvH3WhQpnlg= 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= gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0= gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e h1:S9GbmC1iCgvbLyAokVCwiO6tVIrU9Y7c5oMx1V/ki/Y= google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.50.1 h1:DS/BukOZWp8s6p4Dt/tOaJaTQyPyOoCcrjroHuCeLzY= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= 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.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= 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.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/alexcesaro/statsd.v2 v2.0.0 h1:FXkZSCZIH17vLCO5sO2UucTHsH9pc+17F6pl3JVCwMc= gopkg.in/alexcesaro/statsd.v2 v2.0.0/go.mod h1:i0ubccKGzBVNBpdGV5MocxyA/XlLUJzA7SLonnE4drU= 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-20200227125254-8fa46927fb4f/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/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/square/go-jose.v2 v2.5.1 h1:7odma5RETjNHWJnR32wx8t+Io4djHE1PqxCFx3iiZ2w= gopkg.in/square/go-jose.v2 v2.5.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/vmihailenco/msgpack.v2 v2.9.2 h1:gjPqo9orRVlSAH/065qw3MsFCDpH7fa1KpiizXyllY4= gopkg.in/vmihailenco/msgpack.v2 v2.9.2/go.mod h1:/3Dn1Npt9+MYyLpYYXjInO/5jvMLamn+AEGwNEOatn8= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 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.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/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 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= 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.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/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= gorm.io/driver/mysql v1.3.6 h1:BhX1Y/RyALb+T9bZ3t07wLnPZBukt+IRkMn8UZSNbGM= gorm.io/driver/mysql v1.3.6/go.mod h1:sSIebwZAVPiT+27jK9HIwvsqOGKx3YMPmrA3mBJR10c= gorm.io/gorm v1.23.8 h1:h8sGJ+biDgBA1AD1Ha9gFCx7h8npU7AsLdlkX0n2TpE= gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:L5q+DGLGOQFpo1snNEkLOJT2d1YTW66rWNzatr3He1k=
# Title Updated New
{{.ID.Hex}} {{.Title}} {{.Updated}} Edit Del