Was this helpful?

Reordering locations

Often, a user may wish to reorder the itinerary to suit their preferences. Using the moveItineraryItem operation, you can position a location to the location of your preference.

Prerequisitcs

  • You'll need an itinerary you want to add to and locate the Itinerary ID

  • The itinerary will need to be unassigned to a profile, or you'll need your private API Key

Moving to before/after another location

You can also contextualise the position of the location against another location via positionBeforeSibling or positionAfterSibling.

1# Move an itinerary location to a relative position to another item in the
2# itinerary. You can leverage a query like this allowing the user to drag the
3# location to a position after another element, or specify it to be the first
4# in a collection by switching the position to positionAtStart.
5
6mutation MoveItineraryLocation {
7  # Use the moveItineraryItem operation to moving around locations
8  moveItineraryItem(
9    # Supply your itinerary item (or location)
10    id: "itinerary/ABC123/item/DEF456"
11    # Determine the strategy to position the element
12    # Also includes options: positionAtEnd, position<After/Before>Sibling,
13    # positionAtStart, positionOnLastCollection etc
14    positionAfterSibling: { siblingId: "itinerary/ABC123/item/SIBLING" }
15  ) {
16    # Query back the affected items if necessary. Useful for determining any
17    # changes to directions if you are locally caching them
18    cascaded {
19      created {
20        id
21        __typename
22      }
23      updated {
24        id
25        __typename
26      }
27      deletedIds
28    }
29  }
30}

Sandbox: Configure | Try Operation

Moving to Start/End of list

A simple example can leverage the use of positionAtStart or positionAtEnd.

1# Reorder/move the itinerary location to the start of the sequence. Useful
2# depending on the way you reorder you drag-drop functionality. You can also
3# position using relative positional references, such as positionBeforeSibling
4# or positionAfterSibling if easier. If you are using multi-segment collections
5# you can optionally define using parentId property
6
7mutation MoveItineraryLocationToStartPosition {
8  # Use the moveItineraryItem operation to moving around locations
9  moveItineraryItem(
10    # Supply your itinerary item (or location)
11    id: "itinerary/ABC123"
12    # Determine the strategy to position the element
13    # Also includes options: positionAtEnd, position<After/Before>Sibling, etc
14    positionAtStart: {}
15  ) {
16    # Query back the affected items if necessary. Useful for determining any
17    # changes to directions if you are locally caching them
18    cascaded {
19      created {
20        id
21        __typename
22      }
23      updated {
24        id
25        __typename
26      }
27      deletedIds
28    }
29  }
30}

Sandbox: Configure | Try Operation

alpaca.tech

Copyright © 2024 - Made with love ❤️ in Australia.