graphql-engine/server/lib/api-tests/api-tests.cabal
Puru Gupta 698190894f server: use kriti template to generate query param from list
## Description ✍️
This PR adds support to generate query params directly using a kriti template which can be used to flatten a list of parameter arguments as well.

### Changes in the Metadata API
Earlier the `query_params` key inside `request_transform` used to take in an object of key/value pairs where the `key` represents the query parameter name and `value` points to the value of the parameter or a kriti template which could be resolved to the value.

With this PR, we provide the user with more freedom to generate the complete query string using kriti template. The  `query_params` can now take in a string as well which will be a kriti template. This new change needs to be incorporated on the console and CLI metadata import/export as well.
- [x] CLI: Compatible, no changes required
- [ ] Console

## Changelog ✍️

__Component__ : server

__Type__: feature

__Product__: community-edition

### Short Changelog

use kriti template to generate query param from list of arguments

### Related Issues ✍
https://hasurahq.atlassian.net/browse/GS-243

### Solution and Design ✍
We use a kriti template to generate the complete query parameter string.

| Query Template | Output |
|---|---|
| `{{ concat ([concat({{ range _, x := [\"apple\", \"banana\"] }} \"tags={{x}}&\" {{ end }}), \"flag=smthng\"]) }}`| `tags=apple&tags=banana&flag=smthng`  |
| `{{ concat ([\"tags=\", concat({{ range _, x := $body.input }} \"{{x}},\" {{ end }})]) }}` | `tags=apple%2Cbanana%2C` |

### Steps to test and verify ✍
- start HGE and make the following request to `http://localhost:8080/v1/metadata`:
```json
{
    "type": "test_webhook_transform",
    "args": {
        "webhook_url": "http://localhost:3000",
        "body": {
            "action": {
                "name": "actionName"
            },
            "input": ["apple", "banana"]
        },
        "request_transform": {
            "version": 2,
            "url": "{{$base_url}}",
            "query_params": "{{ concat ([concat({{ range _, x := $body.input }} \"tags={{x}}&\" {{ end }}), \"flag=smthng\"]) }}",
            "template_engine": "Kriti"
        }
    }
}
```
- you should receive the following as output:
```json
{
    "body": {
        "action": {
            "name": "actionName"
        },
        "input": [
            "apple",
            "banana"
        ]
    },
    "headers": [],
    "method": "GET",
    "webhook_url": "http://localhost:3000?tags=apple&tags=banana&flag=smthng"
}
```

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6961
Co-authored-by: Tirumarai Selvan <8663570+tirumaraiselvan@users.noreply.github.com>
GitOrigin-RevId: 712ba038f03009edc3e8eb0435e723304943399a
2022-11-29 20:27:41 +00:00

231 lines
7.6 KiB
Plaintext

