module Hasura.RQL.DDL.GraphqlSchemaIntrospection
  ( runSetGraphqlSchemaIntrospectionOptions,
  )
where

import Control.Lens ((.~))
import Hasura.Base.Error
import Hasura.EncJSON
import Hasura.Prelude
import Hasura.RQL.Types.Common
import Hasura.RQL.Types.GraphqlSchemaIntrospection
import Hasura.RQL.Types.Metadata
import Hasura.RQL.Types.Metadata.Instances ()
import Hasura.RQL.Types.SchemaCache.Build

runSetGraphqlSchemaIntrospectionOptions ::
  (MonadError QErr m, MetadataM m, CacheRWM m) =>
  SetGraphqlIntrospectionOptions ->
  m EncJSON
runSetGraphqlSchemaIntrospectionOptions :: SetGraphqlIntrospectionOptions -> m EncJSON
runSetGraphqlSchemaIntrospectionOptions SetGraphqlIntrospectionOptions
introspectionOptions = do
  m () -> m ()
forall (m :: * -> *) a. (QErrM m, CacheRM m) => m a -> m a
withNewInconsistentObjsCheck (m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$
    MetadataModifier -> m ()
forall (m :: * -> *).
(MetadataM m, CacheRWM m) =>
MetadataModifier -> m ()
buildSchemaCache (MetadataModifier -> m ()) -> MetadataModifier -> m ()
forall a b. (a -> b) -> a -> b
$
      (Metadata -> Metadata) -> MetadataModifier
MetadataModifier ((Metadata -> Metadata) -> MetadataModifier)
-> (Metadata -> Metadata) -> MetadataModifier
forall a b. (a -> b) -> a -> b
$
        (SetGraphqlIntrospectionOptions
 -> Identity SetGraphqlIntrospectionOptions)
-> Metadata -> Identity Metadata
Lens' Metadata SetGraphqlIntrospectionOptions
metaSetGraphqlIntrospectionOptions ((SetGraphqlIntrospectionOptions
  -> Identity SetGraphqlIntrospectionOptions)
 -> Metadata -> Identity Metadata)
-> SetGraphqlIntrospectionOptions -> Metadata -> Metadata
forall s t a b. ASetter s t a b -> b -> s -> t
.~ SetGraphqlIntrospectionOptions
introspectionOptions
  EncJSON -> m EncJSON
forall (m :: * -> *) a. Monad m => a -> m a
return EncJSON
successMsg