graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellNone
LanguageHaskell2010

Hasura.RQL.Types.Endpoint.Trie

Synopsis

Documentation

type MultiMapPathTrie a k v = Trie (PathComponent a) (MultiMap k v) Source #

Trie from PathComponents to MultiMaps

data PathComponent a Source #

A component in a URL path: either a literal or a wildcard parameter

Constructors

PathLiteral a 
PathParam 

Instances

Instances details
Eq a => Eq (PathComponent a) Source # 
Instance details

Defined in Hasura.RQL.Types.Endpoint.Trie

Ord a => Ord (PathComponent a) Source # 
Instance details

Defined in Hasura.RQL.Types.Endpoint.Trie

Show a => Show (PathComponent a) Source # 
Instance details

Defined in Hasura.RQL.Types.Endpoint.Trie

Generic (PathComponent a) Source # 
Instance details

Defined in Hasura.RQL.Types.Endpoint.Trie

Associated Types

type Rep (PathComponent a) :: Type -> Type #

Hashable a => Hashable (PathComponent a) Source # 
Instance details

Defined in Hasura.RQL.Types.Endpoint.Trie

ToJSON a => ToJSONKey (PathComponent a) Source # 
Instance details

Defined in Hasura.RQL.Types.Endpoint.Trie

Methods

toJSONKey :: ToJSONKeyFunction (PathComponent a)

toJSONKeyList :: ToJSONKeyFunction [PathComponent a]

ToJSON a => ToJSON (PathComponent a) Source # 
Instance details

Defined in Hasura.RQL.Types.Endpoint.Trie

Methods

toJSON :: PathComponent a -> Value

toEncoding :: PathComponent a -> Encoding

toJSONList :: [PathComponent a] -> Value

toEncodingList :: [PathComponent a] -> Encoding

type Rep (PathComponent a) Source # 
Instance details

Defined in Hasura.RQL.Types.Endpoint.Trie

type Rep (PathComponent a) = D1 ('MetaData "PathComponent" "Hasura.RQL.Types.Endpoint.Trie" "graphql-engine-1.0.0-inplace" 'False) (C1 ('MetaCons "PathLiteral" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a)) :+: C1 ('MetaCons "PathParam" 'PrefixI 'False) (U1 :: Type -> Type))

data MatchResult a k v Source #

Result of matching a path [PathComponent] a and key k in a MultiMapPathTrie.

MatchResult is a lattice where MatchNotFound is the bottom element and MatchAmbiguous is the top element:

MatchAmbiguous / MatchFound v0 as0 MatchFound v1 as1 / MatchMissingKey (ks0 <> ks1) / MatchMissingKey ks0 MatchMissingKey ks1 / MatchNotFound

Constructors

MatchAmbiguous

Multiple results.

MatchFound v [a]

A single unambiguous result. Returns the value found and a list of parameter bindings.

MatchMissingKey (NonEmpty k)

A path was found, but not a key. Returns a list of keys found.

MatchNotFound

Path was not found in the MultiMapPathTrie.

Instances

Instances details
(Eq v, Eq a, Eq k) => Eq (MatchResult a k v) Source # 
Instance details

Defined in Hasura.RQL.Types.Endpoint.Trie

Methods

(==) :: MatchResult a k v -> MatchResult a k v -> Bool #

(/=) :: MatchResult a k v -> MatchResult a k v -> Bool #

(Show v, Show a, Show k) => Show (MatchResult a k v) Source # 
Instance details

Defined in Hasura.RQL.Types.Endpoint.Trie

Methods

showsPrec :: Int -> MatchResult a k v -> ShowS #

show :: MatchResult a k v -> String #

showList :: [MatchResult a k v] -> ShowS #

Semigroup (MatchResult a k v) Source #

Semigroup and Monoid instances implement join (i.e. least upper bound) on the above lattice.

Instance details

Defined in Hasura.RQL.Types.Endpoint.Trie

Methods

(<>) :: MatchResult a k v -> MatchResult a k v -> MatchResult a k v #

sconcat :: NonEmpty (MatchResult a k v) -> MatchResult a k v #

stimes :: Integral b => b -> MatchResult a k v -> MatchResult a k v #

Monoid (MatchResult a k v) Source # 
Instance details

Defined in Hasura.RQL.Types.Endpoint.Trie

Methods

mempty :: MatchResult a k v #

mappend :: MatchResult a k v -> MatchResult a k v -> MatchResult a k v #

mconcat :: [MatchResult a k v] -> MatchResult a k v #

lookupPath :: (Eq a, Hashable a) => [a] -> Trie (PathComponent a) v -> [(v, [a])] Source #

Look up the value at a path. PathParam matches any path component. Returns a list of pairs containing the value found and bindings for any PathParams.

matchPath :: (Eq a, Eq k, Hashable k, Hashable a) => k -> [a] -> MultiMapPathTrie a k v -> MatchResult a k v Source #

Match a key k and path [a] against a MultiMapPathTrie a k v

ambiguousPathsGrouped :: (Hashable a, Eq k, Hashable k, Ord v, Ord a) => MultiMapPathTrie a k v -> [(Set [PathComponent a], Set v)] Source #

A version of ambiguousPaths that attempts to group all ambiguous paths that have overlapping endpoints

groupAmbiguousPaths :: (Ord a, Ord v) => [(Set [PathComponent a], Set v)] -> [(Set [PathComponent a], Set v)] Source #

ambiguousPaths :: (Eq a, Hashable a, Eq k, Hashable k, Ord v) => MultiMapPathTrie a k v -> [([PathComponent a], Set v)] Source #

Detect and return all ambiguous paths in the MultiMapPathTrie A path p is ambiguous if matchPath k p can return MatchAmbiguous for some k.