---
title: "Examples & Performance Guidelines"
description: "## Usage Examples ### Complete GraphQL Request (cURL) ```` ```jsx curl -X POST \"https://your-server/graphql\" -H \"X-API-Key: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...\" -H \"Content-Type: application/json\" -d '{ \"query\": \"query GetDocuments($limit: Int, $where: DocumentFilterInput) { production { documents(limit: $limit, where: $where) { id title documentDate customer…"
url: "https://extensionkit.unitfly.com/documentation/grapi-examples-performance-guidelines/"
updated: "2026-01-23"
category: GRAPI Wiki and User Guide
---

# Examples & Performance Guidelines

## Usage Examples

### Complete GraphQL Request (cURL)

````
```jsx
curl -X POST "https://your-server/graphql" 
  -H "X-API-Key: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..." 
  -H "Content-Type: application/json" 
  -d '{
    "query": "query GetDocuments($limit: Int, $where: DocumentFilterInput) {
      production {
        documents(limit: $limit, where: $where) {
          id
          title
          documentDate
          customer {
            title
            customerCode
          }
        }
      }
    }",
    "variables": {
      "limit": 10,
      "where": {
        "isActive": { "eq": true },
        "documentDate": { "gte": "2024-01-01T00:00:00Z" }
      }
    }
  }'
```
````

### JavaScript/TypeScript Example

````
```jsx
const query = `query GetCustomerDocuments($customerId: Int!) {
  production {
    documents(
      where: {
        customer: { id: { eq: $customerId } }
        isActive: { eq: true }
      }
    ) {
      id
      title
      documentDate
      documentType {
        displayValue
      }
      files {
        title
        extension
        logicalSize
      }
    }
  }
}`;
const response = await fetch("https://your-server/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-API-Key": "your-jwt-token",
  },
  body: JSON.stringify({
    query,
    variables: {
      customerId: 123,
    },
  }),
});

const data = await response.json();
```
````

### Python Example

````
```jsx
import requests
import json

query = """
query GetDocumentsByType($documentType: String!) {
  production {
    documents(
      where: {
        documentType: {
          displayValue: { contains: $documentType }
        }
        isActive: { eq: true }
      }
    ) {
      id
      title
      documentDate
      customer {
        title
        customerCode
      }
    }
  }
}
"""

response = requests.post(
    "https://your-server/graphql",
    headers={
        "Content-Type": "application/json",
        "X-API-Key": "your-jwt-token",
    },
    json={
        "query": query,
        "variables": {
            "documentType": "Contract"
        }
    }
)

data = response.json()
```
````

## Performance Guidelines

### Query Optimization Best Practices

1. **Selective Field Querying**: Only request fields you need

```
# Good - specific fields
query GetDocuments {
  production {
    documents {
      id
      title
      documentDate
    }
  }
}
# Avoid - requesting all fields unnecessarily
query GetDocuments {
  production {
    documents {
      id
      title
      description
      documentDate
      customer { ... }
      files { ... }
      # ... many more fields    }
  }
}
```

2. **Efficient Filtering**: Use specific filters to reduce result sets

```
# Good - specific filtering
query GetActiveDocuments {
  production {
    documents(where: {
      isActive: { eq: true }
      documentDate: { gte: "2024-01-01T00:00:00Z" }
    }) {
      id
      title
    }
  }
}
```

3. **Lookup Depth Management**: Be mindful of nested object resolution

```
# Good - limited nesting
query GetDocuments {
  production {
    documents {
      id
      title
      customer {
        title
        customerCode
      }
    }
  }
}
# Avoid - excessive nesting
query GetDocuments {
  production {
    documents {
      customer {
        address {
          country {
            region {
              # Too deep            }
          }
        }
      }
    }
  }
}
```

1.

### Recommended Settings for Common Scenarios

**List View (UI Display):**

```
query DocumentList {
  production {
    documents(limit: 50, where: { isActive: { eq: true } }) {
      id
      title
      documentDate
      customer {
        title
      }
      documentType {
        displayValue
      }
    }
  }
}
```

**Detail View (Single Object):**

```
query DocumentDetail($id: Int!) {
  production {
    document(id: $id) {
      id
      title
      description
      documentDate
      documentNumber
      customer {
        title
        customerCode
        contactPerson {
          title
          email
        }
      }
      files {
        title
        extension
        logicalSize
      }
    }
  }
}
```
