Skip to main content

Standard steps

The following are built-in standard steps, provided to accomplish common tasks. Many of them are thin wrappers around an underlying step class, for example loadOne and loadMany both call in to the underlying LoadStep step class. These standard steps can be used as a foundation for your project, and are often sufficient enough for a schema's needs - particularly when integrating with an existing business logic layer.

Loading data

  • loadOne: similar to DataLoader.load, batch loading of single values
  • loadMany: similar to DataLoader.load, batch loading of lists of values

Forming objects and lists

  • list: takes a list of steps and turns it into a single step that resolves to list of the underlying steps' values
  • object: takes an object, the keys of which are steps, and turns it into a single step that resolves to an object where the values are the corresponding underlying steps' values
  • remapKeys: returns step that results in an object made up of the given renamed keys and values from another object step

Operating on lists

  • first: returns the first entry from a list
  • last: returns the last entry from a list
  • reverse: reverses the order of a list
  • filter: returns only the entries in a list that satisfy a callback
  • groupBy: Takes a single dimensional list plan and a mapper that returns a grouping key. Returns a plan that results in a Map where the keys are the grouping keys and the values are lists of the original entries that match these grouping keys.
  • each: Transforms a list by wrapping each element in the list with the given mapper.

Utility

  • polymorphicBranch: a step to help deal with simple polymorphism
  • constant: always returns the given value
  • error: always throws the given error
  • access: accesses the property at the given path for each value
  • lambda: executes a lambda function for each set of values
  • setter: a ModifierStep for setting given values onto a parent step

GraphQL

  • context: returns the GraphQL contextValue
  • connection: wraps a list-returning plan with connection-related capabilities such as PageInfo
  • node: gets a Node by its global object identifier

Realtime

  • listen: Subscribes to the given pubsubOrPlan to get realtime updates on a given topic (topicOrPlan), mapping the resulting event via the itemPlan callback.