Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce result visiting #1718

Merged
merged 4 commits into from
Jul 5, 2020
Merged

Introduce result visiting #1718

merged 4 commits into from
Jul 5, 2020

Commits on Jul 5, 2020

  1. Configuration menu
    Copy the full SHA
    c1810bb View commit details
    Browse the repository at this point in the history
  2. introduce result visiting

    This changes introduces a few generic functions for revisiting data
    
    = visitData can be used to recursively visit an ExecutionResult (or any object)
    
    it takes two functions, one executed when entering the object, one when leaving
    
    = visitResult can be used to visit a result by with a resultVisitorMap and/or an errorVisitorMap
    
    visitResult visits the result using the request, so it knows the object type for every object within the map, as long as the result includes __typename info when requesting abstract types, and also knows the field name for each aliased key within the object.
    
    * it executes the correct visitor from each objectVisitorMap included within the resultVisitorMap depending on the object type and field name
    * it executes object visitors on the object itself when entering and leaving the object using the values from the __enter and __leave dummy field names within the objectVisitorMap
    * it executes any visitors for leaf types included within the resultVisitorMap to provide a simple mechanism of visiting all fields of a certain leaf type
    
    errors can also be visited -- these are meant to provide opportunities for transforming a GraphQLError, including the path, and so, if an errorVisitorMap is included, error visitors from the map will be collected for each field found in the path of the original error.
    yaacovCR committed Jul 5, 2020
    Configuration menu
    Copy the full SHA
    7a31851 View commit details
    Browse the repository at this point in the history
  3. Add result transforming to bundled transformers

    Adds result wrapping capability to the following generic transformers
    
    = TransformCompositeFields
    = TransformInterfaceFields
    = TransformObjectFields
    = TransformRootFields
    = ExtendSchema
    = MapFields
    
    Adds result visiting usage to the following transfromers
    = WrapFields
    = WrapType
    = HoistField
    
    Result visiting was introduced within RenameTypes within the initial
    commit.
    yaacovCR committed Jul 5, 2020
    Configuration menu
    Copy the full SHA
    dcc75ac View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    12fc795 View commit details
    Browse the repository at this point in the history