mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-12 14:05:16 +03:00
Upgrade Ormolu to 0.7.0.0
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9284 GitOrigin-RevId: 2f2cf2ad01900a54e4bdb970205ac0ef313c7e00
This commit is contained in:
parent
e3df24507d
commit
e0c0043e76
@ -1382,9 +1382,9 @@ instance FromJSON HeaderFromValue where
|
||||
parseJSON (Object v) =
|
||||
HeaderFromValue
|
||||
<$> v
|
||||
.: "name"
|
||||
.: "name"
|
||||
<*> v
|
||||
.: "value"
|
||||
.: "value"
|
||||
|
||||
instance ToJSON HeaderFromEnv where
|
||||
toJSON (HeaderFromEnv nameHeaderFromEnv valueFromEnvHeaderFromEnv) =
|
||||
@ -1397,9 +1397,9 @@ instance FromJSON HeaderFromEnv where
|
||||
parseJSON (Object v) =
|
||||
HeaderFromEnv
|
||||
<$> v
|
||||
.: "name"
|
||||
.: "name"
|
||||
<*> v
|
||||
.: "value_from_env"
|
||||
.: "value_from_env"
|
||||
|
||||
instance ToJSON ObjectField where
|
||||
toJSON (ObjectField descriptionObjectField nameObjectField objectFieldTypeObjectField) =
|
||||
@ -1413,11 +1413,11 @@ instance FromJSON ObjectField where
|
||||
parseJSON (Object v) =
|
||||
ObjectField
|
||||
<$> v
|
||||
.:? "description"
|
||||
.:? "description"
|
||||
<*> v
|
||||
.: "name"
|
||||
.: "name"
|
||||
<*> v
|
||||
.: "type"
|
||||
.: "type"
|
||||
|
||||
instance ToJSON HasuraMetadataV2 where
|
||||
toJSON (HasuraMetadataV2 actionsHasuraMetadataV2 allowlistHasuraMetadataV2 cronTriggersHasuraMetadataV2 customTypesHasuraMetadataV2 functionsHasuraMetadataV2 queryCollectionsHasuraMetadataV2 remoteSchemasHasuraMetadataV2 tablesHasuraMetadataV2 versionHasuraMetadataV2) =
|
||||
@ -1437,23 +1437,23 @@ instance FromJSON HasuraMetadataV2 where
|
||||
parseJSON (Object v) =
|
||||
HasuraMetadataV2
|
||||
<$> v
|
||||
.:? "actions"
|
||||
.:? "actions"
|
||||
<*> v
|
||||
.:? "allowlist"
|
||||
.:? "allowlist"
|
||||
<*> v
|
||||
.:? "cron_triggers"
|
||||
.:? "cron_triggers"
|
||||
<*> v
|
||||
.:? "custom_types"
|
||||
.:? "custom_types"
|
||||
<*> v
|
||||
.:? "functions"
|
||||
.:? "functions"
|
||||
<*> v
|
||||
.:? "query_collections"
|
||||
.:? "query_collections"
|
||||
<*> v
|
||||
.:? "remote_schemas"
|
||||
.:? "remote_schemas"
|
||||
<*> v
|
||||
.: "tables"
|
||||
.: "tables"
|
||||
<*> v
|
||||
.: "version"
|
||||
.: "version"
|
||||
|
||||
instance ToJSON Action where
|
||||
toJSON (Action commentAction definitionAction nameAction permissionsAction) =
|
||||
@ -1468,13 +1468,13 @@ instance FromJSON Action where
|
||||
parseJSON (Object v) =
|
||||
Action
|
||||
<$> v
|
||||
.:? "comment"
|
||||
.:? "comment"
|
||||
<*> v
|
||||
.: "definition"
|
||||
.: "definition"
|
||||
<*> v
|
||||
.: "name"
|
||||
.: "name"
|
||||
<*> v
|
||||
.:? "permissions"
|
||||
.:? "permissions"
|
||||
|
||||
instance ToJSON ActionDefinition where
|
||||
toJSON (ActionDefinition argumentsActionDefinition forwardClientHeadersActionDefinition handlerActionDefinition headersActionDefinition kindActionDefinition outputTypeActionDefinition actionDefinitionTypeActionDefinition) =
|
||||
@ -1492,19 +1492,19 @@ instance FromJSON ActionDefinition where
|
||||
parseJSON (Object v) =
|
||||
ActionDefinition
|
||||
<$> v
|
||||
.:? "arguments"
|
||||
.:? "arguments"
|
||||
<*> v
|
||||
.:? "forward_client_headers"
|
||||
.:? "forward_client_headers"
|
||||
<*> v
|
||||
.: "handler"
|
||||
.: "handler"
|
||||
<*> v
|
||||
.:? "headers"
|
||||
.:? "headers"
|
||||
<*> v
|
||||
.:? "kind"
|
||||
.:? "kind"
|
||||
<*> v
|
||||
.:? "output_type"
|
||||
.:? "output_type"
|
||||
<*> v
|
||||
.:? "type"
|
||||
.:? "type"
|
||||
|
||||
instance ToJSON ActionDefinitionType where
|
||||
toJSON MutationActionDefinitionType = "mutation"
|
||||
@ -1527,9 +1527,9 @@ instance FromJSON InputArgument where
|
||||
parseJSON (Object v) =
|
||||
InputArgument
|
||||
<$> v
|
||||
.: "name"
|
||||
.: "name"
|
||||
<*> v
|
||||
.: "type"
|
||||
.: "type"
|
||||
|
||||
instance ToJSON Header where
|
||||
toJSON (Header nameHeader valueHeader valueFromEnvHeader) =
|
||||
@ -1543,11 +1543,11 @@ instance FromJSON Header where
|
||||
parseJSON (Object v) =
|
||||
Header
|
||||
<$> v
|
||||
.: "name"
|
||||
.: "name"
|
||||
<*> v
|
||||
.:? "value"
|
||||
.:? "value"
|
||||
<*> v
|
||||
.:? "value_from_env"
|
||||
.:? "value_from_env"
|
||||
|
||||
instance ToJSON Permission where
|
||||
toJSON (Permission rolePermission) =
|
||||
@ -1559,7 +1559,7 @@ instance FromJSON Permission where
|
||||
parseJSON (Object v) =
|
||||
Permission
|
||||
<$> v
|
||||
.: "role"
|
||||
.: "role"
|
||||
|
||||
instance ToJSON AllowList where
|
||||
toJSON (AllowList collectionAllowList) =
|
||||
@ -1571,7 +1571,7 @@ instance FromJSON AllowList where
|
||||
parseJSON (Object v) =
|
||||
AllowList
|
||||
<$> v
|
||||
.: "collection"
|
||||
.: "collection"
|
||||
|
||||
instance ToJSON CronTrigger where
|
||||
toJSON (CronTrigger commentCronTrigger headersCronTrigger includeInMetadataCronTrigger nameCronTrigger payloadCronTrigger retryConfCronTrigger scheduleCronTrigger webhookCronTrigger) =
|
||||
@ -1590,21 +1590,21 @@ instance FromJSON CronTrigger where
|
||||
parseJSON (Object v) =
|
||||
CronTrigger
|
||||
<$> v
|
||||
.:? "comment"
|
||||
.:? "comment"
|
||||
<*> v
|
||||
.: "headers"
|
||||
.: "headers"
|
||||
<*> v
|
||||
.: "include_in_metadata"
|
||||
.: "include_in_metadata"
|
||||
<*> v
|
||||
.: "name"
|
||||
.: "name"
|
||||
<*> v
|
||||
.:? "payload"
|
||||
.:? "payload"
|
||||
<*> v
|
||||
.:? "retry_conf"
|
||||
.:? "retry_conf"
|
||||
<*> v
|
||||
.: "schedule"
|
||||
.: "schedule"
|
||||
<*> v
|
||||
.: "webhook"
|
||||
.: "webhook"
|
||||
|
||||
instance ToJSON RetryConfST where
|
||||
toJSON (RetryConfST numRetriesRetryConfST retryIntervalSecondsRetryConfST timeoutSecondsRetryConfST toleranceSecondsRetryConfST) =
|
||||
@ -1652,11 +1652,11 @@ instance FromJSON EnumType where
|
||||
parseJSON (Object v) =
|
||||
EnumType
|
||||
<$> v
|
||||
.:? "description"
|
||||
.:? "description"
|
||||
<*> v
|
||||
.: "name"
|
||||
.: "name"
|
||||
<*> v
|
||||
.: "values"
|
||||
.: "values"
|
||||
|
||||
instance ToJSON EnumValue where
|
||||
toJSON (EnumValue descriptionEnumValue isDeprecatedEnumValue valueEnumValue) =
|
||||
@ -1670,11 +1670,11 @@ instance FromJSON EnumValue where
|
||||
parseJSON (Object v) =
|
||||
EnumValue
|
||||
<$> v
|
||||
.:? "description"
|
||||
.:? "description"
|
||||
<*> v
|
||||
.:? "is_deprecated"
|
||||
.:? "is_deprecated"
|
||||
<*> v
|
||||
.: "value"
|
||||
.: "value"
|
||||
|
||||
instance ToJSON InputObjectType where
|
||||
toJSON (InputObjectType descriptionInputObjectType fieldsInputObjectType nameInputObjectType) =
|
||||
@ -1688,11 +1688,11 @@ instance FromJSON InputObjectType where
|
||||
parseJSON (Object v) =
|
||||
InputObjectType
|
||||
<$> v
|
||||
.:? "description"
|
||||
.:? "description"
|
||||
<*> v
|
||||
.: "fields"
|
||||
.: "fields"
|
||||
<*> v
|
||||
.: "name"
|
||||
.: "name"
|
||||
|
||||
instance ToJSON InputObjectField where
|
||||
toJSON (InputObjectField descriptionInputObjectField nameInputObjectField inputObjectFieldTypeInputObjectField) =
|
||||
@ -1706,11 +1706,11 @@ instance FromJSON InputObjectField where
|
||||
parseJSON (Object v) =
|
||||
InputObjectField
|
||||
<$> v
|
||||
.:? "description"
|
||||
.:? "description"
|
||||
<*> v
|
||||
.: "name"
|
||||
.: "name"
|
||||
<*> v
|
||||
.: "type"
|
||||
.: "type"
|
||||
|
||||
instance ToJSON ObjectType where
|
||||
toJSON (ObjectType descriptionObjectType fieldsObjectType nameObjectType relationshipsObjectType) =
|
||||
@ -1725,13 +1725,13 @@ instance FromJSON ObjectType where
|
||||
parseJSON (Object v) =
|
||||
ObjectType
|
||||
<$> v
|
||||
.:? "description"
|
||||
.:? "description"
|
||||
<*> v
|
||||
.: "fields"
|
||||
.: "fields"
|
||||
<*> v
|
||||
.: "name"
|
||||
.: "name"
|
||||
<*> v
|
||||
.:? "relationships"
|
||||
.:? "relationships"
|
||||
|
||||
instance ToJSON CustomTypeObjectRelationship where
|
||||
toJSON (CustomTypeObjectRelationship fieldMappingCustomTypeObjectRelationship nameCustomTypeObjectRelationship remoteTableCustomTypeObjectRelationship customTypeObjectRelationshipTypeCustomTypeObjectRelationship) =
|
||||
@ -1746,13 +1746,13 @@ instance FromJSON CustomTypeObjectRelationship where
|
||||
parseJSON (Object v) =
|
||||
CustomTypeObjectRelationship
|
||||
<$> v
|
||||
.: "field_mapping"
|
||||
.: "field_mapping"
|
||||
<*> v
|
||||
.: "name"
|
||||
.: "name"
|
||||
<*> v
|
||||
.: "remote_table"
|
||||
.: "remote_table"
|
||||
<*> v
|
||||
.: "type"
|
||||
.: "type"
|
||||
|
||||
instance ToJSON CustomTypeObjectRelationshipType where
|
||||
toJSON TypeArrayCustomTypeObjectRelationshipType = "array"
|
||||
@ -1783,9 +1783,9 @@ instance FromJSON QualifiedTable where
|
||||
parseJSON (Object v) =
|
||||
QualifiedTable
|
||||
<$> v
|
||||
.: "name"
|
||||
.: "name"
|
||||
<*> v
|
||||
.: "schema"
|
||||
.: "schema"
|
||||
|
||||
instance ToJSON ScalarType where
|
||||
toJSON (ScalarType descriptionScalarType nameScalarType) =
|
||||
@ -1798,9 +1798,9 @@ instance FromJSON ScalarType where
|
||||
parseJSON (Object v) =
|
||||
ScalarType
|
||||
<$> v
|
||||
.:? "description"
|
||||
.:? "description"
|
||||
<*> v
|
||||
.: "name"
|
||||
.: "name"
|
||||
|
||||
instance ToJSON CustomFunction where
|
||||
toJSON (CustomFunction configurationCustomFunction functionCustomFunction) =
|
||||
@ -1813,9 +1813,9 @@ instance FromJSON CustomFunction where
|
||||
parseJSON (Object v) =
|
||||
CustomFunction
|
||||
<$> v
|
||||
.:? "configuration"
|
||||
.:? "configuration"
|
||||
<*> v
|
||||
.: "function"
|
||||
.: "function"
|
||||
|
||||
instance ToJSON FunctionConfiguration where
|
||||
toJSON (FunctionConfiguration sessionArgumentFunctionConfiguration) =
|
||||
@ -1847,9 +1847,9 @@ instance FromJSON QualifiedFunction where
|
||||
parseJSON (Object v) =
|
||||
QualifiedFunction
|
||||
<$> v
|
||||
.: "name"
|
||||
.: "name"
|
||||
<*> v
|
||||
.: "schema"
|
||||
.: "schema"
|
||||
|
||||
instance ToJSON QueryCollectionEntry where
|
||||
toJSON (QueryCollectionEntry commentQueryCollectionEntry definitionQueryCollectionEntry nameQueryCollectionEntry) =
|
||||
@ -1863,11 +1863,11 @@ instance FromJSON QueryCollectionEntry where
|
||||
parseJSON (Object v) =
|
||||
QueryCollectionEntry
|
||||
<$> v
|
||||
.:? "comment"
|
||||
.:? "comment"
|
||||
<*> v
|
||||
.: "definition"
|
||||
.: "definition"
|
||||
<*> v
|
||||
.: "name"
|
||||
.: "name"
|
||||
|
||||
instance ToJSON Definition where
|
||||
toJSON (Definition queriesDefinition) =
|
||||
@ -1879,7 +1879,7 @@ instance FromJSON Definition where
|
||||
parseJSON (Object v) =
|
||||
Definition
|
||||
<$> v
|
||||
.: "queries"
|
||||
.: "queries"
|
||||
|
||||
instance ToJSON QueryCollection where
|
||||
toJSON (QueryCollection nameQueryCollection queryQueryCollection) =
|
||||
@ -1892,9 +1892,9 @@ instance FromJSON QueryCollection where
|
||||
parseJSON (Object v) =
|
||||
QueryCollection
|
||||
<$> v
|
||||
.: "name"
|
||||
.: "name"
|
||||
<*> v
|
||||
.: "query"
|
||||
.: "query"
|
||||
|
||||
instance ToJSON RemoteSchema where
|
||||
toJSON (RemoteSchema commentRemoteSchema definitionRemoteSchema nameRemoteSchema) =
|
||||
@ -1908,11 +1908,11 @@ instance FromJSON RemoteSchema where
|
||||
parseJSON (Object v) =
|
||||
RemoteSchema
|
||||
<$> v
|
||||
.:? "comment"
|
||||
.:? "comment"
|
||||
<*> v
|
||||
.: "definition"
|
||||
.: "definition"
|
||||
<*> v
|
||||
.: "name"
|
||||
.: "name"
|
||||
|
||||
instance ToJSON RemoteSchemaDef where
|
||||
toJSON (RemoteSchemaDef forwardClientHeadersRemoteSchemaDef headersRemoteSchemaDef timeoutSecondsRemoteSchemaDef urlRemoteSchemaDef urlFromEnvRemoteSchemaDef) =
|
||||
@ -1954,29 +1954,29 @@ instance FromJSON TableEntry where
|
||||
parseJSON (Object v) =
|
||||
TableEntry
|
||||
<$> v
|
||||
.:? "array_relationships"
|
||||
.:? "array_relationships"
|
||||
<*> v
|
||||
.:? "computed_fields"
|
||||
.:? "computed_fields"
|
||||
<*> v
|
||||
.:? "configuration"
|
||||
.:? "configuration"
|
||||
<*> v
|
||||
.:? "delete_permissions"
|
||||
.:? "delete_permissions"
|
||||
<*> v
|
||||
.:? "event_triggers"
|
||||
.:? "event_triggers"
|
||||
<*> v
|
||||
.:? "insert_permissions"
|
||||
.:? "insert_permissions"
|
||||
<*> v
|
||||
.:? "is_enum"
|
||||
.:? "is_enum"
|
||||
<*> v
|
||||
.:? "object_relationships"
|
||||
.:? "object_relationships"
|
||||
<*> v
|
||||
.:? "remote_relationships"
|
||||
.:? "remote_relationships"
|
||||
<*> v
|
||||
.:? "select_permissions"
|
||||
.:? "select_permissions"
|
||||
<*> v
|
||||
.: "table"
|
||||
.: "table"
|
||||
<*> v
|
||||
.:? "update_permissions"
|
||||
.:? "update_permissions"
|
||||
|
||||
instance ToJSON ArrayRelationship where
|
||||
toJSON (ArrayRelationship commentArrayRelationship nameArrayRelationship usingArrayRelationship) =
|
||||
@ -1990,11 +1990,11 @@ instance FromJSON ArrayRelationship where
|
||||
parseJSON (Object v) =
|
||||
ArrayRelationship
|
||||
<$> v
|
||||
.:? "comment"
|
||||
.:? "comment"
|
||||
<*> v
|
||||
.: "name"
|
||||
.: "name"
|
||||
<*> v
|
||||
.: "using"
|
||||
.: "using"
|
||||
|
||||
instance ToJSON ArrRelUsing where
|
||||
toJSON (ArrRelUsing foreignKeyConstraintOnArrRelUsing manualConfigurationArrRelUsing) =
|
||||
@ -2020,9 +2020,9 @@ instance FromJSON ArrRelUsingFKeyOn where
|
||||
parseJSON (Object v) =
|
||||
ArrRelUsingFKeyOn
|
||||
<$> v
|
||||
.: "column"
|
||||
.: "column"
|
||||
<*> v
|
||||
.: "table"
|
||||
.: "table"
|
||||
|
||||
instance ToJSON ArrRelUsingManualMapping where
|
||||
toJSON (ArrRelUsingManualMapping columnMappingArrRelUsingManualMapping remoteTableArrRelUsingManualMapping) =
|
||||
@ -2035,9 +2035,9 @@ instance FromJSON ArrRelUsingManualMapping where
|
||||
parseJSON (Object v) =
|
||||
ArrRelUsingManualMapping
|
||||
<$> v
|
||||
.: "column_mapping"
|
||||
.: "column_mapping"
|
||||
<*> v
|
||||
.: "remote_table"
|
||||
.: "remote_table"
|
||||
|
||||
instance ToJSON ComputedField where
|
||||
toJSON (ComputedField commentComputedField definitionComputedField nameComputedField) =
|
||||
@ -2051,11 +2051,11 @@ instance FromJSON ComputedField where
|
||||
parseJSON (Object v) =
|
||||
ComputedField
|
||||
<$> v
|
||||
.:? "comment"
|
||||
.:? "comment"
|
||||
<*> v
|
||||
.: "definition"
|
||||
.: "definition"
|
||||
<*> v
|
||||
.: "name"
|
||||
.: "name"
|
||||
|
||||
instance ToJSON ComputedFieldDefinition where
|
||||
toJSON (ComputedFieldDefinition functionComputedFieldDefinition sessionArgumentComputedFieldDefinition tableArgumentComputedFieldDefinition) =
|
||||
@ -2069,11 +2069,11 @@ instance FromJSON ComputedFieldDefinition where
|
||||
parseJSON (Object v) =
|
||||
ComputedFieldDefinition
|
||||
<$> v
|
||||
.: "function"
|
||||
.: "function"
|
||||
<*> v
|
||||
.:? "session_argument"
|
||||
.:? "session_argument"
|
||||
<*> v
|
||||
.:? "table_argument"
|
||||
.:? "table_argument"
|
||||
|
||||
instance ToJSON TableConfig where
|
||||
toJSON (TableConfig customColumnNamesTableConfig customNameTableConfig customRootFieldsTableConfig) =
|
||||
@ -2129,11 +2129,11 @@ instance FromJSON DeletePermissionEntry where
|
||||
parseJSON (Object v) =
|
||||
DeletePermissionEntry
|
||||
<$> v
|
||||
.:? "comment"
|
||||
.:? "comment"
|
||||
<*> v
|
||||
.: "permission"
|
||||
.: "permission"
|
||||
<*> v
|
||||
.: "role"
|
||||
.: "role"
|
||||
|
||||
instance ToJSON DeletePermission where
|
||||
toJSON (DeletePermission filterDeletePermission) =
|
||||
@ -2171,17 +2171,17 @@ instance FromJSON EventTrigger where
|
||||
parseJSON (Object v) =
|
||||
EventTrigger
|
||||
<$> v
|
||||
.: "definition"
|
||||
.: "definition"
|
||||
<*> v
|
||||
.:? "headers"
|
||||
.:? "headers"
|
||||
<*> v
|
||||
.: "name"
|
||||
.: "name"
|
||||
<*> v
|
||||
.: "retry_conf"
|
||||
.: "retry_conf"
|
||||
<*> v
|
||||
.:? "webhook"
|
||||
.:? "webhook"
|
||||
<*> v
|
||||
.:? "webhook_from_env"
|
||||
.:? "webhook_from_env"
|
||||
|
||||
instance ToJSON EventTriggerDefinition where
|
||||
toJSON (EventTriggerDefinition deleteEventTriggerDefinition enableManualEventTriggerDefinition insertEventTriggerDefinition updateEventTriggerDefinition) =
|
||||
@ -2196,13 +2196,13 @@ instance FromJSON EventTriggerDefinition where
|
||||
parseJSON (Object v) =
|
||||
EventTriggerDefinition
|
||||
<$> v
|
||||
.:? "delete"
|
||||
.:? "delete"
|
||||
<*> v
|
||||
.: "enable_manual"
|
||||
.: "enable_manual"
|
||||
<*> v
|
||||
.:? "insert"
|
||||
.:? "insert"
|
||||
<*> v
|
||||
.:? "update"
|
||||
.:? "update"
|
||||
|
||||
instance ToJSON OperationSpec where
|
||||
toJSON (OperationSpec columnsOperationSpec payloadOperationSpec) =
|
||||
@ -2215,9 +2215,9 @@ instance FromJSON OperationSpec where
|
||||
parseJSON (Object v) =
|
||||
OperationSpec
|
||||
<$> v
|
||||
.: "columns"
|
||||
.: "columns"
|
||||
<*> v
|
||||
.:? "payload"
|
||||
.:? "payload"
|
||||
|
||||
instance ToJSON EventTriggerColumns where
|
||||
toJSON (EnumInEventTriggerColumns x) = toJSON x
|
||||
@ -2262,11 +2262,11 @@ instance FromJSON InsertPermissionEntry where
|
||||
parseJSON (Object v) =
|
||||
InsertPermissionEntry
|
||||
<$> v
|
||||
.:? "comment"
|
||||
.:? "comment"
|
||||
<*> v
|
||||
.: "permission"
|
||||
.: "permission"
|
||||
<*> v
|
||||
.: "role"
|
||||
.: "role"
|
||||
|
||||
instance ToJSON InsertPermission where
|
||||
toJSON (InsertPermission backendOnlyInsertPermission checkInsertPermission columnsInsertPermission setInsertPermission) =
|
||||
@ -2281,13 +2281,13 @@ instance FromJSON InsertPermission where
|
||||
parseJSON (Object v) =
|
||||
InsertPermission
|
||||
<$> v
|
||||
.:? "backend_only"
|
||||
.:? "backend_only"
|
||||
<*> v
|
||||
.:? "check"
|
||||
.:? "check"
|
||||
<*> v
|
||||
.: "columns"
|
||||
.: "columns"
|
||||
<*> v
|
||||
.:? "set"
|
||||
.:? "set"
|
||||
|
||||
instance ToJSON ObjectRelationship where
|
||||
toJSON (ObjectRelationship commentObjectRelationship nameObjectRelationship usingObjectRelationship) =
|
||||
@ -2301,11 +2301,11 @@ instance FromJSON ObjectRelationship where
|
||||
parseJSON (Object v) =
|
||||
ObjectRelationship
|
||||
<$> v
|
||||
.:? "comment"
|
||||
.:? "comment"
|
||||
<*> v
|
||||
.: "name"
|
||||
.: "name"
|
||||
<*> v
|
||||
.: "using"
|
||||
.: "using"
|
||||
|
||||
instance ToJSON ObjRelUsing where
|
||||
toJSON (ObjRelUsing foreignKeyConstraintOnObjRelUsing manualConfigurationObjRelUsing) =
|
||||
@ -2331,9 +2331,9 @@ instance FromJSON ObjRelUsingManualMapping where
|
||||
parseJSON (Object v) =
|
||||
ObjRelUsingManualMapping
|
||||
<$> v
|
||||
.: "column_mapping"
|
||||
.: "column_mapping"
|
||||
<*> v
|
||||
.: "remote_table"
|
||||
.: "remote_table"
|
||||
|
||||
instance ToJSON RemoteRelationship where
|
||||
toJSON (RemoteRelationship definitionRemoteRelationship nameRemoteRelationship) =
|
||||
@ -2346,9 +2346,9 @@ instance FromJSON RemoteRelationship where
|
||||
parseJSON (Object v) =
|
||||
RemoteRelationship
|
||||
<$> v
|
||||
.: "definition"
|
||||
.: "definition"
|
||||
<*> v
|
||||
.: "name"
|
||||
.: "name"
|
||||
|
||||
instance ToJSON RemoteRelationshipDef where
|
||||
toJSON (RemoteRelationshipDef hasuraFieldsRemoteRelationshipDef remoteFieldRemoteRelationshipDef remoteSchemaRemoteRelationshipDef) =
|
||||
@ -2362,11 +2362,11 @@ instance FromJSON RemoteRelationshipDef where
|
||||
parseJSON (Object v) =
|
||||
RemoteRelationshipDef
|
||||
<$> v
|
||||
.: "hasura_fields"
|
||||
.: "hasura_fields"
|
||||
<*> v
|
||||
.: "remote_field"
|
||||
.: "remote_field"
|
||||
<*> v
|
||||
.: "remote_schema"
|
||||
.: "remote_schema"
|
||||
|
||||
instance ToJSON RemoteFieldValue where
|
||||
toJSON (RemoteFieldValue argumentsRemoteFieldValue fieldRemoteFieldValue) =
|
||||
@ -2379,9 +2379,9 @@ instance FromJSON RemoteFieldValue where
|
||||
parseJSON (Object v) =
|
||||
RemoteFieldValue
|
||||
<$> v
|
||||
.: "arguments"
|
||||
.: "arguments"
|
||||
<*> v
|
||||
.:? "field"
|
||||
.:? "field"
|
||||
|
||||
instance ToJSON SelectPermissionEntry where
|
||||
toJSON (SelectPermissionEntry commentSelectPermissionEntry permissionSelectPermissionEntry roleSelectPermissionEntry) =
|
||||
@ -2395,11 +2395,11 @@ instance FromJSON SelectPermissionEntry where
|
||||
parseJSON (Object v) =
|
||||
SelectPermissionEntry
|
||||
<$> v
|
||||
.:? "comment"
|
||||
.:? "comment"
|
||||
<*> v
|
||||
.: "permission"
|
||||
.: "permission"
|
||||
<*> v
|
||||
.: "role"
|
||||
.: "role"
|
||||
|
||||
instance ToJSON SelectPermission where
|
||||
toJSON (SelectPermission allowAggregationsSelectPermission columnsSelectPermission computedFieldsSelectPermission filterSelectPermission limitSelectPermission) =
|
||||
@ -2415,15 +2415,15 @@ instance FromJSON SelectPermission where
|
||||
parseJSON (Object v) =
|
||||
SelectPermission
|
||||
<$> v
|
||||
.:? "allow_aggregations"
|
||||
.:? "allow_aggregations"
|
||||
<*> v
|
||||
.: "columns"
|
||||
.: "columns"
|
||||
<*> v
|
||||
.:? "computed_fields"
|
||||
.:? "computed_fields"
|
||||
<*> v
|
||||
.:? "filter"
|
||||
.:? "filter"
|
||||
<*> v
|
||||
.:? "limit"
|
||||
.:? "limit"
|
||||
|
||||
instance ToJSON UpdatePermissionEntry where
|
||||
toJSON (UpdatePermissionEntry commentUpdatePermissionEntry permissionUpdatePermissionEntry roleUpdatePermissionEntry) =
|
||||
@ -2437,11 +2437,11 @@ instance FromJSON UpdatePermissionEntry where
|
||||
parseJSON (Object v) =
|
||||
UpdatePermissionEntry
|
||||
<$> v
|
||||
.:? "comment"
|
||||
.:? "comment"
|
||||
<*> v
|
||||
.: "permission"
|
||||
.: "permission"
|
||||
<*> v
|
||||
.: "role"
|
||||
.: "role"
|
||||
|
||||
instance ToJSON UpdatePermission where
|
||||
toJSON (UpdatePermission checkUpdatePermission columnsUpdatePermission filterUpdatePermission setUpdatePermission) =
|
||||
@ -2456,10 +2456,10 @@ instance FromJSON UpdatePermission where
|
||||
parseJSON (Object v) =
|
||||
UpdatePermission
|
||||
<$> v
|
||||
.:? "check"
|
||||
.:? "check"
|
||||
<*> v
|
||||
.: "columns"
|
||||
.: "columns"
|
||||
<*> v
|
||||
.:? "filter"
|
||||
.:? "filter"
|
||||
<*> v
|
||||
.:? "set"
|
||||
.:? "set"
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2,5 +2,5 @@
|
||||
"cabal-install": "3.10.1.0",
|
||||
"ghc": "9.2.5",
|
||||
"hlint": "3.4.1",
|
||||
"ormolu": "0.5.0.1"
|
||||
"ormolu": "0.7.0.0"
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ fromOrderedObject obj =
|
||||
map (bimap K.fromText fromOrdered) $
|
||||
Data.Aeson.Ordered.toList obj
|
||||
|
||||
asObject :: IsString s => Value -> Either s Object
|
||||
asObject :: (IsString s) => Value -> Either s Object
|
||||
asObject = \case
|
||||
Object o -> Right o
|
||||
_ -> Left "expecting ordered object"
|
||||
|
@ -51,31 +51,31 @@ data Options w = Options
|
||||
{ connectionString ::
|
||||
w
|
||||
::: String
|
||||
<?> "Postgres connection string"
|
||||
<?> "Postgres connection string"
|
||||
<!> "postgresql://hasura:hasura@127.0.0.1:65002/hasura",
|
||||
output ::
|
||||
w
|
||||
::: FilePath
|
||||
<?> "Feature matrix output file path"
|
||||
<?> "Feature matrix output file path"
|
||||
<!> "/tmp/feature_matrix_tool_output.html",
|
||||
overrideOutputFile ::
|
||||
w
|
||||
::: Bool
|
||||
<?> "Override output file if exists",
|
||||
<?> "Override output file if exists",
|
||||
createDirectory ::
|
||||
w
|
||||
::: Bool
|
||||
<?> "Create directory if not exists",
|
||||
<?> "Create directory if not exists",
|
||||
-- this is just a flag, we take care of splitting the arguments ourselves.
|
||||
noAsk ::
|
||||
w
|
||||
::: Bool
|
||||
<?> "Do not ask to override output file or create a directory if missing",
|
||||
<?> "Do not ask to override output file or create a directory if missing",
|
||||
-- this is just a flag, we take care of splitting the arguments ourselves.
|
||||
hspec ::
|
||||
w
|
||||
::: Bool
|
||||
<?> "arguments for hspec"
|
||||
<?> "arguments for hspec"
|
||||
}
|
||||
deriving (Generic)
|
||||
|
||||
|
@ -113,11 +113,12 @@ setupTestingMode = do
|
||||
environment <- getEnvironment
|
||||
lookupTestingMode environment `onLeft` error
|
||||
|
||||
hook :: HasCallStack => SpecWith GlobalTestEnvironment -> Spec
|
||||
hook :: (HasCallStack) => SpecWith GlobalTestEnvironment -> Spec
|
||||
hook specs = do
|
||||
(testingMode, (logger, _cleanupLogger)) <-
|
||||
runIO $
|
||||
readIORef globalConfigRef `onNothingM` do
|
||||
runIO
|
||||
$ readIORef globalConfigRef
|
||||
`onNothingM` do
|
||||
testingMode <- setupTestingMode
|
||||
(logger, cleanupLogger) <- setupLogger
|
||||
setupGlobalConfig testingMode (logger, cleanupLogger)
|
||||
@ -134,8 +135,8 @@ hook specs = do
|
||||
TestNoBackends -> True -- this is for catching "everything else"
|
||||
TestNewPostgresVariant {} -> "Postgres" `elem` labels
|
||||
|
||||
aroundAllWith (const . bracket (setupTestEnvironment testingMode logger) teardownTestEnvironment) $
|
||||
mapSpecForest (filterForestWithLabels shouldRunTest) (contextualizeLogger specs)
|
||||
aroundAllWith (const . bracket (setupTestEnvironment testingMode logger) teardownTestEnvironment)
|
||||
$ mapSpecForest (filterForestWithLabels shouldRunTest) (contextualizeLogger specs)
|
||||
|
||||
{-# NOINLINE globalConfigRef #-}
|
||||
globalConfigRef :: IORef (Maybe (TestingMode, (Logger, IO ())))
|
||||
|
@ -90,8 +90,8 @@ postgresRunSqlQuery testEnvironment bulkType = do
|
||||
let backendTypeMetadata = fromMaybe (error "Expected a backend type but got nothing") $ getBackendTypeConfig testEnvironment
|
||||
sourceName = BackendType.backendSourceName backendTypeMetadata
|
||||
backendPrefix = BackendType.backendTypeString backendTypeMetadata
|
||||
postV2Query 200 testEnvironment $
|
||||
[interpolateYaml|
|
||||
postV2Query 200 testEnvironment
|
||||
$ [interpolateYaml|
|
||||
type: #{bulkType}
|
||||
args:
|
||||
- type: #{backendPrefix}_run_sql
|
||||
@ -153,8 +153,8 @@ mssqlRunSqlQuery testEnvironment bulkType = do
|
||||
let backendTypeMetadata = fromMaybe (error "Expected a backend type but got nothing") $ getBackendTypeConfig testEnvironment
|
||||
sourceName = BackendType.backendSourceName backendTypeMetadata
|
||||
backendPrefix = BackendType.backendTypeString backendTypeMetadata
|
||||
postV2Query 200 testEnvironment $
|
||||
[interpolateYaml|
|
||||
postV2Query 200 testEnvironment
|
||||
$ [interpolateYaml|
|
||||
type: #{bulkType}
|
||||
args:
|
||||
- type: #{backendPrefix}_run_sql
|
||||
|
@ -68,52 +68,52 @@ setupFunctions :: TestEnvironment -> [Fixture.SetupAction]
|
||||
setupFunctions testEnv =
|
||||
let schemaName = Schema.getSchemaName testEnv
|
||||
articleTableSQL = unSchemaName schemaName <> ".article"
|
||||
in [ SetupAction.noTeardown $
|
||||
BigQuery.run_ $
|
||||
T.unpack $
|
||||
T.unwords $
|
||||
[ "CREATE TABLE FUNCTION ",
|
||||
fetch_articles_returns_table schemaName,
|
||||
"(a_id INT64, search STRING)",
|
||||
"RETURNS TABLE<id INT64, title STRING, content STRING>",
|
||||
"AS (",
|
||||
"SELECT t.id, t.title, t.content FROM",
|
||||
articleTableSQL,
|
||||
"AS t WHERE t.author_id = a_id and (t.title LIKE `search` OR t.content LIKE `search`)",
|
||||
");"
|
||||
],
|
||||
SetupAction.noTeardown $
|
||||
BigQuery.run_ $
|
||||
T.unpack $
|
||||
T.unwords $
|
||||
[ "CREATE TABLE FUNCTION ",
|
||||
fetch_articles schemaName,
|
||||
"(a_id INT64, search STRING)",
|
||||
"AS (",
|
||||
"SELECT t.* FROM",
|
||||
articleTableSQL,
|
||||
"AS t WHERE t.author_id = a_id and (t.title LIKE `search` OR t.content LIKE `search`)",
|
||||
");"
|
||||
],
|
||||
SetupAction.noTeardown $
|
||||
BigQuery.run_ $
|
||||
T.unpack $
|
||||
T.unwords $
|
||||
[ "CREATE TABLE FUNCTION ",
|
||||
function_no_args schemaName <> "()",
|
||||
"AS (",
|
||||
"SELECT t.* FROM",
|
||||
articleTableSQL,
|
||||
"AS t);"
|
||||
],
|
||||
SetupAction.noTeardown $
|
||||
BigQuery.run_ $
|
||||
T.unpack $
|
||||
T.unwords $
|
||||
[ "CREATE FUNCTION ",
|
||||
add_int schemaName <> "(a INT64, b INT64)",
|
||||
"RETURNS INT64 AS (a + b);"
|
||||
]
|
||||
in [ SetupAction.noTeardown
|
||||
$ BigQuery.run_
|
||||
$ T.unpack
|
||||
$ T.unwords
|
||||
$ [ "CREATE TABLE FUNCTION ",
|
||||
fetch_articles_returns_table schemaName,
|
||||
"(a_id INT64, search STRING)",
|
||||
"RETURNS TABLE<id INT64, title STRING, content STRING>",
|
||||
"AS (",
|
||||
"SELECT t.id, t.title, t.content FROM",
|
||||
articleTableSQL,
|
||||
"AS t WHERE t.author_id = a_id and (t.title LIKE `search` OR t.content LIKE `search`)",
|
||||
");"
|
||||
],
|
||||
SetupAction.noTeardown
|
||||
$ BigQuery.run_
|
||||
$ T.unpack
|
||||
$ T.unwords
|
||||
$ [ "CREATE TABLE FUNCTION ",
|
||||
fetch_articles schemaName,
|
||||
"(a_id INT64, search STRING)",
|
||||
"AS (",
|
||||
"SELECT t.* FROM",
|
||||
articleTableSQL,
|
||||
"AS t WHERE t.author_id = a_id and (t.title LIKE `search` OR t.content LIKE `search`)",
|
||||
");"
|
||||
],
|
||||
SetupAction.noTeardown
|
||||
$ BigQuery.run_
|
||||
$ T.unpack
|
||||
$ T.unwords
|
||||
$ [ "CREATE TABLE FUNCTION ",
|
||||
function_no_args schemaName <> "()",
|
||||
"AS (",
|
||||
"SELECT t.* FROM",
|
||||
articleTableSQL,
|
||||
"AS t);"
|
||||
],
|
||||
SetupAction.noTeardown
|
||||
$ BigQuery.run_
|
||||
$ T.unpack
|
||||
$ T.unwords
|
||||
$ [ "CREATE FUNCTION ",
|
||||
add_int schemaName <> "(a INT64, b INT64)",
|
||||
"RETURNS INT64 AS (a + b);"
|
||||
]
|
||||
]
|
||||
|
||||
fetch_articles_returns_table :: SchemaName -> T.Text
|
||||
|
@ -49,8 +49,8 @@ spec = do
|
||||
[ BigQuery.setupTablesAction schema testEnvironment
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
},
|
||||
@ -205,8 +205,9 @@ tests = do
|
||||
|]
|
||||
_ -> error "Unimplemented"
|
||||
|
||||
when (backendType == "sqlite") $
|
||||
actual >>= \result -> result `shouldAtLeastBe` expected
|
||||
when (backendType == "sqlite")
|
||||
$ actual
|
||||
>>= \result -> result `shouldAtLeastBe` expected
|
||||
|
||||
it "Returns null for an invalid table" \testEnvironment -> do
|
||||
let backendTypeMetadata = fromMaybe (error "Unknown backend") $ getBackendTypeConfig testEnvironment
|
||||
@ -227,5 +228,5 @@ tests = do
|
||||
- made_up_table
|
||||
|]
|
||||
|
||||
when (backendType == "sqlite") $
|
||||
shouldReturnYaml testEnvironment actual Null
|
||||
when (backendType == "sqlite")
|
||||
$ shouldReturnYaml testEnvironment actual Null
|
||||
|
@ -48,7 +48,8 @@ tests = do
|
||||
it "does not include defaults on stand alone export" \testEnvironment -> do
|
||||
response <- postMetadata testEnvironment exportMetadata
|
||||
let response' = Object $ response CL.^. AL.key "metadata" . AL._Object & CL.sans "sources"
|
||||
expected = [yaml| version: 3 |] -- Doesn't include defaults
|
||||
expected = [yaml| version: 3 |]
|
||||
-- Doesn't include defaults
|
||||
response' `shouldBe` expected
|
||||
|
||||
describe "with metadata modifications" do
|
||||
@ -58,7 +59,8 @@ tests = do
|
||||
|
||||
response <- postMetadata testEnvironment exportMetadata
|
||||
let response' = Object $ response CL.^. AL.key "metadata" . AL._Object & CL.sans "sources"
|
||||
expected = [yaml| version: 3 |] -- Shouldn't include defaults
|
||||
expected = [yaml| version: 3 |]
|
||||
-- Shouldn't include defaults
|
||||
response' `shouldBe` expected
|
||||
|
||||
exportMetadata :: Value
|
||||
|
@ -36,8 +36,8 @@ spec =
|
||||
setupPermissionsAction permissions testEnv
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
},
|
||||
|
@ -223,7 +223,8 @@ schemaInspectionTests = describe "Schema and Source Inspection" $ do
|
||||
args:
|
||||
name: *backendString
|
||||
|]
|
||||
) -- Note: These fields are backend specific so we ignore their values and just verify their shapes:
|
||||
)
|
||||
-- Note: These fields are backend specific so we ignore their values and just verify their shapes:
|
||||
<&> Lens.set (key "config_schema_response" . key "other_schemas") J.Null
|
||||
<&> Lens.set (key "config_schema_response" . key "config_schema") J.Null
|
||||
<&> Lens.set (key "capabilities" . _Object . Lens.at "datasets") Nothing
|
||||
@ -403,10 +404,10 @@ schemaCrudTests = describe "A series of actions to setup and teardown a source w
|
||||
let capabilities = getBackendTypeConfig testEnvironment >>= BackendType.parseCapabilities
|
||||
let foreignKeySupport = fromMaybe False $ capabilities ^? _Just . API.cDataSchema . API.dscSupportsForeignKeys
|
||||
let relationshipsSupport = isJust $ capabilities ^? _Just . API.cRelationships . _Just
|
||||
unless relationshipsSupport $
|
||||
pendingWith "Backend does not support local relationships"
|
||||
unless foreignKeySupport $
|
||||
pendingWith "Backend does not support Foreign Key constraints"
|
||||
unless relationshipsSupport
|
||||
$ pendingWith "Backend does not support local relationships"
|
||||
unless foreignKeySupport
|
||||
$ pendingWith "Backend does not support Foreign Key constraints"
|
||||
|
||||
case (backendTypeString &&& backendSourceName) <$> getBackendTypeConfig testEnvironment of
|
||||
Nothing -> pendingWith "Backend Type not found in testEnvironment"
|
||||
@ -439,10 +440,10 @@ schemaCrudTests = describe "A series of actions to setup and teardown a source w
|
||||
let capabilities = getBackendTypeConfig testEnvironment >>= BackendType.parseCapabilities
|
||||
let foreignKeySupport = fromMaybe False $ capabilities ^? _Just . API.cDataSchema . API.dscSupportsForeignKeys
|
||||
let relationshipsSupport = isJust $ capabilities ^? _Just . API.cRelationships . _Just
|
||||
unless relationshipsSupport $
|
||||
pendingWith "Backend does not support local relationships"
|
||||
unless foreignKeySupport $
|
||||
pendingWith "Backend does not support Foreign Key constraints"
|
||||
unless relationshipsSupport
|
||||
$ pendingWith "Backend does not support local relationships"
|
||||
unless foreignKeySupport
|
||||
$ pendingWith "Backend does not support Foreign Key constraints"
|
||||
|
||||
case (backendTypeString &&& backendSourceName) <$> TestEnvironment.getBackendTypeConfig testEnvironment of
|
||||
Nothing -> pendingWith "Backend Type not found in testEnvironment"
|
||||
@ -539,10 +540,10 @@ schemaCrudTests = describe "A series of actions to setup and teardown a source w
|
||||
let capabilities = getBackendTypeConfig testEnvironment >>= BackendType.parseCapabilities
|
||||
let foreignKeySupport = fromMaybe False $ capabilities ^? _Just . API.cDataSchema . API.dscSupportsForeignKeys
|
||||
let relationshipsSupport = isJust $ capabilities ^? _Just . API.cRelationships . _Just
|
||||
unless relationshipsSupport $
|
||||
pendingWith "Backend does not support local relationships"
|
||||
unless foreignKeySupport $
|
||||
pendingWith "Backend does not support Foreign Key constraints"
|
||||
unless relationshipsSupport
|
||||
$ pendingWith "Backend does not support local relationships"
|
||||
unless foreignKeySupport
|
||||
$ pendingWith "Backend does not support Foreign Key constraints"
|
||||
|
||||
case (backendTypeString &&& backendSourceName) <$> TestEnvironment.getBackendTypeConfig testEnvironment of
|
||||
Nothing -> pendingWith "Backend Type not found in testEnvironment"
|
||||
|
@ -115,8 +115,8 @@ tests = describe "Aggregate Query Tests" $ do
|
||||
[ [ ("ArtistIds_Id", API.mkColumnFieldValue $ J.Number 1),
|
||||
("ArtistNames_Name", API.mkColumnFieldValue $ J.String "AC/DC"),
|
||||
( "nodes_Albums",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkRowsQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkRowsQueryResponse
|
||||
[ [("nodes_Title", API.mkColumnFieldValue $ J.String "For Those About To Rock We Salute You")],
|
||||
[("nodes_Title", API.mkColumnFieldValue $ J.String "Let There Be Rock")]
|
||||
]
|
||||
@ -144,43 +144,45 @@ tests = describe "Aggregate Query Tests" $ do
|
||||
|
||||
_mrrRecordedRequest
|
||||
`shouldBe` Just
|
||||
( Query $
|
||||
mkTableRequest
|
||||
( Query
|
||||
$ mkTableRequest
|
||||
(mkTableName "Artist")
|
||||
( emptyQuery
|
||||
& API.qFields
|
||||
?~ mkFieldsMap
|
||||
[ ("ArtistIds_Id", API.ColumnField (API.ColumnName "ArtistId") (API.ScalarType "number")),
|
||||
("ArtistNames_Name", API.ColumnField (API.ColumnName "Name") (API.ScalarType "string")),
|
||||
( "nodes_Albums",
|
||||
API.RelField
|
||||
( API.RelationshipField
|
||||
(API.RelationshipName "Albums")
|
||||
( emptyQuery
|
||||
& API.qFields ?~ mkFieldsMap [("nodes_Title", API.ColumnField (API.ColumnName "Title") (API.ScalarType "string"))]
|
||||
)
|
||||
)
|
||||
)
|
||||
]
|
||||
& API.qLimit ?~ 1
|
||||
?~ mkFieldsMap
|
||||
[ ("ArtistIds_Id", API.ColumnField (API.ColumnName "ArtistId") (API.ScalarType "number")),
|
||||
("ArtistNames_Name", API.ColumnField (API.ColumnName "Name") (API.ScalarType "string")),
|
||||
( "nodes_Albums",
|
||||
API.RelField
|
||||
( API.RelationshipField
|
||||
(API.RelationshipName "Albums")
|
||||
( emptyQuery
|
||||
& API.qFields
|
||||
?~ mkFieldsMap [("nodes_Title", API.ColumnField (API.ColumnName "Title") (API.ScalarType "string"))]
|
||||
)
|
||||
)
|
||||
)
|
||||
]
|
||||
& API.qLimit
|
||||
?~ 1
|
||||
)
|
||||
& API.qrRelationships
|
||||
.~ Set.fromList
|
||||
[ API.RTable
|
||||
API.TableRelationships
|
||||
{ _trelSourceTable = mkTableName "Artist",
|
||||
_trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "Albums",
|
||||
API.Relationship
|
||||
{ _rTargetTable = mkTableName "Album",
|
||||
_rRelationshipType = API.ArrayRelationship,
|
||||
_rColumnMapping = HashMap.fromList [(API.ColumnName "ArtistId", API.ColumnName "ArtistId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
& API.qrRelationships
|
||||
.~ Set.fromList
|
||||
[ API.RTable
|
||||
API.TableRelationships
|
||||
{ _trelSourceTable = mkTableName "Artist",
|
||||
_trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "Albums",
|
||||
API.Relationship
|
||||
{ _rTargetTable = mkTableName "Album",
|
||||
_rRelationshipType = API.ArrayRelationship,
|
||||
_rColumnMapping = HashMap.fromList [(API.ColumnName "ArtistId", API.ColumnName "ArtistId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
mockAgentGraphqlTest "works with multiple aggregate fields and through array relations" $ \_testEnv performGraphqlRequest -> do
|
||||
@ -219,15 +221,15 @@ tests = describe "Aggregate Query Tests" $ do
|
||||
]
|
||||
rows =
|
||||
[ [ ( "nodes_Lines",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkAggregatesQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkAggregatesQueryResponse
|
||||
[ ("aggregate_count", J.Number 2)
|
||||
]
|
||||
)
|
||||
],
|
||||
[ ( "nodes_Lines",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkAggregatesQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkAggregatesQueryResponse
|
||||
[ ("aggregate_count", J.Number 4)
|
||||
]
|
||||
)
|
||||
@ -260,48 +262,50 @@ tests = describe "Aggregate Query Tests" $ do
|
||||
|
||||
_mrrRecordedRequest
|
||||
`shouldBe` Just
|
||||
( Query $
|
||||
mkTableRequest
|
||||
( Query
|
||||
$ mkTableRequest
|
||||
(mkTableName "Invoice")
|
||||
( emptyQuery
|
||||
& API.qFields
|
||||
?~ mkFieldsMap
|
||||
[ ( "nodes_Lines",
|
||||
API.RelField
|
||||
( API.RelationshipField
|
||||
(API.RelationshipName "InvoiceLines")
|
||||
( emptyQuery & API.qAggregates ?~ mkFieldsMap [("aggregate_count", API.StarCount)]
|
||||
)
|
||||
)
|
||||
)
|
||||
]
|
||||
& API.qAggregates
|
||||
?~ mkFieldsMap
|
||||
[ ("counts_count", API.StarCount),
|
||||
("counts_uniqueBillingCountries", API.ColumnCount (API.ColumnCountAggregate (API.ColumnName "BillingCountry") True)),
|
||||
("ids_minimum_Id", API.SingleColumn (singleColumnAggregateMin (API.ColumnName "InvoiceId") (API.ScalarType "number"))),
|
||||
("ids_max_InvoiceId", API.SingleColumn (singleColumnAggregateMax (API.ColumnName "InvoiceId") (API.ScalarType "number")))
|
||||
]
|
||||
& API.qLimit ?~ 2
|
||||
& API.qAggregatesLimit ?~ 2
|
||||
?~ mkFieldsMap
|
||||
[ ( "nodes_Lines",
|
||||
API.RelField
|
||||
( API.RelationshipField
|
||||
(API.RelationshipName "InvoiceLines")
|
||||
( emptyQuery & API.qAggregates ?~ mkFieldsMap [("aggregate_count", API.StarCount)]
|
||||
)
|
||||
)
|
||||
)
|
||||
]
|
||||
& API.qAggregates
|
||||
?~ mkFieldsMap
|
||||
[ ("counts_count", API.StarCount),
|
||||
("counts_uniqueBillingCountries", API.ColumnCount (API.ColumnCountAggregate (API.ColumnName "BillingCountry") True)),
|
||||
("ids_minimum_Id", API.SingleColumn (singleColumnAggregateMin (API.ColumnName "InvoiceId") (API.ScalarType "number"))),
|
||||
("ids_max_InvoiceId", API.SingleColumn (singleColumnAggregateMax (API.ColumnName "InvoiceId") (API.ScalarType "number")))
|
||||
]
|
||||
& API.qLimit
|
||||
?~ 2
|
||||
& API.qAggregatesLimit
|
||||
?~ 2
|
||||
)
|
||||
& API.qrRelationships
|
||||
.~ Set.fromList
|
||||
[ API.RTable
|
||||
API.TableRelationships
|
||||
{ _trelSourceTable = mkTableName "Invoice",
|
||||
_trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "InvoiceLines",
|
||||
API.Relationship
|
||||
{ _rTargetTable = mkTableName "InvoiceLine",
|
||||
_rRelationshipType = API.ArrayRelationship,
|
||||
_rColumnMapping = HashMap.fromList [(API.ColumnName "InvoiceId", API.ColumnName "InvoiceId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
& API.qrRelationships
|
||||
.~ Set.fromList
|
||||
[ API.RTable
|
||||
API.TableRelationships
|
||||
{ _trelSourceTable = mkTableName "Invoice",
|
||||
_trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "InvoiceLines",
|
||||
API.Relationship
|
||||
{ _rTargetTable = mkTableName "InvoiceLine",
|
||||
_rRelationshipType = API.ArrayRelationship,
|
||||
_rColumnMapping = HashMap.fromList [(API.ColumnName "InvoiceId", API.ColumnName "InvoiceId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
singleColumnAggregateMax :: API.ColumnName -> API.ScalarType -> API.SingleColumnAggregate
|
||||
|
@ -138,16 +138,17 @@ tests = describe "Basic Tests" $ do
|
||||
|
||||
_mrrRecordedRequest
|
||||
`shouldBe` Just
|
||||
( Query $
|
||||
mkTableRequest
|
||||
( Query
|
||||
$ mkTableRequest
|
||||
(mkTableName "Album")
|
||||
( emptyQuery
|
||||
& API.qFields
|
||||
?~ mkFieldsMap
|
||||
[ ("id", API.ColumnField (API.ColumnName "AlbumId") (API.ScalarType "number")),
|
||||
("title", API.ColumnField (API.ColumnName "Title") (API.ScalarType "string"))
|
||||
]
|
||||
& API.qLimit ?~ 1
|
||||
?~ mkFieldsMap
|
||||
[ ("id", API.ColumnField (API.ColumnName "AlbumId") (API.ScalarType "number")),
|
||||
("title", API.ColumnField (API.ColumnName "Title") (API.ScalarType "string"))
|
||||
]
|
||||
& API.qLimit
|
||||
?~ 1
|
||||
)
|
||||
)
|
||||
|
||||
@ -192,16 +193,17 @@ tests = describe "Basic Tests" $ do
|
||||
|
||||
_mrrRecordedRequest
|
||||
`shouldBe` Just
|
||||
( Query $
|
||||
mkTableRequest
|
||||
( Query
|
||||
$ mkTableRequest
|
||||
(mkTableName "Artist")
|
||||
( emptyQuery
|
||||
& API.qFields
|
||||
?~ mkFieldsMap
|
||||
[ ("id", API.ColumnField (API.ColumnName "ArtistId") $ API.ScalarType "number"),
|
||||
("name", API.ColumnField (API.ColumnName "Name") $ API.ScalarType "string")
|
||||
]
|
||||
& API.qLimit ?~ 3 -- The permissions limit is smaller than the query limit, so it is used
|
||||
?~ mkFieldsMap
|
||||
[ ("id", API.ColumnField (API.ColumnName "ArtistId") $ API.ScalarType "number"),
|
||||
("name", API.ColumnField (API.ColumnName "Name") $ API.ScalarType "string")
|
||||
]
|
||||
& API.qLimit
|
||||
?~ 3 -- The permissions limit is smaller than the query limit, so it is used
|
||||
)
|
||||
)
|
||||
|
||||
@ -242,21 +244,21 @@ tests = describe "Basic Tests" $ do
|
||||
|
||||
_mrrRecordedRequest
|
||||
`shouldBe` Just
|
||||
( Query $
|
||||
mkTableRequest
|
||||
( Query
|
||||
$ mkTableRequest
|
||||
(mkTableName "Customer")
|
||||
( emptyQuery
|
||||
& API.qFields
|
||||
?~ mkFieldsMap
|
||||
[ ("CustomerId", API.ColumnField (API.ColumnName "CustomerId") $ API.ScalarType "number")
|
||||
]
|
||||
& API.qWhere
|
||||
?~ API.Exists
|
||||
(API.UnrelatedTable $ mkTableName "Employee")
|
||||
( API.ApplyBinaryComparisonOperator
|
||||
API.Equal
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "EmployeeId") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 1) (API.ScalarType "number"))
|
||||
)
|
||||
?~ mkFieldsMap
|
||||
[ ("CustomerId", API.ColumnField (API.ColumnName "CustomerId") $ API.ScalarType "number")
|
||||
]
|
||||
& API.qWhere
|
||||
?~ API.Exists
|
||||
(API.UnrelatedTable $ mkTableName "Employee")
|
||||
( API.ApplyBinaryComparisonOperator
|
||||
API.Equal
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "EmployeeId") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 1) (API.ScalarType "number"))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -87,20 +87,21 @@ tests = describe "Custom scalar parsing tests" $ do
|
||||
|
||||
_mrrRecordedRequest
|
||||
`shouldBe` Just
|
||||
( Query $
|
||||
mkTableRequest
|
||||
( Query
|
||||
$ mkTableRequest
|
||||
(mkTableName "MyCustomScalarsTable")
|
||||
( emptyQuery
|
||||
& API.qFields
|
||||
?~ mkFieldsMap
|
||||
[ ("MyIntColumn", API.ColumnField (API.ColumnName "MyIntColumn") $ API.ScalarType "MyInt"),
|
||||
("MyFloatColumn", API.ColumnField (API.ColumnName "MyFloatColumn") $ API.ScalarType "MyFloat"),
|
||||
("MyStringColumn", API.ColumnField (API.ColumnName "MyStringColumn") $ API.ScalarType "MyString"),
|
||||
("MyBooleanColumn", API.ColumnField (API.ColumnName "MyBooleanColumn") $ API.ScalarType "MyBoolean"),
|
||||
("MyIDColumn", API.ColumnField (API.ColumnName "MyIDColumn") $ API.ScalarType "MyID"),
|
||||
("MyAnythingColumn", API.ColumnField (API.ColumnName "MyAnythingColumn") $ API.ScalarType "MyAnything")
|
||||
]
|
||||
& API.qLimit ?~ 1
|
||||
?~ mkFieldsMap
|
||||
[ ("MyIntColumn", API.ColumnField (API.ColumnName "MyIntColumn") $ API.ScalarType "MyInt"),
|
||||
("MyFloatColumn", API.ColumnField (API.ColumnName "MyFloatColumn") $ API.ScalarType "MyFloat"),
|
||||
("MyStringColumn", API.ColumnField (API.ColumnName "MyStringColumn") $ API.ScalarType "MyString"),
|
||||
("MyBooleanColumn", API.ColumnField (API.ColumnName "MyBooleanColumn") $ API.ScalarType "MyBoolean"),
|
||||
("MyIDColumn", API.ColumnField (API.ColumnName "MyIDColumn") $ API.ScalarType "MyID"),
|
||||
("MyAnythingColumn", API.ColumnField (API.ColumnName "MyAnythingColumn") $ API.ScalarType "MyAnything")
|
||||
]
|
||||
& API.qLimit
|
||||
?~ 1
|
||||
)
|
||||
)
|
||||
|
||||
@ -144,49 +145,50 @@ tests = describe "Custom scalar parsing tests" $ do
|
||||
|
||||
_mrrRecordedRequest
|
||||
`shouldBe` Just
|
||||
( Query $
|
||||
mkTableRequest
|
||||
( Query
|
||||
$ mkTableRequest
|
||||
(mkTableName "MyCustomScalarsTable")
|
||||
( emptyQuery
|
||||
& API.qFields
|
||||
?~ mkFieldsMap
|
||||
[ ("MyIntColumn", API.ColumnField (API.ColumnName "MyIntColumn") $ API.ScalarType "MyInt"),
|
||||
("MyFloatColumn", API.ColumnField (API.ColumnName "MyFloatColumn") $ API.ScalarType "MyFloat"),
|
||||
("MyStringColumn", API.ColumnField (API.ColumnName "MyStringColumn") $ API.ScalarType "MyString"),
|
||||
("MyBooleanColumn", API.ColumnField (API.ColumnName "MyBooleanColumn") $ API.ScalarType "MyBoolean"),
|
||||
("MyIDColumn", API.ColumnField (API.ColumnName "MyIDColumn") $ API.ScalarType "MyID"),
|
||||
("MyAnythingColumn", API.ColumnField (API.ColumnName "MyAnythingColumn") $ API.ScalarType "MyAnything")
|
||||
]
|
||||
& API.qLimit ?~ 1
|
||||
& API.qWhere
|
||||
?~ And
|
||||
( Set.fromList
|
||||
[ ApplyBinaryComparisonOperator
|
||||
Equal
|
||||
(ComparisonColumn CurrentTable (ColumnName "MyBooleanColumn") (ScalarType "MyBoolean"))
|
||||
(ScalarValueComparison $ ScalarValue (J.Bool True) (ScalarType "MyBoolean")),
|
||||
ApplyBinaryComparisonOperator
|
||||
Equal
|
||||
(ComparisonColumn CurrentTable (ColumnName "MyFloatColumn") (ScalarType "MyFloat"))
|
||||
(ScalarValueComparison $ ScalarValue (J.Number 3.14) (ScalarType "MyFloat")),
|
||||
ApplyBinaryComparisonOperator
|
||||
Equal
|
||||
(ComparisonColumn CurrentTable (ColumnName "MyStringColumn") (ScalarType "MyString"))
|
||||
(ScalarValueComparison $ ScalarValue (J.String "foo") (ScalarType "MyString")),
|
||||
ApplyBinaryComparisonOperator
|
||||
Equal
|
||||
(ComparisonColumn CurrentTable (ColumnName "MyIDColumn") (ScalarType "MyID"))
|
||||
(ScalarValueComparison $ ScalarValue (J.String "x") (ScalarType "MyID")),
|
||||
ApplyBinaryComparisonOperator
|
||||
Equal
|
||||
(ComparisonColumn CurrentTable (ColumnName "MyIntColumn") (ScalarType "MyInt"))
|
||||
(ScalarValueComparison $ ScalarValue (J.Number 42.0) (ScalarType "MyInt")),
|
||||
ApplyBinaryComparisonOperator
|
||||
Equal
|
||||
(ComparisonColumn CurrentTable (ColumnName "MyAnythingColumn") (ScalarType "MyAnything"))
|
||||
(ScalarValueComparison $ ScalarValue (J.Object mempty) (ScalarType "MyAnything"))
|
||||
]
|
||||
)
|
||||
?~ mkFieldsMap
|
||||
[ ("MyIntColumn", API.ColumnField (API.ColumnName "MyIntColumn") $ API.ScalarType "MyInt"),
|
||||
("MyFloatColumn", API.ColumnField (API.ColumnName "MyFloatColumn") $ API.ScalarType "MyFloat"),
|
||||
("MyStringColumn", API.ColumnField (API.ColumnName "MyStringColumn") $ API.ScalarType "MyString"),
|
||||
("MyBooleanColumn", API.ColumnField (API.ColumnName "MyBooleanColumn") $ API.ScalarType "MyBoolean"),
|
||||
("MyIDColumn", API.ColumnField (API.ColumnName "MyIDColumn") $ API.ScalarType "MyID"),
|
||||
("MyAnythingColumn", API.ColumnField (API.ColumnName "MyAnythingColumn") $ API.ScalarType "MyAnything")
|
||||
]
|
||||
& API.qLimit
|
||||
?~ 1
|
||||
& API.qWhere
|
||||
?~ And
|
||||
( Set.fromList
|
||||
[ ApplyBinaryComparisonOperator
|
||||
Equal
|
||||
(ComparisonColumn CurrentTable (ColumnName "MyBooleanColumn") (ScalarType "MyBoolean"))
|
||||
(ScalarValueComparison $ ScalarValue (J.Bool True) (ScalarType "MyBoolean")),
|
||||
ApplyBinaryComparisonOperator
|
||||
Equal
|
||||
(ComparisonColumn CurrentTable (ColumnName "MyFloatColumn") (ScalarType "MyFloat"))
|
||||
(ScalarValueComparison $ ScalarValue (J.Number 3.14) (ScalarType "MyFloat")),
|
||||
ApplyBinaryComparisonOperator
|
||||
Equal
|
||||
(ComparisonColumn CurrentTable (ColumnName "MyStringColumn") (ScalarType "MyString"))
|
||||
(ScalarValueComparison $ ScalarValue (J.String "foo") (ScalarType "MyString")),
|
||||
ApplyBinaryComparisonOperator
|
||||
Equal
|
||||
(ComparisonColumn CurrentTable (ColumnName "MyIDColumn") (ScalarType "MyID"))
|
||||
(ScalarValueComparison $ ScalarValue (J.String "x") (ScalarType "MyID")),
|
||||
ApplyBinaryComparisonOperator
|
||||
Equal
|
||||
(ComparisonColumn CurrentTable (ColumnName "MyIntColumn") (ScalarType "MyInt"))
|
||||
(ScalarValueComparison $ ScalarValue (J.Number 42.0) (ScalarType "MyInt")),
|
||||
ApplyBinaryComparisonOperator
|
||||
Equal
|
||||
(ComparisonColumn CurrentTable (ColumnName "MyAnythingColumn") (ScalarType "MyAnything"))
|
||||
(ScalarValueComparison $ ScalarValue (J.Object mempty) (ScalarType "MyAnything"))
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -114,8 +114,8 @@ tests = do
|
||||
[ ("deletedRows_AlbumId", API.mkColumnFieldValue $ J.Number 112),
|
||||
("deletedRows_Title", API.mkColumnFieldValue $ J.String "The Number of The Beast"),
|
||||
( "deletedRows_Artist",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkRowsQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkRowsQueryResponse
|
||||
[ [ ("ArtistId", API.mkColumnFieldValue $ J.Number 90),
|
||||
("Name", API.mkColumnFieldValue $ J.String "Iron Maiden")
|
||||
]
|
||||
@ -126,8 +126,8 @@ tests = do
|
||||
[ ("deletedRows_AlbumId", API.mkColumnFieldValue $ J.Number 113),
|
||||
("deletedRows_Title", API.mkColumnFieldValue $ J.String "The X Factor"),
|
||||
( "deletedRows_Artist",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkRowsQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkRowsQueryResponse
|
||||
[ [ ("ArtistId", API.mkColumnFieldValue $ J.Number 90),
|
||||
("Name", API.mkColumnFieldValue $ J.String "Iron Maiden")
|
||||
]
|
||||
@ -138,8 +138,8 @@ tests = do
|
||||
[ ("deletedRows_AlbumId", API.mkColumnFieldValue $ J.Number 114),
|
||||
("deletedRows_Title", API.mkColumnFieldValue $ J.String "Virtual XI"),
|
||||
( "deletedRows_Artist",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkRowsQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkRowsQueryResponse
|
||||
[ [ ("ArtistId", API.mkColumnFieldValue $ J.Number 90),
|
||||
("Name", API.mkColumnFieldValue $ J.String "Iron Maiden")
|
||||
]
|
||||
@ -179,57 +179,58 @@ tests = do
|
||||
let expectedRequest =
|
||||
emptyMutationRequest
|
||||
& API.mrTableRelationships
|
||||
.~ Set.fromList
|
||||
[ API.TableRelationships
|
||||
{ API._trelSourceTable = mkTableName "Album",
|
||||
API._trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "Artist",
|
||||
API.Relationship
|
||||
{ API._rTargetTable = mkTableName "Artist",
|
||||
API._rRelationshipType = API.ObjectRelationship,
|
||||
API._rColumnMapping = HashMap.fromList [(API.ColumnName "ArtistId", API.ColumnName "ArtistId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
& API.mrOperations
|
||||
.~ [ API.DeleteOperation $
|
||||
API.DeleteMutationOperation
|
||||
{ API._dmoTable = mkTableName "Album",
|
||||
API._dmoWhere =
|
||||
Just . API.And $
|
||||
Set.fromList
|
||||
[ API.ApplyBinaryComparisonOperator
|
||||
API.Equal
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "ArtistId") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 90) (API.ScalarType "number")),
|
||||
API.ApplyBinaryComparisonOperator
|
||||
API.GreaterThan
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "AlbumId") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 111) (API.ScalarType "number"))
|
||||
],
|
||||
API._dmoReturningFields =
|
||||
mkFieldsMap
|
||||
[ ("deletedRows_AlbumId", API.ColumnField (API.ColumnName "AlbumId") (API.ScalarType "number")),
|
||||
("deletedRows_Title", API.ColumnField (API.ColumnName "Title") (API.ScalarType "string")),
|
||||
( "deletedRows_Artist",
|
||||
API.RelField
|
||||
( API.RelationshipField
|
||||
(API.RelationshipName "Artist")
|
||||
( emptyQuery
|
||||
& API.qFields
|
||||
?~ mkFieldsMap
|
||||
[ ("ArtistId", API.ColumnField (API.ColumnName "ArtistId") $ API.ScalarType "number"),
|
||||
("Name", API.ColumnField (API.ColumnName "Name") $ API.ScalarType "string")
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
.~ Set.fromList
|
||||
[ API.TableRelationships
|
||||
{ API._trelSourceTable = mkTableName "Album",
|
||||
API._trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "Artist",
|
||||
API.Relationship
|
||||
{ API._rTargetTable = mkTableName "Artist",
|
||||
API._rRelationshipType = API.ObjectRelationship,
|
||||
API._rColumnMapping = HashMap.fromList [(API.ColumnName "ArtistId", API.ColumnName "ArtistId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
& API.mrOperations
|
||||
.~ [ API.DeleteOperation
|
||||
$ API.DeleteMutationOperation
|
||||
{ API._dmoTable = mkTableName "Album",
|
||||
API._dmoWhere =
|
||||
Just
|
||||
. API.And
|
||||
$ Set.fromList
|
||||
[ API.ApplyBinaryComparisonOperator
|
||||
API.Equal
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "ArtistId") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 90) (API.ScalarType "number")),
|
||||
API.ApplyBinaryComparisonOperator
|
||||
API.GreaterThan
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "AlbumId") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 111) (API.ScalarType "number"))
|
||||
],
|
||||
API._dmoReturningFields =
|
||||
mkFieldsMap
|
||||
[ ("deletedRows_AlbumId", API.ColumnField (API.ColumnName "AlbumId") (API.ScalarType "number")),
|
||||
("deletedRows_Title", API.ColumnField (API.ColumnName "Title") (API.ScalarType "string")),
|
||||
( "deletedRows_Artist",
|
||||
API.RelField
|
||||
( API.RelationshipField
|
||||
(API.RelationshipName "Artist")
|
||||
( emptyQuery
|
||||
& API.qFields
|
||||
?~ mkFieldsMap
|
||||
[ ("ArtistId", API.ColumnField (API.ColumnName "ArtistId") $ API.ScalarType "number"),
|
||||
("Name", API.ColumnField (API.ColumnName "Name") $ API.ScalarType "string")
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
_mrrRecordedRequest `shouldBe` Just (Mutation expectedRequest)
|
||||
|
||||
mockAgentGraphqlTest "delete row by pk with delete permissions" $ \_testEnv performGraphqlRequest -> do
|
||||
@ -257,8 +258,8 @@ tests = do
|
||||
[ ("AlbumId", API.mkColumnFieldValue $ J.Number 112),
|
||||
("Title", API.mkColumnFieldValue $ J.String "The Number of The Beast"),
|
||||
( "Artist",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkRowsQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkRowsQueryResponse
|
||||
[ [ ("ArtistId", API.mkColumnFieldValue $ J.Number 90),
|
||||
("Name", API.mkColumnFieldValue $ J.String "Iron Maiden")
|
||||
]
|
||||
@ -286,55 +287,56 @@ tests = do
|
||||
let expectedRequest =
|
||||
emptyMutationRequest
|
||||
& API.mrTableRelationships
|
||||
.~ Set.fromList
|
||||
[ API.TableRelationships
|
||||
{ API._trelSourceTable = mkTableName "Album",
|
||||
API._trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "Artist",
|
||||
API.Relationship
|
||||
{ API._rTargetTable = mkTableName "Artist",
|
||||
API._rRelationshipType = API.ObjectRelationship,
|
||||
API._rColumnMapping = HashMap.fromList [(API.ColumnName "ArtistId", API.ColumnName "ArtistId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
& API.mrOperations
|
||||
.~ [ API.DeleteOperation $
|
||||
API.DeleteMutationOperation
|
||||
{ API._dmoTable = mkTableName "Album",
|
||||
API._dmoWhere =
|
||||
Just . API.And $
|
||||
Set.fromList
|
||||
[ API.ApplyBinaryComparisonOperator
|
||||
API.Equal
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "ArtistId") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 90) (API.ScalarType "number")),
|
||||
API.ApplyBinaryComparisonOperator
|
||||
API.Equal
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "AlbumId") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 112) (API.ScalarType "number"))
|
||||
],
|
||||
API._dmoReturningFields =
|
||||
mkFieldsMap
|
||||
[ ("AlbumId", API.ColumnField (API.ColumnName "AlbumId") (API.ScalarType "number")),
|
||||
("Title", API.ColumnField (API.ColumnName "Title") (API.ScalarType "string")),
|
||||
( "Artist",
|
||||
API.RelField
|
||||
( API.RelationshipField
|
||||
(API.RelationshipName "Artist")
|
||||
( emptyQuery
|
||||
& API.qFields
|
||||
?~ mkFieldsMap
|
||||
[ ("ArtistId", API.ColumnField (API.ColumnName "ArtistId") $ API.ScalarType "number"),
|
||||
("Name", API.ColumnField (API.ColumnName "Name") $ API.ScalarType "string")
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
.~ Set.fromList
|
||||
[ API.TableRelationships
|
||||
{ API._trelSourceTable = mkTableName "Album",
|
||||
API._trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "Artist",
|
||||
API.Relationship
|
||||
{ API._rTargetTable = mkTableName "Artist",
|
||||
API._rRelationshipType = API.ObjectRelationship,
|
||||
API._rColumnMapping = HashMap.fromList [(API.ColumnName "ArtistId", API.ColumnName "ArtistId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
& API.mrOperations
|
||||
.~ [ API.DeleteOperation
|
||||
$ API.DeleteMutationOperation
|
||||
{ API._dmoTable = mkTableName "Album",
|
||||
API._dmoWhere =
|
||||
Just
|
||||
. API.And
|
||||
$ Set.fromList
|
||||
[ API.ApplyBinaryComparisonOperator
|
||||
API.Equal
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "ArtistId") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 90) (API.ScalarType "number")),
|
||||
API.ApplyBinaryComparisonOperator
|
||||
API.Equal
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "AlbumId") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 112) (API.ScalarType "number"))
|
||||
],
|
||||
API._dmoReturningFields =
|
||||
mkFieldsMap
|
||||
[ ("AlbumId", API.ColumnField (API.ColumnName "AlbumId") (API.ScalarType "number")),
|
||||
("Title", API.ColumnField (API.ColumnName "Title") (API.ScalarType "string")),
|
||||
( "Artist",
|
||||
API.RelField
|
||||
( API.RelationshipField
|
||||
(API.RelationshipName "Artist")
|
||||
( emptyQuery
|
||||
& API.qFields
|
||||
?~ mkFieldsMap
|
||||
[ ("ArtistId", API.ColumnField (API.ColumnName "ArtistId") $ API.ScalarType "number"),
|
||||
("Name", API.ColumnField (API.ColumnName "Name") $ API.ScalarType "string")
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
_mrrRecordedRequest `shouldBe` Just (Mutation expectedRequest)
|
||||
|
@ -94,16 +94,17 @@ tests = describe "Error Protocol Tests" $ do
|
||||
|
||||
_mrrRecordedRequest
|
||||
`shouldBe` Just
|
||||
( Query $
|
||||
mkTableRequest
|
||||
( Query
|
||||
$ mkTableRequest
|
||||
(mkTableName "Album")
|
||||
( emptyQuery
|
||||
& API.qFields
|
||||
?~ mkFieldsMap
|
||||
[ ("id", API.ColumnField (API.ColumnName "AlbumId") $ API.ScalarType "number"),
|
||||
("title", API.ColumnField (API.ColumnName "Title") $ API.ScalarType "string")
|
||||
]
|
||||
& API.qLimit ?~ 1
|
||||
?~ mkFieldsMap
|
||||
[ ("id", API.ColumnField (API.ColumnName "AlbumId") $ API.ScalarType "number"),
|
||||
("title", API.ColumnField (API.ColumnName "Title") $ API.ScalarType "string")
|
||||
]
|
||||
& API.qLimit
|
||||
?~ 1
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -123,8 +123,8 @@ tests = do
|
||||
[ ("insertedRows_AlbumId", API.mkColumnFieldValue $ J.Number 9001),
|
||||
("insertedRows_Title", API.mkColumnFieldValue $ J.String "Super Mega Rock"),
|
||||
( "insertedRows_Artist",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkRowsQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkRowsQueryResponse
|
||||
[ [ ("ArtistId", API.mkColumnFieldValue $ J.Number 2),
|
||||
("Name", API.mkColumnFieldValue $ J.String "Accept")
|
||||
]
|
||||
@ -135,8 +135,8 @@ tests = do
|
||||
[ ("insertedRows_AlbumId", API.mkColumnFieldValue $ J.Number 9002),
|
||||
("insertedRows_Title", API.mkColumnFieldValue $ J.String "Accept This"),
|
||||
( "insertedRows_Artist",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkRowsQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkRowsQueryResponse
|
||||
[ [ ("ArtistId", API.mkColumnFieldValue $ J.Number 2),
|
||||
("Name", API.mkColumnFieldValue $ J.String "Accept")
|
||||
]
|
||||
@ -171,76 +171,76 @@ tests = do
|
||||
let expectedRequest =
|
||||
emptyMutationRequest
|
||||
& API.mrTableRelationships
|
||||
.~ Set.fromList
|
||||
[ API.TableRelationships
|
||||
{ API._trelSourceTable = mkTableName "Album",
|
||||
API._trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "Artist",
|
||||
API.Relationship
|
||||
{ API._rTargetTable = mkTableName "Artist",
|
||||
API._rRelationshipType = API.ObjectRelationship,
|
||||
API._rColumnMapping = HashMap.fromList [(API.ColumnName "ArtistId", API.ColumnName "ArtistId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
& API.mrInsertSchema
|
||||
.~ Set.fromList
|
||||
[ API.TableInsertSchema
|
||||
{ API._tisTable = mkTableName "Album",
|
||||
API._tisPrimaryKey = Just $ API.ColumnName "AlbumId" :| [],
|
||||
API._tisFields =
|
||||
mkFieldsMap
|
||||
[ ("AlbumId", API.ColumnInsert $ API.ColumnInsertSchema (API.ColumnName "AlbumId") (API.ColumnTypeScalar $ API.ScalarType "number") False (Just API.AutoIncrement)),
|
||||
("ArtistId", API.ColumnInsert $ API.ColumnInsertSchema (API.ColumnName "ArtistId") (API.ColumnTypeScalar $ API.ScalarType "number") False Nothing),
|
||||
("Title", API.ColumnInsert $ API.ColumnInsertSchema (API.ColumnName "Title") (API.ColumnTypeScalar $ API.ScalarType "string") False Nothing)
|
||||
]
|
||||
}
|
||||
]
|
||||
& API.mrOperations
|
||||
.~ [ API.InsertOperation $
|
||||
API.InsertMutationOperation
|
||||
{ API._imoTable = mkTableName "Album",
|
||||
API._imoRows =
|
||||
[ API.RowObject $
|
||||
mkFieldsMap
|
||||
[ ("AlbumId", API.mkColumnInsertFieldValue $ J.Number 9001),
|
||||
("ArtistId", API.mkColumnInsertFieldValue $ J.Number 2),
|
||||
("Title", API.mkColumnInsertFieldValue $ J.String "Super Mega Rock")
|
||||
],
|
||||
API.RowObject $
|
||||
mkFieldsMap
|
||||
[ ("AlbumId", API.mkColumnInsertFieldValue $ J.Number 9002),
|
||||
("ArtistId", API.mkColumnInsertFieldValue $ J.Number 2),
|
||||
("Title", API.mkColumnInsertFieldValue $ J.String "Accept This")
|
||||
]
|
||||
],
|
||||
API._imoPostInsertCheck =
|
||||
Just $
|
||||
API.ApplyBinaryComparisonOperator
|
||||
API.Equal
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "ArtistId") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 2) (API.ScalarType "number")),
|
||||
API._imoReturningFields =
|
||||
mkFieldsMap
|
||||
[ ("insertedRows_AlbumId", API.ColumnField (API.ColumnName "AlbumId") (API.ScalarType "number")),
|
||||
("insertedRows_Title", API.ColumnField (API.ColumnName "Title") (API.ScalarType "string")),
|
||||
( "insertedRows_Artist",
|
||||
API.RelField
|
||||
( API.RelationshipField
|
||||
(API.RelationshipName "Artist")
|
||||
( emptyQuery
|
||||
& API.qFields
|
||||
?~ mkFieldsMap
|
||||
[ ("ArtistId", API.ColumnField (API.ColumnName "ArtistId") $ API.ScalarType "number"),
|
||||
("Name", API.ColumnField (API.ColumnName "Name") $ API.ScalarType "string")
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
.~ Set.fromList
|
||||
[ API.TableRelationships
|
||||
{ API._trelSourceTable = mkTableName "Album",
|
||||
API._trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "Artist",
|
||||
API.Relationship
|
||||
{ API._rTargetTable = mkTableName "Artist",
|
||||
API._rRelationshipType = API.ObjectRelationship,
|
||||
API._rColumnMapping = HashMap.fromList [(API.ColumnName "ArtistId", API.ColumnName "ArtistId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
& API.mrInsertSchema
|
||||
.~ Set.fromList
|
||||
[ API.TableInsertSchema
|
||||
{ API._tisTable = mkTableName "Album",
|
||||
API._tisPrimaryKey = Just $ API.ColumnName "AlbumId" :| [],
|
||||
API._tisFields =
|
||||
mkFieldsMap
|
||||
[ ("AlbumId", API.ColumnInsert $ API.ColumnInsertSchema (API.ColumnName "AlbumId") (API.ColumnTypeScalar $ API.ScalarType "number") False (Just API.AutoIncrement)),
|
||||
("ArtistId", API.ColumnInsert $ API.ColumnInsertSchema (API.ColumnName "ArtistId") (API.ColumnTypeScalar $ API.ScalarType "number") False Nothing),
|
||||
("Title", API.ColumnInsert $ API.ColumnInsertSchema (API.ColumnName "Title") (API.ColumnTypeScalar $ API.ScalarType "string") False Nothing)
|
||||
]
|
||||
}
|
||||
]
|
||||
& API.mrOperations
|
||||
.~ [ API.InsertOperation
|
||||
$ API.InsertMutationOperation
|
||||
{ API._imoTable = mkTableName "Album",
|
||||
API._imoRows =
|
||||
[ API.RowObject
|
||||
$ mkFieldsMap
|
||||
[ ("AlbumId", API.mkColumnInsertFieldValue $ J.Number 9001),
|
||||
("ArtistId", API.mkColumnInsertFieldValue $ J.Number 2),
|
||||
("Title", API.mkColumnInsertFieldValue $ J.String "Super Mega Rock")
|
||||
],
|
||||
API.RowObject
|
||||
$ mkFieldsMap
|
||||
[ ("AlbumId", API.mkColumnInsertFieldValue $ J.Number 9002),
|
||||
("ArtistId", API.mkColumnInsertFieldValue $ J.Number 2),
|
||||
("Title", API.mkColumnInsertFieldValue $ J.String "Accept This")
|
||||
]
|
||||
],
|
||||
API._imoPostInsertCheck =
|
||||
Just
|
||||
$ API.ApplyBinaryComparisonOperator
|
||||
API.Equal
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "ArtistId") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 2) (API.ScalarType "number")),
|
||||
API._imoReturningFields =
|
||||
mkFieldsMap
|
||||
[ ("insertedRows_AlbumId", API.ColumnField (API.ColumnName "AlbumId") (API.ScalarType "number")),
|
||||
("insertedRows_Title", API.ColumnField (API.ColumnName "Title") (API.ScalarType "string")),
|
||||
( "insertedRows_Artist",
|
||||
API.RelField
|
||||
( API.RelationshipField
|
||||
(API.RelationshipName "Artist")
|
||||
( emptyQuery
|
||||
& API.qFields
|
||||
?~ mkFieldsMap
|
||||
[ ("ArtistId", API.ColumnField (API.ColumnName "ArtistId") $ API.ScalarType "number"),
|
||||
("Name", API.ColumnField (API.ColumnName "Name") $ API.ScalarType "string")
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
_mrrRecordedRequest `shouldBe` Just (Mutation expectedRequest)
|
||||
|
@ -113,17 +113,19 @@ tests = describe "Order By Tests" $ do
|
||||
|
||||
_mrrRecordedRequest
|
||||
`shouldBe` Just
|
||||
( Query $
|
||||
mkTableRequest
|
||||
( Query
|
||||
$ mkTableRequest
|
||||
(mkTableName "Album")
|
||||
( emptyQuery
|
||||
& API.qFields
|
||||
?~ mkFieldsMap
|
||||
[ ("AlbumId", API.ColumnField (API.ColumnName "AlbumId") $ API.ScalarType "number"),
|
||||
("Title", API.ColumnField (API.ColumnName "Title") $ API.ScalarType "string")
|
||||
]
|
||||
& API.qLimit ?~ 3
|
||||
& API.qOrderBy ?~ API.OrderBy mempty (API.OrderByElement [] (API.OrderByColumn (API.ColumnName "AlbumId")) API.Ascending :| [])
|
||||
?~ mkFieldsMap
|
||||
[ ("AlbumId", API.ColumnField (API.ColumnName "AlbumId") $ API.ScalarType "number"),
|
||||
("Title", API.ColumnField (API.ColumnName "Title") $ API.ScalarType "string")
|
||||
]
|
||||
& API.qLimit
|
||||
?~ 3
|
||||
& API.qOrderBy
|
||||
?~ API.OrderBy mempty (API.OrderByElement [] (API.OrderByColumn (API.ColumnName "AlbumId")) API.Ascending :| [])
|
||||
)
|
||||
)
|
||||
|
||||
@ -156,51 +158,53 @@ tests = describe "Order By Tests" $ do
|
||||
|
||||
_mrrRecordedRequest
|
||||
`shouldBe` Just
|
||||
( Query $
|
||||
mkTableRequest
|
||||
( Query
|
||||
$ mkTableRequest
|
||||
(mkTableName "Artist")
|
||||
( emptyQuery
|
||||
& API.qFields ?~ mkFieldsMap [("Name", API.ColumnField (API.ColumnName "Name") (API.ScalarType "string"))]
|
||||
& API.qLimit ?~ 2
|
||||
& API.qOrderBy
|
||||
?~ API.OrderBy
|
||||
( HashMap.fromList
|
||||
& API.qFields
|
||||
?~ mkFieldsMap [("Name", API.ColumnField (API.ColumnName "Name") (API.ScalarType "string"))]
|
||||
& API.qLimit
|
||||
?~ 2
|
||||
& API.qOrderBy
|
||||
?~ API.OrderBy
|
||||
( HashMap.fromList
|
||||
[ ( API.RelationshipName "Albums",
|
||||
API.OrderByRelation Nothing mempty
|
||||
)
|
||||
]
|
||||
)
|
||||
( NE.fromList
|
||||
[ API.OrderByElement [API.RelationshipName "Albums"] API.OrderByStarCountAggregate API.Ascending,
|
||||
API.OrderByElement
|
||||
[API.RelationshipName "Albums"]
|
||||
( API.OrderBySingleColumnAggregate
|
||||
$ API.SingleColumnAggregate
|
||||
(API.SingleColumnAggregateFunction [G.name|max|])
|
||||
(API.ColumnName "AlbumId")
|
||||
(API.ScalarType "number")
|
||||
)
|
||||
API.Ascending
|
||||
]
|
||||
)
|
||||
)
|
||||
& API.qrRelationships
|
||||
.~ Set.fromList
|
||||
[ API.RTable
|
||||
API.TableRelationships
|
||||
{ _trelSourceTable = mkTableName "Artist",
|
||||
_trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "Albums",
|
||||
API.OrderByRelation Nothing mempty
|
||||
API.Relationship
|
||||
{ _rTargetTable = mkTableName "Album",
|
||||
_rRelationshipType = API.ArrayRelationship,
|
||||
_rColumnMapping = HashMap.fromList [(API.ColumnName "ArtistId", API.ColumnName "ArtistId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
)
|
||||
( NE.fromList
|
||||
[ API.OrderByElement [API.RelationshipName "Albums"] API.OrderByStarCountAggregate API.Ascending,
|
||||
API.OrderByElement
|
||||
[API.RelationshipName "Albums"]
|
||||
( API.OrderBySingleColumnAggregate $
|
||||
API.SingleColumnAggregate
|
||||
(API.SingleColumnAggregateFunction [G.name|max|])
|
||||
(API.ColumnName "AlbumId")
|
||||
(API.ScalarType "number")
|
||||
)
|
||||
API.Ascending
|
||||
]
|
||||
)
|
||||
)
|
||||
& API.qrRelationships
|
||||
.~ Set.fromList
|
||||
[ API.RTable
|
||||
API.TableRelationships
|
||||
{ _trelSourceTable = mkTableName "Artist",
|
||||
_trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "Albums",
|
||||
API.Relationship
|
||||
{ _rTargetTable = mkTableName "Album",
|
||||
_rRelationshipType = API.ArrayRelationship,
|
||||
_rColumnMapping = HashMap.fromList [(API.ColumnName "ArtistId", API.ColumnName "ArtistId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
rowsResponse :: [[(API.FieldName, API.FieldValue)]] -> API.QueryResponse
|
||||
|
@ -162,14 +162,14 @@ tests = describe "Object Relationships Tests" $ do
|
||||
mkRowsQueryResponse
|
||||
[ [ ("Name", API.mkColumnFieldValue $ J.String "For Those About To Rock (We Salute You)"),
|
||||
( "Genre",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkRowsQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkRowsQueryResponse
|
||||
[ [("Name", API.mkColumnFieldValue $ J.String "Rock")]
|
||||
]
|
||||
),
|
||||
( "MediaType",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkRowsQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkRowsQueryResponse
|
||||
[ [("Name", API.mkColumnFieldValue $ J.String "MPEG audio file")]
|
||||
]
|
||||
)
|
||||
@ -192,56 +192,57 @@ tests = describe "Object Relationships Tests" $ do
|
||||
|
||||
_mrrRecordedRequest
|
||||
`shouldBe` Just
|
||||
( Query $
|
||||
mkTableRequest
|
||||
( Query
|
||||
$ mkTableRequest
|
||||
(mkTableName "Track")
|
||||
( emptyQuery
|
||||
& API.qFields
|
||||
?~ mkFieldsMap
|
||||
[ ("Name", API.ColumnField (API.ColumnName "Name") $ API.ScalarType "string"),
|
||||
( "Genre",
|
||||
API.RelField
|
||||
( API.RelationshipField
|
||||
(API.RelationshipName "Genre")
|
||||
(emptyQuery & API.qFields ?~ mkFieldsMap [("Name", API.ColumnField (API.ColumnName "Name") $ API.ScalarType "string")])
|
||||
)
|
||||
),
|
||||
( "MediaType",
|
||||
API.RelField
|
||||
( API.RelationshipField
|
||||
(API.RelationshipName "MediaType")
|
||||
(emptyQuery & API.qFields ?~ mkFieldsMap [("Name", API.ColumnField (API.ColumnName "Name") $ API.ScalarType "string")])
|
||||
)
|
||||
)
|
||||
]
|
||||
& API.qLimit ?~ 1
|
||||
?~ mkFieldsMap
|
||||
[ ("Name", API.ColumnField (API.ColumnName "Name") $ API.ScalarType "string"),
|
||||
( "Genre",
|
||||
API.RelField
|
||||
( API.RelationshipField
|
||||
(API.RelationshipName "Genre")
|
||||
(emptyQuery & API.qFields ?~ mkFieldsMap [("Name", API.ColumnField (API.ColumnName "Name") $ API.ScalarType "string")])
|
||||
)
|
||||
),
|
||||
( "MediaType",
|
||||
API.RelField
|
||||
( API.RelationshipField
|
||||
(API.RelationshipName "MediaType")
|
||||
(emptyQuery & API.qFields ?~ mkFieldsMap [("Name", API.ColumnField (API.ColumnName "Name") $ API.ScalarType "string")])
|
||||
)
|
||||
)
|
||||
]
|
||||
& API.qLimit
|
||||
?~ 1
|
||||
)
|
||||
& API.qrRelationships
|
||||
.~ Set.fromList
|
||||
[ API.RTable
|
||||
API.TableRelationships
|
||||
{ _trelSourceTable = mkTableName "Track",
|
||||
_trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "Genre",
|
||||
API.Relationship
|
||||
{ _rTargetTable = mkTableName "Genre",
|
||||
_rRelationshipType = API.ObjectRelationship,
|
||||
_rColumnMapping = HashMap.fromList [(API.ColumnName "GenreId", API.ColumnName "GenreId")]
|
||||
}
|
||||
),
|
||||
( API.RelationshipName "MediaType",
|
||||
API.Relationship
|
||||
{ _rTargetTable = mkTableName "MediaType",
|
||||
_rRelationshipType = API.ObjectRelationship,
|
||||
_rColumnMapping =
|
||||
HashMap.fromList
|
||||
[(API.ColumnName "MediaTypeId", API.ColumnName "MediaTypeId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
& API.qrRelationships
|
||||
.~ Set.fromList
|
||||
[ API.RTable
|
||||
API.TableRelationships
|
||||
{ _trelSourceTable = mkTableName "Track",
|
||||
_trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "Genre",
|
||||
API.Relationship
|
||||
{ _rTargetTable = mkTableName "Genre",
|
||||
_rRelationshipType = API.ObjectRelationship,
|
||||
_rColumnMapping = HashMap.fromList [(API.ColumnName "GenreId", API.ColumnName "GenreId")]
|
||||
}
|
||||
),
|
||||
( API.RelationshipName "MediaType",
|
||||
API.Relationship
|
||||
{ _rTargetTable = mkTableName "MediaType",
|
||||
_rRelationshipType = API.ObjectRelationship,
|
||||
_rColumnMapping =
|
||||
HashMap.fromList
|
||||
[(API.ColumnName "MediaTypeId", API.ColumnName "MediaTypeId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
mockAgentGraphqlTest "works with an order by that navigates relationships" $ \_testEnv performGraphqlRequest -> do
|
||||
@ -262,11 +263,11 @@ tests = describe "Object Relationships Tests" $ do
|
||||
let queryResponse =
|
||||
mkRowsQueryResponse
|
||||
[ [ ( "Album",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkRowsQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkRowsQueryResponse
|
||||
[ [ ( "Artist",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkRowsQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkRowsQueryResponse
|
||||
[[("Name", API.mkColumnFieldValue $ J.String "Zeca Pagodinho")]]
|
||||
)
|
||||
]
|
||||
@ -291,87 +292,88 @@ tests = describe "Object Relationships Tests" $ do
|
||||
|
||||
_mrrRecordedRequest
|
||||
`shouldBe` Just
|
||||
( Query $
|
||||
mkTableRequest
|
||||
( Query
|
||||
$ mkTableRequest
|
||||
(mkTableName "Track")
|
||||
( emptyQuery
|
||||
& API.qFields
|
||||
?~ mkFieldsMap
|
||||
[ ("Name", API.ColumnField (API.ColumnName "Name") $ API.ScalarType "string"),
|
||||
( "Album",
|
||||
API.RelField
|
||||
( API.RelationshipField
|
||||
(API.RelationshipName "Album")
|
||||
( emptyQuery
|
||||
& API.qFields
|
||||
?~ mkFieldsMap
|
||||
[ ( "Artist",
|
||||
API.RelField
|
||||
( API.RelationshipField
|
||||
(API.RelationshipName "Artist")
|
||||
(emptyQuery & API.qFields ?~ mkFieldsMap [("Name", API.ColumnField (API.ColumnName "Name") (API.ScalarType "string"))])
|
||||
)
|
||||
?~ mkFieldsMap
|
||||
[ ("Name", API.ColumnField (API.ColumnName "Name") $ API.ScalarType "string"),
|
||||
( "Album",
|
||||
API.RelField
|
||||
( API.RelationshipField
|
||||
(API.RelationshipName "Album")
|
||||
( emptyQuery
|
||||
& API.qFields
|
||||
?~ mkFieldsMap
|
||||
[ ( "Artist",
|
||||
API.RelField
|
||||
( API.RelationshipField
|
||||
(API.RelationshipName "Artist")
|
||||
(emptyQuery & API.qFields ?~ mkFieldsMap [("Name", API.ColumnField (API.ColumnName "Name") (API.ScalarType "string"))])
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
]
|
||||
& API.qLimit ?~ 1
|
||||
& API.qOrderBy
|
||||
?~ API.OrderBy
|
||||
( HashMap.fromList
|
||||
[ ( API.RelationshipName "Album",
|
||||
API.OrderByRelation
|
||||
Nothing
|
||||
( HashMap.fromList
|
||||
[ ( API.RelationshipName "Artist",
|
||||
API.OrderByRelation
|
||||
Nothing
|
||||
mempty
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
]
|
||||
& API.qLimit
|
||||
?~ 1
|
||||
& API.qOrderBy
|
||||
?~ API.OrderBy
|
||||
( HashMap.fromList
|
||||
[ ( API.RelationshipName "Album",
|
||||
API.OrderByRelation
|
||||
Nothing
|
||||
( HashMap.fromList
|
||||
[ ( API.RelationshipName "Artist",
|
||||
API.OrderByRelation
|
||||
Nothing
|
||||
mempty
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
]
|
||||
)
|
||||
( NE.fromList
|
||||
[ API.OrderByElement [API.RelationshipName "Album", API.RelationshipName "Artist"] (API.OrderByColumn (API.ColumnName "Name")) API.Descending,
|
||||
API.OrderByElement [] (API.OrderByColumn (API.ColumnName "Name")) API.Ascending
|
||||
]
|
||||
)
|
||||
)
|
||||
& API.qrRelationships
|
||||
.~ Set.fromList
|
||||
[ API.RTable
|
||||
API.TableRelationships
|
||||
{ _trelSourceTable = mkTableName "Track",
|
||||
_trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "Album",
|
||||
API.Relationship
|
||||
{ _rTargetTable = mkTableName "Album",
|
||||
_rRelationshipType = API.ObjectRelationship,
|
||||
_rColumnMapping = HashMap.fromList [(API.ColumnName "AlbumId", API.ColumnName "AlbumId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
)
|
||||
( NE.fromList
|
||||
[ API.OrderByElement [API.RelationshipName "Album", API.RelationshipName "Artist"] (API.OrderByColumn (API.ColumnName "Name")) API.Descending,
|
||||
API.OrderByElement [] (API.OrderByColumn (API.ColumnName "Name")) API.Ascending
|
||||
},
|
||||
API.RTable
|
||||
API.TableRelationships
|
||||
{ _trelSourceTable = mkTableName "Album",
|
||||
_trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "Artist",
|
||||
API.Relationship
|
||||
{ _rTargetTable = mkTableName "Artist",
|
||||
_rRelationshipType = API.ObjectRelationship,
|
||||
_rColumnMapping = HashMap.fromList [(API.ColumnName "ArtistId", API.ColumnName "ArtistId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
& API.qrRelationships
|
||||
.~ Set.fromList
|
||||
[ API.RTable
|
||||
API.TableRelationships
|
||||
{ _trelSourceTable = mkTableName "Track",
|
||||
_trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "Album",
|
||||
API.Relationship
|
||||
{ _rTargetTable = mkTableName "Album",
|
||||
_rRelationshipType = API.ObjectRelationship,
|
||||
_rColumnMapping = HashMap.fromList [(API.ColumnName "AlbumId", API.ColumnName "AlbumId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
},
|
||||
API.RTable
|
||||
API.TableRelationships
|
||||
{ _trelSourceTable = mkTableName "Album",
|
||||
_trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "Artist",
|
||||
API.Relationship
|
||||
{ _rTargetTable = mkTableName "Artist",
|
||||
_rRelationshipType = API.ObjectRelationship,
|
||||
_rColumnMapping = HashMap.fromList [(API.ColumnName "ArtistId", API.ColumnName "ArtistId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
mockAgentGraphqlTest "works with an order by that navigates a relationship with table permissions" $ \_testEnv performGraphqlRequest -> do
|
||||
@ -402,69 +404,71 @@ tests = describe "Object Relationships Tests" $ do
|
||||
|
||||
_mrrRecordedRequest
|
||||
`shouldBe` Just
|
||||
( Query $
|
||||
mkTableRequest
|
||||
( Query
|
||||
$ mkTableRequest
|
||||
(mkTableName "Employee")
|
||||
( emptyQuery
|
||||
& API.qFields ?~ mkFieldsMap [("EmployeeId", API.ColumnField (API.ColumnName "EmployeeId") $ API.ScalarType "number")]
|
||||
& API.qLimit ?~ 1
|
||||
& API.qWhere
|
||||
?~ API.Exists
|
||||
(API.RelatedTable $ API.RelationshipName "SupportRepForCustomers")
|
||||
( API.ApplyBinaryComparisonOperator
|
||||
API.Equal
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "Country") $ API.ScalarType "string")
|
||||
(API.AnotherColumnComparison (API.ComparisonColumn API.QueryTable (API.ColumnName "Country") $ API.ScalarType "string"))
|
||||
)
|
||||
& API.qOrderBy
|
||||
?~ API.OrderBy
|
||||
( HashMap.fromList
|
||||
[ ( API.RelationshipName "SupportRepForCustomers",
|
||||
API.OrderByRelation
|
||||
( Just $
|
||||
API.Exists (API.RelatedTable $ API.RelationshipName "SupportRep") $
|
||||
API.ApplyBinaryComparisonOperator
|
||||
API.Equal
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "Country") $ API.ScalarType "string")
|
||||
(API.AnotherColumnComparison (API.ComparisonColumn API.QueryTable (API.ColumnName "Country") $ API.ScalarType "string"))
|
||||
)
|
||||
mempty
|
||||
& API.qFields
|
||||
?~ mkFieldsMap [("EmployeeId", API.ColumnField (API.ColumnName "EmployeeId") $ API.ScalarType "number")]
|
||||
& API.qLimit
|
||||
?~ 1
|
||||
& API.qWhere
|
||||
?~ API.Exists
|
||||
(API.RelatedTable $ API.RelationshipName "SupportRepForCustomers")
|
||||
( API.ApplyBinaryComparisonOperator
|
||||
API.Equal
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "Country") $ API.ScalarType "string")
|
||||
(API.AnotherColumnComparison (API.ComparisonColumn API.QueryTable (API.ColumnName "Country") $ API.ScalarType "string"))
|
||||
)
|
||||
& API.qOrderBy
|
||||
?~ API.OrderBy
|
||||
( HashMap.fromList
|
||||
[ ( API.RelationshipName "SupportRepForCustomers",
|
||||
API.OrderByRelation
|
||||
( Just
|
||||
$ API.Exists (API.RelatedTable $ API.RelationshipName "SupportRep")
|
||||
$ API.ApplyBinaryComparisonOperator
|
||||
API.Equal
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "Country") $ API.ScalarType "string")
|
||||
(API.AnotherColumnComparison (API.ComparisonColumn API.QueryTable (API.ColumnName "Country") $ API.ScalarType "string"))
|
||||
)
|
||||
mempty
|
||||
)
|
||||
]
|
||||
)
|
||||
(API.OrderByElement [API.RelationshipName "SupportRepForCustomers"] API.OrderByStarCountAggregate API.Descending :| [])
|
||||
)
|
||||
& API.qrRelationships
|
||||
.~ Set.fromList
|
||||
[ API.RTable
|
||||
API.TableRelationships
|
||||
{ _trelSourceTable = mkTableName "Customer",
|
||||
_trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "SupportRep",
|
||||
API.Relationship
|
||||
{ _rTargetTable = mkTableName "Employee",
|
||||
_rRelationshipType = API.ObjectRelationship,
|
||||
_rColumnMapping = HashMap.fromList [(API.ColumnName "SupportRepId", API.ColumnName "EmployeeId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
)
|
||||
(API.OrderByElement [API.RelationshipName "SupportRepForCustomers"] API.OrderByStarCountAggregate API.Descending :| [])
|
||||
)
|
||||
& API.qrRelationships
|
||||
.~ Set.fromList
|
||||
[ API.RTable
|
||||
API.TableRelationships
|
||||
{ _trelSourceTable = mkTableName "Customer",
|
||||
_trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "SupportRep",
|
||||
API.Relationship
|
||||
{ _rTargetTable = mkTableName "Employee",
|
||||
_rRelationshipType = API.ObjectRelationship,
|
||||
_rColumnMapping = HashMap.fromList [(API.ColumnName "SupportRepId", API.ColumnName "EmployeeId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
},
|
||||
API.RTable
|
||||
API.TableRelationships
|
||||
{ _trelSourceTable = mkTableName "Employee",
|
||||
_trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "SupportRepForCustomers",
|
||||
API.Relationship
|
||||
{ _rTargetTable = mkTableName "Customer",
|
||||
_rRelationshipType = API.ArrayRelationship,
|
||||
_rColumnMapping = HashMap.fromList [(API.ColumnName "EmployeeId", API.ColumnName "SupportRepId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
API.RTable
|
||||
API.TableRelationships
|
||||
{ _trelSourceTable = mkTableName "Employee",
|
||||
_trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "SupportRepForCustomers",
|
||||
API.Relationship
|
||||
{ _rTargetTable = mkTableName "Customer",
|
||||
_rRelationshipType = API.ArrayRelationship,
|
||||
_rColumnMapping = HashMap.fromList [(API.ColumnName "EmployeeId", API.ColumnName "SupportRepId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
@ -474,7 +478,9 @@ noRelationshipsCapabilityMockConfig =
|
||||
Mock.chinookMock
|
||||
{ Mock._capabilitiesResponse =
|
||||
Mock._capabilitiesResponse Mock.chinookMock
|
||||
& API.crCapabilities . API.cRelationships .~ Nothing -- Remove relationships capability
|
||||
& API.crCapabilities
|
||||
. API.cRelationships
|
||||
.~ Nothing -- Remove relationships capability
|
||||
}
|
||||
|
||||
noRelationshipsCapabilitySourceMetadata :: J.Value
|
||||
|
@ -111,7 +111,7 @@ postgresTables =
|
||||
pgSourceName :: String
|
||||
pgSourceName = "pg_source"
|
||||
|
||||
setupPostgres :: HasCallStack => TestEnvironment -> IO ()
|
||||
setupPostgres :: (HasCallStack) => TestEnvironment -> IO ()
|
||||
setupPostgres testEnv = do
|
||||
let sourceConfig = Postgres.defaultSourceConfiguration testEnv
|
||||
schemaName = Schema.getSchemaName testEnv
|
||||
@ -142,7 +142,7 @@ setupPostgres testEnv = do
|
||||
name: #{tableName table}
|
||||
|]
|
||||
|
||||
registerRemoteRelationships :: HasCallStack => TestEnvironment -> IO ()
|
||||
registerRemoteRelationships :: (HasCallStack) => TestEnvironment -> IO ()
|
||||
registerRemoteRelationships testEnv = do
|
||||
let mockAgentSourceName = BackendType.backendSourceName Mock.backendTypeMetadata
|
||||
schemaName = Schema.getSchemaName testEnv
|
||||
@ -214,8 +214,8 @@ tests = do
|
||||
let queryResponse =
|
||||
mkRowsQueryResponse
|
||||
[ [ ( "query",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkRowsQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkRowsQueryResponse
|
||||
[ [ ("AlbumId", API.mkColumnFieldValue $ J.Number 1),
|
||||
("Title", API.mkColumnFieldValue $ J.String "For Those About To Rock We Salute You")
|
||||
],
|
||||
@ -226,8 +226,8 @@ tests = do
|
||||
)
|
||||
],
|
||||
[ ( "query",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkRowsQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkRowsQueryResponse
|
||||
[ [ ("AlbumId", API.mkColumnFieldValue $ J.Number 2),
|
||||
("Title", API.mkColumnFieldValue $ J.String "Balls to the Wall")
|
||||
],
|
||||
@ -264,22 +264,22 @@ tests = do
|
||||
|
||||
_mrrRecordedRequest
|
||||
`shouldBe` Just
|
||||
( Query $
|
||||
mkTableRequest
|
||||
( Query
|
||||
$ mkTableRequest
|
||||
(mkTableName "Album")
|
||||
( emptyQuery
|
||||
& API.qFields
|
||||
?~ mkFieldsMap
|
||||
[ ("AlbumId", API.ColumnField (API.ColumnName "AlbumId") $ API.ScalarType "number"),
|
||||
("Title", API.ColumnField (API.ColumnName "Title") $ API.ScalarType "string")
|
||||
]
|
||||
?~ mkFieldsMap
|
||||
[ ("AlbumId", API.ColumnField (API.ColumnName "AlbumId") $ API.ScalarType "number"),
|
||||
("Title", API.ColumnField (API.ColumnName "Title") $ API.ScalarType "string")
|
||||
]
|
||||
)
|
||||
& API._QRTable
|
||||
. API.trForeach
|
||||
?~ NonEmpty.fromList
|
||||
[ HashMap.fromList [(API.ColumnName "ArtistId", API.ScalarValue (J.Number 1) (API.ScalarType "number"))],
|
||||
HashMap.fromList [(API.ColumnName "ArtistId", API.ScalarValue (J.Number 2) (API.ScalarType "number"))]
|
||||
]
|
||||
& API._QRTable
|
||||
. API.trForeach
|
||||
?~ NonEmpty.fromList
|
||||
[ HashMap.fromList [(API.ColumnName "ArtistId", API.ScalarValue (J.Number 1) (API.ScalarType "number"))],
|
||||
HashMap.fromList [(API.ColumnName "ArtistId", API.ScalarValue (J.Number 2) (API.ScalarType "number"))]
|
||||
]
|
||||
)
|
||||
|
||||
mockAgentGraphqlTest "can act as the target of a remote object relationship" $ \testEnv performGraphqlRequest -> do
|
||||
@ -301,8 +301,8 @@ tests = do
|
||||
let queryResponse =
|
||||
mkRowsQueryResponse
|
||||
[ [ ( "query",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkRowsQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkRowsQueryResponse
|
||||
[ [ ("AlbumId", API.mkColumnFieldValue $ J.Number 3),
|
||||
("Title", API.mkColumnFieldValue $ J.String "Restless and Wild")
|
||||
]
|
||||
@ -310,8 +310,8 @@ tests = do
|
||||
)
|
||||
],
|
||||
[ ( "query",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkRowsQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkRowsQueryResponse
|
||||
[ [ ("AlbumId", API.mkColumnFieldValue $ J.Number 1),
|
||||
("Title", API.mkColumnFieldValue $ J.String "For Those About To Rock We Salute You")
|
||||
]
|
||||
@ -319,8 +319,8 @@ tests = do
|
||||
)
|
||||
],
|
||||
[ ( "query",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkRowsQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkRowsQueryResponse
|
||||
[ [ ("AlbumId", API.mkColumnFieldValue $ J.Number 4),
|
||||
("Title", API.mkColumnFieldValue $ J.String "Let There Be Rock")
|
||||
]
|
||||
@ -355,23 +355,23 @@ tests = do
|
||||
|
||||
_mrrRecordedRequest
|
||||
`shouldBe` Just
|
||||
( Query $
|
||||
mkTableRequest
|
||||
( Query
|
||||
$ mkTableRequest
|
||||
(mkTableName "Album")
|
||||
( emptyQuery
|
||||
& API.qFields
|
||||
?~ mkFieldsMap
|
||||
[ ("AlbumId", API.ColumnField (API.ColumnName "AlbumId") $ API.ScalarType "number"),
|
||||
("Title", API.ColumnField (API.ColumnName "Title") $ API.ScalarType "string")
|
||||
]
|
||||
?~ mkFieldsMap
|
||||
[ ("AlbumId", API.ColumnField (API.ColumnName "AlbumId") $ API.ScalarType "number"),
|
||||
("Title", API.ColumnField (API.ColumnName "Title") $ API.ScalarType "string")
|
||||
]
|
||||
)
|
||||
& API._QRTable
|
||||
. API.trForeach
|
||||
?~ NonEmpty.fromList
|
||||
[ HashMap.fromList [(API.ColumnName "AlbumId", API.ScalarValue (J.Number 3) (API.ScalarType "number"))],
|
||||
HashMap.fromList [(API.ColumnName "AlbumId", API.ScalarValue (J.Number 1) (API.ScalarType "number"))],
|
||||
HashMap.fromList [(API.ColumnName "AlbumId", API.ScalarValue (J.Number 4) (API.ScalarType "number"))]
|
||||
]
|
||||
& API._QRTable
|
||||
. API.trForeach
|
||||
?~ NonEmpty.fromList
|
||||
[ HashMap.fromList [(API.ColumnName "AlbumId", API.ScalarValue (J.Number 3) (API.ScalarType "number"))],
|
||||
HashMap.fromList [(API.ColumnName "AlbumId", API.ScalarValue (J.Number 1) (API.ScalarType "number"))],
|
||||
HashMap.fromList [(API.ColumnName "AlbumId", API.ScalarValue (J.Number 4) (API.ScalarType "number"))]
|
||||
]
|
||||
)
|
||||
|
||||
mockAgentGraphqlTest "can act as the target of an aggregation over a remote array relationship" $ \testEnv performGraphqlRequest -> do
|
||||
@ -398,8 +398,8 @@ tests = do
|
||||
let queryResponse =
|
||||
mkRowsQueryResponse
|
||||
[ [ ( "query",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkQueryResponse
|
||||
[ [ ("nodes_AlbumId", API.mkColumnFieldValue $ J.Number 1),
|
||||
("nodes_Title", API.mkColumnFieldValue $ J.String "For Those About To Rock We Salute You")
|
||||
],
|
||||
@ -412,8 +412,8 @@ tests = do
|
||||
)
|
||||
],
|
||||
[ ( "query",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkQueryResponse
|
||||
[ [ ("nodes_AlbumId", API.mkColumnFieldValue $ J.Number 2),
|
||||
("nodes_Title", API.mkColumnFieldValue $ J.String "Balls to the Wall")
|
||||
],
|
||||
@ -458,23 +458,24 @@ tests = do
|
||||
|
||||
_mrrRecordedRequest
|
||||
`shouldBe` Just
|
||||
( Query $
|
||||
mkTableRequest
|
||||
( Query
|
||||
$ mkTableRequest
|
||||
(mkTableName "Album")
|
||||
( emptyQuery
|
||||
& API.qFields
|
||||
?~ mkFieldsMap
|
||||
[ ("nodes_AlbumId", API.ColumnField (API.ColumnName "AlbumId") $ API.ScalarType "number"),
|
||||
("nodes_Title", API.ColumnField (API.ColumnName "Title") $ API.ScalarType "string")
|
||||
]
|
||||
& API.qAggregates ?~ mkFieldsMap [("aggregate_count", API.StarCount)]
|
||||
?~ mkFieldsMap
|
||||
[ ("nodes_AlbumId", API.ColumnField (API.ColumnName "AlbumId") $ API.ScalarType "number"),
|
||||
("nodes_Title", API.ColumnField (API.ColumnName "Title") $ API.ScalarType "string")
|
||||
]
|
||||
& API.qAggregates
|
||||
?~ mkFieldsMap [("aggregate_count", API.StarCount)]
|
||||
)
|
||||
& API._QRTable
|
||||
. API.trForeach
|
||||
?~ NonEmpty.fromList
|
||||
[ HashMap.fromList [(API.ColumnName "ArtistId", API.ScalarValue (J.Number 1) (API.ScalarType "number"))],
|
||||
HashMap.fromList [(API.ColumnName "ArtistId", API.ScalarValue (J.Number 2) (API.ScalarType "number"))]
|
||||
]
|
||||
& API._QRTable
|
||||
. API.trForeach
|
||||
?~ NonEmpty.fromList
|
||||
[ HashMap.fromList [(API.ColumnName "ArtistId", API.ScalarValue (J.Number 1) (API.ScalarType "number"))],
|
||||
HashMap.fromList [(API.ColumnName "ArtistId", API.ScalarValue (J.Number 2) (API.ScalarType "number"))]
|
||||
]
|
||||
)
|
||||
|
||||
errorTests :: SpecWith (TestEnvironment, Mock.MockAgentEnvironment)
|
||||
|
@ -133,16 +133,17 @@ tests = describe "Transformed Configuration Tests" $ do
|
||||
|
||||
_mrrRecordedRequest
|
||||
`shouldBe` Just
|
||||
( Query $
|
||||
mkTableRequest
|
||||
( Query
|
||||
$ mkTableRequest
|
||||
(mkTableName "Album")
|
||||
( emptyQuery
|
||||
& API.qFields
|
||||
?~ mkFieldsMap
|
||||
[ ("id", API.ColumnField (API.ColumnName "AlbumId") $ API.ScalarType "number"),
|
||||
("title", API.ColumnField (API.ColumnName "Title") $ API.ScalarType "string")
|
||||
]
|
||||
& API.qLimit ?~ 1
|
||||
?~ mkFieldsMap
|
||||
[ ("id", API.ColumnField (API.ColumnName "AlbumId") $ API.ScalarType "number"),
|
||||
("title", API.ColumnField (API.ColumnName "Title") $ API.ScalarType "string")
|
||||
]
|
||||
& API.qLimit
|
||||
?~ 1
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -134,8 +134,8 @@ tests = do
|
||||
[ ("updatedRows_TrackId", API.mkColumnFieldValue $ J.Number 3),
|
||||
("updatedRows_Name", API.mkColumnFieldValue $ J.String "Another Name"),
|
||||
( "updatedRows_Genre",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkRowsQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkRowsQueryResponse
|
||||
[ [ ("Name", API.mkColumnFieldValue $ J.String "Rock")
|
||||
]
|
||||
]
|
||||
@ -145,8 +145,8 @@ tests = do
|
||||
[ ("updatedRows_TrackId", API.mkColumnFieldValue $ J.Number 4),
|
||||
("updatedRows_Name", API.mkColumnFieldValue $ J.String "Another Name"),
|
||||
( "updatedRows_Genre",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkRowsQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkRowsQueryResponse
|
||||
[ [ ("Name", API.mkColumnFieldValue $ J.String "Rock")
|
||||
]
|
||||
]
|
||||
@ -156,8 +156,8 @@ tests = do
|
||||
[ ("updatedRows_TrackId", API.mkColumnFieldValue $ J.Number 5),
|
||||
("updatedRows_Name", API.mkColumnFieldValue $ J.String "Another Name"),
|
||||
( "updatedRows_Genre",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkRowsQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkRowsQueryResponse
|
||||
[ [ ("Name", API.mkColumnFieldValue $ J.String "Rock")
|
||||
]
|
||||
]
|
||||
@ -193,78 +193,79 @@ tests = do
|
||||
let expectedRequest =
|
||||
emptyMutationRequest
|
||||
& API.mrTableRelationships
|
||||
.~ Set.fromList
|
||||
[ API.TableRelationships
|
||||
{ API._trelSourceTable = mkTableName "Track",
|
||||
API._trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "Genre",
|
||||
API.Relationship
|
||||
{ API._rTargetTable = mkTableName "Genre",
|
||||
API._rRelationshipType = API.ObjectRelationship,
|
||||
API._rColumnMapping = HashMap.fromList [(API.ColumnName "GenreId", API.ColumnName "GenreId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
& API.mrOperations
|
||||
.~ [ API.UpdateOperation $
|
||||
API.UpdateMutationOperation
|
||||
{ API._umoTable = mkTableName "Track",
|
||||
API._umoUpdates =
|
||||
Set.fromList
|
||||
[ API.SetColumn $
|
||||
API.RowColumnOperatorValue
|
||||
{ API._rcovColumn = API.ColumnName "Name",
|
||||
API._rcovValue = J.String "Another Name",
|
||||
API._rcovValueType = API.ScalarType "string"
|
||||
},
|
||||
API.CustomUpdateColumnOperator (API.UpdateColumnOperatorName [G.name|inc|]) $
|
||||
API.RowColumnOperatorValue
|
||||
{ API._rcovColumn = API.ColumnName "Milliseconds",
|
||||
API._rcovValue = J.Number 1000,
|
||||
API._rcovValueType = API.ScalarType "number"
|
||||
},
|
||||
API.SetColumn $
|
||||
API.RowColumnOperatorValue
|
||||
{ API._rcovColumn = API.ColumnName "AlbumId",
|
||||
API._rcovValue = J.Number 3,
|
||||
API._rcovValueType = API.ScalarType "number"
|
||||
}
|
||||
.~ Set.fromList
|
||||
[ API.TableRelationships
|
||||
{ API._trelSourceTable = mkTableName "Track",
|
||||
API._trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "Genre",
|
||||
API.Relationship
|
||||
{ API._rTargetTable = mkTableName "Genre",
|
||||
API._rRelationshipType = API.ObjectRelationship,
|
||||
API._rColumnMapping = HashMap.fromList [(API.ColumnName "GenreId", API.ColumnName "GenreId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
& API.mrOperations
|
||||
.~ [ API.UpdateOperation
|
||||
$ API.UpdateMutationOperation
|
||||
{ API._umoTable = mkTableName "Track",
|
||||
API._umoUpdates =
|
||||
Set.fromList
|
||||
[ API.SetColumn
|
||||
$ API.RowColumnOperatorValue
|
||||
{ API._rcovColumn = API.ColumnName "Name",
|
||||
API._rcovValue = J.String "Another Name",
|
||||
API._rcovValueType = API.ScalarType "string"
|
||||
},
|
||||
API.CustomUpdateColumnOperator (API.UpdateColumnOperatorName [G.name|inc|])
|
||||
$ API.RowColumnOperatorValue
|
||||
{ API._rcovColumn = API.ColumnName "Milliseconds",
|
||||
API._rcovValue = J.Number 1000,
|
||||
API._rcovValueType = API.ScalarType "number"
|
||||
},
|
||||
API.SetColumn
|
||||
$ API.RowColumnOperatorValue
|
||||
{ API._rcovColumn = API.ColumnName "AlbumId",
|
||||
API._rcovValue = J.Number 3,
|
||||
API._rcovValueType = API.ScalarType "number"
|
||||
}
|
||||
],
|
||||
API._umoWhere =
|
||||
Just
|
||||
. API.And
|
||||
$ Set.fromList
|
||||
[ API.ApplyBinaryComparisonOperator
|
||||
API.Equal
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "AlbumId") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 3) (API.ScalarType "number")),
|
||||
API.ApplyBinaryComparisonOperator
|
||||
API.Equal
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "GenreId") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 1) (API.ScalarType "number"))
|
||||
],
|
||||
API._umoWhere =
|
||||
Just . API.And $
|
||||
Set.fromList
|
||||
[ API.ApplyBinaryComparisonOperator
|
||||
API.Equal
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "AlbumId") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 3) (API.ScalarType "number")),
|
||||
API.ApplyBinaryComparisonOperator
|
||||
API.Equal
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "GenreId") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 1) (API.ScalarType "number"))
|
||||
],
|
||||
API._umoPostUpdateCheck =
|
||||
Just $
|
||||
API.ApplyBinaryComparisonOperator
|
||||
API.GreaterThan
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "UnitPrice") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 0) (API.ScalarType "number")),
|
||||
API._umoReturningFields =
|
||||
mkFieldsMap
|
||||
[ ("updatedRows_TrackId", API.ColumnField (API.ColumnName "TrackId") (API.ScalarType "number")),
|
||||
("updatedRows_Name", API.ColumnField (API.ColumnName "Name") (API.ScalarType "string")),
|
||||
( "updatedRows_Genre",
|
||||
API.RelField
|
||||
( API.RelationshipField
|
||||
(API.RelationshipName "Genre")
|
||||
(emptyQuery & API.qFields ?~ mkFieldsMap [("Name", API.ColumnField (API.ColumnName "Name") $ API.ScalarType "string")])
|
||||
)
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
API._umoPostUpdateCheck =
|
||||
Just
|
||||
$ API.ApplyBinaryComparisonOperator
|
||||
API.GreaterThan
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "UnitPrice") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 0) (API.ScalarType "number")),
|
||||
API._umoReturningFields =
|
||||
mkFieldsMap
|
||||
[ ("updatedRows_TrackId", API.ColumnField (API.ColumnName "TrackId") (API.ScalarType "number")),
|
||||
("updatedRows_Name", API.ColumnField (API.ColumnName "Name") (API.ScalarType "string")),
|
||||
( "updatedRows_Genre",
|
||||
API.RelField
|
||||
( API.RelationshipField
|
||||
(API.RelationshipName "Genre")
|
||||
(emptyQuery & API.qFields ?~ mkFieldsMap [("Name", API.ColumnField (API.ColumnName "Name") $ API.ScalarType "string")])
|
||||
)
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
_mrrRecordedRequest `shouldBe` Just (Mutation expectedRequest)
|
||||
|
||||
mockAgentGraphqlTest "update_many rows with update permissions" $ \_testEnv performGraphqlRequest -> do
|
||||
@ -297,8 +298,8 @@ tests = do
|
||||
[ ("updatedRows_TrackId", API.mkColumnFieldValue $ J.Number 3),
|
||||
("updatedRows_Name", API.mkColumnFieldValue $ J.String "Another Name"),
|
||||
( "updatedRows_Genre",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkRowsQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkRowsQueryResponse
|
||||
[ [ ("Name", API.mkColumnFieldValue $ J.String "Rock")
|
||||
]
|
||||
]
|
||||
@ -314,8 +315,8 @@ tests = do
|
||||
[ ("updatedRows_TrackId", API.mkColumnFieldValue $ J.Number 4),
|
||||
("updatedRows_Name", API.mkColumnFieldValue $ J.String "Better Name"),
|
||||
( "updatedRows_Genre",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkRowsQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkRowsQueryResponse
|
||||
[ [ ("Name", API.mkColumnFieldValue $ J.String "Rock")
|
||||
]
|
||||
]
|
||||
@ -325,8 +326,8 @@ tests = do
|
||||
[ ("updatedRows_TrackId", API.mkColumnFieldValue $ J.Number 5),
|
||||
("updatedRows_Name", API.mkColumnFieldValue $ J.String "Better Name"),
|
||||
( "updatedRows_Genre",
|
||||
API.mkRelationshipFieldValue $
|
||||
mkRowsQueryResponse
|
||||
API.mkRelationshipFieldValue
|
||||
$ mkRowsQueryResponse
|
||||
[ [ ("Name", API.mkColumnFieldValue $ J.String "Rock")
|
||||
]
|
||||
]
|
||||
@ -362,8 +363,8 @@ tests = do
|
||||
|]
|
||||
|
||||
let sharedPostUpdateCheck =
|
||||
Just $
|
||||
API.ApplyBinaryComparisonOperator
|
||||
Just
|
||||
$ API.ApplyBinaryComparisonOperator
|
||||
API.GreaterThan
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "UnitPrice") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 0) (API.ScalarType "number"))
|
||||
@ -382,99 +383,101 @@ tests = do
|
||||
let expectedRequest =
|
||||
emptyMutationRequest
|
||||
& API.mrTableRelationships
|
||||
.~ Set.fromList
|
||||
[ API.TableRelationships
|
||||
{ API._trelSourceTable = mkTableName "Track",
|
||||
API._trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "Genre",
|
||||
API.Relationship
|
||||
{ API._rTargetTable = mkTableName "Genre",
|
||||
API._rRelationshipType = API.ObjectRelationship,
|
||||
API._rColumnMapping = HashMap.fromList [(API.ColumnName "GenreId", API.ColumnName "GenreId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
& API.mrOperations
|
||||
.~ [ API.UpdateOperation $
|
||||
API.UpdateMutationOperation
|
||||
{ API._umoTable = mkTableName "Track",
|
||||
API._umoUpdates =
|
||||
Set.fromList
|
||||
[ API.SetColumn $
|
||||
API.RowColumnOperatorValue
|
||||
{ API._rcovColumn = API.ColumnName "Name",
|
||||
API._rcovValue = J.String "Another Name",
|
||||
API._rcovValueType = API.ScalarType "string"
|
||||
},
|
||||
API.CustomUpdateColumnOperator (API.UpdateColumnOperatorName [G.name|inc|]) $
|
||||
API.RowColumnOperatorValue
|
||||
{ API._rcovColumn = API.ColumnName "Milliseconds",
|
||||
API._rcovValue = J.Number 1000,
|
||||
API._rcovValueType = API.ScalarType "number"
|
||||
},
|
||||
API.SetColumn $
|
||||
API.RowColumnOperatorValue
|
||||
{ API._rcovColumn = API.ColumnName "AlbumId",
|
||||
API._rcovValue = J.Number 3,
|
||||
API._rcovValueType = API.ScalarType "number"
|
||||
}
|
||||
.~ Set.fromList
|
||||
[ API.TableRelationships
|
||||
{ API._trelSourceTable = mkTableName "Track",
|
||||
API._trelRelationships =
|
||||
HashMap.fromList
|
||||
[ ( API.RelationshipName "Genre",
|
||||
API.Relationship
|
||||
{ API._rTargetTable = mkTableName "Genre",
|
||||
API._rRelationshipType = API.ObjectRelationship,
|
||||
API._rColumnMapping = HashMap.fromList [(API.ColumnName "GenreId", API.ColumnName "GenreId")]
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
& API.mrOperations
|
||||
.~ [ API.UpdateOperation
|
||||
$ API.UpdateMutationOperation
|
||||
{ API._umoTable = mkTableName "Track",
|
||||
API._umoUpdates =
|
||||
Set.fromList
|
||||
[ API.SetColumn
|
||||
$ API.RowColumnOperatorValue
|
||||
{ API._rcovColumn = API.ColumnName "Name",
|
||||
API._rcovValue = J.String "Another Name",
|
||||
API._rcovValueType = API.ScalarType "string"
|
||||
},
|
||||
API.CustomUpdateColumnOperator (API.UpdateColumnOperatorName [G.name|inc|])
|
||||
$ API.RowColumnOperatorValue
|
||||
{ API._rcovColumn = API.ColumnName "Milliseconds",
|
||||
API._rcovValue = J.Number 1000,
|
||||
API._rcovValueType = API.ScalarType "number"
|
||||
},
|
||||
API.SetColumn
|
||||
$ API.RowColumnOperatorValue
|
||||
{ API._rcovColumn = API.ColumnName "AlbumId",
|
||||
API._rcovValue = J.Number 3,
|
||||
API._rcovValueType = API.ScalarType "number"
|
||||
}
|
||||
],
|
||||
API._umoWhere =
|
||||
Just
|
||||
. API.And
|
||||
$ Set.fromList
|
||||
[ API.ApplyBinaryComparisonOperator
|
||||
API.Equal
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "AlbumId") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 3) (API.ScalarType "number")),
|
||||
API.ApplyBinaryComparisonOperator
|
||||
API.Equal
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "TrackId") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 3) (API.ScalarType "number"))
|
||||
],
|
||||
API._umoWhere =
|
||||
Just . API.And $
|
||||
Set.fromList
|
||||
[ API.ApplyBinaryComparisonOperator
|
||||
API.Equal
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "AlbumId") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 3) (API.ScalarType "number")),
|
||||
API.ApplyBinaryComparisonOperator
|
||||
API.Equal
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "TrackId") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 3) (API.ScalarType "number"))
|
||||
],
|
||||
API._umoPostUpdateCheck = sharedPostUpdateCheck,
|
||||
API._umoReturningFields = sharedReturning
|
||||
},
|
||||
API.UpdateOperation $
|
||||
API.UpdateMutationOperation
|
||||
{ API._umoTable = mkTableName "Track",
|
||||
API._umoUpdates =
|
||||
Set.fromList
|
||||
[ API.SetColumn $
|
||||
API.RowColumnOperatorValue
|
||||
{ API._rcovColumn = API.ColumnName "Name",
|
||||
API._rcovValue = J.String "Better Name",
|
||||
API._rcovValueType = API.ScalarType "string"
|
||||
},
|
||||
API.CustomUpdateColumnOperator (API.UpdateColumnOperatorName [G.name|inc|]) $
|
||||
API.RowColumnOperatorValue
|
||||
{ API._rcovColumn = API.ColumnName "UnitPrice",
|
||||
API._rcovValue = J.Number 1,
|
||||
API._rcovValueType = API.ScalarType "number"
|
||||
},
|
||||
API.SetColumn $
|
||||
API.RowColumnOperatorValue
|
||||
{ API._rcovColumn = API.ColumnName "AlbumId",
|
||||
API._rcovValue = J.Number 3,
|
||||
API._rcovValueType = API.ScalarType "number"
|
||||
}
|
||||
API._umoPostUpdateCheck = sharedPostUpdateCheck,
|
||||
API._umoReturningFields = sharedReturning
|
||||
},
|
||||
API.UpdateOperation
|
||||
$ API.UpdateMutationOperation
|
||||
{ API._umoTable = mkTableName "Track",
|
||||
API._umoUpdates =
|
||||
Set.fromList
|
||||
[ API.SetColumn
|
||||
$ API.RowColumnOperatorValue
|
||||
{ API._rcovColumn = API.ColumnName "Name",
|
||||
API._rcovValue = J.String "Better Name",
|
||||
API._rcovValueType = API.ScalarType "string"
|
||||
},
|
||||
API.CustomUpdateColumnOperator (API.UpdateColumnOperatorName [G.name|inc|])
|
||||
$ API.RowColumnOperatorValue
|
||||
{ API._rcovColumn = API.ColumnName "UnitPrice",
|
||||
API._rcovValue = J.Number 1,
|
||||
API._rcovValueType = API.ScalarType "number"
|
||||
},
|
||||
API.SetColumn
|
||||
$ API.RowColumnOperatorValue
|
||||
{ API._rcovColumn = API.ColumnName "AlbumId",
|
||||
API._rcovValue = J.Number 3,
|
||||
API._rcovValueType = API.ScalarType "number"
|
||||
}
|
||||
],
|
||||
API._umoWhere =
|
||||
Just
|
||||
. API.And
|
||||
$ Set.fromList
|
||||
[ API.ApplyBinaryComparisonOperator
|
||||
API.Equal
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "AlbumId") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 3) (API.ScalarType "number")),
|
||||
API.ApplyBinaryComparisonOperator
|
||||
API.GreaterThan
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "TrackId") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 3) (API.ScalarType "number"))
|
||||
],
|
||||
API._umoWhere =
|
||||
Just . API.And $
|
||||
Set.fromList
|
||||
[ API.ApplyBinaryComparisonOperator
|
||||
API.Equal
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "AlbumId") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 3) (API.ScalarType "number")),
|
||||
API.ApplyBinaryComparisonOperator
|
||||
API.GreaterThan
|
||||
(API.ComparisonColumn API.CurrentTable (API.ColumnName "TrackId") $ API.ScalarType "number")
|
||||
(API.ScalarValueComparison $ API.ScalarValue (J.Number 3) (API.ScalarType "number"))
|
||||
],
|
||||
API._umoPostUpdateCheck = sharedPostUpdateCheck,
|
||||
API._umoReturningFields = sharedReturning
|
||||
}
|
||||
]
|
||||
API._umoPostUpdateCheck = sharedPostUpdateCheck,
|
||||
API._umoReturningFields = sharedReturning
|
||||
}
|
||||
]
|
||||
_mrrRecordedRequest `shouldBe` Just (Mutation expectedRequest)
|
||||
|
@ -98,8 +98,8 @@ setupFunction testEnv =
|
||||
let schemaName = Schema.getSchemaName testEnv
|
||||
in [ Fixture.SetupAction
|
||||
{ Fixture.setupAction =
|
||||
BigQuery.run_ $
|
||||
[i|
|
||||
BigQuery.run_
|
||||
$ [i|
|
||||
CREATE TABLE FUNCTION #{ unSchemaName schemaName }.fetch_articles_implicit_return(a_id INT64, search STRING)
|
||||
AS
|
||||
SELECT article_alias.*
|
||||
@ -111,8 +111,8 @@ setupFunction testEnv =
|
||||
},
|
||||
Fixture.SetupAction
|
||||
{ Fixture.setupAction =
|
||||
BigQuery.run_ $
|
||||
[i|
|
||||
BigQuery.run_
|
||||
$ [i|
|
||||
CREATE TABLE FUNCTION #{ unSchemaName schemaName }.fetch_articles_explicit_return(a_id INT64, search STRING)
|
||||
RETURNS TABLE<id INT64, title STRING, content STRING, author_id INT64> AS
|
||||
SELECT article_alias.id, article_alias.title, article_alias.content, article_alias.author_id
|
||||
|
@ -49,8 +49,8 @@ spec =
|
||||
|
||||
jsonType :: Schema.ScalarType
|
||||
jsonType =
|
||||
Schema.TCustomType $
|
||||
Schema.defaultBackendScalarType
|
||||
Schema.TCustomType
|
||||
$ Schema.defaultBackendScalarType
|
||||
{ Schema.bstPostgres = Just "JSON",
|
||||
Schema.bstCitus = Just "JSON",
|
||||
Schema.bstCockroach = Just "JSON"
|
||||
@ -58,8 +58,8 @@ jsonType =
|
||||
|
||||
jsonbType :: Schema.ScalarType
|
||||
jsonbType =
|
||||
Schema.TCustomType $
|
||||
Schema.defaultBackendScalarType
|
||||
Schema.TCustomType
|
||||
$ Schema.defaultBackendScalarType
|
||||
{ Schema.bstPostgres = Just "JSONB",
|
||||
Schema.bstCitus = Just "JSONB",
|
||||
Schema.bstCockroach = Just "JSONB"
|
||||
@ -67,8 +67,8 @@ jsonbType =
|
||||
|
||||
mkJsonValue :: Text -> Schema.ScalarValue
|
||||
mkJsonValue json =
|
||||
Schema.VCustomValue $
|
||||
Schema.defaultBackendScalarValue
|
||||
Schema.VCustomValue
|
||||
$ Schema.defaultBackendScalarValue
|
||||
{ Schema.bsvPostgres = Just (Schema.Quoted json),
|
||||
Schema.bsvCitus = Just (Schema.Quoted json),
|
||||
Schema.bsvCockroach = Just (Schema.Quoted json)
|
||||
|
@ -70,8 +70,8 @@ schema =
|
||||
|
||||
defaultDateTimeType :: Schema.ScalarType
|
||||
defaultDateTimeType =
|
||||
Schema.TCustomType $
|
||||
Schema.defaultBackendScalarType
|
||||
Schema.TCustomType
|
||||
$ Schema.defaultBackendScalarType
|
||||
{ Schema.bstMssql = Just "DATETIME DEFAULT GETDATE()",
|
||||
Schema.bstCitus = Just "TIMESTAMP DEFAULT NOW()",
|
||||
Schema.bstPostgres = Just "TIMESTAMP DEFAULT NOW()",
|
||||
|
@ -82,8 +82,8 @@ schema = [dummyTable]
|
||||
tests :: SpecWith (TestEnvironment, (GraphqlEngine.Server, Webhook.EventsQueue))
|
||||
tests =
|
||||
describe "special characters of different languages in event trigger payload are encoded in UTF-8" do
|
||||
it "check: inserting a new row invokes a event trigger" $
|
||||
\(testEnvironment, (_, (Webhook.EventsQueue eventsQueue))) -> do
|
||||
it "check: inserting a new row invokes a event trigger"
|
||||
$ \(testEnvironment, (_, (Webhook.EventsQueue eventsQueue))) -> do
|
||||
let backendTypeMetadata = fromMaybe (error "Expected a backend type but got nothing") $ getBackendTypeConfig testEnvironment
|
||||
sourceName = BackendType.backendSourceName backendTypeMetadata
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
@ -166,8 +166,8 @@ dbSetup testEnvironment webhookServer = do
|
||||
|
||||
-- Track table using custom_name for the special character column since GraphQL
|
||||
-- spec does not support special characters
|
||||
GraphqlEngine.postMetadata_ testEnvironment $
|
||||
[interpolateYaml|
|
||||
GraphqlEngine.postMetadata_ testEnvironment
|
||||
$ [interpolateYaml|
|
||||
type: bulk
|
||||
args:
|
||||
- type: #{backendPrefix}_track_table
|
||||
|
@ -75,8 +75,8 @@ authorsTable tableName =
|
||||
tests :: SpecWith (TestEnvironment, (GraphqlEngine.Server, Webhook.EventsQueue))
|
||||
tests =
|
||||
describe "dropping a source with event triggers should remove 'hdb_catalog' schema and the SQL triggers created on the table" do
|
||||
it "check: inserting a new row invokes a event trigger" $
|
||||
\(testEnvironment, (_, (Webhook.EventsQueue eventsQueue))) -> do
|
||||
it "check: inserting a new row invokes a event trigger"
|
||||
$ \(testEnvironment, (_, (Webhook.EventsQueue eventsQueue))) -> do
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
insertQuery =
|
||||
@ -115,8 +115,8 @@ tests =
|
||||
|
||||
eventPayload `shouldBeYaml` expectedEventPayload
|
||||
|
||||
it "drop source, check the table works as it was before event trigger was created on it" $
|
||||
\(testEnvironment, _) -> do
|
||||
it "drop source, check the table works as it was before event trigger was created on it"
|
||||
$ \(testEnvironment, _) -> do
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
let dropSourceQuery =
|
||||
@ -184,8 +184,8 @@ mssqlSetupWithEventTriggers testEnvironment webhookServer = do
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
webhookServerEchoEndpoint = GraphqlEngine.serverUrl webhookServer ++ "/echo"
|
||||
GraphqlEngine.postMetadata_ testEnvironment $
|
||||
[interpolateYaml|
|
||||
GraphqlEngine.postMetadata_ testEnvironment
|
||||
$ [interpolateYaml|
|
||||
type: bulk
|
||||
args:
|
||||
- type: mssql_create_event_trigger
|
||||
|
@ -77,8 +77,8 @@ tests =
|
||||
-- The test checks that the event trigger retries as expected. In the test, we fire up the event trigger by adding a
|
||||
-- row to the table. We wait for a few seconds so the event has retried completely and then see if the number of
|
||||
-- retries are 2 (the event retries once)
|
||||
it "check: the total number of tries is (number of retries + 1)" $
|
||||
\(testEnvironment, (_, (Webhook.EventsQueue eventsQueue))) -> do
|
||||
it "check: the total number of tries is (number of retries + 1)"
|
||||
$ \(testEnvironment, (_, (Webhook.EventsQueue eventsQueue))) -> do
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
insertQuery =
|
||||
@ -154,8 +154,8 @@ mssqlSetupWithEventTriggers testEnvironment webhookServer = do
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
webhookServerNextRetryEndpoint = GraphqlEngine.serverUrl webhookServer ++ "/nextRetry"
|
||||
GraphqlEngine.postMetadata_ testEnvironment $
|
||||
[interpolateYaml|
|
||||
GraphqlEngine.postMetadata_ testEnvironment
|
||||
$ [interpolateYaml|
|
||||
type: bulk
|
||||
args:
|
||||
- type: mssql_create_event_trigger
|
||||
@ -175,8 +175,8 @@ mssqlSetupWithEventTriggers testEnvironment webhookServer = do
|
||||
|
||||
mssqlTeardown :: TestEnvironment -> IO ()
|
||||
mssqlTeardown testEnvironment = do
|
||||
GraphqlEngine.postMetadata_ testEnvironment $
|
||||
[yaml|
|
||||
GraphqlEngine.postMetadata_ testEnvironment
|
||||
$ [yaml|
|
||||
type: bulk
|
||||
args:
|
||||
- type: mssql_delete_event_trigger
|
||||
|
@ -83,8 +83,8 @@ articlesTable tableName =
|
||||
tests :: SpecWith (TestEnvironment, (GraphqlEngine.Server, Webhook.EventsQueue))
|
||||
tests =
|
||||
describe "verify trigger status when logical replication is used" do
|
||||
it "verify trigger is enabled on logical replication" $
|
||||
\(testEnvironment, (webhookServer, (Webhook.EventsQueue _eventsQueue))) -> do
|
||||
it "verify trigger is enabled on logical replication"
|
||||
$ \(testEnvironment, (webhookServer, (Webhook.EventsQueue _eventsQueue))) -> do
|
||||
mssqlSetupWithEventTriggers testEnvironment webhookServer "True"
|
||||
let getTriggerInfoQuery =
|
||||
[interpolateYaml|
|
||||
@ -116,8 +116,8 @@ tests =
|
||||
(GraphqlEngine.postV2Query 200 testEnvironment getTriggerInfoQuery)
|
||||
expectedResponseForEnablingTriggers
|
||||
|
||||
it "verify trigger is disabled on logical replication" $
|
||||
\(testEnvironment, (webhookServer, (Webhook.EventsQueue _eventsQueue))) -> do
|
||||
it "verify trigger is disabled on logical replication"
|
||||
$ \(testEnvironment, (webhookServer, (Webhook.EventsQueue _eventsQueue))) -> do
|
||||
mssqlSetupWithEventTriggers testEnvironment webhookServer "False"
|
||||
let getTriggerInfoQuery =
|
||||
[interpolateYaml|
|
||||
@ -158,8 +158,8 @@ mssqlSetupWithEventTriggers testEnvironment webhookServer triggerOnReplication =
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
webhookServerEchoEndpoint = GraphqlEngine.serverUrl webhookServer ++ "/echo"
|
||||
GraphqlEngine.postMetadata_ testEnvironment $
|
||||
[interpolateYaml|
|
||||
GraphqlEngine.postMetadata_ testEnvironment
|
||||
$ [interpolateYaml|
|
||||
type: bulk
|
||||
args:
|
||||
- type: mssql_create_event_trigger
|
||||
@ -181,8 +181,8 @@ mssqlSetupWithEventTriggers testEnvironment webhookServer triggerOnReplication =
|
||||
|
||||
mssqlTeardown :: TestEnvironment -> IO ()
|
||||
mssqlTeardown testEnvironment = do
|
||||
GraphqlEngine.postMetadata_ testEnvironment $
|
||||
[yaml|
|
||||
GraphqlEngine.postMetadata_ testEnvironment
|
||||
$ [yaml|
|
||||
type: mssql_delete_event_trigger
|
||||
args:
|
||||
name: author_trigger
|
||||
|
@ -69,8 +69,8 @@ authorsTable tableName =
|
||||
|
||||
tests :: SpecWith (TestEnvironment, (GraphqlEngine.Server, Webhook.EventsQueue))
|
||||
tests = describe "weird trigger names are allowed" do
|
||||
it "metadata_api: allow creating an event trigger with weird name via replace_metadata" $
|
||||
\(testEnvironment, (webhookServer, _)) -> do
|
||||
it "metadata_api: allow creating an event trigger with weird name via replace_metadata"
|
||||
$ \(testEnvironment, (webhookServer, _)) -> do
|
||||
let createEventTriggerWithWeirdName =
|
||||
addEventTriggerViaReplaceMetadata testEnvironment "weird]name]" webhookServer
|
||||
createEventTriggerWithWeirdNameExpectedResponse =
|
||||
|
@ -87,8 +87,8 @@ articlesTable tableName =
|
||||
tests :: SpecWith (TestEnvironment, (GraphqlEngine.Server, Webhook.EventsQueue))
|
||||
tests =
|
||||
describe "only unique trigger names are allowed" do
|
||||
it "check: inserting a new row invokes a event trigger" $
|
||||
\(testEnvironment, (_, (Webhook.EventsQueue eventsQueue))) -> do
|
||||
it "check: inserting a new row invokes a event trigger"
|
||||
$ \(testEnvironment, (_, (Webhook.EventsQueue eventsQueue))) -> do
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
insertQuery =
|
||||
@ -127,8 +127,8 @@ tests =
|
||||
|
||||
eventPayload `shouldBeYaml` expectedEventPayload
|
||||
|
||||
it "metadata_api: does not allow creating an event trigger with a name that already exists" $
|
||||
\(testEnvironment, (webhookServer, _)) -> do
|
||||
it "metadata_api: does not allow creating an event trigger with a name that already exists"
|
||||
$ \(testEnvironment, (webhookServer, _)) -> do
|
||||
-- metadata <- GraphqlEngine.exportMetadata testEnvironment
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
@ -160,8 +160,8 @@ tests =
|
||||
(GraphqlEngine.postWithHeadersStatus 400 testEnvironment "/v1/metadata/" mempty createEventTriggerWithDuplicateName)
|
||||
createEventTriggerWithDuplicateNameExpectedResponse
|
||||
|
||||
it "replace_metadata: does not allow creating an event trigger with a name that already exists" $
|
||||
\(testEnvironment, (webhookServer, _)) -> do
|
||||
it "replace_metadata: does not allow creating an event trigger with a name that already exists"
|
||||
$ \(testEnvironment, (webhookServer, _)) -> do
|
||||
let replaceMetadata = getReplaceMetadata testEnvironment webhookServer
|
||||
|
||||
replaceMetadataWithDuplicateNameExpectedResponse =
|
||||
@ -186,8 +186,8 @@ mssqlSetupWithEventTriggers testEnvironment webhookServer = do
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
webhookServerEchoEndpoint = GraphqlEngine.serverUrl webhookServer ++ "/echo"
|
||||
GraphqlEngine.postMetadata_ testEnvironment $
|
||||
[interpolateYaml|
|
||||
GraphqlEngine.postMetadata_ testEnvironment
|
||||
$ [interpolateYaml|
|
||||
type: bulk
|
||||
args:
|
||||
- type: mssql_create_event_trigger
|
||||
@ -251,8 +251,8 @@ getReplaceMetadata testEnvironment webhookServer =
|
||||
|
||||
mssqlTeardown :: TestEnvironment -> IO ()
|
||||
mssqlTeardown testEnvironment = do
|
||||
GraphqlEngine.postMetadata_ testEnvironment $
|
||||
[yaml|
|
||||
GraphqlEngine.postMetadata_ testEnvironment
|
||||
$ [yaml|
|
||||
type: bulk
|
||||
args:
|
||||
- type: mssql_delete_event_trigger
|
||||
|
@ -74,8 +74,8 @@ authorsTable tableName =
|
||||
tests :: SpecWith (TestEnvironment, (GraphqlEngine.Server, Webhook.EventsQueue))
|
||||
tests =
|
||||
describe "untrack a table with event triggers should remove the SQL triggers created on the table" do
|
||||
it "check: inserting a new row invokes a event trigger" $
|
||||
\(testEnvironment, (_, (Webhook.EventsQueue eventsQueue))) -> do
|
||||
it "check: inserting a new row invokes a event trigger"
|
||||
$ \(testEnvironment, (_, (Webhook.EventsQueue eventsQueue))) -> do
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
insertQuery =
|
||||
@ -114,8 +114,8 @@ tests =
|
||||
|
||||
eventPayload `shouldBeYaml` expectedEventPayload
|
||||
|
||||
it "untrack table, check the SQL triggers are deleted from the table" $
|
||||
\(testEnvironment, _) -> do
|
||||
it "untrack table, check the SQL triggers are deleted from the table"
|
||||
$ \(testEnvironment, _) -> do
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
untrackTableQuery =
|
||||
@ -178,8 +178,8 @@ mssqlSetup testEnvironment webhookServer = do
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
webhookServerEchoEndpoint = GraphqlEngine.serverUrl webhookServer ++ "/echo"
|
||||
GraphqlEngine.postMetadata_ testEnvironment $
|
||||
[interpolateYaml|
|
||||
GraphqlEngine.postMetadata_ testEnvironment
|
||||
$ [interpolateYaml|
|
||||
type: bulk
|
||||
args:
|
||||
- type: mssql_create_event_trigger
|
||||
|
@ -76,8 +76,8 @@ authorsTable tableName =
|
||||
tests :: SpecWith (TestEnvironment, (GraphqlEngine.Server, Webhook.EventsQueue))
|
||||
tests =
|
||||
describe "doing clear_metadata with an event trigger containing auto cleanup config should succeed" do
|
||||
it "remove source via replace_metadata, check that the event_log table is removed as well" $
|
||||
\(testEnvironment, (_, _)) -> do
|
||||
it "remove source via replace_metadata, check that the event_log table is removed as well"
|
||||
$ \(testEnvironment, (_, _)) -> do
|
||||
-- remove the source using replace_meatadata API
|
||||
let clearMetadata =
|
||||
[yaml|
|
||||
@ -105,8 +105,8 @@ postgresSetup testEnvironment webhookServer = do
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
let webhookServerEchoEndpoint = GraphqlEngine.serverUrl webhookServer ++ "/echo"
|
||||
GraphqlEngine.postMetadata_ testEnvironment $
|
||||
[interpolateYaml|
|
||||
GraphqlEngine.postMetadata_ testEnvironment
|
||||
$ [interpolateYaml|
|
||||
type: bulk
|
||||
args:
|
||||
- type: pg_create_event_trigger
|
||||
|
@ -76,8 +76,8 @@ authorsTable tableName =
|
||||
tests :: SpecWith (TestEnvironment, (GraphqlEngine.Server, Webhook.EventsQueue))
|
||||
tests =
|
||||
describe "event triggers should work when extensions are created in different schema using 'extensions_schema'" do
|
||||
it "check: inserting a new row invokes a event trigger" $
|
||||
\(testEnvironment, (_, (Webhook.EventsQueue eventsQueue))) -> do
|
||||
it "check: inserting a new row invokes a event trigger"
|
||||
$ \(testEnvironment, (_, (Webhook.EventsQueue eventsQueue))) -> do
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
let insertQuery =
|
||||
@ -169,7 +169,7 @@ tests =
|
||||
|
||||
-- ** Setup and teardown override
|
||||
|
||||
postgresSetup :: HasCallStack => TestEnvironment -> GraphqlEngine.Server -> IO ()
|
||||
postgresSetup :: (HasCallStack) => TestEnvironment -> GraphqlEngine.Server -> IO ()
|
||||
postgresSetup testEnvironment webhookServer = do
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
@ -186,8 +186,8 @@ postgresSetup testEnvironment webhookServer = do
|
||||
webhookServerEchoEndpoint = GraphqlEngine.serverUrl webhookServer ++ "/echo"
|
||||
|
||||
-- create a new source
|
||||
GraphqlEngine.postMetadata_ testEnvironment $
|
||||
[yaml|
|
||||
GraphqlEngine.postMetadata_ testEnvironment
|
||||
$ [yaml|
|
||||
type: pg_add_source
|
||||
args:
|
||||
name: *sourceName
|
||||
@ -200,8 +200,8 @@ postgresSetup testEnvironment webhookServer = do
|
||||
Schema.trackTable sourceName theTable testEnvironment
|
||||
|
||||
-- create the event trigger
|
||||
GraphqlEngine.postMetadata_ testEnvironment $
|
||||
[interpolateYaml|
|
||||
GraphqlEngine.postMetadata_ testEnvironment
|
||||
$ [interpolateYaml|
|
||||
type: bulk
|
||||
args:
|
||||
- type: pg_create_event_trigger
|
||||
@ -216,10 +216,10 @@ postgresSetup testEnvironment webhookServer = do
|
||||
columns: "*"
|
||||
|]
|
||||
|
||||
postgresTeardown :: HasCallStack => TestEnvironment -> IO ()
|
||||
postgresTeardown :: (HasCallStack) => TestEnvironment -> IO ()
|
||||
postgresTeardown testEnvironment = do
|
||||
GraphqlEngine.postMetadata_ testEnvironment $
|
||||
[yaml|
|
||||
GraphqlEngine.postMetadata_ testEnvironment
|
||||
$ [yaml|
|
||||
type: bulk
|
||||
args:
|
||||
- type: pg_delete_event_trigger
|
||||
@ -228,8 +228,8 @@ postgresTeardown testEnvironment = do
|
||||
source: hge_test
|
||||
|]
|
||||
|
||||
GraphqlEngine.postMetadata_ testEnvironment $
|
||||
[yaml|
|
||||
GraphqlEngine.postMetadata_ testEnvironment
|
||||
$ [yaml|
|
||||
type: bulk
|
||||
args:
|
||||
- type: pg_drop_source
|
||||
|
@ -83,8 +83,8 @@ articlesTable tableName =
|
||||
tests :: SpecWith (TestEnvironment, (GraphqlEngine.Server, Webhook.EventsQueue))
|
||||
tests =
|
||||
describe "verify trigger status when logical replication is used" do
|
||||
it "verify trigger is enabled on logical replication" $
|
||||
\(testEnvironment, (webhookServer, (Webhook.EventsQueue _eventsQueue))) -> do
|
||||
it "verify trigger is enabled on logical replication"
|
||||
$ \(testEnvironment, (webhookServer, (Webhook.EventsQueue _eventsQueue))) -> do
|
||||
postgresSetupWithEventTriggers testEnvironment webhookServer "True"
|
||||
let getTriggerInfoQuery =
|
||||
[interpolateYaml|
|
||||
@ -118,8 +118,8 @@ tests =
|
||||
(GraphqlEngine.postV2Query 200 testEnvironment getTriggerInfoQuery)
|
||||
expectedResponseForEnablingTriggers
|
||||
|
||||
it "verify trigger is disabled on logical replication" $
|
||||
\(testEnvironment, (webhookServer, (Webhook.EventsQueue _eventsQueue))) -> do
|
||||
it "verify trigger is disabled on logical replication"
|
||||
$ \(testEnvironment, (webhookServer, (Webhook.EventsQueue _eventsQueue))) -> do
|
||||
postgresSetupWithEventTriggers testEnvironment webhookServer "False"
|
||||
let getTriggerInfoQuery =
|
||||
[interpolateYaml|
|
||||
@ -162,8 +162,8 @@ postgresSetupWithEventTriggers testEnvironment webhookServer triggerOnReplicatio
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
webhookServerEchoEndpoint = GraphqlEngine.serverUrl webhookServer ++ "/echo"
|
||||
GraphqlEngine.postMetadata_ testEnvironment $
|
||||
[interpolateYaml|
|
||||
GraphqlEngine.postMetadata_ testEnvironment
|
||||
$ [interpolateYaml|
|
||||
type: pg_create_event_trigger
|
||||
args:
|
||||
name: author_trigger
|
||||
@ -183,8 +183,8 @@ postgresSetupWithEventTriggers testEnvironment webhookServer triggerOnReplicatio
|
||||
|
||||
postgresTeardown :: TestEnvironment -> IO ()
|
||||
postgresTeardown testEnvironment = do
|
||||
GraphqlEngine.postMetadata_ testEnvironment $
|
||||
[yaml|
|
||||
GraphqlEngine.postMetadata_ testEnvironment
|
||||
$ [yaml|
|
||||
type: pg_delete_event_trigger
|
||||
args:
|
||||
name: author_trigger
|
||||
|
@ -165,8 +165,8 @@ postgresTeardown :: TestEnvironment -> IO ()
|
||||
postgresTeardown testEnvironment = do
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
GraphqlEngine.postV2Query_ testEnvironment $
|
||||
[interpolateYaml|
|
||||
GraphqlEngine.postV2Query_ testEnvironment
|
||||
$ [interpolateYaml|
|
||||
type: run_sql
|
||||
args:
|
||||
source: postgres
|
||||
|
@ -75,8 +75,8 @@ authorsTable tableName =
|
||||
tests :: SpecWith (TestEnvironment, (GraphqlEngine.Server, Webhook.EventsQueue))
|
||||
tests =
|
||||
describe "removing a source with event trigger via replace_metadata should also remove the event trigger related stuffs (hdb_catalog.event_log)" do
|
||||
it "remove source via replace_metadata, check that the event_log table is removed as well" $
|
||||
\(testEnvironment, (_, _)) -> do
|
||||
it "remove source via replace_metadata, check that the event_log table is removed as well"
|
||||
$ \(testEnvironment, (_, _)) -> do
|
||||
-- `hdb_catalog.event_log` should be existing before (as we have added an event trigger in setup)
|
||||
checkIfPGTableExists testEnvironment "hdb_catalog.event_log" >>= (`shouldBe` True)
|
||||
|
||||
@ -112,8 +112,8 @@ postgresSetup testEnvironment webhookServer = do
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
let webhookServerEchoEndpoint = GraphqlEngine.serverUrl webhookServer ++ "/echo"
|
||||
GraphqlEngine.postMetadata_ testEnvironment $
|
||||
[interpolateYaml|
|
||||
GraphqlEngine.postMetadata_ testEnvironment
|
||||
$ [interpolateYaml|
|
||||
type: bulk
|
||||
args:
|
||||
- type: pg_create_event_trigger
|
||||
|
@ -120,8 +120,8 @@ args:
|
||||
result_type: CommandOk
|
||||
result: null
|
||||
|]
|
||||
it "inserting a new row should work fine" $
|
||||
\(testEnvironment, (_, (Webhook.EventsQueue eventsQueue))) -> do
|
||||
it "inserting a new row should work fine"
|
||||
$ \(testEnvironment, (_, (Webhook.EventsQueue eventsQueue))) -> do
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
shouldReturnYaml
|
||||
@ -251,8 +251,8 @@ renameTableContainingTriggerTests = do
|
||||
result_type: CommandOk
|
||||
result: null
|
||||
|]
|
||||
it "inserting a new row should work fine" $
|
||||
\(testEnvironment, (_, (Webhook.EventsQueue eventsQueue))) -> do
|
||||
it "inserting a new row should work fine"
|
||||
$ \(testEnvironment, (_, (Webhook.EventsQueue eventsQueue))) -> do
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
shouldReturnYaml
|
||||
@ -294,8 +294,8 @@ postgresSetup testEnvironment webhookServer = do
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
let webhookServerEchoEndpoint = GraphqlEngine.serverUrl webhookServer ++ "/echo"
|
||||
GraphqlEngine.postMetadata_ testEnvironment $
|
||||
[interpolateYaml|
|
||||
GraphqlEngine.postMetadata_ testEnvironment
|
||||
$ [interpolateYaml|
|
||||
type: bulk
|
||||
args:
|
||||
- type: pg_create_event_trigger
|
||||
@ -324,8 +324,8 @@ postgresSetup testEnvironment webhookServer = do
|
||||
|
||||
postgresTeardown :: TestEnvironment -> IO ()
|
||||
postgresTeardown testEnvironment = do
|
||||
GraphqlEngine.postMetadata_ testEnvironment $
|
||||
[yaml|
|
||||
GraphqlEngine.postMetadata_ testEnvironment
|
||||
$ [yaml|
|
||||
type: bulk
|
||||
args:
|
||||
- type: pg_delete_event_trigger
|
||||
|
@ -87,8 +87,8 @@ articlesTable tableName =
|
||||
tests :: SpecWith (TestEnvironment, (GraphqlEngine.Server, Webhook.EventsQueue))
|
||||
tests =
|
||||
describe "only unique trigger names are allowed" do
|
||||
it "check: inserting a new row invokes a event trigger" $
|
||||
\(testEnvironment, (_, (Webhook.EventsQueue eventsQueue))) -> do
|
||||
it "check: inserting a new row invokes a event trigger"
|
||||
$ \(testEnvironment, (_, (Webhook.EventsQueue eventsQueue))) -> do
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
let insertQuery =
|
||||
@ -127,8 +127,8 @@ tests =
|
||||
|
||||
eventPayload `shouldBeYaml` expectedEventPayload
|
||||
|
||||
it "metadata_api: does not allow creating an event trigger with a name that already exists" $
|
||||
\(testEnvironment, (webhookServer, _)) -> do
|
||||
it "metadata_api: does not allow creating an event trigger with a name that already exists"
|
||||
$ \(testEnvironment, (webhookServer, _)) -> do
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
-- metadata <- GraphqlEngine.exportMetadata testEnvironment
|
||||
@ -160,8 +160,8 @@ tests =
|
||||
(GraphqlEngine.postWithHeadersStatus 400 testEnvironment "/v1/metadata/" mempty createEventTriggerWithDuplicateName)
|
||||
createEventTriggerWithDuplicateNameExpectedResponse
|
||||
|
||||
it "replace_metadata: does not allow creating an event trigger with a name that already exists" $
|
||||
\(testEnvironment, (webhookServer, _)) -> do
|
||||
it "replace_metadata: does not allow creating an event trigger with a name that already exists"
|
||||
$ \(testEnvironment, (webhookServer, _)) -> do
|
||||
let replaceMetadata = getReplaceMetadata testEnvironment webhookServer
|
||||
|
||||
replaceMetadataWithDuplicateNameExpectedResponse =
|
||||
@ -186,8 +186,8 @@ postgresSetup testEnvironment webhookServer = do
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
let webhookServerEchoEndpoint = GraphqlEngine.serverUrl webhookServer ++ "/echo"
|
||||
GraphqlEngine.postMetadata_ testEnvironment $
|
||||
[interpolateYaml|
|
||||
GraphqlEngine.postMetadata_ testEnvironment
|
||||
$ [interpolateYaml|
|
||||
type: bulk
|
||||
args:
|
||||
- type: pg_create_event_trigger
|
||||
@ -251,8 +251,8 @@ getReplaceMetadata testEnvironment webhookServer =
|
||||
|
||||
postgresTeardown :: TestEnvironment -> IO ()
|
||||
postgresTeardown testEnvironment = do
|
||||
GraphqlEngine.postMetadata_ testEnvironment $
|
||||
[yaml|
|
||||
GraphqlEngine.postMetadata_ testEnvironment
|
||||
$ [yaml|
|
||||
type: bulk
|
||||
args:
|
||||
- type: pg_delete_event_trigger
|
||||
|
@ -74,8 +74,8 @@ authorsTable tableName =
|
||||
tests :: SpecWith (TestEnvironment, (GraphqlEngine.Server, Webhook.EventsQueue))
|
||||
tests =
|
||||
describe "untrack a table with event triggers should remove the SQL triggers created on the table" do
|
||||
it "check: inserting a new row invokes a event trigger" $
|
||||
\(testEnvironment, (_, (Webhook.EventsQueue eventsQueue))) -> do
|
||||
it "check: inserting a new row invokes a event trigger"
|
||||
$ \(testEnvironment, (_, (Webhook.EventsQueue eventsQueue))) -> do
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
let insertQuery =
|
||||
@ -114,8 +114,8 @@ tests =
|
||||
|
||||
eventPayload `shouldBeYaml` expectedEventPayload
|
||||
|
||||
it "untrack table, check the SQL triggers are deleted from the table" $
|
||||
\(testEnvironment, _) -> do
|
||||
it "untrack table, check the SQL triggers are deleted from the table"
|
||||
$ \(testEnvironment, _) -> do
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
let untrackTableQuery =
|
||||
@ -168,8 +168,8 @@ postgresSetup testEnvironment webhookServer = do
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
let webhookServerEchoEndpoint = GraphqlEngine.serverUrl webhookServer ++ "/echo"
|
||||
GraphqlEngine.postMetadata_ testEnvironment $
|
||||
[interpolateYaml|
|
||||
GraphqlEngine.postMetadata_ testEnvironment
|
||||
$ [interpolateYaml|
|
||||
type: bulk
|
||||
args:
|
||||
- type: pg_create_event_trigger
|
||||
|
@ -106,8 +106,8 @@ schema =
|
||||
|
||||
serialInt :: Schema.ScalarType
|
||||
serialInt =
|
||||
Schema.TCustomType $
|
||||
Schema.defaultBackendScalarType
|
||||
Schema.TCustomType
|
||||
$ Schema.defaultBackendScalarType
|
||||
{ Schema.bstCitus = Just "INT",
|
||||
Schema.bstPostgres = Just "INT",
|
||||
Schema.bstCockroach = Just "INT4"
|
||||
|
@ -308,8 +308,8 @@ tests = do
|
||||
describe "test_nested_select_with_foreign_key_alter" do
|
||||
-- from: queries/graphql_query/citus/nested_select_with_foreign_key_alter_citus.yaml [0]
|
||||
it "Alter foreign key constraint on article table" \testEnvironment -> do
|
||||
void $
|
||||
GraphqlEngine.postV2Query
|
||||
void
|
||||
$ GraphqlEngine.postV2Query
|
||||
200
|
||||
testEnvironment
|
||||
[interpolateYaml|
|
||||
|
@ -36,8 +36,8 @@ spec = do
|
||||
[ BigQuery.setupTablesAction schema testEnv
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True,
|
||||
Fixture.skipTests = Just "BigQuery returns numbers as strings, which means the second test fails"
|
||||
}
|
||||
|
@ -47,8 +47,8 @@ spec = do
|
||||
[ BigQuery.setupTablesAction schema testEnv
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
}
|
||||
|
@ -56,8 +56,8 @@ spec = do
|
||||
[ BigQuery.setupTablesAction schema testEnvironment
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
},
|
||||
|
@ -56,8 +56,8 @@ spec = do
|
||||
[ BigQuery.setupTablesAction schema testEnvironment
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
},
|
||||
|
@ -54,8 +54,8 @@ spec = do
|
||||
[ BigQuery.setupTablesAction tables testEnvironment
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
},
|
||||
|
@ -54,8 +54,8 @@ spec = do
|
||||
[ BigQuery.setupTablesAction schema testEnv
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
},
|
||||
|
@ -21,8 +21,8 @@ featureFlagForNativeQueries = "HASURA_FF_NATIVE_QUERY_INTERFACE"
|
||||
|
||||
spec :: SpecWith GlobalTestEnvironment
|
||||
spec =
|
||||
Fixture.hgeWithEnv [(featureFlagForNativeQueries, "True")] $
|
||||
Fixture.runClean -- re-run fixture setup on every test
|
||||
Fixture.hgeWithEnv [(featureFlagForNativeQueries, "True")]
|
||||
$ Fixture.runClean -- re-run fixture setup on every test
|
||||
( NE.fromList
|
||||
[ (Fixture.fixture $ Fixture.Backend Postgres.backendTypeMetadata)
|
||||
{ Fixture.setupTeardown = \(testEnvironment, _) ->
|
||||
@ -66,8 +66,8 @@ tests = do
|
||||
(Schema.trackLogicalModelCommand source backendTypeMetadata helloWorldLogicalModel)
|
||||
|
||||
-- we expect this to fail
|
||||
void $
|
||||
GraphqlEngine.postMetadataWithStatus
|
||||
void
|
||||
$ GraphqlEngine.postMetadataWithStatus
|
||||
400
|
||||
testEnvironment
|
||||
(Schema.trackNativeQueryCommand source backendTypeMetadata helloWorldNativeQuery)
|
||||
|
@ -53,8 +53,8 @@ spec = do
|
||||
[ BigQuery.setupTablesAction schema testEnv
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
},
|
||||
|
@ -54,8 +54,8 @@ spec = do
|
||||
[ BigQuery.setupTablesAction schema testEnv
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
},
|
||||
|
@ -53,8 +53,8 @@ spec = do
|
||||
[ BigQuery.setupTablesAction schema testEnv
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
},
|
||||
|
@ -28,8 +28,8 @@ import Test.Hspec (SpecWith, it)
|
||||
|
||||
spec :: SpecWith GlobalTestEnvironment
|
||||
spec = do
|
||||
withEachProtocol $
|
||||
Fixture.run
|
||||
withEachProtocol
|
||||
$ Fixture.run
|
||||
( NE.fromList
|
||||
[ (Fixture.fixture $ Fixture.Backend Postgres.backendTypeMetadata)
|
||||
{ Fixture.setupTeardown = \(testEnvironment, _) ->
|
||||
@ -51,8 +51,8 @@ spec = do
|
||||
[ BigQuery.setupTablesAction schema testEnvironment
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
}
|
||||
@ -69,8 +69,8 @@ schema =
|
||||
{ tableColumns =
|
||||
[ Schema.column "id" Schema.TInt,
|
||||
Schema.column "name" Schema.TStr,
|
||||
Schema.column "address" $
|
||||
Schema.TCustomType
|
||||
Schema.column "address"
|
||||
$ Schema.TCustomType
|
||||
Schema.defaultBackendScalarType
|
||||
{ Schema.bstCitus = Just "JSON",
|
||||
Schema.bstCockroach = Just "JSON",
|
||||
@ -82,8 +82,8 @@ schema =
|
||||
tableData =
|
||||
[ [ Schema.VInt 1,
|
||||
Schema.VStr "Justin",
|
||||
Schema.VCustomValue $
|
||||
Schema.defaultBackendScalarValue
|
||||
Schema.VCustomValue
|
||||
$ Schema.defaultBackendScalarValue
|
||||
{ Schema.bsvCitus = Just (Schema.Quoted "{ \"city\": \"Bristol\" }"),
|
||||
Schema.bsvCockroach = Just (Schema.Quoted "{ \"city\": \"Bristol\" }"),
|
||||
Schema.bsvPostgres = Just (Schema.Quoted "{ \"city\": \"Bristol\" }"),
|
||||
|
@ -36,18 +36,18 @@ import Test.Hspec (SpecWith, describe, it)
|
||||
spec :: SpecWith GlobalTestEnvironment
|
||||
spec = do
|
||||
withHge emptyHgeConfig $ do
|
||||
withPostgresSource "postgres-source" $
|
||||
withSchemaName "test_schema" $
|
||||
withPostgresSchema schema $
|
||||
tests
|
||||
withPostgresSource "postgres-source"
|
||||
$ withSchemaName "test_schema"
|
||||
$ withPostgresSchema schema
|
||||
$ tests
|
||||
|
||||
DC.withDcPostgresSource "dc-postgres-source" $
|
||||
withSchemaName "test_schema" $
|
||||
DC.withDcPostgresSchema schema $
|
||||
tests
|
||||
DC.withDcPostgresSource "dc-postgres-source"
|
||||
$ withSchemaName "test_schema"
|
||||
$ DC.withDcPostgresSchema schema
|
||||
$ tests
|
||||
|
||||
withEachProtocol $
|
||||
Fixture.run
|
||||
withEachProtocol
|
||||
$ Fixture.run
|
||||
( NE.fromList
|
||||
[ (Fixture.fixture $ Fixture.Backend Citus.backendTypeMetadata)
|
||||
{ Fixture.setupTeardown = \(testEnvironment, _) ->
|
||||
@ -69,8 +69,8 @@ spec = do
|
||||
[ BigQuery.setupTablesAction schema testEnvironment
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
},
|
||||
|
@ -27,8 +27,8 @@ import Test.Hspec (SpecWith, describe, it)
|
||||
|
||||
spec :: SpecWith GlobalTestEnvironment
|
||||
spec = do
|
||||
withEachProtocol $
|
||||
Fixture.run
|
||||
withEachProtocol
|
||||
$ Fixture.run
|
||||
( NE.fromList
|
||||
[ (Fixture.fixture $ Fixture.Backend Postgres.backendTypeMetadata)
|
||||
{ Fixture.setupTeardown = \(testEnv, _) ->
|
||||
@ -55,8 +55,8 @@ spec = do
|
||||
[ BigQuery.setupTablesAction schema testEnv
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
},
|
||||
|
@ -28,8 +28,8 @@ import Test.Hspec (SpecWith, describe, it)
|
||||
|
||||
spec :: SpecWith GlobalTestEnvironment
|
||||
spec =
|
||||
withEachProtocol $
|
||||
Fixture.run
|
||||
withEachProtocol
|
||||
$ Fixture.run
|
||||
( NE.fromList
|
||||
[ (Fixture.fixture $ Fixture.Backend Postgres.backendTypeMetadata)
|
||||
{ Fixture.setupTeardown = \(testEnvironment, _) ->
|
||||
|
@ -54,8 +54,8 @@ spec = do
|
||||
[ BigQuery.setupTablesAction schema testEnv
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
},
|
||||
|
@ -50,8 +50,8 @@ spec = do
|
||||
[ BigQuery.setupTablesAction schema testEnv
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
},
|
||||
|
@ -52,8 +52,8 @@ spec = do
|
||||
[ BigQuery.setupTablesAction schema testEnv
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
},
|
||||
|
@ -52,8 +52,8 @@ spec = do
|
||||
[ BigQuery.setupTablesAction schema testEnv
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
},
|
||||
|
@ -55,8 +55,8 @@ spec = do
|
||||
[ BigQuery.setupTablesAction schema testEnv
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
},
|
||||
|
@ -55,8 +55,8 @@ spec = do
|
||||
[ BigQuery.setupTablesAction schema testEnv
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
},
|
||||
|
@ -50,8 +50,8 @@ spec = do
|
||||
[ BigQuery.setupTablesAction schema testEnv
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
},
|
||||
|
@ -50,8 +50,8 @@ spec = do
|
||||
[ BigQuery.setupTablesAction schema testEnv
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
},
|
||||
|
@ -76,8 +76,8 @@ schema =
|
||||
|
||||
serialInt :: Schema.ScalarType
|
||||
serialInt =
|
||||
Schema.TCustomType $
|
||||
Schema.defaultBackendScalarType
|
||||
Schema.TCustomType
|
||||
$ Schema.defaultBackendScalarType
|
||||
{ Schema.bstCitus = Just "INT",
|
||||
Schema.bstPostgres = Just "INT",
|
||||
Schema.bstCockroach = Just "INT4"
|
||||
|
@ -57,8 +57,8 @@ spec = do
|
||||
[ BigQuery.setupTablesAction schema testEnv
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
}
|
||||
|
@ -51,8 +51,8 @@ spec = do
|
||||
setupRelationships BigQuery.backendTypeMetadata testEnv
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
},
|
||||
|
@ -66,7 +66,8 @@ setupFunctions testEnv =
|
||||
fetch_users = Schema.unSchemaName schemaName <> ".fetch_users"
|
||||
in Fixture.SetupAction
|
||||
{ Fixture.setupAction = do
|
||||
Postgres.run_ testEnv $
|
||||
Postgres.run_ testEnv
|
||||
$
|
||||
-- get_age postgres function returns the age of a user calculated from the
|
||||
-- birth_year column and in_year input parameter. The in_year should be a future year
|
||||
-- from 2022 (the year when this test is being written)
|
||||
@ -87,7 +88,8 @@ setupFunctions testEnv =
|
||||
end;
|
||||
$function$
|
||||
|]
|
||||
Postgres.run_ testEnv $
|
||||
Postgres.run_ testEnv
|
||||
$
|
||||
-- fetch_users postgres function returns the list of users whose age is equal to given "age" input parameter
|
||||
-- in given future "in_year" parameter. The in_year should be a future year
|
||||
-- from 2022 (the year when this test is being written) and "age" should not be a negative value.
|
||||
|
@ -35,16 +35,16 @@ spec = Fixture.runWithLocalTestEnvironment contexts tests
|
||||
contexts = NE.fromList $ do
|
||||
(rhsName, rhsMkLocalEnv, rhsSetup, rhsTeardown, albumJoin, artistJoin) <- [rhsPostgres, rhsRemoteServer]
|
||||
(lhsName, lhsMkLocalEnv, lhsSetup, lhsTeardown) <- [lhsPostgres, lhsRemoteServer]
|
||||
pure $
|
||||
Fixture.Fixture
|
||||
pure
|
||||
$ Fixture.Fixture
|
||||
{ Fixture.name = Fixture.Combine lhsName rhsName,
|
||||
Fixture.mkLocalTestEnvironment = \testEnvironment -> do
|
||||
lhsServer <- lhsMkLocalEnv testEnvironment
|
||||
rhsServer <- rhsMkLocalEnv testEnvironment
|
||||
pure $ LocalTestTestEnvironment lhsServer rhsServer,
|
||||
Fixture.setupTeardown = \(testEnvironment, LocalTestTestEnvironment lhsServer rhsServer) -> do
|
||||
pure $
|
||||
Fixture.SetupAction
|
||||
pure
|
||||
$ Fixture.SetupAction
|
||||
{ Fixture.setupAction = do
|
||||
let schemaName = Schema.getSchemaName testEnvironment
|
||||
-- RHS must always be setup before the LHS
|
||||
@ -98,8 +98,8 @@ spec = Fixture.runWithLocalTestEnvironment contexts tests
|
||||
rhsRemoteServerMkLocalTestEnvironment,
|
||||
rhsRemoteServerSetup,
|
||||
rhsRemoteServerTeardown,
|
||||
const $
|
||||
[yaml|
|
||||
const
|
||||
$ [yaml|
|
||||
to_remote_schema:
|
||||
remote_schema: target
|
||||
lhs_fields: [album_id]
|
||||
@ -108,8 +108,8 @@ spec = Fixture.runWithLocalTestEnvironment contexts tests
|
||||
arguments:
|
||||
album_id: $album_id
|
||||
|],
|
||||
const $
|
||||
[yaml|
|
||||
const
|
||||
$ [yaml|
|
||||
to_remote_schema:
|
||||
remote_schema: target
|
||||
lhs_fields: [artist_id]
|
||||
@ -288,7 +288,7 @@ data LHSQuery m = LHSQuery
|
||||
}
|
||||
deriving (Generic)
|
||||
|
||||
instance Typeable m => Morpheus.GQLType (LHSQuery m) where
|
||||
instance (Typeable m) => Morpheus.GQLType (LHSQuery m) where
|
||||
typeOptions _ _ = hasuraTypeOptions
|
||||
|
||||
data LHSHasuraTrackArgs = LHSHasuraTrackArgs
|
||||
@ -309,7 +309,7 @@ data LHSHasuraTrack m = LHSHasuraTrack
|
||||
}
|
||||
deriving (Generic)
|
||||
|
||||
instance Typeable m => Morpheus.GQLType (LHSHasuraTrack m) where
|
||||
instance (Typeable m) => Morpheus.GQLType (LHSHasuraTrack m) where
|
||||
typeOptions _ _ = hasuraTypeOptions
|
||||
|
||||
data LHSHasuraTrackOrderBy = LHSHasuraTrackOrderBy
|
||||
@ -368,12 +368,12 @@ lhsRemoteServerMkLocalTestEnvironment _ =
|
||||
Nothing -> \_ _ -> EQ
|
||||
Just orderByArg -> orderTrack orderByArg
|
||||
limitFunction = maybe Hasura.Prelude.id take ta_limit
|
||||
pure $
|
||||
tracks
|
||||
& filter filterFunction
|
||||
& sortBy orderByFunction
|
||||
& limitFunction
|
||||
& map mkTrack
|
||||
pure
|
||||
$ tracks
|
||||
& filter filterFunction
|
||||
& sortBy orderByFunction
|
||||
& limitFunction
|
||||
& map mkTrack
|
||||
-- Returns True iif the given track matches the given boolean expression.
|
||||
matchTrack trackInfo@(trackId, trackTitle, maybeAlbumId, maybeArtistId) (LHSHasuraTrackBoolExp {..}) =
|
||||
and
|
||||
@ -395,18 +395,18 @@ lhsRemoteServerMkLocalTestEnvironment _ =
|
||||
(trackId2, trackTitle2, trackAlbumId2, trackArtistId2) =
|
||||
flip foldMap orderByList \LHSHasuraTrackOrderBy {..} ->
|
||||
if
|
||||
| Just idOrder <- tob_id -> case idOrder of
|
||||
Asc -> compare trackId1 trackId2
|
||||
Desc -> compare trackId2 trackId1
|
||||
| Just titleOrder <- tob_title -> case titleOrder of
|
||||
Asc -> compare trackTitle1 trackTitle2
|
||||
Desc -> compare trackTitle2 trackTitle1
|
||||
| Just albumIdOrder <- tob_album_id ->
|
||||
compareWithNullLast albumIdOrder trackAlbumId1 trackAlbumId2
|
||||
| Just artistIdOrder <- tob_artist_id ->
|
||||
compareWithNullLast artistIdOrder trackArtistId1 trackArtistId2
|
||||
| otherwise ->
|
||||
error "empty track_order object"
|
||||
| Just idOrder <- tob_id -> case idOrder of
|
||||
Asc -> compare trackId1 trackId2
|
||||
Desc -> compare trackId2 trackId1
|
||||
| Just titleOrder <- tob_title -> case titleOrder of
|
||||
Asc -> compare trackTitle1 trackTitle2
|
||||
Desc -> compare trackTitle2 trackTitle1
|
||||
| Just albumIdOrder <- tob_album_id ->
|
||||
compareWithNullLast albumIdOrder trackAlbumId1 trackAlbumId2
|
||||
| Just artistIdOrder <- tob_artist_id ->
|
||||
compareWithNullLast artistIdOrder trackArtistId1 trackArtistId2
|
||||
| otherwise ->
|
||||
error "empty track_order object"
|
||||
compareWithNullLast Desc x1 x2 = compareWithNullLast Asc x2 x1
|
||||
compareWithNullLast Asc Nothing Nothing = EQ
|
||||
compareWithNullLast Asc (Just _) Nothing = LT
|
||||
|
@ -309,7 +309,7 @@ setupMetadata testEnvironment = do
|
||||
--
|
||||
-- We use 'Visual' internally to easily display the 'Value' as YAML
|
||||
-- when the test suite uses its 'Show' instance.
|
||||
shouldReturnOneOfYaml :: HasCallStack => TestEnvironment -> IO Value -> [Value] -> IO ()
|
||||
shouldReturnOneOfYaml :: (HasCallStack) => TestEnvironment -> IO Value -> [Value] -> IO ()
|
||||
shouldReturnOneOfYaml testEnv actualIO candidates = do
|
||||
let Fixture.Options {stringifyNumbers} = _options testEnv
|
||||
actual <- actualIO
|
||||
|
@ -30,11 +30,11 @@ import Test.Schema.RemoteRelationships.MetadataAPI.Common qualified as Common
|
||||
|
||||
spec :: SpecWith GlobalTestEnvironment
|
||||
spec = do
|
||||
Fixture.hgeWithEnv [("HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES", "true")] $
|
||||
Fixture.runWithLocalTestEnvironment contexts testsWithFeatureOn
|
||||
Fixture.hgeWithEnv [("HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES", "true")]
|
||||
$ Fixture.runWithLocalTestEnvironment contexts testsWithFeatureOn
|
||||
|
||||
Fixture.hgeWithEnv [("HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES", "false")] $
|
||||
Fixture.runWithLocalTestEnvironment contexts testsWithFeatureOff
|
||||
Fixture.hgeWithEnv [("HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES", "false")]
|
||||
$ Fixture.runWithLocalTestEnvironment contexts testsWithFeatureOff
|
||||
where
|
||||
lhsFixtures = [lhsPostgres, lhsRemoteServer]
|
||||
rhsFixtures = [rhsPostgres]
|
||||
@ -80,8 +80,8 @@ rhsPostgres =
|
||||
[ SetupAction.noTeardown (rhsPostgresSetup testEnv)
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
}
|
||||
@ -124,29 +124,29 @@ album =
|
||||
|
||||
floatType :: Schema.ScalarType
|
||||
floatType =
|
||||
Schema.TCustomType $
|
||||
Schema.defaultBackendScalarType
|
||||
Schema.TCustomType
|
||||
$ Schema.defaultBackendScalarType
|
||||
{ Schema.bstPostgres = Just "NUMERIC"
|
||||
}
|
||||
|
||||
mkFloatValue :: Text -> Schema.ScalarValue
|
||||
mkFloatValue int =
|
||||
Schema.VCustomValue $
|
||||
Schema.defaultBackendScalarValue
|
||||
Schema.VCustomValue
|
||||
$ Schema.defaultBackendScalarValue
|
||||
{ Schema.bsvPostgres = Just (Schema.Unquoted int)
|
||||
}
|
||||
|
||||
bigIntType :: Schema.ScalarType
|
||||
bigIntType =
|
||||
Schema.TCustomType $
|
||||
Schema.defaultBackendScalarType
|
||||
Schema.TCustomType
|
||||
$ Schema.defaultBackendScalarType
|
||||
{ Schema.bstPostgres = Just "BIGINT"
|
||||
}
|
||||
|
||||
mkBigIntValue :: Text -> Schema.ScalarValue
|
||||
mkBigIntValue int =
|
||||
Schema.VCustomValue $
|
||||
Schema.defaultBackendScalarValue
|
||||
Schema.VCustomValue
|
||||
$ Schema.defaultBackendScalarValue
|
||||
{ Schema.bsvPostgres = Just (Schema.Unquoted int)
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,8 @@ spec =
|
||||
[ Postgres.setupTablesAction schema testEnv
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.skipTests =
|
||||
Just "Disabled until we can dynamically change server settings per test. To test, add EFHideStreamFields to soSubscriptions in Harness.Constants -> serveOptions"
|
||||
}
|
||||
|
@ -54,21 +54,21 @@ schema =
|
||||
functionSetup :: TestEnvironment -> Fixture.SetupAction
|
||||
functionSetup testEnvironment =
|
||||
let schemaName = unSchemaName (getSchemaName testEnvironment)
|
||||
in SetupAction.noTeardown $
|
||||
Postgres.run_ testEnvironment $
|
||||
"CREATE FUNCTION "
|
||||
<> schemaName
|
||||
<> ".authors(author_row "
|
||||
<> schemaName
|
||||
<> ".author) \
|
||||
\RETURNS SETOF "
|
||||
<> schemaName
|
||||
<> ".author AS $$ \
|
||||
\ SELECT * \
|
||||
\ FROM "
|
||||
<> schemaName
|
||||
<> ".author \
|
||||
\$$ LANGUAGE sql STABLE;"
|
||||
in SetupAction.noTeardown
|
||||
$ Postgres.run_ testEnvironment
|
||||
$ "CREATE FUNCTION "
|
||||
<> schemaName
|
||||
<> ".authors(author_row "
|
||||
<> schemaName
|
||||
<> ".author) \
|
||||
\RETURNS SETOF "
|
||||
<> schemaName
|
||||
<> ".author AS $$ \
|
||||
\ SELECT * \
|
||||
\ FROM "
|
||||
<> schemaName
|
||||
<> ".author \
|
||||
\$$ LANGUAGE sql STABLE;"
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Tests
|
||||
|
@ -82,8 +82,8 @@ tests = do
|
||||
scheduledEventsWithInvalidEnvVar :: SpecWith (TestEnvironment, (GraphqlEngine.Server, Webhook.EventsQueue))
|
||||
scheduledEventsWithInvalidEnvVar =
|
||||
describe "creating a scheduled event with invalid env var should add a failed invocation log" do
|
||||
it "check the invocation log requests added for failed request corresponding to invalid header" $
|
||||
\(testEnvironment, (_, _)) -> do
|
||||
it "check the invocation log requests added for failed request corresponding to invalid header"
|
||||
$ \(testEnvironment, (_, _)) -> do
|
||||
-- get all the scheduled event invocations
|
||||
let getScheduledEventInvocationsQuery =
|
||||
[yaml|
|
||||
@ -113,8 +113,8 @@ scheduledEventsWithInvalidEnvVar =
|
||||
postgresSetup :: TestEnvironment -> GraphqlEngine.Server -> IO ()
|
||||
postgresSetup testEnvironment webhookServer = do
|
||||
let webhookServerEchoEndpoint = GraphqlEngine.serverUrl webhookServer ++ "/echo"
|
||||
GraphqlEngine.postMetadata_ testEnvironment $
|
||||
[interpolateYaml|
|
||||
GraphqlEngine.postMetadata_ testEnvironment
|
||||
$ [interpolateYaml|
|
||||
type: create_scheduled_event
|
||||
args:
|
||||
webhook: #{webhookServerEchoEndpoint}
|
||||
|
@ -45,8 +45,8 @@ spec =
|
||||
<> bigquerySetupFunctions testEnv
|
||||
<> setupMetadata testEnv,
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
}
|
||||
@ -114,8 +114,8 @@ postgresSetupFunctions testEnv =
|
||||
articleTableSQL = unSchemaName schemaName <> ".article"
|
||||
in [ Fixture.SetupAction
|
||||
{ Fixture.setupAction =
|
||||
Postgres.run_ testEnv $
|
||||
[i|
|
||||
Postgres.run_ testEnv
|
||||
$ [i|
|
||||
CREATE FUNCTION #{ fetch_articles schemaName }(author_row author, search TEXT)
|
||||
RETURNS SETOF article AS $$
|
||||
SELECT *
|
||||
@ -130,8 +130,8 @@ postgresSetupFunctions testEnv =
|
||||
},
|
||||
Fixture.SetupAction
|
||||
{ Fixture.setupAction =
|
||||
Postgres.run_ testEnv $
|
||||
[i|
|
||||
Postgres.run_ testEnv
|
||||
$ [i|
|
||||
CREATE FUNCTION #{ fetch_articles_no_user_args schemaName }(author_row author)
|
||||
RETURNS SETOF article AS $$
|
||||
SELECT *
|
||||
@ -149,8 +149,8 @@ bigquerySetupFunctions testEnv =
|
||||
articleTableSQL = unSchemaName schemaName <> ".article"
|
||||
in [ Fixture.SetupAction
|
||||
{ Fixture.setupAction =
|
||||
BigQuery.run_ $
|
||||
[i|
|
||||
BigQuery.run_
|
||||
$ [i|
|
||||
CREATE TABLE FUNCTION
|
||||
#{ fetch_articles schemaName }(a_id INT64, search STRING)
|
||||
AS
|
||||
@ -163,8 +163,8 @@ bigquerySetupFunctions testEnv =
|
||||
},
|
||||
Fixture.SetupAction
|
||||
{ Fixture.setupAction =
|
||||
BigQuery.run_ $
|
||||
[i|
|
||||
BigQuery.run_
|
||||
$ [i|
|
||||
CREATE TABLE FUNCTION
|
||||
#{ fetch_articles_no_user_args schemaName }(a_id INT64)
|
||||
AS
|
||||
|
@ -63,8 +63,8 @@ spec = do
|
||||
setupMetadata DoesNotSupportArrayTypes BigQuery.backendTypeMetadata testEnvironment
|
||||
],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
}
|
||||
@ -226,8 +226,8 @@ tests arrayTypeSupport = describe "Permissions on queries" do
|
||||
shouldReturnYaml testEnvironment actual expected
|
||||
|
||||
it "Editor role can select in review and published articles only" \testEnvironment -> do
|
||||
when (arrayTypeSupport == DoesNotSupportArrayTypes) $
|
||||
pendingWith "Backend does not support array types"
|
||||
when (arrayTypeSupport == DoesNotSupportArrayTypes)
|
||||
$ pendingWith "Backend does not support array types"
|
||||
|
||||
let schemaName :: Schema.SchemaName
|
||||
schemaName = Schema.getSchemaName testEnvironment
|
||||
|
@ -79,8 +79,8 @@ schema =
|
||||
|
||||
defaultDateTimeType :: Schema.ScalarType
|
||||
defaultDateTimeType =
|
||||
Schema.TCustomType $
|
||||
Schema.defaultBackendScalarType
|
||||
Schema.TCustomType
|
||||
$ Schema.defaultBackendScalarType
|
||||
{ Schema.bstMssql = Just "DATETIME DEFAULT GETDATE()",
|
||||
Schema.bstCitus = Just "TIMESTAMP DEFAULT NOW()",
|
||||
Schema.bstPostgres = Just "TIMESTAMP DEFAULT NOW()",
|
||||
|
@ -37,15 +37,15 @@ spec = Fixture.runWithLocalTestEnvironmentSingleSetup (NE.fromList [context]) te
|
||||
(Fixture.fixture $ Fixture.RemoteGraphQLServer)
|
||||
{ -- start only one remote server
|
||||
Fixture.mkLocalTestEnvironment = \_testEnvironment ->
|
||||
RemoteServer.run $
|
||||
RemoteServer.generateQueryInterpreter $
|
||||
Query
|
||||
{ object = objectResolver,
|
||||
writer = writerResolver,
|
||||
artist = artistResolver,
|
||||
objects = objectsResolver,
|
||||
articles = articlesResolver
|
||||
},
|
||||
RemoteServer.run
|
||||
$ RemoteServer.generateQueryInterpreter
|
||||
$ Query
|
||||
{ object = objectResolver,
|
||||
writer = writerResolver,
|
||||
artist = artistResolver,
|
||||
objects = objectsResolver,
|
||||
articles = articlesResolver
|
||||
},
|
||||
-- set that remote server as both source and target, for convenience
|
||||
-- start a RHS Postgres for Metadata tests only
|
||||
setupTeardown = \(testEnvironment, server) ->
|
||||
@ -181,7 +181,7 @@ type Article {
|
||||
|
||||
|]
|
||||
|
||||
knownObjects :: Monad m => [(Int, Object m)]
|
||||
knownObjects :: (Monad m) => [(Int, Object m)]
|
||||
knownObjects =
|
||||
[ (101, ObjectWriter writer1),
|
||||
(102, ObjectWriter writer2),
|
||||
@ -202,28 +202,29 @@ knownObjects =
|
||||
article3 = Article (pure 303) (pure "Article3") (pure 201) (pure 102)
|
||||
article4 = Article (pure 304) (pure "Article4") (pure 202) (pure 102)
|
||||
|
||||
objectResolver :: Monad m => Arg "id" Int -> m (Maybe (Object m))
|
||||
objectResolver :: (Monad m) => Arg "id" Int -> m (Maybe (Object m))
|
||||
objectResolver (Arg objectId) = pure $ lookup objectId knownObjects
|
||||
|
||||
writerResolver :: Monad m => Arg "id" Int -> m (Maybe (Writer m))
|
||||
writerResolver :: (Monad m) => Arg "id" Int -> m (Maybe (Writer m))
|
||||
writerResolver (Arg objectId) =
|
||||
pure $ case lookup objectId knownObjects of
|
||||
Just (ObjectWriter w) -> Just w
|
||||
_ -> Nothing
|
||||
|
||||
artistResolver :: Monad m => Arg "id" Int -> m (Maybe (Artist m))
|
||||
artistResolver :: (Monad m) => Arg "id" Int -> m (Maybe (Artist m))
|
||||
artistResolver (Arg objectId) =
|
||||
pure $ case lookup objectId knownObjects of
|
||||
Just (ObjectArtist a) -> Just a
|
||||
_ -> Nothing
|
||||
|
||||
objectsResolver :: Monad m => Arg "ids" [Int] -> m [Maybe (Object m)]
|
||||
objectsResolver :: (Monad m) => Arg "ids" [Int] -> m [Maybe (Object m)]
|
||||
objectsResolver (Arg objectIds) = pure [lookup objectId knownObjects | objectId <- objectIds]
|
||||
|
||||
articlesResolver :: Monad m => Arg "ids" [Int] -> m [Maybe (Article m)]
|
||||
articlesResolver :: (Monad m) => Arg "ids" [Int] -> m [Maybe (Article m)]
|
||||
articlesResolver (Arg objectIds) =
|
||||
pure $
|
||||
objectIds <&> \objectId ->
|
||||
pure
|
||||
$ objectIds
|
||||
<&> \objectId ->
|
||||
case lookup objectId knownObjects of
|
||||
Just (ObjectArticle a) -> Just a
|
||||
_ -> Nothing
|
||||
|
@ -65,8 +65,8 @@ data LocalTestTestEnvironment = LocalTestTestEnvironment
|
||||
|
||||
dbTodbRemoteRelationshipFixture :: Fixture.Fixture LocalTestTestEnvironment
|
||||
dbTodbRemoteRelationshipFixture =
|
||||
( Fixture.fixture $
|
||||
Fixture.Combine
|
||||
( Fixture.fixture
|
||||
$ Fixture.Combine
|
||||
(Fixture.Backend Postgres.backendTypeMetadata)
|
||||
(Fixture.Backend Postgres.backendTypeMetadata)
|
||||
)
|
||||
@ -440,7 +440,7 @@ data LHSQuery m = LHSQuery
|
||||
}
|
||||
deriving (Generic)
|
||||
|
||||
instance Typeable m => Morpheus.GQLType (LHSQuery m) where
|
||||
instance (Typeable m) => Morpheus.GQLType (LHSQuery m) where
|
||||
typeOptions _ _ = hasuraTypeOptions
|
||||
|
||||
data LHSHasuraTrackArgs = LHSHasuraTrackArgs
|
||||
@ -460,7 +460,7 @@ data LHSHasuraTrack m = LHSHasuraTrack
|
||||
}
|
||||
deriving (Generic)
|
||||
|
||||
instance Typeable m => Morpheus.GQLType (LHSHasuraTrack m) where
|
||||
instance (Typeable m) => Morpheus.GQLType (LHSHasuraTrack m) where
|
||||
typeOptions _ _ = hasuraTypeOptions
|
||||
|
||||
data LHSHasuraTrackOrderBy = LHSHasuraTrackOrderBy
|
||||
@ -517,12 +517,12 @@ lhsRemoteServerMkLocalTestEnvironment _ =
|
||||
Nothing -> \_ _ -> EQ
|
||||
Just orderByArg -> orderTrack orderByArg
|
||||
limitFunction = maybe Hasura.Prelude.id take ta_limit
|
||||
pure $
|
||||
tracks
|
||||
& filter filterFunction
|
||||
& sortBy orderByFunction
|
||||
& limitFunction
|
||||
& map mkTrack
|
||||
pure
|
||||
$ tracks
|
||||
& filter filterFunction
|
||||
& sortBy orderByFunction
|
||||
& limitFunction
|
||||
& map mkTrack
|
||||
-- Returns True iif the given track matches the given boolean expression.
|
||||
matchTrack trackInfo@(trackId, trackTitle, maybeAlbumId) (LHSHasuraTrackBoolExp {..}) =
|
||||
and
|
||||
@ -543,16 +543,16 @@ lhsRemoteServerMkLocalTestEnvironment _ =
|
||||
(trackId2, trackTitle2, trackAlbumId2) =
|
||||
flip foldMap orderByList \LHSHasuraTrackOrderBy {..} ->
|
||||
if
|
||||
| Just idOrder <- tob_id -> case idOrder of
|
||||
Asc -> compare trackId1 trackId2
|
||||
Desc -> compare trackId2 trackId1
|
||||
| Just titleOrder <- tob_title -> case titleOrder of
|
||||
Asc -> compare trackTitle1 trackTitle2
|
||||
Desc -> compare trackTitle2 trackTitle1
|
||||
| Just albumIdOrder <- tob_album_id ->
|
||||
compareWithNullLast albumIdOrder trackAlbumId1 trackAlbumId2
|
||||
| otherwise ->
|
||||
error "empty track_order object"
|
||||
| Just idOrder <- tob_id -> case idOrder of
|
||||
Asc -> compare trackId1 trackId2
|
||||
Desc -> compare trackId2 trackId1
|
||||
| Just titleOrder <- tob_title -> case titleOrder of
|
||||
Asc -> compare trackTitle1 trackTitle2
|
||||
Desc -> compare trackTitle2 trackTitle1
|
||||
| Just albumIdOrder <- tob_album_id ->
|
||||
compareWithNullLast albumIdOrder trackAlbumId1 trackAlbumId2
|
||||
| otherwise ->
|
||||
error "empty track_order object"
|
||||
compareWithNullLast Desc x1 x2 = compareWithNullLast Asc x2 x1
|
||||
compareWithNullLast Asc Nothing Nothing = EQ
|
||||
compareWithNullLast Asc (Just _) Nothing = LT
|
||||
|
@ -90,8 +90,8 @@ tests = describe "drop-source-metadata-tests" do
|
||||
let sources = key "sources" . values
|
||||
-- Extract the 'source' DB info from the sources field in metadata
|
||||
sourceDB =
|
||||
Unsafe.fromJust $
|
||||
findOf
|
||||
Unsafe.fromJust
|
||||
$ findOf
|
||||
sources
|
||||
(has $ key "name" . _String . only "source")
|
||||
metadata
|
||||
|
@ -89,8 +89,8 @@ tests = describe "drop-source-metadata-tests" do
|
||||
let remoteSchemas = key "remote_schemas" . values
|
||||
-- Extract the 'source' remote schema and check if any remote relationships exists
|
||||
sourceRemoteSchema =
|
||||
Unsafe.fromJust $
|
||||
findOf
|
||||
Unsafe.fromJust
|
||||
$ findOf
|
||||
remoteSchemas
|
||||
(has $ key "name" . _String . only "source")
|
||||
metadata
|
||||
|
@ -239,7 +239,7 @@ lhsRole2 =
|
||||
selectPermissionSource = Just lhsSourceName_
|
||||
}
|
||||
|
||||
createRemoteRelationship :: HasCallStack => Value -> Value -> TestEnvironment -> IO ()
|
||||
createRemoteRelationship :: (HasCallStack) => Value -> Value -> TestEnvironment -> IO ()
|
||||
createRemoteRelationship lhsTableName rhsTableName testEnvironment = do
|
||||
let backendTypeMetadata = fromMaybe (error "Unknown backend") $ getBackendTypeConfig testEnvironment
|
||||
backendType = BackendType.backendTypeString backendTypeMetadata
|
||||
@ -333,7 +333,7 @@ rhsTable =
|
||||
--------------------------------------------------------------------------------
|
||||
-- LHS Postgres
|
||||
|
||||
lhsPostgresSetup :: HasCallStack => Value -> (TestEnvironment, Maybe Server) -> IO ()
|
||||
lhsPostgresSetup :: (HasCallStack) => Value -> (TestEnvironment, Maybe Server) -> IO ()
|
||||
lhsPostgresSetup rhsTableName (wholeTestEnvironment, _) = do
|
||||
let testEnvironment = focusFixtureLeft wholeTestEnvironment
|
||||
sourceConfig = Postgres.defaultSourceConfiguration testEnvironment
|
||||
@ -359,7 +359,7 @@ lhsPostgresSetup rhsTableName (wholeTestEnvironment, _) = do
|
||||
--------------------------------------------------------------------------------
|
||||
-- LHS Cockroach
|
||||
|
||||
lhsCockroachSetup :: HasCallStack => Value -> (TestEnvironment, Maybe Server) -> IO ()
|
||||
lhsCockroachSetup :: (HasCallStack) => Value -> (TestEnvironment, Maybe Server) -> IO ()
|
||||
lhsCockroachSetup rhsTableName (wholeTestEnvironment, _) = do
|
||||
let testEnvironment = focusFixtureLeft wholeTestEnvironment
|
||||
sourceConfig = Cockroach.defaultSourceConfiguration testEnvironment
|
||||
@ -386,7 +386,7 @@ lhsCockroachSetup rhsTableName (wholeTestEnvironment, _) = do
|
||||
--------------------------------------------------------------------------------
|
||||
-- LHS Citus
|
||||
|
||||
lhsCitusSetup :: HasCallStack => Value -> (TestEnvironment, Maybe Server) -> IO ()
|
||||
lhsCitusSetup :: (HasCallStack) => Value -> (TestEnvironment, Maybe Server) -> IO ()
|
||||
lhsCitusSetup rhsTableName (wholeTestEnvironment, _) = do
|
||||
let testEnvironment = focusFixtureLeft wholeTestEnvironment
|
||||
sourceConfig = Citus.defaultSourceConfiguration testEnvironment
|
||||
@ -412,7 +412,7 @@ lhsCitusSetup rhsTableName (wholeTestEnvironment, _) = do
|
||||
--------------------------------------------------------------------------------
|
||||
-- LHS SQLServer
|
||||
|
||||
lhsSQLServerSetup :: HasCallStack => Value -> (TestEnvironment, Maybe Server) -> IO ()
|
||||
lhsSQLServerSetup :: (HasCallStack) => Value -> (TestEnvironment, Maybe Server) -> IO ()
|
||||
lhsSQLServerSetup rhsTableName (wholeTestEnvironment, _) = do
|
||||
let testEnvironment = focusFixtureLeft wholeTestEnvironment
|
||||
sourceConfig = SQLServer.defaultSourceConfiguration testEnvironment
|
||||
@ -438,7 +438,7 @@ lhsSQLServerSetup rhsTableName (wholeTestEnvironment, _) = do
|
||||
--------------------------------------------------------------------------------
|
||||
-- LHS SQLite
|
||||
|
||||
lhsSqliteSetup :: HasCallStack => Value -> (TestEnvironment, Maybe Server) -> IO API.DatasetCloneName
|
||||
lhsSqliteSetup :: (HasCallStack) => Value -> (TestEnvironment, Maybe Server) -> IO API.DatasetCloneName
|
||||
lhsSqliteSetup rhsTableName (wholeTestEnvironment, _) = do
|
||||
let testEnvironment = focusFixtureLeft wholeTestEnvironment
|
||||
let cloneName = API.DatasetCloneName $ tshow (uniqueTestId testEnvironment) <> "-lhs"
|
||||
@ -502,7 +502,7 @@ data Query m = Query
|
||||
}
|
||||
deriving (Generic)
|
||||
|
||||
instance Typeable m => Morpheus.GQLType (Query m)
|
||||
instance (Typeable m) => Morpheus.GQLType (Query m)
|
||||
|
||||
data HasuraArtistArgs = HasuraArtistArgs
|
||||
{ aa_where :: Maybe HasuraArtistBoolExp,
|
||||
@ -520,7 +520,7 @@ data HasuraArtist m = HasuraArtist
|
||||
}
|
||||
deriving (Generic)
|
||||
|
||||
instance Typeable m => Morpheus.GQLType (HasuraArtist m) where
|
||||
instance (Typeable m) => Morpheus.GQLType (HasuraArtist m) where
|
||||
typeOptions _ _ = hasuraTypeOptions
|
||||
|
||||
data HasuraArtistOrderBy = HasuraArtistOrderBy
|
||||
@ -575,12 +575,12 @@ lhsRemoteServerMkLocalTestEnvironment _ =
|
||||
Nothing -> \_ _ -> EQ
|
||||
Just orderByArg -> orderArtist orderByArg
|
||||
limitFunction = maybe id take aa_limit
|
||||
pure $
|
||||
artists
|
||||
& filter filterFunction
|
||||
& sortBy orderByFunction
|
||||
& limitFunction
|
||||
& map mkArtist
|
||||
pure
|
||||
$ artists
|
||||
& filter filterFunction
|
||||
& sortBy orderByFunction
|
||||
& limitFunction
|
||||
& map mkArtist
|
||||
-- Returns True iif the given artist matches the given boolean expression.
|
||||
matchArtist artistInfo@(artistId, artistName) (HasuraArtistBoolExp {..}) =
|
||||
and
|
||||
@ -599,13 +599,13 @@ lhsRemoteServerMkLocalTestEnvironment _ =
|
||||
(artistId2, artistName2) =
|
||||
flip foldMap orderByList \HasuraArtistOrderBy {..} ->
|
||||
if
|
||||
| Just idOrder <- aob_id ->
|
||||
compareWithNullLast idOrder artistId1 artistId2
|
||||
| Just nameOrder <- aob_name -> case nameOrder of
|
||||
Asc -> compare artistName1 artistName2
|
||||
Desc -> compare artistName2 artistName1
|
||||
| otherwise ->
|
||||
error "empty artist_order object"
|
||||
| Just idOrder <- aob_id ->
|
||||
compareWithNullLast idOrder artistId1 artistId2
|
||||
| Just nameOrder <- aob_name -> case nameOrder of
|
||||
Asc -> compare artistName1 artistName2
|
||||
Desc -> compare artistName2 artistName1
|
||||
| otherwise ->
|
||||
error "empty artist_order object"
|
||||
compareWithNullLast Desc x1 x2 = compareWithNullLast Asc x2 x1
|
||||
compareWithNullLast Asc Nothing Nothing = EQ
|
||||
compareWithNullLast Asc (Just _) Nothing = LT
|
||||
@ -623,7 +623,7 @@ lhsRemoteServerMkLocalTestEnvironment _ =
|
||||
a_name = pure $ Just artistName
|
||||
}
|
||||
|
||||
lhsRemoteServerSetup :: HasCallStack => Value -> (TestEnvironment, Maybe Server) -> IO ()
|
||||
lhsRemoteServerSetup :: (HasCallStack) => Value -> (TestEnvironment, Maybe Server) -> IO ()
|
||||
lhsRemoteServerSetup tableName (testEnvironment, maybeRemoteServer) = case maybeRemoteServer of
|
||||
Nothing -> error "XToDBArrayRelationshipSpec: remote server local testEnvironment did not succesfully create a server"
|
||||
Just remoteServer -> do
|
||||
@ -832,14 +832,14 @@ schemaTests =
|
||||
. key "fields"
|
||||
. values
|
||||
albumsField =
|
||||
Unsafe.fromJust $
|
||||
findOf
|
||||
Unsafe.fromJust
|
||||
$ findOf
|
||||
focusArtistFields
|
||||
(has $ key "name" . _String . only "albums")
|
||||
introspectionResult
|
||||
albumsAggregateField =
|
||||
Unsafe.fromJust $
|
||||
findOf
|
||||
Unsafe.fromJust
|
||||
$ findOf
|
||||
focusArtistFields
|
||||
(has $ key "name" . _String . only "albums_aggregate")
|
||||
introspectionResult
|
||||
|
@ -257,7 +257,7 @@ album =
|
||||
lhsPostgresMkLocalTestEnvironment :: TestEnvironment -> Managed (Maybe Server)
|
||||
lhsPostgresMkLocalTestEnvironment _ = pure Nothing
|
||||
|
||||
lhsPostgresSetup :: HasCallStack => Value -> (TestEnvironment, Maybe Server) -> IO ()
|
||||
lhsPostgresSetup :: (HasCallStack) => Value -> (TestEnvironment, Maybe Server) -> IO ()
|
||||
lhsPostgresSetup rhsTableName (wholeTestEnvironment, _) = do
|
||||
let testEnvironment = focusFixtureLeft wholeTestEnvironment
|
||||
sourceName = "source"
|
||||
@ -323,7 +323,7 @@ args:
|
||||
lhsCitusMkLocalTestEnvironment :: TestEnvironment -> Managed (Maybe Server)
|
||||
lhsCitusMkLocalTestEnvironment _ = pure Nothing
|
||||
|
||||
lhsCitusSetup :: HasCallStack => Value -> (TestEnvironment, Maybe Server) -> IO ()
|
||||
lhsCitusSetup :: (HasCallStack) => Value -> (TestEnvironment, Maybe Server) -> IO ()
|
||||
lhsCitusSetup rhsTableName (wholeTestEnvironment, _) = do
|
||||
let testEnvironment = focusFixtureLeft wholeTestEnvironment
|
||||
sourceName = "source"
|
||||
@ -389,7 +389,7 @@ args:
|
||||
lhsCockroachMkLocalTestEnvironment :: TestEnvironment -> Managed (Maybe Server)
|
||||
lhsCockroachMkLocalTestEnvironment _ = pure Nothing
|
||||
|
||||
lhsCockroachSetup :: HasCallStack => Value -> (TestEnvironment, Maybe Server) -> IO ()
|
||||
lhsCockroachSetup :: (HasCallStack) => Value -> (TestEnvironment, Maybe Server) -> IO ()
|
||||
lhsCockroachSetup rhsTableName (wholeTestEnvironment, _) = do
|
||||
let testEnvironment = focusFixtureLeft wholeTestEnvironment
|
||||
sourceName = "source"
|
||||
@ -455,7 +455,7 @@ lhsCockroachSetup rhsTableName (wholeTestEnvironment, _) = do
|
||||
lhsSQLServerMkLocalTestEnvironment :: TestEnvironment -> Managed (Maybe Server)
|
||||
lhsSQLServerMkLocalTestEnvironment _ = pure Nothing
|
||||
|
||||
lhsSQLServerSetup :: HasCallStack => Value -> (TestEnvironment, Maybe Server) -> IO ()
|
||||
lhsSQLServerSetup :: (HasCallStack) => Value -> (TestEnvironment, Maybe Server) -> IO ()
|
||||
lhsSQLServerSetup rhsTableName (wholeTestEnvironment, _) = do
|
||||
let testEnvironment = focusFixtureLeft wholeTestEnvironment
|
||||
sourceName = "source"
|
||||
@ -519,7 +519,7 @@ args:
|
||||
--------------------------------------------------------------------------------
|
||||
-- LHS SQLite
|
||||
|
||||
lhsSqliteSetup :: HasCallStack => Value -> (TestEnvironment, Maybe Server) -> IO API.DatasetCloneName
|
||||
lhsSqliteSetup :: (HasCallStack) => Value -> (TestEnvironment, Maybe Server) -> IO API.DatasetCloneName
|
||||
lhsSqliteSetup rhsTableName (wholeTestEnvironment, _) = do
|
||||
let testEnvironment = focusFixtureLeft wholeTestEnvironment
|
||||
let cloneName = API.DatasetCloneName $ tshow (uniqueTestId testEnvironment) <> "-lhs"
|
||||
@ -611,7 +611,7 @@ data Query m = Query
|
||||
}
|
||||
deriving (Generic)
|
||||
|
||||
instance Typeable m => Morpheus.GQLType (Query m)
|
||||
instance (Typeable m) => Morpheus.GQLType (Query m)
|
||||
|
||||
data HasuraTrackArgs = HasuraTrackArgs
|
||||
{ ta_where :: Maybe HasuraTrackBoolExp,
|
||||
@ -630,7 +630,7 @@ data HasuraTrack m = HasuraTrack
|
||||
}
|
||||
deriving (Generic)
|
||||
|
||||
instance Typeable m => Morpheus.GQLType (HasuraTrack m) where
|
||||
instance (Typeable m) => Morpheus.GQLType (HasuraTrack m) where
|
||||
typeOptions _ _ = hasuraTypeOptions
|
||||
|
||||
data HasuraTrackOrderBy = HasuraTrackOrderBy
|
||||
@ -687,12 +687,12 @@ lhsRemoteServerMkLocalTestEnvironment _ =
|
||||
Nothing -> \_ _ -> EQ
|
||||
Just orderByArg -> orderTrack orderByArg
|
||||
limitFunction = maybe Hasura.Prelude.id take ta_limit
|
||||
pure $
|
||||
tracks
|
||||
& filter filterFunction
|
||||
& sortBy orderByFunction
|
||||
& limitFunction
|
||||
& map mkTrack
|
||||
pure
|
||||
$ tracks
|
||||
& filter filterFunction
|
||||
& sortBy orderByFunction
|
||||
& limitFunction
|
||||
& map mkTrack
|
||||
-- Returns True iif the given track matches the given boolean expression.
|
||||
matchTrack trackInfo@(trackId, trackTitle, maybeAlbumId) (HasuraTrackBoolExp {..}) =
|
||||
and
|
||||
@ -713,16 +713,16 @@ lhsRemoteServerMkLocalTestEnvironment _ =
|
||||
(trackId2, trackTitle2, trackAlbumId2) =
|
||||
flip foldMap orderByList \HasuraTrackOrderBy {..} ->
|
||||
if
|
||||
| Just idOrder <- tob_id -> case idOrder of
|
||||
Asc -> compare trackId1 trackId2
|
||||
Desc -> compare trackId2 trackId1
|
||||
| Just titleOrder <- tob_title -> case titleOrder of
|
||||
Asc -> compare trackTitle1 trackTitle2
|
||||
Desc -> compare trackTitle2 trackTitle1
|
||||
| Just albumIdOrder <- tob_album_id ->
|
||||
compareWithNullLast albumIdOrder trackAlbumId1 trackAlbumId2
|
||||
| otherwise ->
|
||||
error "empty track_order object"
|
||||
| Just idOrder <- tob_id -> case idOrder of
|
||||
Asc -> compare trackId1 trackId2
|
||||
Desc -> compare trackId2 trackId1
|
||||
| Just titleOrder <- tob_title -> case titleOrder of
|
||||
Asc -> compare trackTitle1 trackTitle2
|
||||
Desc -> compare trackTitle2 trackTitle1
|
||||
| Just albumIdOrder <- tob_album_id ->
|
||||
compareWithNullLast albumIdOrder trackAlbumId1 trackAlbumId2
|
||||
| otherwise ->
|
||||
error "empty track_order object"
|
||||
compareWithNullLast Desc x1 x2 = compareWithNullLast Asc x2 x1
|
||||
compareWithNullLast Asc Nothing Nothing = EQ
|
||||
compareWithNullLast Asc (Just _) Nothing = LT
|
||||
@ -745,7 +745,7 @@ lhsRemoteServerMkLocalTestEnvironment _ =
|
||||
t_album_id = pure albumId
|
||||
}
|
||||
|
||||
lhsRemoteServerSetup :: HasCallStack => Value -> (TestEnvironment, Maybe Server) -> IO ()
|
||||
lhsRemoteServerSetup :: (HasCallStack) => Value -> (TestEnvironment, Maybe Server) -> IO ()
|
||||
lhsRemoteServerSetup tableName (testEnvironment, maybeRemoteServer) = case maybeRemoteServer of
|
||||
Nothing -> error "XToDBObjectRelationshipSpec: remote server local testEnvironment did not succesfully create a server"
|
||||
Just remoteServer -> do
|
||||
|
@ -47,8 +47,8 @@ spec :: SpecWith GlobalTestEnvironment
|
||||
spec = Fixture.runWithLocalTestEnvironment contexts tests
|
||||
where
|
||||
contexts =
|
||||
NE.fromList $
|
||||
map
|
||||
NE.fromList
|
||||
$ map
|
||||
mkFixture
|
||||
[ (Fixture.fixture $ Fixture.Backend Postgres.backendTypeMetadata)
|
||||
{ Fixture.mkLocalTestEnvironment = lhsPostgresMkLocalTestEnvironment,
|
||||
@ -431,7 +431,7 @@ data LHSQuery m = LHSQuery
|
||||
}
|
||||
deriving (Generic)
|
||||
|
||||
instance Typeable m => Morpheus.GQLType (LHSQuery m) where
|
||||
instance (Typeable m) => Morpheus.GQLType (LHSQuery m) where
|
||||
typeOptions _ _ = hasuraTypeOptions
|
||||
|
||||
data LHSHasuraTrackArgs = LHSHasuraTrackArgs
|
||||
@ -451,7 +451,7 @@ data LHSHasuraTrack m = LHSHasuraTrack
|
||||
}
|
||||
deriving (Generic)
|
||||
|
||||
instance Typeable m => Morpheus.GQLType (LHSHasuraTrack m) where
|
||||
instance (Typeable m) => Morpheus.GQLType (LHSHasuraTrack m) where
|
||||
typeOptions _ _ = hasuraTypeOptions
|
||||
|
||||
data LHSHasuraTrackOrderBy = LHSHasuraTrackOrderBy
|
||||
@ -508,12 +508,12 @@ lhsRemoteServerMkLocalTestEnvironment _ =
|
||||
Nothing -> \_ _ -> EQ
|
||||
Just orderByArg -> orderTrack orderByArg
|
||||
limitFunction = maybe Hasura.Prelude.id take ta_limit
|
||||
pure $
|
||||
tracks
|
||||
& filter filterFunction
|
||||
& sortBy orderByFunction
|
||||
& limitFunction
|
||||
& map mkTrack
|
||||
pure
|
||||
$ tracks
|
||||
& filter filterFunction
|
||||
& sortBy orderByFunction
|
||||
& limitFunction
|
||||
& map mkTrack
|
||||
-- Returns True iif the given track matches the given boolean expression.
|
||||
matchTrack trackInfo@(trackId, trackTitle, maybeAlbumId) (LHSHasuraTrackBoolExp {..}) =
|
||||
and
|
||||
@ -534,16 +534,16 @@ lhsRemoteServerMkLocalTestEnvironment _ =
|
||||
(trackId2, trackTitle2, trackAlbumId2) =
|
||||
flip foldMap orderByList \LHSHasuraTrackOrderBy {..} ->
|
||||
if
|
||||
| Just idOrder <- tob_id -> case idOrder of
|
||||
Asc -> compare trackId1 trackId2
|
||||
Desc -> compare trackId2 trackId1
|
||||
| Just titleOrder <- tob_title -> case titleOrder of
|
||||
Asc -> compare trackTitle1 trackTitle2
|
||||
Desc -> compare trackTitle2 trackTitle1
|
||||
| Just albumIdOrder <- tob_album_id ->
|
||||
compareWithNullLast albumIdOrder trackAlbumId1 trackAlbumId2
|
||||
| otherwise ->
|
||||
error "empty track_order object"
|
||||
| Just idOrder <- tob_id -> case idOrder of
|
||||
Asc -> compare trackId1 trackId2
|
||||
Desc -> compare trackId2 trackId1
|
||||
| Just titleOrder <- tob_title -> case titleOrder of
|
||||
Asc -> compare trackTitle1 trackTitle2
|
||||
Desc -> compare trackTitle2 trackTitle1
|
||||
| Just albumIdOrder <- tob_album_id ->
|
||||
compareWithNullLast albumIdOrder trackAlbumId1 trackAlbumId2
|
||||
| otherwise ->
|
||||
error "empty track_order object"
|
||||
compareWithNullLast Desc x1 x2 = compareWithNullLast Asc x2 x1
|
||||
compareWithNullLast Asc Nothing Nothing = EQ
|
||||
compareWithNullLast Asc (Just _) Nothing = LT
|
||||
|
@ -27,11 +27,11 @@ spec = Fixture.runWithLocalTestEnvironment (NE.fromList [context]) tests
|
||||
(Fixture.fixture $ Fixture.RemoteGraphQLServer)
|
||||
{ -- start only one remote server
|
||||
Fixture.mkLocalTestEnvironment = \_testEnvironment ->
|
||||
RemoteServer.run $
|
||||
RemoteServer.generateQueryInterpreter $
|
||||
Query
|
||||
{ echoEnum = echoEnumResolver
|
||||
},
|
||||
RemoteServer.run
|
||||
$ RemoteServer.generateQueryInterpreter
|
||||
$ Query
|
||||
{ echoEnum = echoEnumResolver
|
||||
},
|
||||
setupTeardown = \(testEnvironment, server) ->
|
||||
[ Fixture.SetupAction
|
||||
{ Fixture.setupAction =
|
||||
@ -175,5 +175,5 @@ enum Profession {
|
||||
|
||||
|]
|
||||
|
||||
echoEnumResolver :: Monad m => Arg "x" Profession -> m Profession
|
||||
echoEnumResolver :: (Monad m) => Arg "x" Profession -> m Profession
|
||||
echoEnumResolver (Arg x) = pure x
|
||||
|
@ -44,8 +44,8 @@ spec = do
|
||||
{ Fixture.setupTeardown = \(testEnv, _) ->
|
||||
[BigQuery.setupTablesAction schema testEnv],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
}
|
||||
|
@ -72,8 +72,8 @@ spec = do
|
||||
{ Fixture.setupTeardown = \(testEnv, _) ->
|
||||
[BigQuery.setupTablesAction schema testEnv],
|
||||
Fixture.customOptions =
|
||||
Just $
|
||||
Fixture.defaultOptions
|
||||
Just
|
||||
$ Fixture.defaultOptions
|
||||
{ Fixture.stringifyNumbers = True
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ import Control.Monad.Trans.Writer
|
||||
-- NB: This is conceptually different from `ArrowApply`, which expresses that a
|
||||
-- given `Arrow` /is/ a Kleisli arrow. `ArrowInterpret` has no such condition
|
||||
-- on @arr@.
|
||||
interpretWriter :: ArrowWriter w arr => Writer w a `arr` a
|
||||
interpretWriter :: (ArrowWriter w arr) => Writer w a `arr` a
|
||||
interpretWriter = proc m -> do
|
||||
let (a, w) = runWriter m
|
||||
tellA -< w
|
||||
|
@ -211,15 +211,15 @@ agentOptionsParser =
|
||||
<> metavar "JSON"
|
||||
<> help "The configuration JSON to be sent to the agent via the X-Hasura-DataConnector-Config header. If omitted, datasets will be used to load test data and provide this configuration dynamically"
|
||||
)
|
||||
<|> DatasetConfig
|
||||
<$> optional
|
||||
( option
|
||||
configValue
|
||||
( long "merge-agent-config"
|
||||
<> metavar "JSON"
|
||||
<> help "Datasets will be used to load test data and provide configuration JSON to be sent to the agent via the X-Hasura-DataConnector-Config header. This config will be merged with the dataset-provided config before being sent to the agent."
|
||||
)
|
||||
)
|
||||
<|> DatasetConfig
|
||||
<$> optional
|
||||
( option
|
||||
configValue
|
||||
( long "merge-agent-config"
|
||||
<> metavar "JSON"
|
||||
<> help "Datasets will be used to load test data and provide configuration JSON to be sent to the agent via the X-Hasura-DataConnector-Config header. This config will be merged with the dataset-provided config before being sent to the agent."
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
exportDataConfigParser :: Parser ExportDataConfig
|
||||
@ -252,5 +252,5 @@ baseUrl = eitherReader $ left show . parseBaseUrl
|
||||
configValue :: ReadM API.Config
|
||||
configValue = fmap API.Config jsonValue
|
||||
|
||||
jsonValue :: FromJSON v => ReadM v
|
||||
jsonValue :: (FromJSON v) => ReadM v
|
||||
jsonValue = eitherReader (eitherDecodeStrict' . Text.encodeUtf8 . Text.pack)
|
||||
|
@ -46,13 +46,13 @@ import Test.Expectations (yamlShow)
|
||||
import Test.Sandwich (HasBaseContext, expectationFailure)
|
||||
import Prelude
|
||||
|
||||
client :: RunClient m => API.Routes (AsClientT m)
|
||||
client :: (RunClient m) => API.Routes (AsClientT m)
|
||||
client = genericClient @API.Routes
|
||||
|
||||
getCapabilitiesGuarded :: (HasBaseContext context, MonadReader context m, MonadThrow m, MonadIO m) => AgentClientT m API.CapabilitiesResponse
|
||||
getCapabilitiesGuarded = guardCapabilitiesResponse =<< (client // API._capabilities)
|
||||
|
||||
guardCapabilitiesResponse :: MonadThrow m => Union API.CapabilitiesResponses -> m API.CapabilitiesResponse
|
||||
guardCapabilitiesResponse :: (MonadThrow m) => Union API.CapabilitiesResponses -> m API.CapabilitiesResponse
|
||||
guardCapabilitiesResponse = API.capabilitiesCase defaultAction successAction errorAction
|
||||
where
|
||||
defaultAction = expectationFailure "Expected CapabilitiesResponse"
|
||||
@ -72,7 +72,7 @@ getSchemaGuarded = do
|
||||
(sourceName, config) <- getSourceNameAndConfig
|
||||
guardSchemaResponse =<< (client // API._schema) sourceName config
|
||||
|
||||
guardSchemaResponse :: MonadThrow m => Union API.SchemaResponses -> m API.SchemaResponse
|
||||
guardSchemaResponse :: (MonadThrow m) => Union API.SchemaResponses -> m API.SchemaResponse
|
||||
guardSchemaResponse = API.schemaCase defaultAction successAction errorAction
|
||||
where
|
||||
defaultAction = expectationFailure "Expected SchemaResponse"
|
||||
@ -84,7 +84,7 @@ queryGuarded queryRequest = do
|
||||
(sourceName, config) <- getSourceNameAndConfig
|
||||
guardQueryResponse =<< (client // API._query) sourceName config queryRequest
|
||||
|
||||
guardQueryResponse :: MonadThrow m => Union API.QueryResponses -> m API.QueryResponse
|
||||
guardQueryResponse :: (MonadThrow m) => Union API.QueryResponses -> m API.QueryResponse
|
||||
guardQueryResponse = API.queryCase defaultAction successAction errorAction
|
||||
where
|
||||
defaultAction = expectationFailure "Expected QueryResponse"
|
||||
@ -96,7 +96,7 @@ queryExpectError queryRequest = do
|
||||
(sourceName, config) <- getSourceNameAndConfig
|
||||
guardQueryErrorResponse =<< (client // API._query) sourceName config queryRequest
|
||||
|
||||
guardQueryErrorResponse :: MonadThrow m => Union API.QueryResponses -> m API.ErrorResponse
|
||||
guardQueryErrorResponse :: (MonadThrow m) => Union API.QueryResponses -> m API.ErrorResponse
|
||||
guardQueryErrorResponse = API.queryCase defaultAction successAction errorAction
|
||||
where
|
||||
defaultAction = expectationFailure "Expected ErrorResponse"
|
||||
@ -116,7 +116,7 @@ mutationGuarded mutationRequest = do
|
||||
(sourceName, config) <- getSourceNameAndConfig
|
||||
guardMutationResponse =<< (client // API._mutation) sourceName config mutationRequest
|
||||
|
||||
guardMutationResponse :: MonadThrow m => Union API.MutationResponses -> m API.MutationResponse
|
||||
guardMutationResponse :: (MonadThrow m) => Union API.MutationResponses -> m API.MutationResponse
|
||||
guardMutationResponse = API.mutationCase defaultAction successAction errorAction
|
||||
where
|
||||
defaultAction = expectationFailure "Expected MutationResponse"
|
||||
@ -128,7 +128,7 @@ mutationExpectError mutationRequest = do
|
||||
(sourceName, config) <- getSourceNameAndConfig
|
||||
guardMutationErrorResponse =<< (client // API._mutation) sourceName config mutationRequest
|
||||
|
||||
guardMutationErrorResponse :: MonadThrow m => Union API.MutationResponses -> m API.ErrorResponse
|
||||
guardMutationErrorResponse :: (MonadThrow m) => Union API.MutationResponses -> m API.ErrorResponse
|
||||
guardMutationErrorResponse = API.mutationCase defaultAction successAction errorAction
|
||||
where
|
||||
defaultAction = expectationFailure "Expected ErrorResponse"
|
||||
|
@ -51,7 +51,7 @@ import Prelude
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
newtype AgentIOClient = AgentIOClient (forall m. MonadIO m => Client m (NamedRoutes API.Routes))
|
||||
newtype AgentIOClient = AgentIOClient (forall m. (MonadIO m) => Client m (NamedRoutes API.Routes))
|
||||
|
||||
configHeader :: HeaderName
|
||||
configHeader = CI.mk "X-Hasura-DataConnector-Config"
|
||||
@ -61,7 +61,7 @@ newtype AgentAuthKey = AgentAuthKey {getAgentAuthKey :: ByteString}
|
||||
eeLicenseKeyHeader :: HeaderName
|
||||
eeLicenseKeyHeader = CI.mk "X-Hasura-License"
|
||||
|
||||
mkHttpClientManager :: MonadIO m => SensitiveOutputHandling -> Maybe AgentAuthKey -> m HttpClient.Manager
|
||||
mkHttpClientManager :: (MonadIO m) => SensitiveOutputHandling -> Maybe AgentAuthKey -> m HttpClient.Manager
|
||||
mkHttpClientManager sensitiveOutputHandling agentAuthKey =
|
||||
let modifyRequest = addHeaderRedaction sensitiveOutputHandling . maybe id addLicenseKeyHeader agentAuthKey
|
||||
settings = HttpClient.defaultManagerSettings {HttpClient.managerModifyRequest = pure . modifyRequest}
|
||||
@ -76,7 +76,7 @@ addHeaderRedaction sensitiveOutputHandling request =
|
||||
AllowSensitiveOutput -> request
|
||||
DisallowSensitiveOutput -> request {HttpClient.redactHeaders = HttpClient.redactHeaders request <> Set.fromList [configHeader, eeLicenseKeyHeader]}
|
||||
|
||||
mkAgentIOClient :: MonadIO m => SensitiveOutputHandling -> Maybe AgentAuthKey -> BaseUrl -> m AgentIOClient
|
||||
mkAgentIOClient :: (MonadIO m) => SensitiveOutputHandling -> Maybe AgentAuthKey -> BaseUrl -> m AgentIOClient
|
||||
mkAgentIOClient sensitiveOutputHandling agentAuthKey agentBaseUrl = do
|
||||
manager <- mkHttpClientManager sensitiveOutputHandling agentAuthKey
|
||||
let clientEnv = mkClientEnv manager agentBaseUrl
|
||||
@ -90,7 +90,7 @@ data AgentClientConfig = AgentClientConfig
|
||||
_accSensitiveOutputHandling :: SensitiveOutputHandling
|
||||
}
|
||||
|
||||
mkAgentClientConfig :: MonadIO m => SensitiveOutputHandling -> Maybe AgentAuthKey -> BaseUrl -> m AgentClientConfig
|
||||
mkAgentClientConfig :: (MonadIO m) => SensitiveOutputHandling -> Maybe AgentAuthKey -> BaseUrl -> m AgentClientConfig
|
||||
mkAgentClientConfig sensitiveOutputHandling agentAuthKey agentBaseUrl = do
|
||||
manager <- mkHttpClientManager sensitiveOutputHandling agentAuthKey
|
||||
pure $ AgentClientConfig agentBaseUrl manager sensitiveOutputHandling
|
||||
@ -174,10 +174,10 @@ runRequestAcceptStatus' acceptStatus request = do
|
||||
then pure $ response
|
||||
else throwClientError $ mkFailureResponse _accBaseUrl request response
|
||||
|
||||
getClientState :: Monad m => AgentClientT m AgentClientState
|
||||
getClientState :: (Monad m) => AgentClientT m AgentClientState
|
||||
getClientState = AgentClientT get
|
||||
|
||||
incrementRequestCounter :: Monad m => AgentClientT m ()
|
||||
incrementRequestCounter :: (Monad m) => AgentClientT m ()
|
||||
incrementRequestCounter = AgentClientT $ modify' \state -> state {_acsRequestCounter = _acsRequestCounter state + 1}
|
||||
|
||||
redactJsonResponse :: Method -> ByteString -> J.Value -> J.Value
|
||||
|
@ -801,8 +801,8 @@ mkSubqueryAggregatesFieldValue :: HashMap API.FieldName J.Value -> API.FieldValu
|
||||
mkSubqueryAggregatesFieldValue aggregates =
|
||||
API.mkRelationshipFieldValue $ API.QueryResponse Nothing (Just aggregates)
|
||||
|
||||
mkAndExpr :: Foldable f => f API.Expression -> API.Expression
|
||||
mkAndExpr :: (Foldable f) => f API.Expression -> API.Expression
|
||||
mkAndExpr = API.And . Set.fromList . Foldable.toList
|
||||
|
||||
mkOrExpr :: Foldable f => f API.Expression -> API.Expression
|
||||
mkOrExpr :: (Foldable f) => f API.Expression -> API.Expression
|
||||
mkOrExpr = API.Or . Set.fromList . Foldable.toList
|
||||
|
@ -30,7 +30,7 @@ newtype YamlShow = YamlShow {unYamlShow :: Value}
|
||||
instance Show YamlShow where
|
||||
show = T.unpack . TE.decodeUtf8With TE.lenientDecode . Yaml.encode . unYamlShow
|
||||
|
||||
yamlShow :: ToJSON value => value -> String
|
||||
yamlShow :: (ToJSON value) => value -> String
|
||||
yamlShow = show . YamlShow . toJSON
|
||||
|
||||
-- | Compares two JSON values for equality, but prints their diff upon failure
|
||||
|
@ -141,7 +141,7 @@ spec TestData {..} API.Capabilities {..} = describe "schema API" $ preloadAgentS
|
||||
Maybe API.TableInfo -> -- Actual table
|
||||
ExampleT innerContext m ()
|
||||
) ->
|
||||
forall context. HasPreloadedAgentSchema context => SpecFree context IO ()
|
||||
forall context. (HasPreloadedAgentSchema context) => SpecFree context IO ()
|
||||
testPerTable description test =
|
||||
describe description $ do
|
||||
forM_ _tdSchemaTables $ \expectedTable@API.TableInfo {..} -> do
|
||||
|
@ -37,17 +37,17 @@ instance ToErrorValue () where
|
||||
-- > [J.Number 1, J.Bool True, J.String "three"]
|
||||
-- Will be printed as:
|
||||
-- > "[1, true, \"three\"]"
|
||||
instance ToErrorValue a => ToErrorValue [a] where
|
||||
instance (ToErrorValue a) => ToErrorValue [a] where
|
||||
toErrorValue values = "[" <> commaSeparatedValues <> "]"
|
||||
where
|
||||
commaSeparatedValues = foldr1 (<>) $ List.intersperse (toErrorMessage ", ") (map toErrorValue values)
|
||||
|
||||
-- | Will be printed as a list
|
||||
instance ToErrorValue a => ToErrorValue (NonEmpty a) where
|
||||
instance (ToErrorValue a) => ToErrorValue (NonEmpty a) where
|
||||
toErrorValue = toErrorValue . NonEmpty.toList
|
||||
|
||||
-- | Will be printed as a list
|
||||
instance ToErrorValue a => ToErrorValue (HashSet a) where
|
||||
instance (ToErrorValue a) => ToErrorValue (HashSet a) where
|
||||
toErrorValue = toErrorValue . HashSet.toList
|
||||
|
||||
-- | Will be printed with single quotes surrounding it
|
||||
|
@ -105,7 +105,7 @@ spec =
|
||||
newtype Thing a = Thing a
|
||||
deriving newtype (Eq, Hashable)
|
||||
|
||||
instance Show a => ToErrorValue (Thing a) where
|
||||
instance (Show a) => ToErrorValue (Thing a) where
|
||||
toErrorValue (Thing x) = toErrorMessage $ "Thing " <> Text.pack (show x)
|
||||
|
||||
newtype SingleQuoted = SingleQuoted Char
|
||||
|
@ -96,7 +96,7 @@ instance Generator Void where
|
||||
instance Generator Name where
|
||||
genValue = genValueWith [genName]
|
||||
|
||||
generate :: MonadIO m => Gen a -> m a
|
||||
generate :: (MonadIO m) => Gen a -> m a
|
||||
generate = Gen.sample
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
@ -107,7 +107,7 @@ genDocument :: Gen Document
|
||||
genDocument =
|
||||
Document <$> Gen.list (Range.linear 0 3) genDefinition
|
||||
|
||||
genExecutableDocument :: Generator a => Gen (ExecutableDocument a)
|
||||
genExecutableDocument :: (Generator a) => Gen (ExecutableDocument a)
|
||||
genExecutableDocument =
|
||||
ExecutableDocument <$> Gen.list (Range.linear 1 3) genExecutableDefinition
|
||||
|
||||
@ -219,21 +219,21 @@ genDefinition =
|
||||
DefinitionTypeSystem <$> genTypeSystemDefinition
|
||||
]
|
||||
|
||||
genExecutableDefinition :: Generator a => Gen (ExecutableDefinition a)
|
||||
genExecutableDefinition :: (Generator a) => Gen (ExecutableDefinition a)
|
||||
genExecutableDefinition =
|
||||
Gen.choice
|
||||
[ ExecutableDefinitionOperation <$> genOperationDefinition,
|
||||
ExecutableDefinitionFragment <$> genFragmentDefinition
|
||||
]
|
||||
|
||||
genOperationDefinition :: Generator a => Gen (OperationDefinition FragmentSpread a)
|
||||
genOperationDefinition :: (Generator a) => Gen (OperationDefinition FragmentSpread a)
|
||||
genOperationDefinition =
|
||||
Gen.choice
|
||||
[ OperationDefinitionTyped <$> genTypedOperationDefinition,
|
||||
OperationDefinitionUnTyped <$> genSelectionSet
|
||||
]
|
||||
|
||||
genTypedOperationDefinition :: Generator a => Gen (TypedOperationDefinition FragmentSpread a)
|
||||
genTypedOperationDefinition :: (Generator a) => Gen (TypedOperationDefinition FragmentSpread a)
|
||||
genTypedOperationDefinition =
|
||||
TypedOperationDefinition
|
||||
<$> genOperationType
|
||||
@ -422,10 +422,10 @@ genTypeSystemDirectiveLocation =
|
||||
|
||||
-- Structure
|
||||
|
||||
genSelectionSet :: Generator a => Gen (SelectionSet FragmentSpread a)
|
||||
genSelectionSet :: (Generator a) => Gen (SelectionSet FragmentSpread a)
|
||||
genSelectionSet = mkListNonEmpty genSelection
|
||||
|
||||
genSelection :: Generator a => Gen (Selection FragmentSpread a)
|
||||
genSelection :: (Generator a) => Gen (Selection FragmentSpread a)
|
||||
genSelection =
|
||||
Gen.recursive
|
||||
Gen.choice
|
||||
@ -435,20 +435,20 @@ genSelection =
|
||||
SelectionInlineFragment <$> genInlineFragment
|
||||
]
|
||||
|
||||
genFragmentSpread :: Generator a => Gen (FragmentSpread a)
|
||||
genFragmentSpread :: (Generator a) => Gen (FragmentSpread a)
|
||||
genFragmentSpread =
|
||||
FragmentSpread
|
||||
<$> genName
|
||||
<*> genDirectives
|
||||
|
||||
genInlineFragment :: Generator a => Gen (InlineFragment FragmentSpread a)
|
||||
genInlineFragment :: (Generator a) => Gen (InlineFragment FragmentSpread a)
|
||||
genInlineFragment =
|
||||
InlineFragment
|
||||
<$> Gen.maybe genName
|
||||
<*> genDirectives
|
||||
<*> genSelectionSet
|
||||
|
||||
genField :: Generator a => Gen (Field FragmentSpread a)
|
||||
genField :: (Generator a) => Gen (Field FragmentSpread a)
|
||||
genField =
|
||||
Field
|
||||
<$> Gen.maybe genName
|
||||
@ -457,16 +457,16 @@ genField =
|
||||
<*> genDirectives
|
||||
<*> genSelectionSet
|
||||
|
||||
genDirective :: Generator a => Gen (Directive a)
|
||||
genDirective :: (Generator a) => Gen (Directive a)
|
||||
genDirective =
|
||||
Directive
|
||||
<$> genName
|
||||
<*> (HashMap.fromList <$> mkList genArgument)
|
||||
|
||||
genDirectives :: Generator a => Gen [Directive a]
|
||||
genDirectives :: (Generator a) => Gen [Directive a]
|
||||
genDirectives = mkList genDirective
|
||||
|
||||
genArgument :: Generator a => Gen (Name, Value a)
|
||||
genArgument :: (Generator a) => Gen (Name, Value a)
|
||||
genArgument = (,) <$> genName <*> genValue
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
@ -136,10 +136,10 @@ class PossibleTypes pos where
|
||||
instance PossibleTypes () where
|
||||
possibleTypes = pure ()
|
||||
|
||||
selectionSet :: Variable var => Parser (AST.SelectionSet AST.FragmentSpread var)
|
||||
selectionSet :: (Variable var) => Parser (AST.SelectionSet AST.FragmentSpread var)
|
||||
selectionSet = braces $ many1 selection
|
||||
|
||||
selection :: Variable var => Parser (AST.Selection AST.FragmentSpread var)
|
||||
selection :: (Variable var) => Parser (AST.Selection AST.FragmentSpread var)
|
||||
selection =
|
||||
AST.SelectionField <$> field
|
||||
-- Inline first to catch `on` case
|
||||
@ -155,7 +155,7 @@ aliasAndFld = do
|
||||
Nothing -> return (Nothing, n)
|
||||
{-# INLINE aliasAndFld #-}
|
||||
|
||||
field :: Variable var => Parser (AST.Field AST.FragmentSpread var)
|
||||
field :: (Variable var) => Parser (AST.Field AST.FragmentSpread var)
|
||||
field = do
|
||||
(alM, n) <- aliasAndFld
|
||||
AST.Field alM n
|
||||
@ -165,7 +165,7 @@ field = do
|
||||
|
||||
-- * Fragments
|
||||
|
||||
fragmentSpread :: Variable var => Parser (AST.FragmentSpread var)
|
||||
fragmentSpread :: (Variable var) => Parser (AST.FragmentSpread var)
|
||||
-- TODO: Make sure it fails when `... on`.
|
||||
-- See https://facebook.github.io/graphql/#FragmentSpread
|
||||
fragmentSpread =
|
||||
@ -175,7 +175,7 @@ fragmentSpread =
|
||||
<*> optempty directives
|
||||
|
||||
-- InlineFragment tried first in order to guard against 'on' keyword
|
||||
inlineFragment :: Variable var => Parser (AST.InlineFragment AST.FragmentSpread var)
|
||||
inlineFragment :: (Variable var) => Parser (AST.InlineFragment AST.FragmentSpread var)
|
||||
inlineFragment =
|
||||
AST.InlineFragment
|
||||
<$ tok "..."
|
||||
@ -207,7 +207,7 @@ number = do
|
||||
|
||||
-- This will try to pick the first type it can runParser. If you are working with
|
||||
-- explicit types use the `typedValue` parser.
|
||||
value :: Variable var => Parser (AST.Value var)
|
||||
value :: (Variable var) => Parser (AST.Value var)
|
||||
value =
|
||||
tok
|
||||
( AST.VVariable <$> variable
|
||||
@ -254,17 +254,17 @@ stringLiteral = unescapeText =<< (char '"' *> jstring_ <?> "string")
|
||||
unescapeText :: Text -> Parser Text
|
||||
unescapeText str = either fail pure $ A.parseOnly jstring ("\"" <> encodeUtf8 str <> "\"")
|
||||
|
||||
listLiteral :: Variable var => Parser [AST.Value var]
|
||||
listLiteral :: (Variable var) => Parser [AST.Value var]
|
||||
listLiteral = brackets (many value) <?> "list"
|
||||
|
||||
objectLiteral :: Variable var => Parser (HashMap AST.Name (AST.Value var))
|
||||
objectLiteral :: (Variable var) => Parser (HashMap AST.Name (AST.Value var))
|
||||
objectLiteral = braces (objectFields many) <?> "object"
|
||||
|
||||
arguments :: Variable var => Parser (HashMap AST.Name (AST.Value var))
|
||||
arguments :: (Variable var) => Parser (HashMap AST.Name (AST.Value var))
|
||||
arguments = parens (objectFields many1) <?> "arguments"
|
||||
|
||||
objectFields ::
|
||||
Variable var =>
|
||||
(Variable var) =>
|
||||
(forall b. Parser b -> Parser [b]) ->
|
||||
Parser (HashMap AST.Name (AST.Value var))
|
||||
objectFields several = foldM insertField HashMap.empty =<< several objectField
|
||||
@ -276,10 +276,10 @@ objectFields several = foldM insertField HashMap.empty =<< several objectField
|
||||
|
||||
-- * Directives
|
||||
|
||||
directives :: Variable var => Parser [AST.Directive var]
|
||||
directives :: (Variable var) => Parser [AST.Directive var]
|
||||
directives = many1 directive
|
||||
|
||||
directive :: Variable var => Parser (AST.Directive var)
|
||||
directive :: (Variable var) => Parser (AST.Directive var)
|
||||
directive =
|
||||
AST.Directive
|
||||
<$ tok "@"
|
||||
@ -370,7 +370,7 @@ fieldDefinition =
|
||||
argumentsDefinition :: Parser (AST.ArgumentsDefinition AST.InputValueDefinition)
|
||||
argumentsDefinition = parens $ many1 inputValueDefinition
|
||||
|
||||
interfaceTypeDefinition :: PossibleTypes pos => Parser (AST.InterfaceTypeDefinition pos AST.InputValueDefinition)
|
||||
interfaceTypeDefinition :: (PossibleTypes pos) => Parser (AST.InterfaceTypeDefinition pos AST.InputValueDefinition)
|
||||
interfaceTypeDefinition =
|
||||
AST.InterfaceTypeDefinition
|
||||
<$> optDesc
|
||||
@ -526,7 +526,7 @@ between :: Parser Text -> Parser Text -> Parser a -> Parser a
|
||||
between open close p = tok open *> p <* tok close
|
||||
|
||||
-- `empty` /= `pure mempty` for `Parser`.
|
||||
optempty :: Monoid a => Parser a -> Parser a
|
||||
optempty :: (Monoid a) => Parser a -> Parser a
|
||||
optempty = option mempty
|
||||
|
||||
data Expecting
|
||||
|
@ -124,7 +124,7 @@ instance Printer T.Text where
|
||||
doubleP = T.pack . show
|
||||
|
||||
class Print a where
|
||||
printP :: Printer b => a -> b
|
||||
printP :: (Printer b) => a -> b
|
||||
|
||||
instance Print Void where
|
||||
printP = absurd
|
||||
@ -168,7 +168,7 @@ typedOperationDefinition :: (Print (frag var), Print var, Printer a) => TypedOpe
|
||||
typedOperationDefinition op =
|
||||
operationType (_todType op) <> charP ' ' <> nodeP op
|
||||
|
||||
operationType :: Printer a => OperationType -> a
|
||||
operationType :: (Printer a) => OperationType -> a
|
||||
operationType = \case
|
||||
OperationTypeQuery -> "query"
|
||||
OperationTypeMutation -> "mutation"
|
||||
@ -204,7 +204,7 @@ field (Field alias name args dirs selSets) =
|
||||
<> charP ' '
|
||||
<> selectionSetP selSets
|
||||
|
||||
optAlias :: Printer a => Maybe Name -> a
|
||||
optAlias :: (Printer a) => Maybe Name -> a
|
||||
optAlias = maybe mempty (\a -> nameP a <> textP ": ")
|
||||
|
||||
inlineFragment :: (Print (frag var), Print var, Printer a) => InlineFragment frag var -> a
|
||||
@ -214,14 +214,14 @@ inlineFragment (InlineFragment tc ds sels) =
|
||||
<> optempty directives ds
|
||||
<> selectionSetP sels
|
||||
|
||||
instance Print var => Print (FragmentSpread var) where
|
||||
instance (Print var) => Print (FragmentSpread var) where
|
||||
printP (FragmentSpread name ds) =
|
||||
"..." <> nameP name <> optempty directives ds
|
||||
|
||||
instance Print (NoFragments var) where
|
||||
printP = \case {}
|
||||
|
||||
fragmentDefinition :: Printer a => FragmentDefinition -> a
|
||||
fragmentDefinition :: (Printer a) => FragmentDefinition -> a
|
||||
fragmentDefinition (FragmentDefinition name tc dirs sels) =
|
||||
"fragment "
|
||||
<> nameP name
|
||||
@ -240,7 +240,7 @@ directive (Directive name args) =
|
||||
arguments :: (Print var, Printer a) => HashMap Name (Value var) -> a
|
||||
arguments xs = charP '(' <> objectFields xs <> charP ')'
|
||||
|
||||
variableDefinitions :: Printer a => [VariableDefinition] -> a
|
||||
variableDefinitions :: (Printer a) => [VariableDefinition] -> a
|
||||
variableDefinitions vars =
|
||||
mconcat
|
||||
[ charP '(',
|
||||
@ -250,26 +250,26 @@ variableDefinitions vars =
|
||||
where
|
||||
vars' = intersperse (charP ',') $ map variableDefinition vars
|
||||
|
||||
variableDefinition :: Printer a => VariableDefinition -> a
|
||||
variableDefinition :: (Printer a) => VariableDefinition -> a
|
||||
variableDefinition (VariableDefinition var ty defVal) =
|
||||
variableP var <> ": " <> graphQLType ty <> maybe mempty defaultValue defVal
|
||||
|
||||
defaultValue :: Printer a => Value Void -> a
|
||||
defaultValue :: (Printer a) => Value Void -> a
|
||||
defaultValue v = " = " <> value v
|
||||
|
||||
description :: Printer a => Maybe Description -> a
|
||||
description :: (Printer a) => Maybe Description -> a
|
||||
description Nothing = mempty
|
||||
description (Just desc) = dispatchStringPrinter (unDescription desc) <> " \n"
|
||||
|
||||
-- | Type Reference
|
||||
graphQLType :: Printer a => GType -> a
|
||||
graphQLType :: (Printer a) => GType -> a
|
||||
graphQLType (TypeNamed n x) = nameP x <> nonNull n
|
||||
graphQLType (TypeList n x) = listType x <> nonNull n
|
||||
|
||||
listType :: Printer a => GType -> a
|
||||
listType :: (Printer a) => GType -> a
|
||||
listType ty = charP '[' <> graphQLType ty <> charP ']'
|
||||
|
||||
nonNull :: Printer a => Nullability -> a
|
||||
nonNull :: (Printer a) => Nullability -> a
|
||||
nonNull n = bool (charP '!') mempty $ unNullability n
|
||||
|
||||
-- | Primitives
|
||||
@ -290,7 +290,7 @@ value = \case
|
||||
|
||||
-- | Print a given text as a normal string or as a block string, depending on
|
||||
-- its content.
|
||||
dispatchStringPrinter :: Printer a => Text -> a
|
||||
dispatchStringPrinter :: (Printer a) => Text -> a
|
||||
dispatchStringPrinter t =
|
||||
if printAsBlockString then blockStringValue t else stringValue t
|
||||
where
|
||||
@ -322,10 +322,10 @@ dispatchStringPrinter t =
|
||||
isSourceCharacter = not . isControl
|
||||
|
||||
-- | We use Aeson to decode string values, and therefore use Aeson to encode them back.
|
||||
stringValue :: Printer a => Text -> a
|
||||
stringValue :: (Printer a) => Text -> a
|
||||
stringValue s = textP $ LT.toStrict $ LTE.decodeUtf8 $ J.encode s
|
||||
|
||||
blockStringValue :: Printer a => Text -> a
|
||||
blockStringValue :: (Printer a) => Text -> a
|
||||
blockStringValue t = textP "\"\"\"\n" <> textP t <> textP "\n\"\"\""
|
||||
|
||||
listValue :: (Print var, Printer a) => [Value var] -> a
|
||||
@ -341,7 +341,7 @@ objectFields o = mconcat $ intersperse (charP ',') $ map objectField $ HashMap.t
|
||||
where
|
||||
objectField (name, val) = nameP name <> ": " <> value val
|
||||
|
||||
fromBool :: Printer a => Bool -> a
|
||||
fromBool :: (Printer a) => Bool -> a
|
||||
fromBool True = "true"
|
||||
fromBool False = "false"
|
||||
|
||||
@ -352,7 +352,7 @@ optempty f xs
|
||||
|
||||
schemaDefinition ::
|
||||
forall a.
|
||||
Printer a =>
|
||||
(Printer a) =>
|
||||
SchemaDefinition ->
|
||||
a
|
||||
schemaDefinition (SchemaDefinition dirs rootOpDefs) =
|
||||
@ -362,15 +362,15 @@ schemaDefinition (SchemaDefinition dirs rootOpDefs) =
|
||||
<> mconcat (intersperse (charP ' ') (map rootOperationTypeDefinition rootOpDefs))
|
||||
<> " }"
|
||||
|
||||
rootOperationTypeDefinition :: Printer a => RootOperationTypeDefinition -> a
|
||||
rootOperationTypeDefinition :: (Printer a) => RootOperationTypeDefinition -> a
|
||||
rootOperationTypeDefinition (RootOperationTypeDefinition opType rootName) =
|
||||
operationType opType <> ": " <> nameP rootName
|
||||
|
||||
typeSystemDefinition :: Printer a => TypeSystemDefinition -> a
|
||||
typeSystemDefinition :: (Printer a) => TypeSystemDefinition -> a
|
||||
typeSystemDefinition (TypeSystemDefinitionSchema schemaDefn) = schemaDefinition schemaDefn
|
||||
typeSystemDefinition (TypeSystemDefinitionType typeDefn) = typeDefinitionP typeDefn
|
||||
|
||||
schemaDocument :: Printer a => SchemaDocument -> a
|
||||
schemaDocument :: (Printer a) => SchemaDocument -> a
|
||||
schemaDocument (SchemaDocument typeDefns) =
|
||||
mconcat $ intersperse (textP "\n\n") $ map typeSystemDefinition $ sort $ filter isNotBuiltInScalar typeDefns
|
||||
where
|
||||
@ -383,7 +383,7 @@ schemaDocument (SchemaDocument typeDefns) =
|
||||
) = name `notElem` builtInScalars
|
||||
isNotBuiltInScalar _ = True
|
||||
|
||||
typeDefinitionP :: Printer a => TypeDefinition () InputValueDefinition -> a
|
||||
typeDefinitionP :: (Printer a) => TypeDefinition () InputValueDefinition -> a
|
||||
typeDefinitionP (TypeDefinitionScalar scalarDefn) = scalarTypeDefinition scalarDefn
|
||||
typeDefinitionP (TypeDefinitionObject objDefn) = objectTypeDefinition objDefn
|
||||
typeDefinitionP (TypeDefinitionInterface interfaceDefn) = interfaceTypeDefinition interfaceDefn
|
||||
@ -391,7 +391,7 @@ typeDefinitionP (TypeDefinitionUnion unionDefn) = unionTypeDefinition unionDefn
|
||||
typeDefinitionP (TypeDefinitionEnum enumDefn) = enumTypeDefinition enumDefn
|
||||
typeDefinitionP (TypeDefinitionInputObject inpObjDefn) = inputObjectTypeDefinition inpObjDefn
|
||||
|
||||
scalarTypeDefinition :: Printer a => ScalarTypeDefinition -> a
|
||||
scalarTypeDefinition :: (Printer a) => ScalarTypeDefinition -> a
|
||||
scalarTypeDefinition (ScalarTypeDefinition desc name dirs) =
|
||||
description desc
|
||||
<> "scalar "
|
||||
@ -400,7 +400,7 @@ scalarTypeDefinition (ScalarTypeDefinition desc name dirs) =
|
||||
then mempty
|
||||
else charP ' ' <> optempty directives dirs
|
||||
|
||||
inputValueDefinition :: Printer a => InputValueDefinition -> a
|
||||
inputValueDefinition :: (Printer a) => InputValueDefinition -> a
|
||||
inputValueDefinition (InputValueDefinition desc name gType defVal dirs) =
|
||||
description desc
|
||||
<> nameP name
|
||||
@ -411,7 +411,7 @@ inputValueDefinition (InputValueDefinition desc name gType defVal dirs) =
|
||||
then mempty
|
||||
else charP ' ' <> optempty directives dirs
|
||||
|
||||
fieldDefinition :: Printer a => FieldDefinition InputValueDefinition -> a
|
||||
fieldDefinition :: (Printer a) => FieldDefinition InputValueDefinition -> a
|
||||
fieldDefinition (FieldDefinition desc name args gType dirs) =
|
||||
description desc
|
||||
<> nameP name
|
||||
@ -425,7 +425,7 @@ fieldDefinition (FieldDefinition desc name args gType dirs) =
|
||||
<> graphQLType gType
|
||||
<> optempty directives dirs
|
||||
|
||||
objectTypeDefinition :: Printer a => ObjectTypeDefinition InputValueDefinition -> a
|
||||
objectTypeDefinition :: (Printer a) => ObjectTypeDefinition InputValueDefinition -> a
|
||||
objectTypeDefinition (ObjectTypeDefinition desc name ifaces dirs fieldDefinitions) =
|
||||
description desc
|
||||
<> "type "
|
||||
@ -444,7 +444,7 @@ objectTypeDefinition (ObjectTypeDefinition desc name ifaces dirs fieldDefinition
|
||||
<> "\n"
|
||||
<> "}"
|
||||
|
||||
interfaceTypeDefinition :: Printer a => InterfaceTypeDefinition () InputValueDefinition -> a
|
||||
interfaceTypeDefinition :: (Printer a) => InterfaceTypeDefinition () InputValueDefinition -> a
|
||||
interfaceTypeDefinition (InterfaceTypeDefinition desc name dirs fieldDefinitions _possibleTypes) =
|
||||
-- `possibleTypes` are not included with an interface definition in a GraphQL IDL
|
||||
description desc
|
||||
@ -462,7 +462,7 @@ interfaceTypeDefinition (InterfaceTypeDefinition desc name dirs fieldDefinitions
|
||||
<> "\n"
|
||||
<> "}"
|
||||
|
||||
unionTypeDefinition :: Printer a => UnionTypeDefinition -> a
|
||||
unionTypeDefinition :: (Printer a) => UnionTypeDefinition -> a
|
||||
unionTypeDefinition (UnionTypeDefinition desc name dirs members) =
|
||||
description desc
|
||||
<> "union "
|
||||
@ -472,14 +472,14 @@ unionTypeDefinition (UnionTypeDefinition desc name dirs members) =
|
||||
<> textP " = "
|
||||
<> mconcat (intersperse (textP " | ") $ map nameP $ sort members)
|
||||
|
||||
enumValueDefinition :: Printer a => EnumValueDefinition -> a
|
||||
enumValueDefinition :: (Printer a) => EnumValueDefinition -> a
|
||||
enumValueDefinition (EnumValueDefinition desc name dirs) =
|
||||
description desc
|
||||
<> nameP (unEnumValue name)
|
||||
<> charP ' '
|
||||
<> optempty directives dirs
|
||||
|
||||
enumTypeDefinition :: Printer a => EnumTypeDefinition -> a
|
||||
enumTypeDefinition :: (Printer a) => EnumTypeDefinition -> a
|
||||
enumTypeDefinition (EnumTypeDefinition desc name dirs enumValDefns) =
|
||||
description desc
|
||||
<> "enum "
|
||||
@ -495,7 +495,7 @@ enumTypeDefinition (EnumTypeDefinition desc name dirs enumValDefns) =
|
||||
<> "\n"
|
||||
<> "}"
|
||||
|
||||
inputObjectTypeDefinition :: Printer a => InputObjectTypeDefinition InputValueDefinition -> a
|
||||
inputObjectTypeDefinition :: (Printer a) => InputObjectTypeDefinition InputValueDefinition -> a
|
||||
inputObjectTypeDefinition (InputObjectTypeDefinition desc name dirs valDefns) =
|
||||
description desc
|
||||
<> "input "
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user