graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellNone
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

data InlineEnv Source #

Internal bookkeeping used during inlining.

Constructors

InlineEnv 

Fields

  • _ieFragmentDefinitions :: HashMap Name FragmentDefinition

    All known fragment definitions.

  • _ieFragmentStack :: [Name]

    Fragments we’re currently inlining higher up in the call stack, used to detect fragment cycles.

newtype InlineState Source #

Internal bookkeeping used during inlining.

Constructors

InlineState 

Fields

  • _isFragmentCache :: HashMap Name (InlineFragment NoFragments Name)

    A cache of fragment definitions we’ve already inlined, so we don’t need to inline them again.

isFragmentCache :: Iso' InlineState (HashMap Name (InlineFragment NoFragments Name)) 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 #