graphql-ast-tools
graphql-ast-tools
contains a set of methods to help simplifying a GraphQL Document Node by resolving @skip
and @include
Directives and merging Named Fragments into fields or turning them into Inline Fragments. The goal is to turn a complex document structure with deeply nested fragments into a simpler and shallow one that makes processing easier.
API
/** * Options used in transformDocment */ /** * transformDocument will resolve NamedFragments and turn them into shallow InlineFragments or if possible * merge them directly with Field nodes. If `options.variables` are given it also resolves @include * and @skip directives. */
/** * TypeGetter which is used in `transformDocument`. * Passing a path should return its type and implementing types. * * Examples: * query.users.name => ["String"] * query.users => ["User"] * query.users.flagAction => ["FlagAction", "Action"] * query => ["RootQuery"] * * Special case `type` followed by a type name will * resolve starting from that type, e.g.: * type.User.name => ["String"] * type.RootQuery.users = ["User"] */;
/** * Merge 2 definitions. * * B overwrites A if it does not have an selection set. * Otherwise merge selection sets. */ /** * Merge selectionSets. */