Safe Haskell | Safe-Inferred |
---|---|
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
- type InlineMT m a = MonadError QErr m => StateT InlineState (ReaderT InlineEnv m) a
- type InlineM a = InlineMT (Except QErr) a
- runInlineMT :: forall m a. MonadError QErr m => HashMap Name FragmentDefinition -> InlineMT m a -> m a
- runInlineM :: forall a. HashMap Name FragmentDefinition -> InlineM a -> Either QErr a
- inlineSelectionSet :: (MonadError QErr m, Foldable t) => t FragmentDefinition -> SelectionSet FragmentSpread Name -> m (SelectionSet NoFragments Name)
- inlineField :: MonadInline m => Field FragmentSpread Name -> m (Field NoFragments Name)
Documentation
runInlineMT :: forall m a. MonadError QErr m => HashMap Name FragmentDefinition -> InlineMT m a -> m a Source #
runInlineM :: forall a. HashMap Name FragmentDefinition -> InlineM a -> Either QErr a 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.
inlineField :: MonadInline m => Field FragmentSpread Name -> m (Field NoFragments Name) Source #