Fluent Commerce Logo
Docs
Sign In

GraphQL Query Limits

Essential knowledge

Author:

Fluent Commerce staff

Changed on:

6 Nov 2023

Overview

The following guidelines and specifications apply to the entire schema, with any exceptions documented in the schema of the relevant entity.

Key points

  • Data query general guidelines
  • Data retrieval rules and Query Complexity Calculation Algorithm
  • Complex query examples

General guidelines

The request size is limited to

`2MB`
. Requests over
`2MB`
will return
`HTTP 413 Request Entity Too Large`
response.

The number of attributes is not limited; however, it is important to note that storing many attributes is not considered best practice. While the underlying storage capacity of JSON allows for up to 255MB to be allocated, it is recommended to avoid excessive attributes as they can adversely impact performance and potentially result in errors.

Wherever there's no specific 

`maxLength`
 of a String defined, 255 characters is the default.

There's no hard-coded validation on any of the GraphQL fields (except for 

`enums`
). For example, these include (not a comprehensive list):

  • OrderItemStatus
  • FulfilmentItemStatus
  • CardType
  • LocationType

Data retrieval

A key benefit of GraphQL is that users can send a single request to retrieve data from various sources.

While this is great for developer experience, it does add additional load on the server when an advanced GraphQL query could potentially create tens of thousands of queries to be executed by the backend. Fluent Commerce have therefore added query complexity checks to the GraphQL API. These checks ensure the API remains stable and maintains speed and efficiency.

GraphQL Query Complexity

For each GraphQL query, the platform calculates the complexity of the query based on the number of possible database operations. If the complexity is high, the platform will block the request and advise the user to query again with a lower complexity query. This prevents the server from attempting to execute superfluous requests that will most likely time out.

  • Clients can supply a first or last argument on any connection. If the first and last are not provided, the default argument is the first 10.
  • Values of first and last should be within 1 - 5,000. If the first or last is greater than 5,000, it will be reset to 5,000. This means that the page size limit has been increased from 100 to 5000.
  • Individual requests with a complexity more than 11,111 will result in error code C10001E being displayed.

Query Complexity Calculation Algorithm

Simple Query
1{
2 orders (first: 10) {
3  edges {
4   node {
5    id
6     ref
7      status
8      type
9      items (first: 20) {
10       edges {
11        node {
12         quantity
13        }
14       }
15      }
16     }
17    }
18   }
19  }
20 }
21}

Language: graphqlschema

Name: Simple Query Example

Description:

[Warning: empty required content area]
Complexity Calculation

1 = 1 query for orders

+

1 * 10 = 10 queries for order items

= 11 total queries

Complex Query
1{
2    orders(first:10) {
3     edges {
4      node {
5       id
6       fulfilmentChoice {
7        id
8       }
9       items (first: 20) {
10        edges {
11         node {
12          quantity
13         }
14        }
15       }
16       fulfilments(first: 30) {
17        edges {
18         node {
19          id
20          items(first: 40) {
21            edges {
22             node {
23              id
24              orderItem {
25                id
26              }
27             }
28            }
29           }
30          }
31         }
32        }
33       }
34      }
35     }
36    }

Language: graphqlschema

Name: Complex Query Example

Description:

[Warning: empty required content area]
Complexity Calculation

1 = 1 query for orders

+

1 * 10 = 10 queries for fulfilment choice

1 * 10 = 10 queries for order items

1 * 10 = 10 queries for fulfilment's

1 * 10 * 30 = 300 queries for fulfilment items

1 * 10 * 30 * 40 = 12,000 queries for order items of fulfilment items

+

1 = 1 query for locations

= 12,332 total queries

Complex query examples

What could queries within 11,111 complexity do?

Example 1 

Description: Get 5000 records in a single request

Total Complexity: 10,001

1{
2 orders(first: 5000) {
3  edges {
4   node {
5    id
6    items {
7      edges {
8        node {
9          id
10        }
11      }
12    }
13    fufilments {
14      edges {
15        node {
16          id
17        }
18       }
19      }
20     }
21    }
22  }
23}

Language: graphqlschema

Name: GraphQL Query Example

Description:

[Warning: empty required content area]
Example 2 

Description: Query with 5 level deep nesting

Total Complexity: 11,111

1{
2 orders(first: 10) {
3  edges {
4   node {
5    id
6    fulfilments {
7      edges {
8        node {
9          id
10          articles {
11            edges {
12              node {
13                id
14                consignmentArticles {
15                  edges {
16                    node {
17                      article {
18                        id
19                       }
20                      }
21                     }
22                    }
23                  }
24                }
25              }
26            }
27          }
28        }
29      }
30    }
31  }
32}

Language: graphqlschema

Name: GraphQL Query Example

Description:

[Warning: empty required content area]
Example 3

Description: Retrieve details of an entity

Total Complexity: 1,324

1{
2    orderById(id: 1) {
3      id
4      fulfilmentChoice {
5        id
6    }
7      items {
8        edges {
9          node {
10           id
11          }
12        }
13      }
14      fulfilments {
15        edges {
16          node {
17            id
18            items {
19              edges {
20                node {
21                  id
22                  orderItem {
23                    id
24                  }
25                }
26              }
27            }
28            articles {
29                edges {
30                  node {
31                    id
32                    items {
33                     edges {
34                        node {
35                          id
36                        }
37                    }
38                 }
39                 consignmentArticles {
40                    edges {
41                        node {
42                         article {
43                            id
44                          }
45                        }
46                      }
47                    }
48                  }
49                }
50              }
51            }
52          }
53        }
54     }
55  }

Language: graphqlschema

Name: GraphQL Query Example

Description:

[Warning: empty required content area]
Fluent Commerce staff

Fluent Commerce staff

Copyright © 2024 Fluent Retail Pty Ltd (trading as Fluent Commerce). All rights reserved. No materials on this docs.fluentcommerce.com site may be used in any way and/or for any purpose without prior written authorisation from Fluent Commerce. Current customers and partners shall use these materials strictly in accordance with the terms and conditions of their written agreements with Fluent Commerce or its affiliates.

Fluent Logo