graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellNone
LanguageHaskell2010

Hasura.RQL.DDL.RemoteRelationship.Validate

Description

Validate input queries against remote schemas.

Synopsis

Documentation

data ValidationError Source #

An error validating the remote relationship.

Constructors

RemoteSchemaNotFound RemoteSchemaName 
CouldntFindRemoteField Name Name 
FieldNotFoundInRemoteSchema Name 
NoSuchArgumentForRemote Name 
MissingRequiredArgument Name 
TypeNotFound Name 
JoinFieldNonExistent LHSIdentifier FieldName (HashSet FieldName) 
ExpectedTypeButGot GType GType 
InvalidType GType Text 
InvalidVariable Name (HashSet Name) 
NullNotAllowedHere 
InvalidGTypeForStripping GType 
UnsupportedMultipleElementLists 
UnsupportedEnum 
InvalidGraphQLName Text 
IDTypeJoin Name 
CannotGenerateGraphQLTypeName Name

TODO: Can this be made not reachable? This is the case where the type of the columns that are mapped do not have a graphql representation. This case is probably not reachable as having a db type which can't be representable in GraphQL should definitely fail the entire schema generation process

validateToSchemaRelationship :: MonadError ValidationError m => ToSchemaRelationshipDef -> LHSIdentifier -> RelName -> (RemoteSchemaInfo, IntrospectionResult) -> HashMap FieldName joinField -> m (HashMap FieldName joinField, RemoteSchemaFieldInfo) Source #

Validate a remote schema relationship given a context.

stripInMap :: RelName -> LHSIdentifier -> RemoteSchemaIntrospection -> HashMap Name RemoteSchemaInputValueDefinition -> HashMap Name (Value Name) -> StateT (HashMap Name (TypeDefinition [Name] RemoteSchemaInputValueDefinition)) (Either ValidationError) (HashMap Name RemoteSchemaInputValueDefinition) Source #

Return a map with keys deleted whose template argument is specified as an atomic (variable, constant), keys which are kept have their values modified by stripObject or stripList. This function creates the 'HashMap G.Name G.InputValueDefinition' which modifies the original input parameters (if any) of the remote node/table being used. Only list or object types are preserved and other types are stripped off. The object or list types are preserved because they can be merged, if any arguments are provided by the user while querying a remote join field.

stripValue :: RelName -> LHSIdentifier -> RemoteSchemaIntrospection -> GType -> Value Name -> StateT (HashMap Name (TypeDefinition [Name] RemoteSchemaInputValueDefinition)) (Either ValidationError) (Maybe GType) Source #

Strip a value type completely, or modify it, if the given value is atomic-ish.

stripList :: RelName -> LHSIdentifier -> RemoteSchemaIntrospection -> GType -> Value Name -> StateT (HashMap Name (TypeDefinition [Name] RemoteSchemaInputValueDefinition)) (Either ValidationError) (Maybe GType) Source #

Produce a new type for the list, or strip it entirely.

stripObject :: RelName -> LHSIdentifier -> RemoteSchemaIntrospection -> GType -> HashMap Name (Value Name) -> StateT (HashMap Name (TypeDefinition [Name] RemoteSchemaInputValueDefinition)) (Either ValidationError) GType Source #

Produce a new type for the given InpValInfo, modified by stripInMap. Objects can't be deleted entirely, just keys of an object.

renameTypeForRelationship :: MonadError ValidationError m => RelName -> LHSIdentifier -> Name -> m Name Source #

Produce a new name for a type, used when stripping the schema types for a remote relationship. TODO: Consider a separator character to avoid conflicts.

hasuraFieldToVariable :: MonadError ValidationError m => FieldName -> m Name Source #

Convert a field name to a variable name.

lookupField :: MonadError ValidationError m => Name -> ObjectTypeDefinition RemoteSchemaInputValueDefinition -> m (FieldDefinition RemoteSchemaInputValueDefinition) Source #

Lookup the field in the schema.

validateRemoteArguments :: MonadError ValidationError m => HashMap Name RemoteSchemaInputValueDefinition -> HashMap Name (Value Name) -> HashMap Name joinField -> RemoteSchemaIntrospection -> m () Source #

Validate remote input arguments against the remote schema.

unwrapGraphQLType :: GType -> GType Source #

validateType :: MonadError ValidationError m => HashMap Name joinField -> Value Name -> GType -> RemoteSchemaIntrospection -> m () Source #

Validate a value against a type.

isTypeCoercible :: MonadError ValidationError m => GType -> GType -> m () Source #