menu button

Optional calls

Move Agenda Item by Id

Move Agenda Item by Id

Use the moveAgendaItemById mutation to reorder agenda items within a protocol by shifting a single item one position up or down.

  • Returns success: false (with the unchanged list) when the item is already at the boundary — it does not throw an error, so callers can distinguish “can’t move” from a real failure.
  • The returned agendaItemList entries are of type MoveAgendaItemResultItemType — see Notes below.

GraphQL Mutation

fragment moveAgendaItemDetails on MoveAgendaItemResultItemType {
  id
  title
  textsegments {
    id
    pos
    speakerObj {
      slug
      givenName
      familyName
      gender
      party
      preTitle
      postTitle
      posShort
      posLong
      specialCase
    }
    textJson {
      text
      startTime
      endTime
    }
  }
}

mutation MoveAgendaItemById($agendaItemId: Int!, $direction: String!) {
  moveAgendaItemById(agendaItemId: $agendaItemId, direction: $direction) {
    success
    agendaItemList {
      ...moveAgendaItemDetails
    }
  }
}

Mutation Variables

{
  "agendaItemId": 42,
  "direction": "up"
}
  • agendaItemId (Int, required) — ID of the agenda item to move.
  • direction (String, required) — "up" or "down".

Example JavaScript Implementation

import axios from "axios";

const MOVE_AGENDA_ITEM_BY_ID = `
  fragment moveAgendaItemDetails on MoveAgendaItemResultItemType {
    id
    title
    textsegments {
      id
      pos
      speakerObj {
        slug
        givenName
        familyName
        gender
        party
        preTitle
        postTitle
        posShort
        posLong
        specialCase
      }
      textJson {
        text
        startTime
        endTime
      }
    }
  }

  mutation MoveAgendaItemById($agendaItemId: Int!, $direction: String!) {
    moveAgendaItemById(agendaItemId: $agendaItemId, direction: $direction) {
      success
      agendaItemList {
        ...moveAgendaItemDetails
      }
    }
  }
`;

export async function moveAgendaItem(agendaItemId, direction) {
  const res = await axios.post(
    "https://api-v2.speechmind.com/external/v2/graphql",
    {
      query: MOVE_AGENDA_ITEM_BY_ID,
      variables: { agendaItemId, direction },
    },
    {
      headers: {
        "Content-Type": "application/json",
        "x-api-key": process.env.SPEECHMIND_API_KEY,
      },
    }
  );

  const { success, agendaItemList } = res.data.data.moveAgendaItemById;

  if (!success) {
    console.warn("Item is already at the boundary — no change made.");
  }

  return { success, agendaItemList };
}

// Example usage
moveAgendaItem(42, "up");
moveAgendaItem(42, "down");

Notes

  • When success is false, agendaItemList still contains the current (unchanged) order — you can use it to sync your UI without a separate getResults call.
  • The returned agendaItemList entries are of type MoveAgendaItemResultItemType, not ApiAgendaItemType. Each entry exposes id, title, and the raw textsegments (with speaker and timing data) rather than the AI-generated textList/texts fields. If you need the full agenda item content after a move, follow up with a getResults call.
  • Moving up pulls the previous item’s last segment in front of the target item.
  • Moving down pushes the target item’s first segment after the next item. If the item is first and moving down, that segment’s agendaItem reference is set to null.
  • The mutation is not reversible in one call — call it again in the opposite direction to undo.

Have questions?

Still have questions? Talk to support.