Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module implements fragment inlining, which converts all fragment spreads in a GraphQL query to inline fragments. For example, given a query like
query { users { id ...userFields } } fragment userFields on User { name favoriteColor }
the fragment inliner will convert it to this:
query { users { id ... on User { name favoriteColor } } }
This is a straightforward and mechanical transformation, but it simplifies further processing, since we catch unbound fragments and recursive fragment definitions early in the pipeline, so parsing does not have to worry about it. In that sense, fragment inlining is similar to the variable resolution pass performed by Hasura.GraphQL.Execute.Resolve, but for fragment definitions rather than variables.
Synopsis
- data InlineEnv = InlineEnv {
- _ieFragmentDefinitions :: HashMap Name FragmentDefinition
- _ieFragmentStack :: [Name]
- newtype InlineState = InlineState {
- _isFragmentCache :: HashMap Name (InlineFragment NoFragments Name)
- ieFragmentStack :: Lens' InlineEnv [Name]
- isFragmentCache :: Iso' InlineState (HashMap Name (InlineFragment NoFragments Name))
- type MonadInline m = (MonadError QErr m, MonadReader InlineEnv m, MonadState InlineState m)
- inlineSelectionSet :: (MonadError QErr m, Foldable t) => t FragmentDefinition -> SelectionSet FragmentSpread Name -> m (SelectionSet NoFragments Name)
- inlineSelection :: MonadInline m => Selection FragmentSpread Name -> m (Selection NoFragments Name)
- inlineFragmentSpread :: MonadInline m => FragmentSpread Name -> m (InlineFragment NoFragments Name)
Documentation
Internal bookkeeping used during inlining.
InlineEnv | |
|
newtype InlineState Source #
Internal bookkeeping used during inlining.
InlineState | |
|
ieFragmentStack :: Lens' InlineEnv [Name] Source #
isFragmentCache :: Iso' InlineState (HashMap Name (InlineFragment NoFragments Name)) Source #
type MonadInline m = (MonadError QErr m, MonadReader InlineEnv m, MonadState InlineState m) Source #
inlineSelectionSet :: (MonadError QErr m, Foldable t) => t FragmentDefinition -> SelectionSet FragmentSpread Name -> m (SelectionSet NoFragments Name) Source #
Inlines all fragment spreads in a SelectionSet
; see the module
documentation for Hasura.GraphQL.Execute.Inline for details.
inlineSelection :: MonadInline m => Selection FragmentSpread Name -> m (Selection NoFragments Name) Source #
inlineFragmentSpread :: MonadInline m => FragmentSpread Name -> m (InlineFragment NoFragments Name) Source #