Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- getVariableDefinitionAndValue :: Variable -> (VariableDefinition, (Name, Value))
- unresolveVariables :: forall fragments. Functor fragments => SelectionSet fragments Variable -> SelectionSet fragments Name
- collectVariables :: forall fragments var. (Foldable fragments, Hashable var, Eq var) => SelectionSet fragments var -> HashSet var
- buildExecStepRemote :: RemoteSchemaInfo -> ResultCustomizer -> OperationType -> GraphQLField Void Variable -> Maybe RemoteJoins -> Maybe OperationName -> ExecutionStep
- newtype RemoteJSONVariableMap = RemoteJSONVariableMap (HashMap RemoteJSONVariableKey Int)
- data RemoteJSONVariableKey = RemoteJSONVariableKey !GType !Value
- resolveRemoteVariable :: MonadError QErr m => UserInfo -> RemoteSchemaVariable -> StateT RemoteJSONVariableMap m Variable
- resolveRemoteField :: MonadError QErr m => UserInfo -> RemoteSchemaRootField r RemoteSchemaVariable -> StateT RemoteJSONVariableMap m (RemoteSchemaRootField r Variable)
- runVariableCache :: Monad m => StateT RemoteJSONVariableMap m a -> m a
Documentation
getVariableDefinitionAndValue :: Variable -> (VariableDefinition, (Name, Value)) Source #
unresolveVariables :: forall fragments. Functor fragments => SelectionSet fragments Variable -> SelectionSet fragments Name Source #
collectVariables :: forall fragments var. (Foldable fragments, Hashable var, Eq var) => SelectionSet fragments var -> HashSet var Source #
buildExecStepRemote :: RemoteSchemaInfo -> ResultCustomizer -> OperationType -> GraphQLField Void Variable -> Maybe RemoteJoins -> Maybe OperationName -> ExecutionStep Source #
newtype RemoteJSONVariableMap Source #
Association between keys uniquely identifying some remote JSON variable and
an Int
identifier that will be used to construct a valid variable name to
be used in a GraphQL query.
RemoteJSONVariableMap (HashMap RemoteJSONVariableKey Int) |
data RemoteJSONVariableKey Source #
A unique identifier for some remote JSON variable whose name will need to be substituted when constructing a GraphQL query.
For a detailed explanation of this behavior, see the following comment: https://github.com/hasura/graphql-engine/issues/7170#issuecomment-880838970
RemoteJSONVariableKey !GType !Value |
resolveRemoteVariable :: MonadError QErr m => UserInfo -> RemoteSchemaVariable -> StateT RemoteJSONVariableMap m Variable Source #
Resolves a RemoteSchemaVariable
into a GraphQL Variable
.
A RemoteSchemaVariable
can either be a query variable (i.e. a variable
provided in the query) or it can be a SessionPresetVariable
(in which case
we look up the value of the session variable and coerce it into the
appropriate type and then construct the GraphQL Variable
).
NOTE: The session variable preset is a hard preset (i.e. if the session variable doesn't exist, an error will be thrown).
The name of the GraphQL variable generated will be a GraphQL-ized version of
the session variable (i.e. -
will be replaced with '_'), since session
variables are not valid GraphQL names.
Additionally, we need to handle partially traversed JSON values; likewise, we create a new variable out of thin air.
For example, considering the following schema for a role:
input UserName { firstName : String! @preset(value:Foo) lastName : String! }
type Query { user( user_id: Int! @preset(value:"x-hasura-user-id") user_name: UserName! ): User }
and the incoming query to the graphql-engine is:
query($foo: UserName!) { user(user_name: $foo) { id name } }
with variables:
{ "foo": {"lastName": Bar} }
After resolving the session argument presets, the query that will be sent to the remote server will be:
query ($x_hasura_user_id: Int!, $hasura_json_var_1: String!) { user (user_id: $x_hasura_user_id, user_name: {firstName: Foo, lastName: $hasura_json_var_1}) { id name } }
resolveRemoteField :: MonadError QErr m => UserInfo -> RemoteSchemaRootField r RemoteSchemaVariable -> StateT RemoteJSONVariableMap m (RemoteSchemaRootField r Variable) Source #
TODO: Documentation.
runVariableCache :: Monad m => StateT RemoteJSONVariableMap m a -> m a Source #
TODO: Documentation.