Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data SchemaContext = SchemaContext {}
- data SchemaKind
- isHasuraSchema :: SchemaKind -> Bool
- type MonadBuildSchemaBase m n = (MonadError QErr m, MonadMemoize m, MonadParse n)
- newtype RemoteRelationshipParserBuilder = RemoteRelationshipParserBuilder (forall lhsJoinField r n m. MonadBuildSchemaBase m n => RemoteFieldInfo lhsJoinField -> SchemaT r m (Maybe [FieldParser n (RemoteRelationshipField UnpreparedValue)]))
- ignoreRemoteRelationship :: RemoteRelationshipParserBuilder
- newtype NodeInterfaceParserBuilder = NodeInterfaceParserBuilder {
- runNodeBuilder :: forall m n. MonadBuildSchemaBase m n => SchemaContext -> SchemaOptions -> m (Parser 'Output n NodeMap)
- retrieve :: (MonadReader r m, Has a r) => (a -> b) -> m b
- newtype SchemaT r m a = SchemaT {
- runSchemaT :: ReaderT r m a
- type MonadBuildSourceSchema b r m n = (MonadBuildSchemaBase m n, Has SchemaContext r, Has SchemaOptions r, Has (SourceInfo b) r)
- runSourceSchema :: forall b m a. SchemaContext -> SchemaOptions -> SourceInfo b -> SchemaT (SchemaContext, SchemaOptions, SourceInfo b) m a -> m a
- type MonadBuildRemoteSchema r m n = (MonadBuildSchemaBase m n, Has SchemaContext r, Has CustomizeRemoteFieldName r, Has MkTypename r)
- runRemoteSchema :: SchemaContext -> SchemaT (SchemaContext, MkTypename, CustomizeRemoteFieldName) m a -> m a
- type MonadBuildActionSchema r m n = (MonadBuildSchemaBase m n, Has SchemaContext r, Has SchemaOptions r)
- runActionSchema :: SchemaContext -> SchemaOptions -> SchemaT (SchemaContext, SchemaOptions) m a -> m a
- type SelectExp b = AnnSimpleSelectG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b)
- type StreamSelectExp b = AnnSimpleStreamSelectG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b)
- type AggSelectExp b = AnnAggregateSelectG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b)
- type ConnectionSelectExp b = ConnectionSelect b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b)
- type SelectArgs b = SelectArgsG b (UnpreparedValue b)
- type SelectStreamArgs b = SelectStreamArgsG b (UnpreparedValue b)
- type TablePerms b = TablePermG b (UnpreparedValue b)
- type AnnotatedFields b = AnnFieldsG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b)
- type AnnotatedField b = AnnFieldG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b)
- type ConnectionFields b = ConnectionFields b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b)
- type EdgeFields b = EdgeFields b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b)
- type AnnotatedActionFields = ActionFieldsG (RemoteRelationshipField UnpreparedValue)
- type AnnotatedActionField = ActionFieldG (RemoteRelationshipField UnpreparedValue)
- type AnnotatedNestedObjectSelect b = AnnNestedObjectSelectG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b)
- type AnnotatedNestedArraySelect b = AnnNestedArraySelectG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b)
- data RemoteSchemaParser n = RemoteSchemaParser {
- piQuery :: [FieldParser n (NamespacedField (RemoteSchemaRootField (RemoteRelationshipField UnpreparedValue) RemoteSchemaVariable))]
- piMutation :: Maybe [FieldParser n (NamespacedField (RemoteSchemaRootField (RemoteRelationshipField UnpreparedValue) RemoteSchemaVariable))]
- piSubscription :: Maybe [FieldParser n (NamespacedField (RemoteSchemaRootField (RemoteRelationshipField UnpreparedValue) RemoteSchemaVariable))]
- getTableRoles :: BackendSourceInfo -> [RoleName]
- getLogicalModelRoles :: BackendSourceInfo -> [RoleName]
- askScalarTypeParsingContext :: forall b r m. (MonadReader r m, Has (SourceInfo b) r, Has (ScalarTypeParsingContext b) (SourceConfig b)) => m (ScalarTypeParsingContext b)
- askTableInfo :: forall b r m. (Backend b, MonadError QErr m, MonadReader r m, Has (SourceInfo b) r) => TableName b -> m (TableInfo b)
- askLogicalModelInfo :: forall b r m. (MonadError QErr m, MonadReader r m, Has (SourceInfo b) r) => LogicalModelName -> m (LogicalModelInfo b)
- askNativeQueryInfo :: forall b r m. (MonadError QErr m, MonadReader r m, Has (SourceInfo b) r) => NativeQueryName -> m (NativeQueryInfo b)
- data Scenario
- textToName :: MonadError QErr m => Text -> m Name
- textToGQLIdentifier :: MonadError QErr m => Text -> m GQLNameIdentifier
- partialSQLExpToUnpreparedValue :: PartialSQLExp b -> UnpreparedValue b
- getRedactionExprForColumn :: Backend b => SelPermInfo b -> Column b -> Maybe (AnnRedactionExpUnpreparedValue b)
- getRedactionExprForComputedField :: Backend b => SelPermInfo b -> ComputedFieldName -> Maybe (AnnRedactionExpUnpreparedValue b)
- mapField :: Functor m => InputFieldsParser m (Maybe a) -> (a -> b) -> InputFieldsParser m (Maybe b)
- parsedSelectionsToFields :: (Text -> a) -> InsOrdHashMap Name (ParsedSelection a) -> Fields a
- numericAggOperators :: [GQLNameIdentifier]
- comparisonAggOperators :: [GQLNameIdentifier]
- mkDescriptionWith :: Maybe PGDescription -> Text -> Description
- takeValidTables :: forall b. Backend b => TableCache b -> TableCache b
- takeValidFunctions :: forall b. FunctionCache b -> FunctionCache b
- takeValidNativeQueries :: forall b. NativeQueryCache b -> NativeQueryCache b
- takeValidStoredProcedures :: forall b. StoredProcedureCache b -> StoredProcedureCache b
- requiredFieldParser :: (Functor n, Functor m) => (a -> b) -> m (FieldParser n a) -> m (Maybe (FieldParser n b))
- optionalFieldParser :: (Functor n, Functor m) => (a -> b) -> m (Maybe (FieldParser n a)) -> m (Maybe (FieldParser n b))
- mkEnumTypeName :: forall b r m. (Backend b, MonadError QErr m, Has (SourceInfo b) r) => TableName b -> Maybe Name -> SchemaT r m Name
- addEnumSuffix :: ResolvedSourceCustomization -> GQLNameIdentifier -> Maybe Name -> Name
- peelWithOrigin :: MonadParse m => Parser 'Both m a -> Parser 'Both m (ValueWithOrigin a)
- getIntrospectionResult :: RemoteSchemaPermissions -> RoleName -> RemoteSchemaCtxG remoteFieldInfo -> Maybe IntrospectionResult
Documentation
data SchemaContext Source #
Aggregation of contextual information required to build the schema.
SchemaContext | |
|
data SchemaKind Source #
The kind of schema we're building, and its associated options.
isHasuraSchema :: SchemaKind -> Bool Source #
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.
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.
NodeInterfaceParserBuilder | |
|
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.
SchemaT | |
|
Instances
MonadError e m => MonadError e (SchemaT r m) Source # | |
Defined in Hasura.GraphQL.Schema.Common 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 # | |
MonadTrans (SchemaT r) Source # | |
Defined in Hasura.GraphQL.Schema.Common | |
Applicative m => Applicative (SchemaT r m) Source # | |
Defined in Hasura.GraphQL.Schema.Common | |
Functor m => Functor (SchemaT r m) Source # | |
Monad m => Monad (SchemaT r m) Source # | |
MonadMemoize m => MonadMemoize (SchemaT r m) Source # | |
type MonadBuildSourceSchema b r m n = (MonadBuildSchemaBase m n, Has SchemaContext r, Has SchemaOptions r, Has (SourceInfo b) r) 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.
type MonadBuildRemoteSchema r m n = (MonadBuildSchemaBase m n, Has SchemaContext r, Has CustomizeRemoteFieldName r, Has MkTypename r) 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.
type MonadBuildActionSchema r m n = (MonadBuildSchemaBase m n, Has SchemaContext r, Has SchemaOptions r) Source #
runActionSchema :: SchemaContext -> SchemaOptions -> SchemaT (SchemaContext, SchemaOptions) m a -> m a Source #
Runs a schema-building computation with all the context required to build actions.
type SelectExp b = AnnSimpleSelectG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) Source #
type StreamSelectExp b = AnnSimpleStreamSelectG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) Source #
type AggSelectExp b = AnnAggregateSelectG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) Source #
type ConnectionSelectExp b = ConnectionSelect b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) Source #
type SelectArgs b = SelectArgsG b (UnpreparedValue b) Source #
type SelectStreamArgs b = SelectStreamArgsG b (UnpreparedValue b) Source #
type TablePerms b = TablePermG b (UnpreparedValue b) Source #
type AnnotatedFields b = AnnFieldsG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) Source #
type AnnotatedField b = AnnFieldG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) Source #
type ConnectionFields b = ConnectionFields b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) Source #
type EdgeFields b = EdgeFields b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) Source #
type AnnotatedNestedObjectSelect b = AnnNestedObjectSelectG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) Source #
type AnnotatedNestedArraySelect b = AnnNestedArraySelectG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) Source #
data RemoteSchemaParser n Source #
getTableRoles :: BackendSourceInfo -> [RoleName] Source #
askScalarTypeParsingContext :: forall b r m. (MonadReader r m, Has (SourceInfo b) r, Has (ScalarTypeParsingContext b) (SourceConfig b)) => m (ScalarTypeParsingContext b) Source #
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
.
Whether the request is sent with `x-hasura-use-backend-only-permissions` set to true
.
Instances
Enum Scenario Source # | |
Defined in Hasura.GraphQL.Schema.Common | |
Show Scenario Source # | |
Eq Scenario Source # | |
textToName :: MonadError QErr m => Text -> m Name Source #
textToGQLIdentifier :: MonadError QErr m => Text -> m GQLNameIdentifier Source #
getRedactionExprForColumn :: Backend b => SelPermInfo b -> Column b -> Maybe (AnnRedactionExpUnpreparedValue b) Source #
getRedactionExprForComputedField :: Backend b => SelPermInfo b -> ComputedFieldName -> Maybe (AnnRedactionExpUnpreparedValue b) Source #
mapField :: Functor m => InputFieldsParser m (Maybe a) -> (a -> b) -> InputFieldsParser m (Maybe b) Source #
parsedSelectionsToFields Source #
:: (Text -> a) | how to handle |
-> InsOrdHashMap Name (ParsedSelection a) | |
-> Fields a |
mkDescriptionWith :: Maybe PGDescription -> Text -> Description Source #
takeValidTables :: forall b. Backend b => TableCache b -> TableCache b Source #
takeValidFunctions :: forall b. FunctionCache b -> FunctionCache b Source #
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.
peelWithOrigin :: MonadParse m => Parser 'Both m a -> Parser 'Both m (ValueWithOrigin a) Source #
getIntrospectionResult :: RemoteSchemaPermissions -> RoleName -> RemoteSchemaCtxG remoteFieldInfo -> Maybe IntrospectionResult Source #