Request

Response

    Query Complexity and Depth Limits

    The GraphQL API provided by our service has query complexity and depth limits in place to ensure optimal performance and prevent abuse. The query complexity limits define how much data can be requested from the GraphQL API in one request by a client. Query depth limit determines the number of nesting levels of the field. Each field in the query contributes to the overall complexity score and each nested selection contributes to the overall depth score.

    The complexity of a GraphQL query is determined based on several factors like the number of fields requested and custom directives or arguments that affect complexity.

    Complexity limit


    Query complexity limit = 75

    The complexity limit for Manufacturing Data Model GraphQL API is set to 75 fields. The complexity score of a query must not exceed this limit; otherwise, the server will reject the query and return an error message.

    The following code block describes the query and error response when the complexity limit is surpassed.

    Query

    query GetModel($modelId: ID!) {
            model(modelId: $modelId) {
                id
                name {
                    value
                }
                designItem{
                    id
                    name
                    extensionType
                }
                thumbnail {
                    status
                    signedUrl
                }
                component {
                   id
                   name {
                       value
                   }
                   partNumber {
                       value
                   }
                   description {
                       value
                   }
                   primaryModel{
                       name{
                           value
                           displayValue
                           definition{
                               applicableEntityTypes
                               collection{
                                   definitions{
                                       results{
                                           description
                                           isArchived
                                           isReadOnly
                                           isSearchable
                                           name
                                           propertyBehavior
                                           shouldCopy
                                           shouldDisplayInSummary
                                           specification
                                           units{
                                               id
                                               name
                                           }
                                       }
                                   }
                               }
                              internalSearchId
                           }
                           definition{
                              localizedName
                           }
                       }
                       component{
                          allProperties{
                            results{
                                name
                                value
                            }
                          }
                       baseProperties{
                          results{
                             definition{
                                collection{
                                   description
                                   id
                                   name
                                 }
                             }
                          }
                       }
                       bomRelations{
                          results{
                             id
                             quantity
                             sequenceNumber
                             toComponent{
                                hasChildren
                                hub{
                                   allPropertyDefinitionCollections{
                                      results{
                                         description
                                      }
                                   }
                                }
                             }
                          }
                       }
                    }
                    isConfiguration
                    isPrimary
                    isTip
                    timestamp
                    version{
                        createdBy{
                            createdOn
                        }
                        status
                        timestamp
                    }
                    history{
                        results{
                            author{
                                createdOn
                                email
                                firstName
                                lastModifiedOn
                                lastName
                                userName
                            }
                        }
                    }
                }
            }
        }
    }
    
    Show More

    Error Response

    {
        "errors": [
            {
                "message": "Current query complexity of 76 exceeds the limit of 75. Try reducing the number of fields in the query.",
                "extensions": {
                    "classification": "ExecutionAborted"
                }
            }
        ]
    }
    
    Show More

    Depth limit


    Query depth limit = 20

    The depth limit for Manufacturing Data Model GraphQL API is set to 20 nesting levels. The depth score of a query must not exceed this limit; otherwise, the server will reject the query and return an error message.

    The following code block describes the query and error response when the depth limit is surpassed.

    Query

    query GetModel($modelId: ID!) {
        model (modelId: $modelId) {
            id
            name{
                value
            }
            assemblyRelations{
                results{
                    fromModel{
                        id
                        assemblyRelations{
                            results{
                                fromModel{
                                    id
                                    assemblyRelations{
                                        results{
                                            fromModel{
                                                id
                                                assemblyRelations{
                                                    results{
                                                        fromModel{
                                                            id
                                                            assemblyRelations{
                                                                results{
                                                                    fromModel{
                                                                        id
                                                                        assemblyRelations{
                                                                            results{
                                                                                fromModel{
                                                                                    id
                                                                                    assemblyRelations{
                                                                                        results{
                                                                                            fromModel{
                                                                                                id
                                                                                                assemblyRelations{
                                                                                                    results{
                                                                                                        fromModel{
                                                                                                            id
                                                                                                            assemblyRelations{
                                                                                                                results{
                                                                                                                    fromModel{
                                                                                                                        id
                                                                                                                        assemblyRelations{
                                                                                                                            results{
                                                                                                                                fromModel{
                                                                                                                                    id
                                                                                                                                    assemblyRelations{
                                                                                                                                        results{
                                                                                                                                            fromModel{
                                                                                                                                                id
                                                                                                                                            }
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    toModel{
                        id
                    }
                }
            }
        }
    }
    
    Show More

    Error Response

    {
        "data": null,
        "errors": [
            {
                "message": "maximum query depth exceeded 35 > 20. Try reducing the depth of your query.",
                "path": [],
                "extensions": {
                    "classification": "ExecutionAborted",
                    "errorType": "BAD_REQUEST",
                    "service": "mfgdm-core"
                }
            }
        ],
        "extensions": {
            "pointValue": {
                "requestedQueryPointValue": 83
            }
        }
    }
    
    Show More

    Note: It is essential to optimize your queries to stay within the complexity and depth limits for optimal performance and better user experience.

    Recommendations for optimization

    To optimize your queries and keep them within the complexity limits, consider implementing the following best practices:

    1. Selective Field Selection: Request only those fields that you need to minimize unnecessary data retrieval.
    2. Pagination: Implement pagination techniques, such as limit-offset or cursor-based pagination, to retrieve smaller subsets of data instead of fetching all results in a single query.
    3. Query Splitting: Split larger complex queries into smaller chunks to receive a more responsive experience.

    Testing and debugging

    During development and testing, it is essential to verify the complexity and depth of your queries. You can use the data explorer tool to test your queries and identify and address any potential complexity or depth issues.