# GraphQL API에 대한 속도 제한 및 쿼리 제한

GitHub GraphQL API에는 GitHub의 서버에 대한 과도하거나 남용적인 호출을 방지하기 위한 제한이 적용되어 있습니다.

## 주요 속도 제한

속도 제한은 기본적으로 GitHub Enterprise Server에 대해 비활성화되어 있습니다. 인스턴스에 대한 트래픽률 제한을 확인하려면 사이트 관리자에게 문의하세요.

사이트 관리자는 인스턴스에 대한 트래픽률 제한을 설정할 수 있습니다. 자세한 내용은 [속도 제한 구성](/ko/enterprise-server@3.22/admin/configuring-settings/configuring-user-applications-for-your-enterprise/configuring-rate-limits)을(를) 참조하세요.

인스턴스 외부의 사용자 또는 조직에 대한 앱을 개발하는 경우 표준 GitHub 속도 제한이 적용됩니다. 자세한 내용은 설명서의 [GraphQL API에 대한 속도 제한 및 쿼리 제한](/ko/graphql/overview/rate-limits-and-query-limits-for-the-graphql-api) 을 GitHub Free 참조하세요.

## 노드 제한

[schema](/ko/enterprise-server@3.22/graphql/guides/introduction-to-graphql#schema) 유효성 검사를 통과하려면 모든 GraphQL API [calls](/ko/enterprise-server@3.22/graphql/guides/forming-calls-with-graphql)은 다음 표준을 충족해야 합니다.

* 클라이언트는 `first` 또는 `last` 인수를 임의의 [connection](/ko/enterprise-server@3.22/graphql/guides/introduction-to-graphql#connection)에 제공해야 합니다.
* `first` 및 `last`의 값은 1\~100 이내여야 합니다.
* 개별 호출은 총 500,000개 이상의 [nodes](/ko/enterprise-server@3.22/graphql/guides/introduction-to-graphql#node) 요청할 수 없습니다.

### 호출에서 노드 계산

이 두 예제에서는 호출에서 총 노드를 계산하는 방법을 보여 줍니다.

1. 단순 쿼리:

   <pre>query {
     viewer {
       repositories(first: <span class="redbox">50</span>) {

edges {
repository:node {
name

issues(first: <span class="greenbox">10</span>) {
totalCount
edges {
node {
title
bodyHTML
}
}
}
}
}
}
}
}</pre>

계산:

   <pre><span class="redbox">50</span>         = 50 repositories
    +
   <span class="redbox">50</span> x <span class="greenbox">10</span>  = 500 repository issues

= 550 total nodes</pre>

1. 복합 쿼리:

   <pre>query {
     viewer {
       repositories(first: <span class="redbox">50</span>) {

edges {
repository:node {
name

pullRequests(first: <span class="greenbox">20</span>) {
edges {
pullRequest:node {
title

comments(first: <span class="bluebox">10</span>) {
edges {
comment:node {
bodyHTML
}
}
}
}
}
}

issues(first: <span class="greenbox">20</span>) {
totalCount
edges {
issue:node {
title
bodyHTML

comments(first: <span class="bluebox">10</span>) {
edges {
comment:node {
bodyHTML
}
}
}
}
}
}
}
}
}

```
   followers(first: <span class="bluebox">10</span>) {
```

edges {
follower:node {
login
}
}
}
}
}</code></pre>

계산:

   <pre><span class="redbox">50</span>              = 50 repositories
    +
   <span class="redbox">50</span> x <span class="greenbox">20</span>       = 1,000 pullRequests
    +
   <span class="redbox">50</span> x <span class="greenbox">20</span> x <span class="bluebox">10</span> = 10,000 pullRequest comments
    +
   <span class="redbox">50</span> x <span class="greenbox">20</span>       = 1,000 issues
    +
   <span class="redbox">50</span> x <span class="greenbox">20</span> x <span class="bluebox">10</span> = 10,000 issue comments
    +
   <span class="bluebox">10</span>              = 10 followers

= 22,060 total nodes</pre>

## 쿼리 최적화 전략

* **개체 수 제한**: `first` 또는 `last` 인수에 더 작은 값을 설정하고, 페이지 나누기를 통해 결과를 처리하도록 하십시오.
* **쿼리 깊이 줄이기**: 필요한 경우가 아니면 깊게 중첩된 개체 요청 피하기
* **결과 필터링**: 인수를 사용하여 데이터를 필터링하고 필요한 항목만 반환
* **대규모 쿼리 분할**: 복잡한 쿼리를 여러 개의 더 단순한 쿼리로 분할
* **필요한 필드만 요청**: 사용 가능한 모든 필드를 요청하는 대신 필요한 필드만 선택

이러한 전략을 따르면 리소스 제한에 도달할 가능성을 줄이고, API 요청의 성능과 안정성을 향상시킬 수 있습니다.