Full query:
{
  order(order_id: 234567) {
    order_id
    increment_id
    items [
      item_id
      product_id
      sku
      name
      qty
      voucher_template_id
      voucher_distribution
      voucher_value
      vouchers [
        entity_id
        voucher_id
        voucher_code
        voucher_pin
        valid_to
        created_at
        sent_at
      ]
    ]
  }
}

result: (order not found)
{
  "data": {
    "order": null
  }
}

result: (order have no Retain24 products)
{
  "data": {
    "order": {
      "order_id": 234567,
      "increment_id": "A-234567",
      "items": []
    }
  }
}

result: (order have Retain24 product, no assigned vouchers)
{
  "data": {
    "order": {
      "order_id": 234567,
      "increment_id": "A-234567",
      "items": [
        {
          "item_id": 1234,
          "product_id": 1234,
          "sku": "123456",
          "name": "Product name",
          "qty": 1,
          "voucher_template_id": "bcd234bcd234bcd234",
          "voucher_distribution": 1,
          "voucher_value": 100.0,
          "vouchers": []
        }
      ]
    }
  }
}

result: (order have Retain24 product, with assigned voucher)
{
  "data": {
    "order": {
      "order_id": 234567,
      "increment_id": "A-234567",
      "items": [
        {
          "item_id": 1234,
          "product_id": 1234,
          "sku": "123456",
          "name": "Product name",
          "qty": 1,
          "voucher_template_id": "bcd234bcd234bcd234",
          "voucher_distribution": 1,
          "voucher_value": 100.0,
          "vouchers": [
            {
              "entity_id": 234,
              "voucher_id": "bcd234bcd234bcd234",
              "voucher_code": "ponmlkjihgfedcba",
              "voucher_pin": null,
              "valid_to": "2021-12-31",
              "created_at": "2020-01-01",
              "sent_at": null
            }
          ]
        }
      ]
    }
  }
}

---------------------------------------------------------------------------------

schema {
  query: Query,
}

type Query {
  order(order_id: ID!): Retain24Order
}

type Retain24Order {
  order_id: ID!,
  increment_id: ID!,
  items: [Retain24Item!]!
}

type Retain24Item {
  item_id: Int!,
  product_id: Int!,
  sku: String!,
  name: String,
  voucher_template_id: String!,
  voucher_distribution: Int!,
  voucher_value: Float!,
  vouchers: [Retain24Voucher!]!
}

type Retain24Voucher {
  entity_id: Int!,
  voucher_id: String!,
  voucher_code: String!,
  voucher_pin: String,
  valid_to: Date!,
  created_at: Date!,
  sent_at: Date
}

scalar Date

---------------------------------------------------------------------------------

query: (assign and send all vouchers)
mutation?
{
  action(order_id: 1234, item_id: null, methods: [ASSIGN_VOUCHERS,SEND_VOUCHERS]) {
    order_id
    item_id
    errors {
      method
      message
    }
  }
}

result: (success)
{
  "data": {
    "action": {
      "order_id": 1234,
      "item_id": null,
      "errors": null
    }
  }
}

result: (error)
{
  "data": {
    "action": {
      "order_id": 1234,
      "item_id": null,
      "errors": [
        {
          "method": "ASSIGN_VOUCHERS",
          "message": "Voucher out of stock"
        }
      ]
    }
  }
}

schema?

type Retain24Action {
  order_id: ID!,
  item_id: Int,
  errors: [Retain24Error!]
}

Enum Retain24Method {
  ASSIGN_VOUCHERS,
  SEND_VOUCHERS
}

type Retain24Error {
  method: Retain24Method,
  message: String!
}

---------------------------------------------------------------------------------

Mutation?
{
  retain24(code: "wefwer234525rewseg"
}

type Retain24 {
  code: String!
  isPhone: Boolean!
  pin: String
}


  

        if (array_key_exists("code", $retain24) && $retain24["code"]) {
            $model = Mage::getModel("Crossroads_Retain24/validation")->load($quote->getEntityId());
            $code = trim($retain24["code"]);
            $isPhone = array_key_exists("isPhone", $retain24) ? (bool) $retain24["isPhone"] : false;

            if ($code != $model->getCode() || !$model->getValidationId() ||
                    ($isPhone != $model->getIsPhone()) ||
                    ($isPhone || $model->getRequiresPin()) &&
                    (array_key_exists("pin", $retain24) && $retain24["pin"] !== $model->getPin())) {
                $quote->setRetain24Code($code);
                $quote->setRetain24Pin(array_key_exists("pin", $retain24) ? $retain24["pin"] : null);

                $code_data = $helper->validate($store, $code, $isPhone, array_key_exists("pin", $retain24) ? $retain24["pin"