这是indexloc提供的服务,不要输入任何密码
Skip to content
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
16 changes: 8 additions & 8 deletions server/src-lib/Hasura/GraphQL/Context.hs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ mkCompExpInp colTy =
, bool [] (map (mk $ mkScalarTy PGText) stringOps) isStringTy
, bool [] (map jsonbOpToInpVal jsonbOps) isJsonbTy
, bool [] (stDWithinOpInpVal : map geomOpToInpVal geomOps) isGeometryTy
, [InpValInfo Nothing "_is_null" $ G.TypeNamed (G.Nullability True) $ G.NamedType "Boolean"]
, [InpValInfo Nothing "_is_null" Nothing $ G.TypeNamed (G.Nullability True) $ G.NamedType "Boolean"]
]) HasuraType
where
tyDesc = mconcat
Expand All @@ -200,7 +200,7 @@ mkCompExpInp colTy =
PGVarchar -> True
PGText -> True
_ -> False
mk t n = InpValInfo Nothing n $ G.toGT t
mk t n = InpValInfo Nothing n Nothing $ G.toGT t
colScalarTy = mkScalarTy colTy
-- colScalarListTy = GA.GTList colGTy
typedOps =
Expand All @@ -218,7 +218,7 @@ mkCompExpInp colTy =
isJsonbTy = case colTy of
PGJSONB -> True
_ -> False
jsonbOpToInpVal (op, ty, desc) = InpValInfo (Just desc) op ty
jsonbOpToInpVal (op, ty, desc) = InpValInfo (Just desc) op Nothing ty
jsonbOps =
[ ( "_contains"
, G.toGT $ mkScalarTy PGJSONB
Expand All @@ -244,7 +244,7 @@ mkCompExpInp colTy =

-- Geometry related ops
stDWithinOpInpVal =
InpValInfo (Just stDWithinDesc) "_st_d_within" $ G.toGT stDWithinInpTy
InpValInfo (Just stDWithinDesc) "_st_d_within" Nothing $ G.toGT stDWithinInpTy
stDWithinDesc =
"is the column within a distance from a geometry value"

Expand All @@ -253,7 +253,7 @@ mkCompExpInp colTy =
_ -> False

geomOpToInpVal (op, desc) =
InpValInfo (Just desc) op $ G.toGT $ mkScalarTy PGGeometry
InpValInfo (Just desc) op Nothing $ G.toGT $ mkScalarTy PGGeometry
geomOps =
[
( "_st_contains"
Expand Down Expand Up @@ -352,15 +352,15 @@ mkGCtx (TyAgg tyInfos fldInfos ordByEnums funcArgCtx) (RootFlds flds) insCtxMap
G.toGT $ G.NamedType "__Type"
where
typeFldArgs = mapFromL _iviName [
InpValInfo (Just "name of the type") "name"
InpValInfo (Just "name of the type") "name" Nothing
$ G.toGT $ G.toNT $ G.NamedType "String"
]

stDWithinInpM = bool Nothing (Just stDWithinInp) (PGGeometry `elem` colTys)
stDWithinInp =
mkHsraInpTyInfo Nothing stDWithinInpTy $ fromInpValL
[ InpValInfo Nothing "from" $ G.toGT $ G.toNT $ mkScalarTy PGGeometry
, InpValInfo Nothing "distance" $ G.toNT $ G.toNT $ mkScalarTy PGFloat
[ InpValInfo Nothing "from" Nothing $ G.toGT $ G.toNT $ mkScalarTy PGGeometry
, InpValInfo Nothing "distance" Nothing $ G.toNT $ G.toNT $ mkScalarTy PGFloat
]

emptyGCtx :: GCtx
Expand Down
15 changes: 8 additions & 7 deletions server/src-lib/Hasura/GraphQL/RemoteServer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import qualified Data.HashMap.Strict as Map
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import qualified Language.GraphQL.Draft.Syntax as G
import qualified Language.GraphQL.Draft.Parser as G
import qualified Network.HTTP.Client as HTTP
import qualified Network.Wreq as Wreq

Expand All @@ -25,6 +26,7 @@ import qualified Hasura.GraphQL.Schema as GS
import qualified Hasura.GraphQL.Validate.Types as VT



introspectionQuery :: BL.ByteString
introspectionQuery = $(embedStringFile "src-rsr/introspection.json")

Expand Down Expand Up @@ -265,11 +267,15 @@ instance J.FromJSON (FromIntrospection G.InputValueDefinition) where
name <- o .: "name"
desc <- o .:? "description"
_type <- o .: "type"
--defValue <- o .: "defaultValue"
defVal <- o .:? "defaultValue"
let desc' = fmap fromIntrospection desc
r = G.InputValueDefinition desc' name (fromIntrospection _type) Nothing
let defVal' = fmap fromIntrospection defVal
r = G.InputValueDefinition desc' name (fromIntrospection _type) defVal'
return $ FromIntrospection r

instance J.FromJSON (FromIntrospection G.ValueConst) where
parseJSON = J.withText "defaultValue" $ \t -> fmap FromIntrospection
$ either (fail . T.unpack) return $ G.parseValueConst t

-- instance J.FromJSON (FromIntrospection G.ListType) where
-- parseJSON = parseJSON
Expand All @@ -284,11 +290,6 @@ instance J.FromJSON (FromIntrospection G.InputValueDefinition) where
-- ofVal <- o .: "value"
-- return $ FromIntrospection $ G.ObjectFieldG name ofVal

-- instance J.FromJSON (FromIntrospection G.ValueConst) where
-- parseJSON =
-- fmap FromIntrospection .
-- $(J.mkParseJSON J.defaultOptions{J.sumEncoding=J.UntaggedValue} ''G.ValueConst)

-- instance J.FromJSON (FromIntrospection G.Value) where
-- parseJSON =
-- fmap FromIntrospection .
Expand Down
5 changes: 3 additions & 2 deletions server/src-lib/Hasura/GraphQL/Resolve/Introspect.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import qualified Language.GraphQL.Draft.Syntax as G

import Hasura.GraphQL.Resolve.Context
import Hasura.GraphQL.Resolve.InputValue
import Hasura.GraphQL.Validate.InputValue
import Hasura.GraphQL.Validate.Context
import Hasura.GraphQL.Validate.Field
import Hasura.GraphQL.Validate.Types
Expand Down Expand Up @@ -201,15 +202,15 @@ inputValueR
:: ( MonadReader r m, Has TypeMap r
, MonadError QErr m)
=> Field -> InpValInfo -> m J.Object
inputValueR fld (InpValInfo descM n ty) =
inputValueR fld (InpValInfo descM n defM ty) =
withSubFields (_fSelSet fld) $ \subFld ->
case _fName subFld of
"__typename" -> retJT "__InputValue"
"name" -> retJ $ G.unName n
"description" -> retJ $ fmap G.unDescription descM
"type" -> J.toJSON <$> gtypeR ty subFld
-- TODO: figure out what the spec means by 'string encoding'
"defaultValue" -> return J.Null
"defaultValue" -> retJ $ pPrintValueC <$> defM
_ -> return J.Null

-- 4.5.5
Expand Down
Loading