@@ -5,7 +5,7 @@ import Prelude
55import Data.Maybe (Maybe (..))
66import GraphQL.Client.Alias ((:))
77import GraphQL.Client.Alias.Dynamic (Spread (..))
8- import GraphQL.Client.Args (OrArg (..), (++), (=>> ), (+++ ))
8+ import GraphQL.Client.Args (OrArg (..), andArg , guardArg , (++), (+++ ), (=>> ))
99import GraphQL.Client.AsGql (AsGql )
1010import GraphQL.Client.Variable (Var (..))
1111import GraphQL.Client.Variables (class GetGqlQueryVars , getQueryVars , getVarsTypeNames , withVars )
@@ -237,6 +237,82 @@ testGqlVarsCreatedAt =
237237 , created_at_lt: 3
238238 }
239239
240+ testGqlVarsOrArg
241+ :: Proxy
242+ { created_at_eq :: Proxy " Int"
243+ , created_at_lt :: Proxy " Int"
244+ , myVar :: Proxy " customId"
245+ }
246+ testGqlVarsOrArg =
247+ getGqlQueryVars $
248+ { users:
249+ { where: { created_at: { eq: guardArg false $ Var @" created_at_eq" @Int , lt: guardArg false $ Var @" created_at_lt" @Int } }
250+ }
251+ =>> { id: guardArg false $ Var @" myVar" @Int }
252+ }
253+
254+ testGqlVarsAndArg
255+ :: Proxy
256+ { created_at_eq :: Proxy " Int"
257+ , created_at_lt :: Proxy " Int"
258+ , id1 :: Proxy " customId"
259+ , id2 :: Proxy " customId"
260+ }
261+ testGqlVarsAndArg =
262+ getGqlQueryVars $
263+ { users:
264+ { where:
265+ { created_at:
266+ andArg
267+ { eq: Var @" created_at_eq" @Int }
268+ { lt: Var @" created_at_lt" @Int }
269+ }
270+ }
271+ =>>
272+ andArg
273+ { id: Var @" id1" @Int }
274+ { id: Var @" id2" @Int }
275+ }
276+
277+ testGqlVarsComplex
278+ :: Proxy
279+ { created_at_eq :: Proxy " Int"
280+ , created_at_eq_2 :: Proxy " Int"
281+ , created_at_lt :: Proxy " Int"
282+ , created_at_lt_2 :: Proxy " Int"
283+ , id1 :: Proxy " customId"
284+ , id2 :: Proxy " customId"
285+ , id3 :: Proxy " customId"
286+ , id4 :: Proxy " customId"
287+ }
288+ testGqlVarsComplex =
289+ getGqlQueryVars $
290+ { users:
291+ { where:
292+ { created_at:
293+ andArg
294+ { eq:
295+ if true then ArgL $ Var @" created_at_eq" @Int
296+ else ArgR $ Var @" created_at_eq_2" @Int
297+ }
298+ { lt:
299+ if true then ArgL $ Var @" created_at_lt" @Int
300+ else ArgR $ Var @" created_at_lt_2" @Int
301+ }
302+ }
303+ }
304+ =>>
305+ andArg
306+ { id:
307+ if true then ArgL $ Var @" id1" @Int
308+ else ArgR $ Var @" id2" @Int
309+ }
310+ { id:
311+ if true then ArgL $ Var @" id3" @Int
312+ else ArgR $ Var @" id4" @Int
313+ }
314+ }
315+
240316testBasic
241317 :: Proxy
242318 { var1 :: Int
0 commit comments