Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Representation for queries going to remote schemas. Due to the existence of remote relationships from remote schemas, we can't simply reuse the GraphQL document AST we define in graphql-parser-hs, and instead redefine a custom structure to represent such queries.
Synopsis
- data SelectionSet r var
- = SelectionSetObject (ObjectSelectionSet r var)
- | SelectionSetUnion (DeduplicatedSelectionSet r var)
- | SelectionSetInterface (DeduplicatedSelectionSet r var)
- | SelectionSetNone
- data DeduplicatedSelectionSet r var = DeduplicatedSelectionSet {}
- type ObjectSelectionSet r var = InsOrdHashMap Name (Field r var)
- mkInterfaceSelectionSet :: HashSet Name -> [(Name, ObjectSelectionSet r var)] -> DeduplicatedSelectionSet r var
- mkUnionSelectionSet :: [(Name, ObjectSelectionSet r var)] -> DeduplicatedSelectionSet r var
- data Field r var
- = FieldGraphQL (GraphQLField r var)
- | FieldRemote (SchemaRemoteRelationshipSelect r)
- data GraphQLField r var = GraphQLField {
- _fAlias :: Name
- _fName :: Name
- _fArguments :: HashMap Name (Value var)
- _fDirectives :: [Directive var]
- _fSelectionSet :: SelectionSet r var
- mkGraphQLField :: Maybe Name -> Name -> HashMap Name (Value var) -> [Directive var] -> SelectionSet r var -> GraphQLField r var
- data RemoteSchemaRootField r var = RemoteSchemaRootField {}
- data SchemaRemoteRelationshipSelect r = SchemaRemoteRelationshipSelect {}
- data RemoteFieldArgument = RemoteFieldArgument {}
- data RemoteSchemaSelect r = RemoteSchemaSelect {}
- convertSelectionSet :: forall var. Eq var => SelectionSet Void var -> SelectionSet NoFragments var
- convertGraphQLField :: Eq var => GraphQLField Void var -> Field NoFragments var
- _FieldRemote :: forall r var. Prism' (Field r var) (SchemaRemoteRelationshipSelect r)
- _FieldGraphQL :: forall r var var. Prism (Field r var) (Field r var) (GraphQLField r var) (GraphQLField r var)
- fSelectionSet :: forall r var r. Lens (GraphQLField r var) (GraphQLField r var) (SelectionSet r var) (SelectionSet r var)
- fName :: forall r var. Lens' (GraphQLField r var) Name
- fDirectives :: forall r var. Lens' (GraphQLField r var) [Directive var]
- fArguments :: forall r var. Lens' (GraphQLField r var) (HashMap Name (Value var))
- fAlias :: forall r var. Lens' (GraphQLField r var) Name
- dssMemberSelectionSets :: forall r var r var. Lens (DeduplicatedSelectionSet r var) (DeduplicatedSelectionSet r var) (HashMap Name (ObjectSelectionSet r var)) (HashMap Name (ObjectSelectionSet r var))
- dssCommonFields :: forall r var. Lens' (DeduplicatedSelectionSet r var) (HashSet Name)
Documentation
data SelectionSet r var Source #
Custom representation of a selection set.
Similarly to other parts of the IR, the r
argument is used for remote
relationships.
SelectionSetObject (ObjectSelectionSet r var) | |
SelectionSetUnion (DeduplicatedSelectionSet r var) | |
SelectionSetInterface (DeduplicatedSelectionSet r var) | |
SelectionSetNone |
Instances
data DeduplicatedSelectionSet r var Source #
Representation of the normalized selection set of an interface/union type.
This representation is used to attempt to minimize the size of the GraphQL query that eventually gets sent to the GraphQL server by defining as many fields as possible on the abstract type.
DeduplicatedSelectionSet | |
|
Instances
type ObjectSelectionSet r var = InsOrdHashMap Name (Field r var) Source #
mkInterfaceSelectionSet Source #
:: HashSet Name | Member fields of the interface |
-> [(Name, ObjectSelectionSet r var)] | Selection sets for all the member types |
-> DeduplicatedSelectionSet r var |
Constructs an InterfaceSelectionSet
from a set of interface fields and an
association list of the fields. This function ensures that __typename
is
present in the set of interface fields.
:: [(Name, ObjectSelectionSet r var)] | Selection sets for all the member types |
-> DeduplicatedSelectionSet r var |
Constructs an UnionSelectionSet
from a list of the fields, using a
singleton set of __typename
for the set of common fields.
Representation of one individual field.
This particular type is the reason why we need a different representation from the one in 'graphql-parser-hs': we differentiate between selection fields that target the actual remote schema, and fields that, instead, are remote from it and need to be treated differently.
Instances
Foldable (Field r) Source # | |
Defined in Hasura.RQL.IR.RemoteSchema fold :: Monoid m => Field r m -> m # foldMap :: Monoid m => (a -> m) -> Field r a -> m # foldMap' :: Monoid m => (a -> m) -> Field r a -> m # foldr :: (a -> b -> b) -> b -> Field r a -> b # foldr' :: (a -> b -> b) -> b -> Field r a -> b # foldl :: (b -> a -> b) -> b -> Field r a -> b # foldl' :: (b -> a -> b) -> b -> Field r a -> b # foldr1 :: (a -> a -> a) -> Field r a -> a # foldl1 :: (a -> a -> a) -> Field r a -> a # elem :: Eq a => a -> Field r a -> Bool # maximum :: Ord a => Field r a -> a # minimum :: Ord a => Field r a -> a # | |
Traversable (Field r) Source # | |
Functor (Field r) Source # | |
(Show var, Show r) => Show (Field r var) Source # | |
(Eq var, Eq r) => Eq (Field r var) Source # | |
data GraphQLField r var Source #
Normalized representation of a GraphQL field.
This type is almost identical to Field
, except for the fact that the
selection set is our annotated SelectionSet
, instead of the original
SelectionSet
. We use this type to represent the fields of a selection
that do target the remote schema.
GraphQLField | |
|
Instances
mkGraphQLField :: Maybe Name -> Name -> HashMap Name (Value var) -> [Directive var] -> SelectionSet r var -> GraphQLField r var Source #
data RemoteSchemaRootField r var Source #
Root entry point for a remote schema.
Instances
data SchemaRemoteRelationshipSelect r Source #
A remote relationship's selection and fields required for its join condition.
SchemaRemoteRelationshipSelect | |
|
Instances
data RemoteFieldArgument Source #
Instances
Show RemoteFieldArgument Source # | |
Defined in Hasura.RQL.IR.RemoteSchema showsPrec :: Int -> RemoteFieldArgument -> ShowS # show :: RemoteFieldArgument -> String # showList :: [RemoteFieldArgument] -> ShowS # | |
Eq RemoteFieldArgument Source # | |
Defined in Hasura.RQL.IR.RemoteSchema (==) :: RemoteFieldArgument -> RemoteFieldArgument -> Bool # (/=) :: RemoteFieldArgument -> RemoteFieldArgument -> Bool # |
data RemoteSchemaSelect r Source #
Instances
Show r => Show (RemoteSchemaSelect r) Source # | |
Defined in Hasura.RQL.IR.RemoteSchema showsPrec :: Int -> RemoteSchemaSelect r -> ShowS # show :: RemoteSchemaSelect r -> String # showList :: [RemoteSchemaSelect r] -> ShowS # |
convertSelectionSet :: forall var. Eq var => SelectionSet Void var -> SelectionSet NoFragments var Source #
Converts a normalized selection set back into a selection set as defined in GraphQL spec, in order to send it to a remote server.
This function expects a SelectionSet
for which r
is Void
, which
guarantees that there is no longer any remote join field in the selection
set.
convertGraphQLField :: Eq var => GraphQLField Void var -> Field NoFragments var Source #
_FieldRemote :: forall r var. Prism' (Field r var) (SchemaRemoteRelationshipSelect r) Source #
_FieldGraphQL :: forall r var var. Prism (Field r var) (Field r var) (GraphQLField r var) (GraphQLField r var) Source #
fSelectionSet :: forall r var r. Lens (GraphQLField r var) (GraphQLField r var) (SelectionSet r var) (SelectionSet r var) Source #
fDirectives :: forall r var. Lens' (GraphQLField r var) [Directive var] Source #
fArguments :: forall r var. Lens' (GraphQLField r var) (HashMap Name (Value var)) Source #
dssMemberSelectionSets :: forall r var r var. Lens (DeduplicatedSelectionSet r var) (DeduplicatedSelectionSet r var) (HashMap Name (ObjectSelectionSet r var)) (HashMap Name (ObjectSelectionSet r var)) Source #
dssCommonFields :: forall r var. Lens' (DeduplicatedSelectionSet r var) (HashSet Name) Source #