text: // Copyright (c) Microsoft Corporation. All rights reserved.
  // Licensed under the MIT License.
  
  // WARNING! Do not edit this file manually, your changes will be overwritten.
  
  #include "FieldObject.h"
  #include "InputValueObject.h"
  #include "TypeObject.h"
  
  #include "graphqlservice/internal/Introspection.h"
  
  #include <algorithm>
  #include <functional>
  #include <sstream>
  #include <stdexcept>
  #include <unordered_map>
  
  using namespace std::literals;
  
  namespace graphql::introspection {
  namespace object {
  
  Field::Field(std::shared_ptr<introspection::Field> pimpl) noexcept
  	: service::Object{ getTypeNames(), getResolvers() }
  	, _pimpl { std::make_unique<Model<introspection::Field>>(std::move(pimpl)) }
  {
  }
  
  Field::~Field()
  {
  	// This is empty, but explicitly defined here so that it can access the un-exported destructor
  	// of the implementation type.
  }
  
  service::TypeNames Field::getTypeNames() const noexcept
  {
  	return {
  		R"gql(__Field)gql"sv
  	};
  }
  
  service::ResolverMap Field::getResolvers() const noexcept
  {
  	return {
  		{ R"gql(args)gql"sv, [this](service::ResolverParams&& params) { return resolveArgs(std::move(params)); } },
  		{ R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } },
  		{ R"gql(type)gql"sv, [this](service::ResolverParams&& params) { return resolveType(std::move(params)); } },
  		{ R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } },
  		{ R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } },
  		{ R"gql(isDeprecated)gql"sv, [this](service::ResolverParams&& params) { return resolveIsDeprecated(std::move(params)); } },
  		{ R"gql(deprecationReason)gql"sv, [this](service::ResolverParams&& params) { return resolveDeprecationReason(std::move(params)); } }
  	};
  }
  
  service::AwaitableResolver Field::resolveName(service::ResolverParams&& params) const
  {
  	std::unique_lock resolverLock(_resolverMutex);
  	auto result = _pimpl->getName();
  	resolverLock.unlock();
  
  	return service::ModifiedResult<std::string>::convert(std::move(result), std::move(params));
  }
  
  service::AwaitableResolver Field::resolveDescription(service::ResolverParams&& params) const
  {
  	std::unique_lock resolverLock(_resolverMutex);
  	auto result = _pimpl->getDescription();
  	resolverLock.unlock();
  
  	return service::ModifiedResult<std::string>::convert<service::TypeModifier::Nullable>(std::move(result), std::move(params));
  }
  
  service::AwaitableResolver Field::resolveArgs(service::ResolverParams&& params) const
  {
  	std::unique_lock resolverLock(_resolverMutex);
  	auto result = _pimpl->getArgs();
  	resolverLock.unlock();
  
  	return service::ModifiedResult<InputValue>::convert<service::TypeModifier::List>(std::move(result), std::move(params));
  }
  
  service::AwaitableResolver Field::resolveType(service::ResolverParams&& params) const
  {
  	std::unique_lock resolverLock(_resolverMutex);
  	auto result = _pimpl->getType();
  	resolverLock.unlock();
  
  	return service::ModifiedResult<Type>::convert(std::move(result), std::move(params));
  }
  
  service::AwaitableResolver Field::resolveIsDeprecated(service::ResolverParams&& params) const
  {
  	std::unique_lock resolverLock(_resolverMutex);
  	auto result = _pimpl->getIsDeprecated();
  	resolverLock.unlock();
  
  	return service::ModifiedResult<bool>::convert(std::move(result), std::move(params));
  }
  
  service::AwaitableResolver Field::resolveDeprecationReason(service::ResolverParams&& params) const
  {
  	std::unique_lock resolverLock(_resolverMutex);
  	auto result = _pimpl->getDeprecationReason();
  	resolverLock.unlock();
  
  	return service::ModifiedResult<std::string>::convert<service::TypeModifier::Nullable>(std::move(result), std::move(params));
  }
  
  service::AwaitableResolver Field::resolve_typename(service::ResolverParams&& params) const
  {
  	return service::ModifiedResult<std::string>::convert(std::string{ R"gql(__Field)gql" }, std::move(params));
  }
  
  } // namespace object
  
  void AddFieldDetails(const std::shared_ptr<schema::ObjectType>& typeField, const std::shared_ptr<schema::Schema>& schema)
  {
  	typeField->AddFields({
  		schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))),
  		schema::Field::Make(R"gql(description)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)),
  		schema::Field::Make(R"gql(args)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__InputValue)gql"sv))))),
  		schema::Field::Make(R"gql(type)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Type)gql"sv))),
  		schema::Field::Make(R"gql(isDeprecated)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))),
  		schema::Field::Make(R"gql(deprecationReason)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv))
  	});
  }
  
  } // namespace graphql::introspection
  