graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellSafe-Inferred
LanguageHaskell2010

Hasura.GraphQL.Schema.Common

Synopsis

Documentation

data SchemaContext Source #

Aggregation of contextual information required to build the schema.

Constructors

SchemaContext 

Fields

data SchemaKind Source #

The kind of schema we're building, and its associated options.

type MonadBuildSchemaBase m n = (MonadError QErr m, MonadMemoize m, MonadParse n) Source #

The set of common constraints required to build the schema.

newtype RemoteRelationshipParserBuilder Source #

How a remote relationship field should be processed when building a schema. Injecting this function from the top level avoids having to know how to do top-level dispatch from deep within the schema code.

Note: the inner function type uses an existential qualifier: it is expected that the given function will work for _any_ monad m that has the relevant constraints. This prevents us from passing a function that is specfic to the monad in which the schema construction will run, but avoids having to propagate type annotations to each call site.

Constructors

RemoteRelationshipParserBuilder (forall lhsJoinField r n m. MonadBuildSchemaBase m n => RemoteFieldInfo lhsJoinField -> SchemaT r m (Maybe [FieldParser n (RemoteRelationshipField UnpreparedValue)])) 

ignoreRemoteRelationship :: RemoteRelationshipParserBuilder Source #

A RemoteRelationshipParserBuilder that ignores the field altogether, that can be used in tests or to build a source or remote schema in isolation.

newtype NodeInterfaceParserBuilder Source #

How to build the Relay node.

Similarly to what we do for remote relationships, we pass in the context the builder function required to build the Node interface, in order to avoid the cross-sources cycles it creates otherwise.

retrieve :: (MonadReader r m, Has a r) => (a -> b) -> m b Source #

newtype SchemaT r m a Source #

The monad in which the schema is built.

The implementation of SchemaT is intended to be opaque: running a computation in SchemaT is intended to be done via calls to runSourceSchema and runRemoteSchema, which also enforce what the r parameter should be in each case.

The reason why we want to enforce that the schema is built in a reader on top of an arbitrary base monad is for performance: see Note [SchemaT and stacking] for more information.

In the future, we might monomorphize this further to make MemoizeT explicit.

Constructors

SchemaT 

Fields

Instances

Instances details
MonadError e m => MonadError e (SchemaT r m) Source # 
Instance details

Defined in Hasura.GraphQL.Schema.Common

Methods

throwError :: e -> SchemaT r m a #

catchError :: SchemaT r m a -> (e -> SchemaT r m a) -> SchemaT r m a #

Monad m => MonadReader r (SchemaT r m) Source # 
Instance details

Defined in Hasura.GraphQL.Schema.Common

Methods

ask :: SchemaT r m r #

local :: (r -> r) -> SchemaT r m a -> SchemaT r m a #

reader :: (r -> a) -> SchemaT r m a #

MonadTrans (SchemaT r) Source # 
Instance details

Defined in Hasura.GraphQL.Schema.Common

Methods

lift :: Monad m => m a -> SchemaT r m a #

Applicative m => Applicative (SchemaT r m) Source # 
Instance details

Defined in Hasura.GraphQL.Schema.Common

Methods

pure :: a -> SchemaT r m a #

(<*>) :: SchemaT r m (a -> b) -> SchemaT r m a -> SchemaT r m b #

liftA2 :: (a -> b -> c) -> SchemaT r m a -> SchemaT r m b -> SchemaT r m c #

(*>) :: SchemaT r m a -> SchemaT r m b -> SchemaT r m b #

(<*) :: SchemaT r m a -> SchemaT r m b -> SchemaT r m a #

Functor m => Functor (SchemaT r m) Source # 
Instance details

Defined in Hasura.GraphQL.Schema.Common

Methods

fmap :: (a -> b) -> SchemaT r m a -> SchemaT r m b #

(<$) :: a -> SchemaT r m b -> SchemaT r m a #

Monad m => Monad (SchemaT r m) Source # 
Instance details

Defined in Hasura.GraphQL.Schema.Common

Methods

(>>=) :: SchemaT r m a -> (a -> SchemaT r m b) -> SchemaT r m b #

(>>) :: SchemaT r m a -> SchemaT r m b -> SchemaT r m b #

return :: a -> SchemaT r m a #

MonadMemoize m => MonadMemoize (SchemaT r m) Source # 
Instance details

Defined in Hasura.GraphQL.Schema.Common

Methods

memoizeOn :: (Ord a, Typeable a, Typeable p) => Name -> a -> SchemaT r m p -> SchemaT r m p Source #

runSourceSchema :: forall b m a. SchemaContext -> SchemaOptions -> SourceInfo b -> SchemaT (SchemaContext, SchemaOptions, SourceInfo b) m a -> m a Source #

Runs a schema-building computation with all the context required to build a source.

runRemoteSchema :: SchemaContext -> SchemaT (SchemaContext, MkTypename, CustomizeRemoteFieldName) m a -> m a Source #

Runs a schema-building computation with all the context required to build a remote schema.

runActionSchema :: SchemaContext -> SchemaOptions -> SchemaT (SchemaContext, SchemaOptions) m a -> m a Source #

Runs a schema-building computation with all the context required to build actions.

askTableInfo :: forall b r m. (Backend b, MonadError QErr m, MonadReader r m, Has (SourceInfo b) r) => TableName b -> m (TableInfo b) Source #

Looks up table information for the given table name. This function should never fail, since the schema cache construction process is supposed to ensure all dependencies are resolved. TODO: deduplicate this with CacheRM.

askLogicalModelInfo :: forall b r m. (MonadError QErr m, MonadReader r m, Has (SourceInfo b) r) => LogicalModelName -> m (LogicalModelInfo b) Source #

Looks up logical model information for the given logical model name. This function should never fail, since the schema cache construction process is supposed to ensure all dependencies are resolved. TODO: deduplicate this with CacheRM.

askNativeQueryInfo :: forall b r m. (MonadError QErr m, MonadReader r m, Has (SourceInfo b) r) => NativeQueryName -> m (NativeQueryInfo b) Source #

Looks up native query information for the given native query name. This function should never fail, since the schema cache construction process is supposed to ensure all dependencies are resolved. TODO: deduplicate this with CacheRM.

data Scenario Source #

Whether the request is sent with `x-hasura-use-backend-only-permissions` set to true.

Constructors

Backend 
Frontend 

parsedSelectionsToFields Source #

Arguments

:: (Text -> a)

how to handle __typename fields

-> InsOrdHashMap Name (ParsedSelection a) 
-> Fields a 

takeValidNativeQueries :: forall b. NativeQueryCache b -> NativeQueryCache b Source #

@TODO: Currently we do no validation on native queries in schema. Should we?

takeValidStoredProcedures :: forall b. StoredProcedureCache b -> StoredProcedureCache b Source #

@TODO: Currently we do no validation on stored procedures in schema. Should we?

requiredFieldParser :: (Functor n, Functor m) => (a -> b) -> m (FieldParser n a) -> m (Maybe (FieldParser n b)) Source #

optionalFieldParser :: (Functor n, Functor m) => (a -> b) -> m (Maybe (FieldParser n a)) -> m (Maybe (FieldParser n b)) Source #

mkEnumTypeName :: forall b r m. (Backend b, MonadError QErr m, Has (SourceInfo b) r) => TableName b -> Maybe Name -> SchemaT r m Name Source #

Builds the type name for referenced enum tables.