2021-05-24 23:12:53 +03:00
|
|
|
module Hasura.GraphQL.Schema.RemoteTest (spec) where
|
|
|
|
|
2021-09-24 01:56:37 +03:00
|
|
|
import Control.Lens (Prism', prism', to, (^..), _Right)
|
|
|
|
import Data.Aeson qualified as J
|
|
|
|
import Data.ByteString.Lazy qualified as LBS
|
2021-11-30 17:46:41 +03:00
|
|
|
import Data.HashMap.Strict.Extended qualified as M
|
2021-09-24 01:56:37 +03:00
|
|
|
import Data.Text qualified as T
|
|
|
|
import Data.Text.Extended
|
|
|
|
import Data.Text.RawString
|
|
|
|
import Hasura.Base.Error
|
|
|
|
import Hasura.GraphQL.Execute.Inline
|
|
|
|
import Hasura.GraphQL.Execute.Remote (resolveRemoteVariable, runVariableCache)
|
|
|
|
import Hasura.GraphQL.Execute.Resolve
|
2021-11-30 03:37:14 +03:00
|
|
|
import Hasura.GraphQL.Namespace
|
Enable remote joins from remote schemas in the execution engine.
### Description
This PR adds the ability to perform remote joins from remote schemas in the engine. To do so, we alter the definition of an `ExecutionStep` targeting a remote schema: the `ExecStepRemote` constructor now expects a `Maybe RemoteJoins`. This new argument is used when processing the execution step, in the transport layer (either `Transport.HTTP` or `Transport.WebSocket`).
For this `Maybe RemoteJoins` to be extracted from a parsed query, this PR also extends the `Execute.RemoteJoin.Collect` module, to implement "collection" from a selection set. Not only do those new functions extract the remote joins, but they also apply all necessary transformations to the selection sets (such as inserting the necessary "phantom" fields used as join keys).
Finally in `Execute.RemoteJoin.Join`, we make two changes. First, we now always look for nested remote joins, regardless of whether the join we just performed went to a source or a remote schema; and second we adapt our join tree logic according to the special cases that were added to deal with remote server edge cases.
Additionally, this PR refactors / cleans / documents `Execute.RemoteJoin.RemoteServer`. This is not required as part of this change and could be moved to a separate PR if needed (a similar cleanup of `Join` is done independently in #3894). It also introduces a draft of a new documentation page for this project, that will be refined in the release PR that ships the feature (either #3069 or a copy of it).
While this PR extends the engine, it doesn't plug such relationships in the schema, meaning that, as of this PR, the new code paths in `Join` are technically unreachable. Adding the corresponding schema code and, ultimately, enabling the metadata API will be done in subsequent PRs.
### Keeping track of concrete type names
The main change this PR makes to the existing `Join` code is to handle a new reserved field we sometimes use when targeting remote servers: the `__hasura_internal_typename` field. In short, a GraphQL selection set can sometimes "branch" based on the concrete "runtime type" of the object on which the selection happens:
```graphql
query {
author(id: 53478) {
... on Writer {
name
articles {
title
}
}
... on Artist {
name
articles {
title
}
}
}
}
```
If both of those `articles` are remote joins, we need to be able, when we get the answer, to differentiate between the two different cases. We do this by asking for `__typename`, to be able to decide if we're in the `Writer` or the `Artist` branch of the query.
To avoid further processing / customization of results, we only insert this `__hasura_internal_typename: __typename` field in the query in the case of unions of interfaces AND if we have the guarantee that we will processing the request as part of the remote joins "folding": that is, if there's any remote join in this branch in the tree. Otherwise, we don't insert the field, and we leave that part of the response untouched.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3810
GitOrigin-RevId: 89aaf16274d68e26ad3730b80c2d2fdc2896b96c
2022-03-09 06:17:28 +03:00
|
|
|
import Hasura.GraphQL.Parser.Column (UnpreparedValue)
|
2021-09-24 01:56:37 +03:00
|
|
|
import Hasura.GraphQL.Parser.Internal.Parser qualified as P
|
|
|
|
import Hasura.GraphQL.Parser.Schema
|
|
|
|
import Hasura.GraphQL.Parser.TestUtils
|
|
|
|
import Hasura.GraphQL.RemoteServer (identityCustomizer)
|
|
|
|
import Hasura.GraphQL.Schema.Remote
|
|
|
|
import Hasura.Prelude
|
2022-02-25 23:37:32 +03:00
|
|
|
import Hasura.RQL.IR.RemoteSchema
|
Enable remote joins from remote schemas in the execution engine.
### Description
This PR adds the ability to perform remote joins from remote schemas in the engine. To do so, we alter the definition of an `ExecutionStep` targeting a remote schema: the `ExecStepRemote` constructor now expects a `Maybe RemoteJoins`. This new argument is used when processing the execution step, in the transport layer (either `Transport.HTTP` or `Transport.WebSocket`).
For this `Maybe RemoteJoins` to be extracted from a parsed query, this PR also extends the `Execute.RemoteJoin.Collect` module, to implement "collection" from a selection set. Not only do those new functions extract the remote joins, but they also apply all necessary transformations to the selection sets (such as inserting the necessary "phantom" fields used as join keys).
Finally in `Execute.RemoteJoin.Join`, we make two changes. First, we now always look for nested remote joins, regardless of whether the join we just performed went to a source or a remote schema; and second we adapt our join tree logic according to the special cases that were added to deal with remote server edge cases.
Additionally, this PR refactors / cleans / documents `Execute.RemoteJoin.RemoteServer`. This is not required as part of this change and could be moved to a separate PR if needed (a similar cleanup of `Join` is done independently in #3894). It also introduces a draft of a new documentation page for this project, that will be refined in the release PR that ships the feature (either #3069 or a copy of it).
While this PR extends the engine, it doesn't plug such relationships in the schema, meaning that, as of this PR, the new code paths in `Join` are technically unreachable. Adding the corresponding schema code and, ultimately, enabling the metadata API will be done in subsequent PRs.
### Keeping track of concrete type names
The main change this PR makes to the existing `Join` code is to handle a new reserved field we sometimes use when targeting remote servers: the `__hasura_internal_typename` field. In short, a GraphQL selection set can sometimes "branch" based on the concrete "runtime type" of the object on which the selection happens:
```graphql
query {
author(id: 53478) {
... on Writer {
name
articles {
title
}
}
... on Artist {
name
articles {
title
}
}
}
}
```
If both of those `articles` are remote joins, we need to be able, when we get the answer, to differentiate between the two different cases. We do this by asking for `__typename`, to be able to decide if we're in the `Writer` or the `Artist` branch of the query.
To avoid further processing / customization of results, we only insert this `__hasura_internal_typename: __typename` field in the query in the case of unions of interfaces AND if we have the guarantee that we will processing the request as part of the remote joins "folding": that is, if there's any remote join in this branch in the tree. Otherwise, we don't insert the field, and we leave that part of the response untouched.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3810
GitOrigin-RevId: 89aaf16274d68e26ad3730b80c2d2fdc2896b96c
2022-03-09 06:17:28 +03:00
|
|
|
import Hasura.RQL.IR.Root
|
2021-09-24 01:56:37 +03:00
|
|
|
import Hasura.RQL.Types.RemoteSchema
|
|
|
|
import Hasura.RQL.Types.SchemaCache
|
|
|
|
import Hasura.Session
|
|
|
|
import Language.GraphQL.Draft.Parser qualified as G
|
|
|
|
import Language.GraphQL.Draft.Syntax qualified as G
|
|
|
|
import Network.URI qualified as N
|
|
|
|
import Test.Hspec
|
2021-05-24 23:12:53 +03:00
|
|
|
|
|
|
|
-- test tools
|
|
|
|
|
|
|
|
runError :: Monad m => ExceptT QErr m a -> m a
|
|
|
|
runError = runExceptT >=> (`onLeft` (error . T.unpack . qeError))
|
|
|
|
|
|
|
|
mkTestRemoteSchema :: Text -> RemoteSchemaIntrospection
|
2021-09-24 01:56:37 +03:00
|
|
|
mkTestRemoteSchema schema = RemoteSchemaIntrospection $
|
2021-11-30 17:46:41 +03:00
|
|
|
M.fromListOn getTypeName $
|
|
|
|
runIdentity $
|
|
|
|
runError $ do
|
|
|
|
G.SchemaDocument types <- G.parseSchemaDocument schema `onLeft` throw500
|
|
|
|
pure $ flip mapMaybe types \case
|
|
|
|
G.TypeSystemDefinitionSchema _ -> Nothing
|
|
|
|
G.TypeSystemDefinitionType td -> Just $ case fmap toRemoteInputValue td of
|
|
|
|
G.TypeDefinitionScalar std -> G.TypeDefinitionScalar std
|
|
|
|
G.TypeDefinitionObject otd -> G.TypeDefinitionObject otd
|
|
|
|
G.TypeDefinitionUnion utd -> G.TypeDefinitionUnion utd
|
|
|
|
G.TypeDefinitionEnum etd -> G.TypeDefinitionEnum etd
|
|
|
|
G.TypeDefinitionInputObject itd -> G.TypeDefinitionInputObject itd
|
|
|
|
G.TypeDefinitionInterface itd ->
|
|
|
|
G.TypeDefinitionInterface $
|
|
|
|
G.InterfaceTypeDefinition
|
|
|
|
{ G._itdDescription = G._itdDescription itd,
|
|
|
|
G._itdName = G._itdName itd,
|
|
|
|
G._itdDirectives = G._itdDirectives itd,
|
|
|
|
G._itdFieldsDefinition = G._itdFieldsDefinition itd,
|
|
|
|
G._itdPossibleTypes = []
|
|
|
|
}
|
2021-05-24 23:12:53 +03:00
|
|
|
where
|
2021-09-24 01:56:37 +03:00
|
|
|
toRemoteInputValue ivd =
|
|
|
|
RemoteSchemaInputValueDefinition
|
|
|
|
{ _rsitdDefinition = ivd,
|
|
|
|
_rsitdPresetArgument =
|
|
|
|
choice $
|
|
|
|
G._ivdDirectives ivd <&> \dir -> do
|
|
|
|
guard $ G._dName dir == $$(G.litName "preset")
|
|
|
|
value <- M.lookup $$(G.litName "value") $ G._dArguments dir
|
|
|
|
Just $ case value of
|
|
|
|
G.VString "x-hasura-test" ->
|
|
|
|
G.VVariable $
|
|
|
|
SessionPresetVariable (mkSessionVariable "x-hasura-test") $$(G.litName "String") SessionArgumentPresetScalar
|
|
|
|
_ -> absurd <$> value
|
|
|
|
}
|
2021-05-24 23:12:53 +03:00
|
|
|
|
|
|
|
mkTestExecutableDocument :: Text -> ([G.VariableDefinition], G.SelectionSet G.NoFragments G.Name)
|
2021-09-24 01:56:37 +03:00
|
|
|
mkTestExecutableDocument t = runIdentity $
|
|
|
|
runError $ do
|
|
|
|
G.ExecutableDocument execDoc <- G.parseExecutableDoc t `onLeft` throw500
|
|
|
|
case execDoc of
|
|
|
|
[G.ExecutableDefinitionOperation op] -> case op of
|
|
|
|
G.OperationDefinitionUnTyped selSet -> ([],) <$> inlineSelectionSet [] selSet
|
|
|
|
G.OperationDefinitionTyped opDef -> do
|
|
|
|
unless (G._todType opDef == G.OperationTypeQuery) $
|
|
|
|
throw500 "only queries for now"
|
|
|
|
resSelSet <- inlineSelectionSet [] $ G._todSelectionSet opDef
|
|
|
|
pure (G._todVariableDefinitions opDef, resSelSet)
|
|
|
|
_ -> throw500 "must have only one query in the document"
|
2021-05-24 23:12:53 +03:00
|
|
|
|
|
|
|
mkTestVariableValues :: LBS.ByteString -> M.HashMap G.Name J.Value
|
2021-09-24 01:56:37 +03:00
|
|
|
mkTestVariableValues vars = runIdentity $
|
|
|
|
runError $ do
|
|
|
|
value <- J.eitherDecode vars `onLeft` (throw500 . T.pack)
|
|
|
|
case value of
|
|
|
|
J.Object vs ->
|
|
|
|
M.fromList <$> for (M.toList vs) \(name, val) -> do
|
|
|
|
gname <- G.mkName name `onNothing` throw500 ("wrong Name: " <>> name)
|
|
|
|
pure (gname, val)
|
|
|
|
_ -> throw500 "variables must be an object"
|
|
|
|
|
|
|
|
buildQueryParsers ::
|
|
|
|
RemoteSchemaIntrospection ->
|
Enable remote joins from remote schemas in the execution engine.
### Description
This PR adds the ability to perform remote joins from remote schemas in the engine. To do so, we alter the definition of an `ExecutionStep` targeting a remote schema: the `ExecStepRemote` constructor now expects a `Maybe RemoteJoins`. This new argument is used when processing the execution step, in the transport layer (either `Transport.HTTP` or `Transport.WebSocket`).
For this `Maybe RemoteJoins` to be extracted from a parsed query, this PR also extends the `Execute.RemoteJoin.Collect` module, to implement "collection" from a selection set. Not only do those new functions extract the remote joins, but they also apply all necessary transformations to the selection sets (such as inserting the necessary "phantom" fields used as join keys).
Finally in `Execute.RemoteJoin.Join`, we make two changes. First, we now always look for nested remote joins, regardless of whether the join we just performed went to a source or a remote schema; and second we adapt our join tree logic according to the special cases that were added to deal with remote server edge cases.
Additionally, this PR refactors / cleans / documents `Execute.RemoteJoin.RemoteServer`. This is not required as part of this change and could be moved to a separate PR if needed (a similar cleanup of `Join` is done independently in #3894). It also introduces a draft of a new documentation page for this project, that will be refined in the release PR that ships the feature (either #3069 or a copy of it).
While this PR extends the engine, it doesn't plug such relationships in the schema, meaning that, as of this PR, the new code paths in `Join` are technically unreachable. Adding the corresponding schema code and, ultimately, enabling the metadata API will be done in subsequent PRs.
### Keeping track of concrete type names
The main change this PR makes to the existing `Join` code is to handle a new reserved field we sometimes use when targeting remote servers: the `__hasura_internal_typename` field. In short, a GraphQL selection set can sometimes "branch" based on the concrete "runtime type" of the object on which the selection happens:
```graphql
query {
author(id: 53478) {
... on Writer {
name
articles {
title
}
}
... on Artist {
name
articles {
title
}
}
}
}
```
If both of those `articles` are remote joins, we need to be able, when we get the answer, to differentiate between the two different cases. We do this by asking for `__typename`, to be able to decide if we're in the `Writer` or the `Artist` branch of the query.
To avoid further processing / customization of results, we only insert this `__hasura_internal_typename: __typename` field in the query in the case of unions of interfaces AND if we have the guarantee that we will processing the request as part of the remote joins "folding": that is, if there's any remote join in this branch in the tree. Otherwise, we don't insert the field, and we leave that part of the response untouched.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3810
GitOrigin-RevId: 89aaf16274d68e26ad3730b80c2d2fdc2896b96c
2022-03-09 06:17:28 +03:00
|
|
|
IO (P.FieldParser TestMonad (GraphQLField (RemoteRelationshipField UnpreparedValue) RemoteSchemaVariable))
|
2021-05-24 23:12:53 +03:00
|
|
|
buildQueryParsers introspection = do
|
|
|
|
let introResult = IntrospectionResult introspection $$(G.litName "Query") Nothing Nothing
|
Enable remote joins from remote schemas in the execution engine.
### Description
This PR adds the ability to perform remote joins from remote schemas in the engine. To do so, we alter the definition of an `ExecutionStep` targeting a remote schema: the `ExecStepRemote` constructor now expects a `Maybe RemoteJoins`. This new argument is used when processing the execution step, in the transport layer (either `Transport.HTTP` or `Transport.WebSocket`).
For this `Maybe RemoteJoins` to be extracted from a parsed query, this PR also extends the `Execute.RemoteJoin.Collect` module, to implement "collection" from a selection set. Not only do those new functions extract the remote joins, but they also apply all necessary transformations to the selection sets (such as inserting the necessary "phantom" fields used as join keys).
Finally in `Execute.RemoteJoin.Join`, we make two changes. First, we now always look for nested remote joins, regardless of whether the join we just performed went to a source or a remote schema; and second we adapt our join tree logic according to the special cases that were added to deal with remote server edge cases.
Additionally, this PR refactors / cleans / documents `Execute.RemoteJoin.RemoteServer`. This is not required as part of this change and could be moved to a separate PR if needed (a similar cleanup of `Join` is done independently in #3894). It also introduces a draft of a new documentation page for this project, that will be refined in the release PR that ships the feature (either #3069 or a copy of it).
While this PR extends the engine, it doesn't plug such relationships in the schema, meaning that, as of this PR, the new code paths in `Join` are technically unreachable. Adding the corresponding schema code and, ultimately, enabling the metadata API will be done in subsequent PRs.
### Keeping track of concrete type names
The main change this PR makes to the existing `Join` code is to handle a new reserved field we sometimes use when targeting remote servers: the `__hasura_internal_typename` field. In short, a GraphQL selection set can sometimes "branch" based on the concrete "runtime type" of the object on which the selection happens:
```graphql
query {
author(id: 53478) {
... on Writer {
name
articles {
title
}
}
... on Artist {
name
articles {
title
}
}
}
}
```
If both of those `articles` are remote joins, we need to be able, when we get the answer, to differentiate between the two different cases. We do this by asking for `__typename`, to be able to decide if we're in the `Writer` or the `Artist` branch of the query.
To avoid further processing / customization of results, we only insert this `__hasura_internal_typename: __typename` field in the query in the case of unions of interfaces AND if we have the guarantee that we will processing the request as part of the remote joins "folding": that is, if there's any remote join in this branch in the tree. Otherwise, we don't insert the field, and we leave that part of the response untouched.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3810
GitOrigin-RevId: 89aaf16274d68e26ad3730b80c2d2fdc2896b96c
2022-03-09 06:17:28 +03:00
|
|
|
remoteSchemaInfo = RemoteSchemaInfo (ValidatedRemoteSchemaDef N.nullURI [] False 60 Nothing) identityCustomizer
|
2021-11-30 03:37:14 +03:00
|
|
|
ParsedIntrospection query _ _ <-
|
2021-09-24 01:56:37 +03:00
|
|
|
runError $
|
Enable remote joins from remote schemas in the execution engine.
### Description
This PR adds the ability to perform remote joins from remote schemas in the engine. To do so, we alter the definition of an `ExecutionStep` targeting a remote schema: the `ExecStepRemote` constructor now expects a `Maybe RemoteJoins`. This new argument is used when processing the execution step, in the transport layer (either `Transport.HTTP` or `Transport.WebSocket`).
For this `Maybe RemoteJoins` to be extracted from a parsed query, this PR also extends the `Execute.RemoteJoin.Collect` module, to implement "collection" from a selection set. Not only do those new functions extract the remote joins, but they also apply all necessary transformations to the selection sets (such as inserting the necessary "phantom" fields used as join keys).
Finally in `Execute.RemoteJoin.Join`, we make two changes. First, we now always look for nested remote joins, regardless of whether the join we just performed went to a source or a remote schema; and second we adapt our join tree logic according to the special cases that were added to deal with remote server edge cases.
Additionally, this PR refactors / cleans / documents `Execute.RemoteJoin.RemoteServer`. This is not required as part of this change and could be moved to a separate PR if needed (a similar cleanup of `Join` is done independently in #3894). It also introduces a draft of a new documentation page for this project, that will be refined in the release PR that ships the feature (either #3069 or a copy of it).
While this PR extends the engine, it doesn't plug such relationships in the schema, meaning that, as of this PR, the new code paths in `Join` are technically unreachable. Adding the corresponding schema code and, ultimately, enabling the metadata API will be done in subsequent PRs.
### Keeping track of concrete type names
The main change this PR makes to the existing `Join` code is to handle a new reserved field we sometimes use when targeting remote servers: the `__hasura_internal_typename` field. In short, a GraphQL selection set can sometimes "branch" based on the concrete "runtime type" of the object on which the selection happens:
```graphql
query {
author(id: 53478) {
... on Writer {
name
articles {
title
}
}
... on Artist {
name
articles {
title
}
}
}
}
```
If both of those `articles` are remote joins, we need to be able, when we get the answer, to differentiate between the two different cases. We do this by asking for `__typename`, to be able to decide if we're in the `Writer` or the `Artist` branch of the query.
To avoid further processing / customization of results, we only insert this `__hasura_internal_typename: __typename` field in the query in the case of unions of interfaces AND if we have the guarantee that we will processing the request as part of the remote joins "folding": that is, if there's any remote join in this branch in the tree. Otherwise, we don't insert the field, and we leave that part of the response untouched.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3810
GitOrigin-RevId: 89aaf16274d68e26ad3730b80c2d2fdc2896b96c
2022-03-09 06:17:28 +03:00
|
|
|
buildRemoteParser introResult remoteSchemaInfo
|
2021-09-24 01:56:37 +03:00
|
|
|
pure $
|
2021-11-30 03:37:14 +03:00
|
|
|
head query <&> \case
|
Enable remote joins from remote schemas in the execution engine.
### Description
This PR adds the ability to perform remote joins from remote schemas in the engine. To do so, we alter the definition of an `ExecutionStep` targeting a remote schema: the `ExecStepRemote` constructor now expects a `Maybe RemoteJoins`. This new argument is used when processing the execution step, in the transport layer (either `Transport.HTTP` or `Transport.WebSocket`).
For this `Maybe RemoteJoins` to be extracted from a parsed query, this PR also extends the `Execute.RemoteJoin.Collect` module, to implement "collection" from a selection set. Not only do those new functions extract the remote joins, but they also apply all necessary transformations to the selection sets (such as inserting the necessary "phantom" fields used as join keys).
Finally in `Execute.RemoteJoin.Join`, we make two changes. First, we now always look for nested remote joins, regardless of whether the join we just performed went to a source or a remote schema; and second we adapt our join tree logic according to the special cases that were added to deal with remote server edge cases.
Additionally, this PR refactors / cleans / documents `Execute.RemoteJoin.RemoteServer`. This is not required as part of this change and could be moved to a separate PR if needed (a similar cleanup of `Join` is done independently in #3894). It also introduces a draft of a new documentation page for this project, that will be refined in the release PR that ships the feature (either #3069 or a copy of it).
While this PR extends the engine, it doesn't plug such relationships in the schema, meaning that, as of this PR, the new code paths in `Join` are technically unreachable. Adding the corresponding schema code and, ultimately, enabling the metadata API will be done in subsequent PRs.
### Keeping track of concrete type names
The main change this PR makes to the existing `Join` code is to handle a new reserved field we sometimes use when targeting remote servers: the `__hasura_internal_typename` field. In short, a GraphQL selection set can sometimes "branch" based on the concrete "runtime type" of the object on which the selection happens:
```graphql
query {
author(id: 53478) {
... on Writer {
name
articles {
title
}
}
... on Artist {
name
articles {
title
}
}
}
}
```
If both of those `articles` are remote joins, we need to be able, when we get the answer, to differentiate between the two different cases. We do this by asking for `__typename`, to be able to decide if we're in the `Writer` or the `Artist` branch of the query.
To avoid further processing / customization of results, we only insert this `__hasura_internal_typename: __typename` field in the query in the case of unions of interfaces AND if we have the guarantee that we will processing the request as part of the remote joins "folding": that is, if there's any remote join in this branch in the tree. Otherwise, we don't insert the field, and we leave that part of the response untouched.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3810
GitOrigin-RevId: 89aaf16274d68e26ad3730b80c2d2fdc2896b96c
2022-03-09 06:17:28 +03:00
|
|
|
NotNamespaced remoteFld -> _rfField remoteFld
|
2021-11-30 03:37:14 +03:00
|
|
|
Namespaced _ ->
|
|
|
|
-- Shouldn't happen if we're using identityCustomizer
|
|
|
|
-- TODO: add some tests for remote schema customization
|
|
|
|
error "buildQueryParsers: unexpected Namespaced field"
|
2021-09-24 01:56:37 +03:00
|
|
|
|
|
|
|
runQueryParser ::
|
|
|
|
P.FieldParser TestMonad any ->
|
|
|
|
([G.VariableDefinition], G.SelectionSet G.NoFragments G.Name) ->
|
|
|
|
M.HashMap G.Name J.Value ->
|
|
|
|
any
|
2021-08-05 00:23:33 +03:00
|
|
|
runQueryParser parser (varDefs, selSet) vars = runIdentity . runError $ do
|
2021-05-24 23:12:53 +03:00
|
|
|
(_, resolvedSelSet) <- resolveVariables varDefs vars [] selSet
|
|
|
|
field <- case resolvedSelSet of
|
|
|
|
[G.SelectionField f] -> pure f
|
2021-09-24 01:56:37 +03:00
|
|
|
_ -> error "expecting only one field in the query"
|
2021-05-24 23:12:53 +03:00
|
|
|
runTest (P.fParser parser field) `onLeft` throw500
|
|
|
|
|
2021-09-24 01:56:37 +03:00
|
|
|
run ::
|
|
|
|
-- | schema
|
|
|
|
Text ->
|
|
|
|
-- | query
|
|
|
|
Text ->
|
|
|
|
-- | variables
|
|
|
|
LBS.ByteString ->
|
Enable remote joins from remote schemas in the execution engine.
### Description
This PR adds the ability to perform remote joins from remote schemas in the engine. To do so, we alter the definition of an `ExecutionStep` targeting a remote schema: the `ExecStepRemote` constructor now expects a `Maybe RemoteJoins`. This new argument is used when processing the execution step, in the transport layer (either `Transport.HTTP` or `Transport.WebSocket`).
For this `Maybe RemoteJoins` to be extracted from a parsed query, this PR also extends the `Execute.RemoteJoin.Collect` module, to implement "collection" from a selection set. Not only do those new functions extract the remote joins, but they also apply all necessary transformations to the selection sets (such as inserting the necessary "phantom" fields used as join keys).
Finally in `Execute.RemoteJoin.Join`, we make two changes. First, we now always look for nested remote joins, regardless of whether the join we just performed went to a source or a remote schema; and second we adapt our join tree logic according to the special cases that were added to deal with remote server edge cases.
Additionally, this PR refactors / cleans / documents `Execute.RemoteJoin.RemoteServer`. This is not required as part of this change and could be moved to a separate PR if needed (a similar cleanup of `Join` is done independently in #3894). It also introduces a draft of a new documentation page for this project, that will be refined in the release PR that ships the feature (either #3069 or a copy of it).
While this PR extends the engine, it doesn't plug such relationships in the schema, meaning that, as of this PR, the new code paths in `Join` are technically unreachable. Adding the corresponding schema code and, ultimately, enabling the metadata API will be done in subsequent PRs.
### Keeping track of concrete type names
The main change this PR makes to the existing `Join` code is to handle a new reserved field we sometimes use when targeting remote servers: the `__hasura_internal_typename` field. In short, a GraphQL selection set can sometimes "branch" based on the concrete "runtime type" of the object on which the selection happens:
```graphql
query {
author(id: 53478) {
... on Writer {
name
articles {
title
}
}
... on Artist {
name
articles {
title
}
}
}
}
```
If both of those `articles` are remote joins, we need to be able, when we get the answer, to differentiate between the two different cases. We do this by asking for `__typename`, to be able to decide if we're in the `Writer` or the `Artist` branch of the query.
To avoid further processing / customization of results, we only insert this `__hasura_internal_typename: __typename` field in the query in the case of unions of interfaces AND if we have the guarantee that we will processing the request as part of the remote joins "folding": that is, if there's any remote join in this branch in the tree. Otherwise, we don't insert the field, and we leave that part of the response untouched.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3810
GitOrigin-RevId: 89aaf16274d68e26ad3730b80c2d2fdc2896b96c
2022-03-09 06:17:28 +03:00
|
|
|
IO (GraphQLField (RemoteRelationshipField UnpreparedValue) RemoteSchemaVariable)
|
2021-08-05 00:23:33 +03:00
|
|
|
run schema query variables = do
|
|
|
|
parser <- buildQueryParsers $ mkTestRemoteSchema schema
|
2021-09-24 01:56:37 +03:00
|
|
|
pure $
|
|
|
|
runQueryParser
|
|
|
|
parser
|
|
|
|
(mkTestExecutableDocument query)
|
|
|
|
(mkTestVariableValues variables)
|
2021-05-24 23:12:53 +03:00
|
|
|
|
|
|
|
-- actual test
|
|
|
|
|
|
|
|
spec :: Spec
|
|
|
|
spec = do
|
|
|
|
testNoVarExpansionIfNoPreset
|
|
|
|
testNoVarExpansionIfNoPresetUnlessTopLevelOptionalField
|
|
|
|
testPartialVarExpansionIfPreset
|
2021-08-05 00:23:33 +03:00
|
|
|
testVariableSubstitutionCollision
|
2021-05-24 23:12:53 +03:00
|
|
|
|
|
|
|
testNoVarExpansionIfNoPreset :: Spec
|
|
|
|
testNoVarExpansionIfNoPreset = it "variables aren't expanded if there's no preset" $ do
|
2021-09-24 01:56:37 +03:00
|
|
|
field <-
|
|
|
|
run
|
|
|
|
-- schema
|
|
|
|
[raw|
|
2021-05-24 23:12:53 +03:00
|
|
|
scalar Int
|
|
|
|
|
|
|
|
input A {
|
|
|
|
b: B
|
|
|
|
}
|
|
|
|
|
|
|
|
input B {
|
|
|
|
c: C
|
|
|
|
}
|
|
|
|
|
|
|
|
input C {
|
|
|
|
i: Int
|
|
|
|
}
|
|
|
|
|
|
|
|
type Query {
|
|
|
|
test(a: A!): Int
|
|
|
|
}
|
|
|
|
|]
|
2021-09-24 01:56:37 +03:00
|
|
|
-- query
|
|
|
|
[raw|
|
2021-05-24 23:12:53 +03:00
|
|
|
query($a: A!) {
|
|
|
|
test(a: $a)
|
|
|
|
}
|
|
|
|
|]
|
2021-09-24 01:56:37 +03:00
|
|
|
-- variables
|
|
|
|
[raw|
|
2021-05-24 23:12:53 +03:00
|
|
|
{
|
|
|
|
"a": {
|
|
|
|
"b": {
|
|
|
|
"c": {
|
|
|
|
"i": 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|]
|
Enable remote joins from remote schemas in the execution engine.
### Description
This PR adds the ability to perform remote joins from remote schemas in the engine. To do so, we alter the definition of an `ExecutionStep` targeting a remote schema: the `ExecStepRemote` constructor now expects a `Maybe RemoteJoins`. This new argument is used when processing the execution step, in the transport layer (either `Transport.HTTP` or `Transport.WebSocket`).
For this `Maybe RemoteJoins` to be extracted from a parsed query, this PR also extends the `Execute.RemoteJoin.Collect` module, to implement "collection" from a selection set. Not only do those new functions extract the remote joins, but they also apply all necessary transformations to the selection sets (such as inserting the necessary "phantom" fields used as join keys).
Finally in `Execute.RemoteJoin.Join`, we make two changes. First, we now always look for nested remote joins, regardless of whether the join we just performed went to a source or a remote schema; and second we adapt our join tree logic according to the special cases that were added to deal with remote server edge cases.
Additionally, this PR refactors / cleans / documents `Execute.RemoteJoin.RemoteServer`. This is not required as part of this change and could be moved to a separate PR if needed (a similar cleanup of `Join` is done independently in #3894). It also introduces a draft of a new documentation page for this project, that will be refined in the release PR that ships the feature (either #3069 or a copy of it).
While this PR extends the engine, it doesn't plug such relationships in the schema, meaning that, as of this PR, the new code paths in `Join` are technically unreachable. Adding the corresponding schema code and, ultimately, enabling the metadata API will be done in subsequent PRs.
### Keeping track of concrete type names
The main change this PR makes to the existing `Join` code is to handle a new reserved field we sometimes use when targeting remote servers: the `__hasura_internal_typename` field. In short, a GraphQL selection set can sometimes "branch" based on the concrete "runtime type" of the object on which the selection happens:
```graphql
query {
author(id: 53478) {
... on Writer {
name
articles {
title
}
}
... on Artist {
name
articles {
title
}
}
}
}
```
If both of those `articles` are remote joins, we need to be able, when we get the answer, to differentiate between the two different cases. We do this by asking for `__typename`, to be able to decide if we're in the `Writer` or the `Artist` branch of the query.
To avoid further processing / customization of results, we only insert this `__hasura_internal_typename: __typename` field in the query in the case of unions of interfaces AND if we have the guarantee that we will processing the request as part of the remote joins "folding": that is, if there's any remote join in this branch in the tree. Otherwise, we don't insert the field, and we leave that part of the response untouched.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3810
GitOrigin-RevId: 89aaf16274d68e26ad3730b80c2d2fdc2896b96c
2022-03-09 06:17:28 +03:00
|
|
|
let arg = head $ M.toList $ _fArguments field
|
2021-09-24 01:56:37 +03:00
|
|
|
arg
|
|
|
|
`shouldBe` ( $$(G.litName "a"),
|
|
|
|
-- the parser did not create a new JSON variable, and forwarded the query variable unmodified
|
|
|
|
G.VVariable $
|
|
|
|
QueryVariable $
|
|
|
|
Variable
|
|
|
|
(VIRequired $$(G.litName "a"))
|
|
|
|
(G.TypeNamed (G.Nullability False) $$(G.litName "A"))
|
|
|
|
(JSONValue $ J.Object $ M.fromList [("b", J.Object $ M.fromList [("c", J.Object $ M.fromList [("i", J.Number 0)])])])
|
|
|
|
)
|
2021-05-24 23:12:53 +03:00
|
|
|
|
|
|
|
testNoVarExpansionIfNoPresetUnlessTopLevelOptionalField :: Spec
|
|
|
|
testNoVarExpansionIfNoPresetUnlessTopLevelOptionalField = it "unless fieldOptional peels the variable first" $ do
|
2021-09-24 01:56:37 +03:00
|
|
|
field <-
|
|
|
|
run
|
|
|
|
-- schema
|
|
|
|
[raw|
|
2021-05-24 23:12:53 +03:00
|
|
|
scalar Int
|
|
|
|
|
|
|
|
input A {
|
|
|
|
b: B
|
|
|
|
}
|
|
|
|
|
|
|
|
input B {
|
|
|
|
c: C
|
|
|
|
}
|
|
|
|
|
|
|
|
input C {
|
|
|
|
i: Int
|
|
|
|
}
|
|
|
|
|
|
|
|
type Query {
|
|
|
|
test(a: A): Int
|
|
|
|
}
|
|
|
|
|]
|
2021-09-24 01:56:37 +03:00
|
|
|
-- query
|
|
|
|
[raw|
|
2021-05-24 23:12:53 +03:00
|
|
|
query($a: A) {
|
|
|
|
test(a: $a)
|
|
|
|
}
|
|
|
|
|]
|
2021-09-24 01:56:37 +03:00
|
|
|
-- variables
|
|
|
|
[raw|
|
2021-05-24 23:12:53 +03:00
|
|
|
{
|
|
|
|
"a": {
|
|
|
|
"b": {
|
|
|
|
"c": {
|
|
|
|
"i": 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|]
|
Enable remote joins from remote schemas in the execution engine.
### Description
This PR adds the ability to perform remote joins from remote schemas in the engine. To do so, we alter the definition of an `ExecutionStep` targeting a remote schema: the `ExecStepRemote` constructor now expects a `Maybe RemoteJoins`. This new argument is used when processing the execution step, in the transport layer (either `Transport.HTTP` or `Transport.WebSocket`).
For this `Maybe RemoteJoins` to be extracted from a parsed query, this PR also extends the `Execute.RemoteJoin.Collect` module, to implement "collection" from a selection set. Not only do those new functions extract the remote joins, but they also apply all necessary transformations to the selection sets (such as inserting the necessary "phantom" fields used as join keys).
Finally in `Execute.RemoteJoin.Join`, we make two changes. First, we now always look for nested remote joins, regardless of whether the join we just performed went to a source or a remote schema; and second we adapt our join tree logic according to the special cases that were added to deal with remote server edge cases.
Additionally, this PR refactors / cleans / documents `Execute.RemoteJoin.RemoteServer`. This is not required as part of this change and could be moved to a separate PR if needed (a similar cleanup of `Join` is done independently in #3894). It also introduces a draft of a new documentation page for this project, that will be refined in the release PR that ships the feature (either #3069 or a copy of it).
While this PR extends the engine, it doesn't plug such relationships in the schema, meaning that, as of this PR, the new code paths in `Join` are technically unreachable. Adding the corresponding schema code and, ultimately, enabling the metadata API will be done in subsequent PRs.
### Keeping track of concrete type names
The main change this PR makes to the existing `Join` code is to handle a new reserved field we sometimes use when targeting remote servers: the `__hasura_internal_typename` field. In short, a GraphQL selection set can sometimes "branch" based on the concrete "runtime type" of the object on which the selection happens:
```graphql
query {
author(id: 53478) {
... on Writer {
name
articles {
title
}
}
... on Artist {
name
articles {
title
}
}
}
}
```
If both of those `articles` are remote joins, we need to be able, when we get the answer, to differentiate between the two different cases. We do this by asking for `__typename`, to be able to decide if we're in the `Writer` or the `Artist` branch of the query.
To avoid further processing / customization of results, we only insert this `__hasura_internal_typename: __typename` field in the query in the case of unions of interfaces AND if we have the guarantee that we will processing the request as part of the remote joins "folding": that is, if there's any remote join in this branch in the tree. Otherwise, we don't insert the field, and we leave that part of the response untouched.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3810
GitOrigin-RevId: 89aaf16274d68e26ad3730b80c2d2fdc2896b96c
2022-03-09 06:17:28 +03:00
|
|
|
let arg = head $ M.toList $ _fArguments field
|
2021-09-24 01:56:37 +03:00
|
|
|
arg
|
|
|
|
`shouldBe` ( $$(G.litName "a"),
|
|
|
|
-- fieldOptional has peeled the variable; all we see is a JSON blob, and in doubt
|
|
|
|
-- we repackage it as a newly minted JSON variable
|
|
|
|
G.VVariable $
|
|
|
|
RemoteJSONValue
|
|
|
|
(G.TypeNamed (G.Nullability True) $$(G.litName "A"))
|
|
|
|
(J.Object $ M.fromList [("b", J.Object $ M.fromList [("c", J.Object $ M.fromList [("i", J.Number 0)])])])
|
|
|
|
)
|
2021-05-24 23:12:53 +03:00
|
|
|
|
|
|
|
testPartialVarExpansionIfPreset :: Spec
|
|
|
|
testPartialVarExpansionIfPreset = it "presets cause partial var expansion" $ do
|
2021-09-24 01:56:37 +03:00
|
|
|
field <-
|
|
|
|
run
|
|
|
|
-- schema
|
|
|
|
[raw|
|
2021-05-24 23:12:53 +03:00
|
|
|
scalar Int
|
|
|
|
|
|
|
|
input A {
|
|
|
|
x: Int @preset(value: 0)
|
|
|
|
b: B
|
|
|
|
}
|
|
|
|
|
|
|
|
input B {
|
|
|
|
c: C
|
|
|
|
}
|
|
|
|
|
|
|
|
input C {
|
|
|
|
i: Int
|
|
|
|
}
|
|
|
|
|
|
|
|
type Query {
|
|
|
|
test(a: A!): Int
|
|
|
|
}
|
|
|
|
|]
|
2021-09-24 01:56:37 +03:00
|
|
|
-- query
|
|
|
|
[raw|
|
2021-05-24 23:12:53 +03:00
|
|
|
query($a: A!) {
|
|
|
|
test(a: $a)
|
|
|
|
}
|
|
|
|
|]
|
2021-09-24 01:56:37 +03:00
|
|
|
-- variables
|
|
|
|
[raw|
|
2021-05-24 23:12:53 +03:00
|
|
|
{
|
|
|
|
"a": {
|
|
|
|
"b": {
|
|
|
|
"c": {
|
|
|
|
"i": 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|]
|
Enable remote joins from remote schemas in the execution engine.
### Description
This PR adds the ability to perform remote joins from remote schemas in the engine. To do so, we alter the definition of an `ExecutionStep` targeting a remote schema: the `ExecStepRemote` constructor now expects a `Maybe RemoteJoins`. This new argument is used when processing the execution step, in the transport layer (either `Transport.HTTP` or `Transport.WebSocket`).
For this `Maybe RemoteJoins` to be extracted from a parsed query, this PR also extends the `Execute.RemoteJoin.Collect` module, to implement "collection" from a selection set. Not only do those new functions extract the remote joins, but they also apply all necessary transformations to the selection sets (such as inserting the necessary "phantom" fields used as join keys).
Finally in `Execute.RemoteJoin.Join`, we make two changes. First, we now always look for nested remote joins, regardless of whether the join we just performed went to a source or a remote schema; and second we adapt our join tree logic according to the special cases that were added to deal with remote server edge cases.
Additionally, this PR refactors / cleans / documents `Execute.RemoteJoin.RemoteServer`. This is not required as part of this change and could be moved to a separate PR if needed (a similar cleanup of `Join` is done independently in #3894). It also introduces a draft of a new documentation page for this project, that will be refined in the release PR that ships the feature (either #3069 or a copy of it).
While this PR extends the engine, it doesn't plug such relationships in the schema, meaning that, as of this PR, the new code paths in `Join` are technically unreachable. Adding the corresponding schema code and, ultimately, enabling the metadata API will be done in subsequent PRs.
### Keeping track of concrete type names
The main change this PR makes to the existing `Join` code is to handle a new reserved field we sometimes use when targeting remote servers: the `__hasura_internal_typename` field. In short, a GraphQL selection set can sometimes "branch" based on the concrete "runtime type" of the object on which the selection happens:
```graphql
query {
author(id: 53478) {
... on Writer {
name
articles {
title
}
}
... on Artist {
name
articles {
title
}
}
}
}
```
If both of those `articles` are remote joins, we need to be able, when we get the answer, to differentiate between the two different cases. We do this by asking for `__typename`, to be able to decide if we're in the `Writer` or the `Artist` branch of the query.
To avoid further processing / customization of results, we only insert this `__hasura_internal_typename: __typename` field in the query in the case of unions of interfaces AND if we have the guarantee that we will processing the request as part of the remote joins "folding": that is, if there's any remote join in this branch in the tree. Otherwise, we don't insert the field, and we leave that part of the response untouched.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3810
GitOrigin-RevId: 89aaf16274d68e26ad3730b80c2d2fdc2896b96c
2022-03-09 06:17:28 +03:00
|
|
|
let arg = head $ M.toList $ _fArguments field
|
2021-09-24 01:56:37 +03:00
|
|
|
arg
|
|
|
|
`shouldBe` ( $$(G.litName "a"),
|
|
|
|
-- the preset has caused partial variable expansion, only up to where it's needed
|
|
|
|
G.VObject $
|
|
|
|
M.fromList
|
|
|
|
[ ( $$(G.litName "x"),
|
|
|
|
G.VInt 0
|
|
|
|
),
|
|
|
|
( $$(G.litName "b"),
|
|
|
|
G.VVariable $
|
|
|
|
RemoteJSONValue
|
|
|
|
(G.TypeNamed (G.Nullability True) $$(G.litName "B"))
|
|
|
|
(J.Object $ M.fromList [("c", J.Object $ M.fromList [("i", J.Number 0)])])
|
|
|
|
)
|
|
|
|
]
|
|
|
|
)
|
2021-08-05 00:23:33 +03:00
|
|
|
|
|
|
|
-- | Regression test for https://github.com/hasura/graphql-engine/issues/7170
|
|
|
|
testVariableSubstitutionCollision :: Spec
|
|
|
|
testVariableSubstitutionCollision = it "ensures that remote variables are de-duplicated by type and value, not just by value" $ do
|
|
|
|
field <- run schema query variables
|
2021-09-24 01:56:37 +03:00
|
|
|
let dummyUserInfo =
|
|
|
|
UserInfo
|
|
|
|
adminRoleName
|
|
|
|
(mempty @SessionVariables)
|
|
|
|
BOFADisallowed
|
2021-08-05 00:23:33 +03:00
|
|
|
eField <-
|
|
|
|
runExceptT
|
2021-09-24 01:56:37 +03:00
|
|
|
. runVariableCache
|
|
|
|
. traverse (resolveRemoteVariable dummyUserInfo)
|
|
|
|
$ field
|
|
|
|
let variableNames =
|
Enable remote joins from remote schemas in the execution engine.
### Description
This PR adds the ability to perform remote joins from remote schemas in the engine. To do so, we alter the definition of an `ExecutionStep` targeting a remote schema: the `ExecStepRemote` constructor now expects a `Maybe RemoteJoins`. This new argument is used when processing the execution step, in the transport layer (either `Transport.HTTP` or `Transport.WebSocket`).
For this `Maybe RemoteJoins` to be extracted from a parsed query, this PR also extends the `Execute.RemoteJoin.Collect` module, to implement "collection" from a selection set. Not only do those new functions extract the remote joins, but they also apply all necessary transformations to the selection sets (such as inserting the necessary "phantom" fields used as join keys).
Finally in `Execute.RemoteJoin.Join`, we make two changes. First, we now always look for nested remote joins, regardless of whether the join we just performed went to a source or a remote schema; and second we adapt our join tree logic according to the special cases that were added to deal with remote server edge cases.
Additionally, this PR refactors / cleans / documents `Execute.RemoteJoin.RemoteServer`. This is not required as part of this change and could be moved to a separate PR if needed (a similar cleanup of `Join` is done independently in #3894). It also introduces a draft of a new documentation page for this project, that will be refined in the release PR that ships the feature (either #3069 or a copy of it).
While this PR extends the engine, it doesn't plug such relationships in the schema, meaning that, as of this PR, the new code paths in `Join` are technically unreachable. Adding the corresponding schema code and, ultimately, enabling the metadata API will be done in subsequent PRs.
### Keeping track of concrete type names
The main change this PR makes to the existing `Join` code is to handle a new reserved field we sometimes use when targeting remote servers: the `__hasura_internal_typename` field. In short, a GraphQL selection set can sometimes "branch" based on the concrete "runtime type" of the object on which the selection happens:
```graphql
query {
author(id: 53478) {
... on Writer {
name
articles {
title
}
}
... on Artist {
name
articles {
title
}
}
}
}
```
If both of those `articles` are remote joins, we need to be able, when we get the answer, to differentiate between the two different cases. We do this by asking for `__typename`, to be able to decide if we're in the `Writer` or the `Artist` branch of the query.
To avoid further processing / customization of results, we only insert this `__hasura_internal_typename: __typename` field in the query in the case of unions of interfaces AND if we have the guarantee that we will processing the request as part of the remote joins "folding": that is, if there's any remote join in this branch in the tree. Otherwise, we don't insert the field, and we leave that part of the response untouched.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3810
GitOrigin-RevId: 89aaf16274d68e26ad3730b80c2d2fdc2896b96c
2022-03-09 06:17:28 +03:00
|
|
|
eField ^.. _Right . to _fArguments . traverse . _VVariable . to vInfo . to getName . to G.unName
|
2021-08-05 00:23:33 +03:00
|
|
|
variableNames `shouldBe` ["hasura_json_var_1", "hasura_json_var_2"]
|
|
|
|
where
|
|
|
|
-- A schema whose values are representable as collections of JSON values.
|
|
|
|
schema :: Text
|
2021-09-24 01:56:37 +03:00
|
|
|
schema =
|
|
|
|
[raw|
|
2021-08-05 00:23:33 +03:00
|
|
|
scalar Int
|
|
|
|
scalar String
|
|
|
|
|
|
|
|
type Query {
|
|
|
|
test(a: [Int], b: [String]): Int
|
|
|
|
}
|
|
|
|
|]
|
|
|
|
-- A query against values from 'schema' using JSON variable substitution.
|
|
|
|
query :: Text
|
2021-09-24 01:56:37 +03:00
|
|
|
query =
|
|
|
|
[raw|
|
2021-08-05 00:23:33 +03:00
|
|
|
query($a: [Int], $b: [String]) {
|
|
|
|
test(a: $a, b: $b)
|
|
|
|
}
|
|
|
|
|]
|
|
|
|
-- Two identical JSON variables to substitute; 'schema' and 'query' declare
|
|
|
|
-- that these variables should have different types despite both being
|
|
|
|
-- empty collections.
|
|
|
|
variables :: LBS.ByteString
|
2021-09-24 01:56:37 +03:00
|
|
|
variables =
|
|
|
|
[raw|
|
2021-08-05 00:23:33 +03:00
|
|
|
{
|
|
|
|
"a": [],
|
|
|
|
"b": []
|
|
|
|
}
|
|
|
|
|]
|
|
|
|
|
|
|
|
-- | Convenience function to focus on a 'G.VVariable' when pulling test values
|
|
|
|
-- out in 'testVariableSubstitutionCollision'.
|
|
|
|
_VVariable :: Prism' (G.Value var) var
|
|
|
|
_VVariable = prism' upcast downcast
|
|
|
|
where
|
|
|
|
upcast = G.VVariable
|
|
|
|
downcast = \case
|
|
|
|
G.VVariable var -> Just var
|
2021-09-24 01:56:37 +03:00
|
|
|
_ -> Nothing
|