def _expose_all_eligible_locations(match_query, location_types, eligible_locations):
    """Return a MATCH query where all eligible locations are valid as query start locations."""
    eligible_location_types = dict()

    new_match_traversals = []
    for current_traversal in match_query.match_traversals:
        new_traversal = []
        for match_step in current_traversal:
            new_step = match_step
            current_step_location = match_step.as_block.location

            if current_step_location in eligible_locations:
                # This location is eligible. We need to make sure it has an associated type bound,
                # so that it produces a "class:" clause that will make it a valid query start
                # location. It either already has such a type bound, or we can use the type
                # implied by the GraphQL query structure to add one.
                current_type_bound = _calculate_type_bound_at_step(match_step)
                previous_type_bound = eligible_location_types.get(current_step_location, None)
                if current_type_bound is None:
                    current_type_bound = location_types[current_step_location].name
                    new_coerce_type_block = CoerceType({current_type_bound})
                    new_step = match_step._replace(coerce_type_block=new_coerce_type_block)
                else:
                    # There is a type bound here. We simply ensure that the bound is not conflicting
                    # with any other type bound at a different MATCH step with the same location.
                    _assert_type_bounds_are_not_conflicting(
                        current_type_bound, previous_type_bound, current_step_location, match_query)

                # Record the deduced type bound, so that if we encounter this location again,
                # we ensure that we again infer the same type bound.
                eligible_location_types[current_step_location] = current_type_bound
            else:
                # This function may only be called if there are no preferred locations. Since this
                # location cannot be preferred, and is not eligible, it must be ineligible.
                # No action is necessary in this case.
                pass

            new_traversal.append(new_step)
        new_match_traversals.append(new_traversal)
    return match_query._replace(match_traversals=new_match_traversals)
def _expose_all_eligible_locations ( match_query , location_types , eligible_locations ) : eligible_location_types = dict ( ) new_match_traversals = [ ] for current_traversal in match_query . match_traversals : new_traversal = [ ] for match_step in current_traversal : new_step = match_step current_step_location = match_step . as_block . location if current_step_location in eligible_locations : current_type_bound = _calculate_type_bound_at_step ( match_step ) previous_type_bound = eligible_location_types . get ( current_step_location , None ) if current_type_bound is None : current_type_bound = location_types [ current_step_location ] . name new_coerce_type_block = CoerceType ( { current_type_bound } ) new_step = match_step . _replace ( coerce_type_block = new_coerce_type_block ) else : _assert_type_bounds_are_not_conflicting ( current_type_bound , previous_type_bound , current_step_location , match_query ) eligible_location_types [ current_step_location ] = current_type_bound else : pass new_traversal . append ( new_step ) new_match_traversals . append ( new_traversal ) return match_query . _replace ( match_traversals = new_match_traversals )
Return a MATCH query where all eligible locations are valid as query start locations.