Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* introduce result visiting This changes introduces a few generic functions for revisiting data, demonstrating use of some of them within the RenameTypes transform. = 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. * Add result transforming to bundled transformers These transformers now can utilize the visitData method to recursively visit the result and modify it as necessary by checking the __typename value. State about fields can be saved within the transformation context. 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
- Loading branch information