How to jump to a specific date in a cursor based relay paginated connection?

I’ve got a cursor base paginated relay connection which is ordered by a startDatetime timestamp. The query looks like this;

  query UnassignedShiftsQuery($first: Int, $cursor: String) {
    user {
      id
      unassignedShifts(first: $first, after: $cursor) {
        edges {
          __typename
          cursor
          node {
            ...OpenShiftFragment
          }
        }
        pageInfo {
          ...PageInfoFragment
        }
        __typename
      }
    }
  }

  ${OPEN_SHIFT_FRAGMENT}
  ${PAGE_INFO_FRAGMENT}

And the relevant schema in Absinthe:

  connection(node_type: :open_shift, non_null_edges: true, non_null_edge: true) do
    edge do
      field :node, non_null(:open_shift)
    end
  end

  object :user do
    field :id, non_null(:string)
    connection field :unassigned_shifts, node_type: :open_shift, non_null_connection: true do
      resolve(&Resolvers.Shifts.list_shifts/3)
    end
  end

  object :open_shift do
    field :id, non_null(:string)
    field :start_datetime, non_null(:datetime)
  end

And the Shifts resolver;

  def list_shifts(_parent, args, %{context: %{current_user: user}}) do
    Absinthe.Relay.Connection.from_query(
      Shifts.unassigned_shifts(user),
      &get_preloaded_shifts/1,
      args
    )
  end

  defp get_preloaded_shifts(query) do
    query
    |> Repo.all()
    |> Repo.preload([:shift_type])
  end

Where, for the sake of brevity Shifts.unassigned_shifts could be assumed to be;

 def unassigned_shifts(user) do
    from shifts in Backend.Shifts.Shift,
      order_by: shifts.start_datetime,
      where: shifts.user_id == ^user.id
  end

After the the initial query is rendered, the user can select an arbitrary date that they would like to jump to whist remaining in the paginated list. This thing is huge, so they may want to jump to a date and then scroll back and forth from there.

In subsequent queries I can pass that date in the fetchMore query, but how to I apply that in the Absinthe.Relay.Connection.from_query call in the resolver. Simplistically I’m thinking I need to take the date, turn that into a cursor and pass that cursor into the args that from_query takes, but I’m not sure if I’m on the right track or how to go about it.

I’m reasonably new to Elixir so haven’t been able to work this out from reading the Absinthe source so any pointers would be really helpful.

Thanks! :smiley: