fragment OrderFields on Order {
  id
  market {
    id
  }
  type
  side
  size
  status
  rejectionReason
  price
  timeInForce
  remaining
  expiresAt
  createdAt
  updatedAt
  liquidityProvision {
    __typename
  }
  peggedOrder {
    __typename
  }
}

query OrderById($orderId: ID!) {
  orderByID(id: $orderId) {
    ...OrderFields
  }
}

query Orders(
  $partyId: ID!
  $pagination: Pagination
  $dateRange: DateRange
  $filter: OrderFilter
  $marketId: ID
) {
  party(id: $partyId) {
    id
    ordersConnection(
      pagination: $pagination
      dateRange: $dateRange
      filter: $filter
      marketId: $marketId
    ) {
      edges {
        node {
          ...OrderFields
        }
        cursor
      }
      pageInfo {
        startCursor
        endCursor
        hasNextPage
        hasPreviousPage
      }
    }
  }
}

fragment OrderUpdateFields on OrderUpdate {
  id
  marketId
  type
  side
  size
  status
  rejectionReason
  price
  timeInForce
  remaining
  expiresAt
  createdAt
  updatedAt
  liquidityProvisionId
  peggedOrder {
    __typename
  }
}

subscription OrdersUpdate($partyId: ID!, $marketId: ID) {
  orders(partyId: $partyId, marketId: $marketId) {
    ...OrderUpdateFields
  }
}