cabal-version: 2.2
name: api-tests
version: 1.0.0
library
build-tool-depends: hspec-discover:hspec-discover
hs-source-dirs: src
default-extensions:
BlockArguments
DataKinds
DeriveGeneric
DerivingStrategies
ImportQualifiedPost
LambdaCase
MultiWayIf
NamedFieldPuns
NoImplicitPrelude
OverloadedStrings
PatternGuards
QuasiQuotes
RecordWildCards
ScopedTypeVariables
TypeApplications
TypeFamilies
build-depends:
, HUnit
, aeson
, base
, bytestring
, dc-api
, fast-logger
, graphql-parser
, hasura-prelude
, hspec
, hspec-core
, http-conduit
, http-types
, lens
, lens-aeson
, managed
, morpheus-graphql
, pg-client
, postgresql-simple
, postgres-options
, safe-exceptions
, split
, sop-core
, test-harness
, text
, unordered-containers
, uuid
, vector
exposed-modules:
Spec
SpecHook
Test.API.ExplainSpec
Test.API.Metadata.ComputedFieldsSpec
Test.API.Metadata.InconsistentSpec
Test.API.Schema.RunSQLSpec
Test.Auth.Authorization.DisableRootFields.Common
Test.Auth.Authorization.DisableRootFields.DefaultRootFieldsSpec
Test.Auth.Authorization.DisableRootFields.SelectPermission.DisableAllRootFieldsSpec
Test.Auth.Authorization.DisableRootFields.SelectPermission.EnableAggSpec
Test.Auth.Authorization.DisableRootFields.SelectPermission.EnableAllRootFieldsSpec
Test.Auth.Authorization.DisableRootFields.SelectPermission.EnablePKSpec
Test.Auth.Authorization.DisableRootFields.SelectPermission.RelationshipSpec
Test.Databases.BigQuery.Queries.SpatialTypesSpec
Test.Databases.BigQuery.Queries.TypeInterpretationSpec
Test.Databases.Postgres.BackendOnlyPermissionsSpec
Test.Databases.Postgres.DataValidation.PermissionSpec
Test.Databases.Postgres.JsonbSpec
Test.Databases.Postgres.TimestampSpec
Test.Databases.Postgres.UniqueConstraintsSpec
Test.Databases.SQLServer.DefaultValues.OnConflictSpec
Test.Databases.SQLServer.InsertVarcharColumnSpec
Test.Databases.SQLServer.VarcharLiteralsSpec
Test.DataConnector.AggregateQuerySpec
Test.DataConnector.MetadataApiSpec
Test.DataConnector.MockAgent.AggregateQuerySpec
Test.DataConnector.MockAgent.BasicQuerySpec
Test.DataConnector.MockAgent.ErrorSpec
Test.DataConnector.MockAgent.QueryRelationshipsSpec
Test.DataConnector.MockAgent.TransformedConfigurationSpec
Test.DataConnector.QuerySpec
Test.DataConnector.SelectPermissionsSpec
Test.EventTriggers.MSSQL.EventTriggersUniqueNameSpec
Test.EventTriggers.MSSQL.EventTriggerDropSourceCleanupSpec
Test.EventTriggers.MSSQL.EventTriggersUntrackTableCleanupSpec
Test.EventTriggers.MSSQL.EventTriggersForReplicationSpec
Test.EventTriggers.PG.EventTriggersExtensionSchemaSpec
Test.EventTriggers.PG.EventTriggersRecreationSpec
Test.EventTriggers.PG.EventTriggersReplaceMetadataCleanupSpec
Test.EventTriggers.PG.EventTriggersRunSQLSpec
Test.EventTriggers.PG.EventTriggersUniqueNameSpec
Test.EventTriggers.PG.EventTriggersUntrackTableCleanupSpec
Test.EventTriggers.PG.EventTriggersForReplicationSpec
Test.Harness.Quoter.YamlSpec
Test.HelloWorldSpec
Test.Mutations.Delete.AllSpec
Test.Mutations.Delete.FieldSpec
Test.Mutations.Delete.NestedFieldSpec
Test.Mutations.Delete.PrimaryKeySpec
Test.Mutations.Insert.MultipleSpec
Test.Mutations.Insert.SingleSpec
Test.Mutations.MultiplePerRequest.UpdateManySpec
Test.Mutations.Update.FieldSpec
Test.Mutations.Update.PrimaryKeySpec
Test.Mutations.Upsert.OnConflictSpec
Test.PortedFromPytest.TestGraphQLQueryBasicCitus
Test.Queries.AggregationSpec
Test.Queries.DistinctSpec
Test.Queries.FilterSearch.AggregationPredicatesSpec
Test.Queries.FilterSearch.FilterSearchSpec
Test.Queries.NestedObjectSpec
Test.Queries.Paginate.LimitSpec
Test.Queries.Paginate.OffsetSpec
Test.Queries.Simple.NoQueriesAvailableSpec
Test.Queries.Simple.ObjectQueriesSpec
Test.Queries.Simple.OperationNameSpec
Test.Queries.Simple.PrimaryKeySpec
Test.Queries.SortSpec
Test.Queries.VariablesAliasesFragments.AliasesSpec
Test.Queries.VariablesAliasesFragments.Directives.DirectivesSpec
Test.Queries.VariablesAliasesFragments.Directives.IncludeAndSkipSpec
Test.Queries.VariablesAliasesFragments.Directives.IncludeSpec
Test.Queries.VariablesAliasesFragments.Directives.SkipSpec
Test.Queries.VariablesAliasesFragments.FragmentsSpec
Test.Queries.VariablesAliasesFragments.VariablesSpec
Test.Regression.AggregateBoolExpConflictSpec
Test.Regression.ArrayLiteralTextEncodingSpec
Test.Regression.DoNotTruncateSessionVariables8158Spec
Test.Regression.DropColumnWithPermissions8415Spec
Test.Regression.InsertOnConflict8260Spec
Test.Regression.LongIdentifiers3796Spec
Test.Regression.MultiColumnObjectRelationshipsSpec
Test.Regression.NullRemoteRelationship8345Spec
Test.Regression.NullsOrderParsing8780Spec
Test.Regression.ObjectRelationshipsLimit7936Spec
Test.Regression.StreamConflictSpec
Test.Regression.UsingTheSameFunctionForRootFieldAndComputedField8643Spec
Test.Schema.ComputedFieldsSpec
Test.Schema.ConflictsSpec
Test.Schema.CustomFieldNames.MutationSpec
Test.Schema.CustomFieldNames.QuerySpec
Test.Schema.CustomFieldsSpec
Test.Schema.DataValidations.Permissions.InsertSpec
Test.Schema.DataValidations.Permissions.SelectSpec
Test.Schema.DefaultValues.DefaultValuesSpec
Test.Schema.DefaultValues.OnConflictSpec
Test.Schema.EnumsSpec
Test.Schema.RemoteSchemaCustomizationSpec
Test.Schema.RemoteRelationships.FromRemoteSchemaSpec
Test.Schema.RemoteRelationships.MetadataAPI.ClearMetadataSpec
Test.Schema.RemoteRelationships.MetadataAPI.Common
Test.Schema.RemoteRelationships.MetadataAPI.DropSource.DBtoDBRelationshipSpec
Test.Schema.RemoteRelationships.MetadataAPI.DropSource.RSToDBRelationshipSpec
Test.Schema.RemoteRelationships.XToDBArrayRelationshipSpec
Test.Schema.RemoteRelationships.XToDBObjectRelationshipSpec
Test.Schema.RemoteRelationships.XToRemoteSchemaRelationshipSpec
Test.Schema.TableRelationships.ArrayRelationshipsSpec
Test.Schema.TableRelationships.ObjectRelationshipsSpec
Test.Schema.TableRelationships.PortedSpec
Test.Schema.ViewsSpec
Test.Subscriptions.DerivedDataSpec
Test.Subscriptions.RowUpdatesSpec
Test.Subscriptions.StreamingSubscriptionsSpec
Test.Webhook.WebhookTransformSpec
executable api-tests
build-depends:
, api-tests
, base
, hspec
default-language: Haskell2010
-- Turning off optimizations is intentional; tests aren't
-- performance sensitive and waiting for compilation is a problem.
ghc-options:
-Wall
-Werror
-threaded
-rtsopts "-with-rtsopts=-N"
hs-source-dirs: test-runner
main-is: Main.hs
executable render-feature-matrix
build-depends:
, aeson
, attoparsec
, base
, bytestring
, containers
, lucid2
, mtl
, text
default-extensions:
BlockArguments
DataKinds
DeriveGeneric
DerivingStrategies
ImportQualifiedPost
MultiWayIf
NamedFieldPuns
NoImplicitPrelude
OverloadedStrings
PatternGuards
RecordWildCards
ScopedTypeVariables
TypeApplications
TypeFamilies
hs-source-dirs: src-render-feature-matrix
default-language: Haskell2010
-- Turning off optimizations is intentional; tests aren't
-- performance sensitive and waiting for compilation is a problem.
ghc-options:
-Wall
-Werror
-threaded
-rtsopts "-with-rtsopts=-N"
main-is: Main.hs