mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-17 20:41:49 +03:00
823babe885
## Migrating, for server devs You will need the fork of 9.2.4 that we're using (for now): ``` ghcup -c -n install ghc --force -u "https://storage.googleapis.com/graphql-engine-cdn.hasura.io/ghc-bindists/ghc-x86_64-deb10-linux-9.2.4-hasura-fix.tar.xz" 9.2.4 ``` or for m1 mac: ``` ghcup -c -n install ghc --force -u "https://storage.googleapis.com/graphql-engine-cdn.hasura.io/ghc-bindists/ghc-arm64-apple-darwin-9.2.4-hasura-fix.tar.xz" ``` Samir is working on a nix build for nix folx PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6154 GitOrigin-RevId: 6716e3f2ee19f0281c8ad25383a1241fc362d616
58 lines
1.5 KiB
Haskell
58 lines
1.5 KiB
Haskell
{-# LANGUAGE UndecidableInstances #-}
|
|
|
|
module Hasura.RQL.IR.Value
|
|
( UnpreparedValue (..),
|
|
ValueWithOrigin (..),
|
|
openValueOrigin,
|
|
mkParameter,
|
|
)
|
|
where
|
|
|
|
import Hasura.GraphQL.Parser.Variable
|
|
import Hasura.Prelude
|
|
import Hasura.RQL.Types.Backend
|
|
import Hasura.RQL.Types.Column
|
|
import Hasura.SQL.Backend
|
|
import Hasura.Session (SessionVariable)
|
|
|
|
data UnpreparedValue (b :: BackendType)
|
|
= -- | A SQL value that can be parameterized over.
|
|
UVParameter
|
|
(Maybe VariableInfo)
|
|
-- ^ The GraphQL variable this value came from, if any.
|
|
(ColumnValue b)
|
|
| -- | A literal SQL expression that /cannot/ be parameterized over.
|
|
UVLiteral (SQLExpression b)
|
|
| -- | The entire session variables JSON object.
|
|
UVSession
|
|
| -- | A single session variable.
|
|
UVSessionVar (SessionVarType b) SessionVariable
|
|
|
|
deriving instance
|
|
( Backend b,
|
|
Eq (ColumnValue b)
|
|
) =>
|
|
Eq (UnpreparedValue b)
|
|
|
|
deriving instance
|
|
( Backend b,
|
|
Show (ColumnValue b)
|
|
) =>
|
|
Show (UnpreparedValue b)
|
|
|
|
-- | This indicates whether a variable value came from a certain GraphQL variable
|
|
data ValueWithOrigin a
|
|
= ValueWithOrigin VariableInfo a
|
|
| ValueNoOrigin a
|
|
deriving (Functor)
|
|
|
|
openValueOrigin :: ValueWithOrigin a -> a
|
|
openValueOrigin (ValueWithOrigin _ a) = a
|
|
openValueOrigin (ValueNoOrigin a) = a
|
|
|
|
mkParameter :: ValueWithOrigin (ColumnValue b) -> UnpreparedValue b
|
|
mkParameter (ValueWithOrigin valInfo columnValue) =
|
|
UVParameter (Just valInfo) columnValue
|
|
mkParameter (ValueNoOrigin columnValue) =
|
|
UVParameter Nothing columnValue
|