Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Variants as well as data type enums #140

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/GraphQL/Client/Args.purs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Data.Bifunctor (class Bifunctor)
import Data.Maybe (Maybe)
import Data.Newtype (class Newtype)
import Data.Symbol (class IsSymbol)
import Data.Variant (Variant)
import GraphQL.Client.Args.AllowedMismatch (AllowedMismatch)
import GraphQL.Client.AsGql (AsGql)
import GraphQL.Client.NullArray (NullArray)
Expand Down Expand Up @@ -70,7 +71,8 @@ class ArgGqlAt at params arg
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 argToGqlVariant :: (Union r () params) => ArgGqlAt at (Variant params) (Variant r)
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
Expand Down
3 changes: 3 additions & 0 deletions src/GraphQL/Client/ToGqlString.purs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import Data.String.Regex.Flags (global)
import Data.String.Regex.Unsafe (unsafeRegex)
import Data.Symbol (class IsSymbol, reflectSymbol)
import Data.Time (Time)
import Data.Variant (Unvariant(..), Variant, unvariant)
import Foreign (Foreign)
import Foreign.Object (Object)
import Foreign.Object as Object
Expand Down Expand Up @@ -317,6 +318,8 @@ else instance gqlArgStringErrorBoundary :: GqlArgString a => GqlArgString (Error
toGqlArgStringImpl (ErrorBoundary a) = toGqlArgStringImpl a
else instance gqlArgStringAllowedMismatch :: GqlArgString a => GqlArgString (AllowedMismatch t a) where
toGqlArgStringImpl = unwrap >>> toGqlArgStringImpl
else instance gqlargVariant :: GqlArgString (Variant r) where
toGqlArgStringImpl v = unvariant v # \(Unvariant f) -> f \p _ -> reflectSymbol p
else instance gqlArgStringVar :: IsSymbol sym => GqlArgString (Var sym a) where
toGqlArgStringImpl _ = "$" <> reflectSymbol (Proxy :: Proxy sym)
else instance gqlArgStringOrArg ::
Expand Down
Loading