Skip to content

Commit

Permalink
Extend variable checks to ErrorBoundary, Identity and GqlUnion.
Browse files Browse the repository at this point in the history
  • Loading branch information
bakhtiyarneyman committed May 1, 2024
1 parent 4d58b7e commit 032b71b
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/GraphQL/Client/Variables.purs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import Prelude
import Control.Apply (lift2)
import Data.Argonaut.Core (Json, jsonEmptyObject)
import Data.Argonaut.Encode (class EncodeJson, encodeJson)
import Data.Identity (Identity)
import Data.List (List(..), intercalate)
import Data.Maybe (Maybe(..))
import Data.Newtype (class Newtype, unwrap)
Expand Down Expand Up @@ -142,6 +143,12 @@ else instance getVarOrArg ::
varR = getVar (Proxy :: _ r)
in
lift2 Record.merge varL varR
-- else instance getVarUnion ::
-- ( HFoldl GetVarRec (Proxy {}) { | query } (Proxy { | var })
-- ) =>
-- GetVar (GqlUnion query) { | var } where
-- getVar _ = Proxy -- q >>= \query -> hfoldl GetVarRec (Proxy :: _ {}) (query :: { | query })

else instance getVarRecord ::
( HFoldl GetVarRec (Proxy {}) { | query } (Proxy { | var })
) =>
Expand Down Expand Up @@ -220,6 +227,24 @@ else instance varsTypeCheckedWithoutVars ::
getVarsJson _ _ = jsonEmptyObject
getVarsTypeNames _ _ = ""

else instance varsTypeCheckedIdentity ::
GetVar query {} =>
VarsTypeChecked schema (Identity query) where
getVarsJson _ _ = jsonEmptyObject
getVarsTypeNames _ _ = ""

else instance varsTypeCheckedErrorBoundary ::
GetVar query {} =>
VarsTypeChecked schema (ErrorBoundary query) where
getVarsJson _ _ = jsonEmptyObject
getVarsTypeNames _ _ = ""

else instance varsTypeCheckedUnion ::
GetVar { | query } {} =>
VarsTypeChecked schema (GqlUnion query) where
getVarsJson _ _ = jsonEmptyObject
getVarsTypeNames _ _ = ""

else instance varsTypeCheckedSpread ::
GetVar (Spread alias arg fields) {} =>
VarsTypeChecked schema (Spread alias arg fields) where
Expand Down Expand Up @@ -398,4 +423,3 @@ endsWith c str =

removeSuffix :: Char -> String -> String
removeSuffix c str = if endsWith c str then String.take (String.length str - 1) str else str

0 comments on commit 032b71b

Please sign in to comment.