Searching and Filtering

Learn how to effectively search and filter data in the Duro API using our powerful filtering system.

Basic Query Structure

All component searches use this base query structure:

query FilterBOMComponents($filter: ComponentFilter) {
  componentSearch(filter: $filter) {
    nodes {
      id
      name
      status
    }
  }
}

Query Parameters

Our GraphQL API supports various filtering options:

query {
  components(
    first: 10
    filter: {
      status: ACTIVE
      partNumber: { contains: "ABC" }
      createdAt: { gte: "2024-01-01" }
    }
  ) {
    edges {
      node {
        id
        name
        partNumber
      }
    }
  }
}

Available Filters

  • Text matching (contains, startsWith, endsWith)

  • Numeric comparisons (eq, gt, lt, gte, lte)

  • Date ranges

  • Enum values

  • Boolean flags

Sorting Results

query {
  components(
    first: 10
    orderBy: { field: CREATED_AT, direction: DESC }
  ) {
    edges {
      node {
        id
        name
        createdAt
      }
    }
  }
}

Pagination

We use cursor-based pagination for optimal performance:

query {
  components(
    first: 10
    after: "cursor_value"
  ) {
    pageInfo {
      hasNextPage
      endCursor
    }
    edges {
      cursor
      node {
        id
      }
    }
  }
}

Filter Operators

The filtering system supports these operators:

  • eq: Exact match

  • in: Match any value in an array

  • contains: String contains

  • gte/lte: Greater/Less than or equal

  • isNull: Check for null values

  • notIn: Exclude values in array

Common Search Patterns

1. Manufacturer and Status Filter

Find components by manufacturer and status:

{
  "filter": {
    "and": [
      {
        "status": {
          "eq": "Prototype"
        }
      },
      {
        "manufacturer": {
          "name": {
            "in": ["Texas Instruments", "Analog Devices"]
          }
        }
      }
    ]
  }
}

2. Date Range and Part Number Filter

Search by CPN and creation date:

{
  "filter": {
    "and": [
      {
        "cpn": {
          "in": ["CPN-001", "CPN-002", "CPN-003"]
        }
      },
      {
        "createdAt": {
          "gte": "2023-01-01",
          "lte": "2023-12-31"
        }
      }
    ]
  }
}

Find components by category and name pattern:

{
  "filter": {
    "and": [
      {
        "name": {
          "contains": "47uH"
        }
      },
      {
        "category": {
          "name": {
            "eq": "Capacitor"
          }
        }
      },
      {
        "isModified": {
          "eq": true
        }
      }
    ]
  }
}

Advanced Filtering

The API supports complex logical combinations using and and or operators. Here's an advanced example:

{
  "filter": {
    "or": [
      {
        "and": [
          {
            "status": {
              "eq": "Design"
            }
          },
          {
            "procurement": {
              "type": {
                "in": ["MAKE", "BUY"]
              }
            }
          }
        ]
      },
      {
        "and": [
          {
            "isFavorited": {
              "eq": true
            }
          },
          {
            "revision": {
              "gte": "B"
            }
          }
        ]
      }
    ],
    "and": [
      {
        "mpn": {
          "isNull": false
        }
      },
      {
        "category": {
          "name": {
            "notIn": ["Top Level Assembly"]
          }
        }
      }
    ]
  }
}

This complex filter demonstrates:

  • Nested logical operators

  • Multiple condition groups

  • Mixed filter types

  • Exclusion conditions

Best Practices

  1. Start with simple filters and add complexity as needed

  2. Use appropriate operators for better performance

  3. Consider pagination for large result sets

  4. Test complex filters with smaller data sets first

Complex filters can impact query performance. Consider breaking down complex searches into simpler queries if possible.

Next Steps

Learn about managing access with Datarooms & RBAC to control who can perform these searches.

Last updated