From 7ac472af127efd3341240917c6b5209bc700ede2 Mon Sep 17 00:00:00 2001 From: Jenny Ly <32417800+lycb@users.noreply.github.com> Date: Wed, 27 Aug 2025 18:12:26 -0400 Subject: [PATCH 1/2] [GraphQL] Update GraphQL API rate limit docs to include new hard limits (#57118) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Siara <108543037+SiaraMist@users.noreply.github.com> --- .../using-pagination-in-the-graphql-api.md | 2 +- content/graphql/overview/index.md | 2 +- ...s-and-query-limits-for-the-graphql-api.md} | 261 ++++++++++-------- 3 files changed, 145 insertions(+), 120 deletions(-) rename content/graphql/overview/{rate-limits-and-node-limits-for-the-graphql-api.md => rate-limits-and-query-limits-for-the-graphql-api.md} (89%) diff --git a/content/graphql/guides/using-pagination-in-the-graphql-api.md b/content/graphql/guides/using-pagination-in-the-graphql-api.md index c36b34ea077b..0f726261aa5a 100644 --- a/content/graphql/guides/using-pagination-in-the-graphql-api.md +++ b/content/graphql/guides/using-pagination-in-the-graphql-api.md @@ -46,7 +46,7 @@ In this example, `pageInfo.startCursor` gives the cursor for the first item on t ## Changing the number of items per page -The `first` and `last` arguments control how many items are returned. The maximum number of items you can fetch using the `first` or `last` argument is 100. You may need to request fewer than 100 items if your query touches a lot of data in order to avoid hitting a rate or node limit. For more information, see [AUTOTITLE](/graphql/overview/rate-limits-and-node-limits-for-the-graphql-api). +The `first` and `last` arguments control how many items are returned. The maximum number of items you can fetch using the `first` or `last` argument is 100. You may need to request fewer than 100 items if your query touches a lot of data in order to avoid hitting a rate or node limit. For more information, see [AUTOTITLE](/graphql/overview/rate-limits-and-query-limits-for-the-graphql-api). ## Traversing the data set using pagination diff --git a/content/graphql/overview/index.md b/content/graphql/overview/index.md index 7565e625d3ff..35a7b1e60855 100644 --- a/content/graphql/overview/index.md +++ b/content/graphql/overview/index.md @@ -11,6 +11,6 @@ children: - /breaking-changes - /changelog - /explorer - - /rate-limits-and-node-limits-for-the-graphql-api + - /rate-limits-and-query-limits-for-the-graphql-api --- diff --git a/content/graphql/overview/rate-limits-and-node-limits-for-the-graphql-api.md b/content/graphql/overview/rate-limits-and-query-limits-for-the-graphql-api.md similarity index 89% rename from content/graphql/overview/rate-limits-and-node-limits-for-the-graphql-api.md rename to content/graphql/overview/rate-limits-and-query-limits-for-the-graphql-api.md index 5b75a9b8d401..32fc0f89abe0 100644 --- a/content/graphql/overview/rate-limits-and-node-limits-for-the-graphql-api.md +++ b/content/graphql/overview/rate-limits-and-query-limits-for-the-graphql-api.md @@ -1,10 +1,11 @@ --- -title: Rate limits and node limits for the GraphQL API -shortTitle: Rate and node limits +title: Rate limits and query limits for the GraphQL API +shortTitle: Rate and query limits intro: 'The {% data variables.product.prodname_dotcom %} GraphQL API has limitations in place to protect against excessive or abusive calls to {% data variables.product.prodname_dotcom %}''s servers.' redirect_from: - /v4/guides/resource-limitations - /graphql/overview/resource-limitations + - /graphql/overview/rate-limits-and-node-limits-for-the-graphql-api versions: fpt: '*' ghec: '*' @@ -13,122 +14,6 @@ topics: - API --- -## Node limit - -To pass [schema](/graphql/guides/introduction-to-graphql#schema) validation, all GraphQL API [calls](/graphql/guides/forming-calls-with-graphql) must meet these standards: - -* Clients must supply a `first` or `last` argument on any [connection](/graphql/guides/introduction-to-graphql#connection). -* Values of `first` and `last` must be within 1-100. -* Individual calls cannot request more than 500,000 total [nodes](/graphql/guides/introduction-to-graphql#node). - -### Calculating nodes in a call - -These two examples show how to calculate the total nodes in a call. - -1. Simple query: - -
query {
- viewer {
- repositories(first: 50) {
- edges {
- repository:node {
- name
-
- issues(first: 10) {
- totalCount
- edges {
- node {
- title
- bodyHTML
- }
- }
- }
- }
- }
- }
- }
- }
-
- Calculation:
-
- 50 = 50 repositories - + - 50 x 10 = 500 repository issues - - = 550 total nodes- -1. Complex query: - -
query {
- viewer {
- repositories(first: 50) {
- edges {
- repository:node {
- name
-
- pullRequests(first: 20) {
- edges {
- pullRequest:node {
- title
-
- comments(first: 10) {
- edges {
- comment:node {
- bodyHTML
- }
- }
- }
- }
- }
- }
-
- issues(first: 20) {
- totalCount
- edges {
- issue:node {
- title
- bodyHTML
-
- comments(first: 10) {
- edges {
- comment:node {
- bodyHTML
- }
- }
- }
- }
- }
- }
- }
- }
- }
-
- followers(first: 10) {
- edges {
- follower:node {
- login
- }
- }
- }
- }
- }
-
- Calculation:
-
- 50 = 50 repositories - + - 50 x 20 = 1,000 pullRequests - + - 50 x 20 x 10 = 10,000 pullRequest comments - + - 50 x 20 = 1,000 issues - + - 50 x 20 x 10 = 10,000 issue comments - + - 10 = 10 followers - - = 22,060 total nodes- ## Primary rate limit {% ifversion ghes %} @@ -278,6 +163,126 @@ You should also subscribe to webhook events instead of polling the API for data. You can also stream the audit log in order to view API requests. This can help you troubleshoot integrations that are exceeding the rate limit. For more information, see [AUTOTITLE](/admin/monitoring-activity-in-your-enterprise/reviewing-audit-logs-for-your-enterprise/streaming-the-audit-log-for-your-enterprise). +{% endif %} + +## Node limit + +To pass [schema](/graphql/guides/introduction-to-graphql#schema) validation, all GraphQL API [calls](/graphql/guides/forming-calls-with-graphql) must meet these standards: + +* Clients must supply a `first` or `last` argument on any [connection](/graphql/guides/introduction-to-graphql#connection). +* Values of `first` and `last` must be within 1-100. +* Individual calls cannot request more than 500,000 total [nodes](/graphql/guides/introduction-to-graphql#node). + +### Calculating nodes in a call + +These two examples show how to calculate the total nodes in a call. + +1. Simple query: + +
query {
+ viewer {
+ repositories(first: 50) {
+ edges {
+ repository:node {
+ name
+
+ issues(first: 10) {
+ totalCount
+ edges {
+ node {
+ title
+ bodyHTML
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ Calculation:
+
+ 50 = 50 repositories + + + 50 x 10 = 500 repository issues + + = 550 total nodes+ +1. Complex query: + +
query {
+ viewer {
+ repositories(first: 50) {
+ edges {
+ repository:node {
+ name
+
+ pullRequests(first: 20) {
+ edges {
+ pullRequest:node {
+ title
+
+ comments(first: 10) {
+ edges {
+ comment:node {
+ bodyHTML
+ }
+ }
+ }
+ }
+ }
+ }
+
+ issues(first: 20) {
+ totalCount
+ edges {
+ issue:node {
+ title
+ bodyHTML
+
+ comments(first: 10) {
+ edges {
+ comment:node {
+ bodyHTML
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ followers(first: 10) {
+ edges {
+ follower:node {
+ login
+ }
+ }
+ }
+ }
+ }
+
+ Calculation:
+
+ 50 = 50 repositories + + + 50 x 20 = 1,000 pullRequests + + + 50 x 20 x 10 = 10,000 pullRequest comments + + + 50 x 20 = 1,000 issues + + + 50 x 20 x 10 = 10,000 issue comments + + + 10 = 10 followers + + = 22,060 total nodes+ + {% ifversion not ghes %} + ## Timeouts If {% data variables.product.github %} takes more than 10 seconds to process an API request, {% data variables.product.github %} will terminate the request and you will receive a timeout response and a message reporting that "We couldn't respond to your request in time". @@ -288,4 +293,24 @@ You can check the status of the GraphQL API at [githubstatus.com](https://www.gi If a timeout occurs for any of your API requests, additional points will be deducted from your primary rate limit for the next hour to protect the speed and reliability of the API. +## Other resource limits + +To protect the speed and reliability of the API, {% data variables.product.github %} also enforces other resource limitations. If your GraphQL query consumes too many resources, {% data variables.product.github %} will terminate the request and return partial results along with an error indicating that resource limits were exceeded. + +**Examples of queries that may exceed resource limits:** + +* Requesting thousands of objects or deeply nested relationships in a single query. +* Using large `first` or `last` arguments in multiple connections simultaneously. +* Fetching extensive details for each object, such as all comments, reactions, and related issues for every repository. + {% endif %} + +## Query optimization strategies + +* **Limit the number of objects**: Use smaller values for `first` or `last` arguments and paginate through results. +* **Reduce query depth**: Avoid requesting deeply nested objects unless necessary. +* **Filter results**: Use arguments to filter data and return only what you need. +* **Split large queries**: Break up complex queries into multiple simpler queries. +* **Request only required fields**: Select only the fields you need, rather than requesting all available fields. + +By following these strategies, you can reduce the likelihood of hitting resource limits and improve the performance and reliability of your API requests. From d87dc3324632d96bf8ac3b1ca49e8243fde5dc02 Mon Sep 17 00:00:00 2001 From: Sophie <29382425+sophietheking@users.noreply.github.com> Date: Thu, 28 Aug 2025 00:42:22 +0200 Subject: [PATCH 2/2] Proxima Self-Service Phase 1 (#57248) Co-authored-by: Raymond Tiu