graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellSafe-Inferred
LanguageHaskell2010

Hasura.GraphQL.Execute.Inline

Description

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

Documentation

type InlineMT m a = MonadError QErr m => StateT InlineState (ReaderT InlineEnv m) 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.