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

Hasura.GraphQL.Execute.Remote

Synopsis

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 #

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.

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

Constructors

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 } }

runVariableCache :: Monad m => StateT RemoteJSONVariableMap m a -> m a Source #

TODO: Documentation.