Skip to content

Commit

Permalink
put AsGql first and add at to notnull class
Browse files Browse the repository at this point in the history
  • Loading branch information
roryc89 committed Sep 15, 2023
1 parent 9d05853 commit fd63f42
Showing 1 changed file with 36 additions and 35 deletions.
71 changes: 36 additions & 35 deletions src/GraphQL/Client/Args.purs
Original file line number Diff line number Diff line change
Expand Up @@ -59,31 +59,30 @@ guardArg b args =
onlyArgs :: forall a. a -> Args a Unit
onlyArgs a = Args a unit


class ArgGql :: forall param arg. param -> arg -> Constraint
class ArgGql params args
class ArgGql params args

instance ArgGqlAt any params args => ArgGql params args

class ArgGqlAt :: forall param arg. Symbol -> param -> arg -> Constraint
class ArgGqlAt at params arg

instance argToGqlNotNull :: (IsNotNull param arg, ArgGqlAt at param arg) => ArgGqlAt at (NotNull param) arg
else instance argToGqlIgnore :: ArgGqlAt at param IgnoreArg
else instance argAsGql :: ArgGqlAt at param arg => ArgGqlAt at (AsGql gqlName param) arg
else instance argVarJson :: ArgGqlAt at Json (Var sym Json) -- Json can only be used with a variable
else instance argToGqlJsonNotAllowed :: TE.Fail (TE.Text "A `Json` query argument can only be used as a variable ") => ArgGqlAt at Json Json
else instance argVar :: ArgGqlAt at param arg => ArgGqlAt at param (Var sym arg)
else instance argToGqlArrayNull :: ArgGqlAt at (Array param) NullArray
else instance argToGqlArrayAnds :: (ArgGqlAt at (Array param) a1, ArgGqlAt at (Array param) a2) => ArgGqlAt at (Array param) (AndArgs a1 a2)
else instance argToGqlOrArg :: (ArgGqlAt at param argL, ArgGqlAt at param argR) => ArgGqlAt at param (OrArg argL argR)
else instance argToGqlMaybe :: ArgGqlAt at param arg => ArgGqlAt at param (Maybe arg)
else instance argToGqlArray :: ArgGqlAt at param arg => ArgGqlAt at (Array param) (Array arg)
else instance argToGqlArrayOne :: ArgGqlAt at param arg => ArgGqlAt at (Array param) arg
else instance argToGqlRecord :: RecordArg p a u => ArgGqlAt at { | p } { | a }
else instance allowedArgMismatch :: ArgGqlAt at p schemaType => ArgGqlAt at p (AllowedMismatch schemaType a)
else instance argGqlIdentity :: ArgGqlAt at a a
else instance argToGqlNewtypeRecord :: (Newtype n { | p }, RecordArg p a u) => ArgGqlAt at n { | a }
instance argAsGql :: ArgGqlAt at param arg => ArgGqlAt at (AsGql gqlName param) arg
else instance argToGqlNotNull :: (IsNotNull at param arg, ArgGqlAt at param arg) => ArgGqlAt at (NotNull param) arg
else instance argToGqlIgnore :: ArgGqlAt at param IgnoreArg
else instance argVarJson :: ArgGqlAt at Json (Var sym Json) -- Json can only be used with a variable
else instance argToGqlJsonNotAllowed :: TE.Fail (TE.Text "A `Json` query argument can only be used as a variable ") => ArgGqlAt at Json Json
else instance argVar :: ArgGqlAt at param arg => ArgGqlAt at param (Var sym arg)
else instance argToGqlArrayNull :: ArgGqlAt at (Array param) NullArray
else instance argToGqlArrayAnds :: (ArgGqlAt at (Array param) a1, ArgGqlAt at (Array param) a2) => ArgGqlAt at (Array param) (AndArgs a1 a2)
else instance argToGqlOrArg :: (ArgGqlAt at param argL, ArgGqlAt at param argR) => ArgGqlAt at param (OrArg argL argR)
else instance argToGqlMaybe :: ArgGqlAt at param arg => ArgGqlAt at param (Maybe arg)
else instance argToGqlArray :: ArgGqlAt at param arg => ArgGqlAt at (Array param) (Array arg)
else instance argToGqlArrayOne :: ArgGqlAt at param arg => ArgGqlAt at (Array param) arg
else instance argToGqlRecord :: RecordArg p a u => ArgGqlAt at { | p } { | a }
else instance allowedArgMismatch :: ArgGqlAt at p schemaType => ArgGqlAt at p (AllowedMismatch schemaType a)
else instance argGqlIdentity :: ArgGqlAt at a a
else instance argToGqlNewtypeRecord :: (Newtype n { | p }, RecordArg p a u) => ArgGqlAt at n { | a }
else instance argMismatch ::
( TE.Fail
( TE.Above
Expand All @@ -92,16 +91,17 @@ else instance argMismatch ::
(TE.Text " ")
( TE.Above
(TE.Beside (TE.Text "Schema: ") (TE.Quote param))
(TE.Above (TE.Beside (TE.Text "Query: ") (TE.Quote arg))
(TE.Beside (TE.Text "At: ") (TE.Quote at)))
( TE.Above (TE.Beside (TE.Text "Query: ") (TE.Quote arg))
(TE.Beside (TE.Text "At: ") (TE.Quote at))
)
)
)
)
) =>
ArgGqlAt at param arg

class IsNotNull :: forall k1 k2. k1 -> k2 -> Constraint
class IsNotNull param arg
class IsNotNull :: forall k1 k2. Symbol -> k1 -> k2 -> Constraint
class IsNotNull at param arg

instance
( TE.Fail
Expand All @@ -111,12 +111,14 @@ instance
(TE.Text " ")
( TE.Above
(TE.Beside (TE.Text "Schema: ") (TE.Quote param))
(TE.Beside (TE.Text "Query: ") (TE.Quote (Maybe arg)))
( TE.Above (TE.Beside (TE.Text "Query: ") (TE.Quote arg))
(TE.Beside (TE.Text "At: ") (TE.Quote at))
)
)
)
)
) =>
IsNotNull param (Maybe arg)
IsNotNull at param (Maybe arg)

else instance
( TE.Fail
Expand All @@ -126,22 +128,24 @@ else instance
(TE.Text " ")
( TE.Above
(TE.Beside (TE.Text "Schema: ") (TE.Quote param))
(TE.Beside (TE.Text "Query: ") (TE.Quote IgnoreArg))
( TE.Above (TE.Beside (TE.Text "Query: ") (TE.Quote IgnoreArg))
(TE.Beside (TE.Text "At: ") (TE.Quote at))
)
)
)
)
) =>
IsNotNull param IgnoreArg
IsNotNull at param IgnoreArg
else instance
( IsNotNull param arg
( IsNotNull at param arg
) =>
IsNotNull (AsGql gqlName param) arg
IsNotNull at (AsGql gqlName param) arg
else instance
( IsNotNull param l
, IsNotNull param r
( IsNotNull at param l
, IsNotNull at param r
) =>
IsNotNull param (OrArg l r)
else instance IsNotNull param arg
IsNotNull at param (OrArg l r)
else instance IsNotNull at param arg

class HMapWithIndex (ArgPropToGql p) { | a } u <= RecordArg p a u

Expand Down Expand Up @@ -179,6 +183,3 @@ else instance argsSatisifyOthers_ ::
FoldingWithIndex (ArgsSatisifyNotNullsProps args) (Proxy sym) Unit param Unit where
foldingWithIndex (ArgsSatisifyNotNullsProps _) _ _ _ = unit




0 comments on commit fd63f42

Please sign in to comment.