Missing children in GraphQL response

Hello people from Speckleland!

With GraphQL I am requesting all children() from my commit object, which thus should include all the objects in the model. So far it seemed to work and I never questioned it.

But in one of my cases, the totalCount property says there would be 20380 children, but I actually only receive 19363.

I tried different limits like 90000 or smaller and then using cursors. I also tried different depths (although I already learned to just leave it away). I am always missing the same amount of children. Apparently, I don’t really know what’s missing, but I know that at least a referenced material is missing (that’s how I noticed). If I am querying that material directly, I receive it as expected.

What could be the reasons for that?

Thanks in advance! :pray:

PS: The model is coming from Revit and my query looks like that:

Hey Steffen,

Good catch on this! I’d suggest introducing a depth parameter to the children() query and removing the cursor for now to see if that makes a difference.

  1. Adding depth:

    • Speckle’s GraphQL API has depth-based traversal, meaning some deeply nested objects might not be included unless explicitly requested.
    • While the default depth usually works, setting it explicitly (e.g., depth: 10) can help ensure all expected children are retrieved.
    • You can experiment with different values: 10 or 50 should be more than enough, while something extreme like 10000 might be overkill or even restricted.
    • Indeed reducing depth can aso be desirable in certain circumstancaes as another data payload reduction measure.
  2. Removing cursor:

    • If you’re fetching everything in one go, leaving cursor empty shouldn’t be necessary.
    • We can always bring it back later if pagination turns out to be a desirable feature.

Suggested Query:

    query {
      project(id: "272fd38422") {
        object(
          id: "4a5706505be38d74440ce926050d3501"
        ) {
          id
          speckleType
          children(
            select: [
              "id",
              "name",
              "elementId",
              "applicationId",
              "builtInCategory",
              "category",
              "speckle_type",
              "materialQuantities"
            ],
            depth: 10,
            limit: 21000
          ) {
            totalCount
            objects {
              id
            }
          }
        }
      }
    }
    

Let me know if this helps.

1 Like

Hey Jonathon!

Nice hearing from you! :slight_smile:

Your proposed query has basically been my initial query (inluding no cursor and high limit), except leaving the depth value completely, because of what we discussed here: How to query more than one element in a Revit model - #12 by samberger

In short, the depth seems buggy - especially the depth of 10 :smiling_imp: (in the other post’s project/query, but also in the current project). The 10 results in very, very few results (same problem as in the other post):

Nevertheless, I did experiment with the depth and increased it step by step. In my current case it behaved reasonable, and there is no increase in received elements for depth 7, 8, 9.

:confused:

What else I’ve tried by now:

I wanted to reduce the amount of received elements right from the beginning, to maybe avoid problems with high number of elements. … and just to try something else. Using a query for filtering only elements with a materialQuantities property has been a little tricky (since you haven’t implemented anything for testing null or empty arrays or array lengths), but it seems to work. I made a separate query for receiving all materials, which only returns 32 materials… sadly the missing material still isn’t among them. :frowning:

As I said, I can receive the missing materials if I request it directly, and the material doesn’t really seem to be any different than any other material.

Requesting potentially missing materials seperately (although they still shouldn’t be missing in the first place), might even be “ooo…kaaay”.
But I’m actually even more worried about the other 1000 missing objects, which I won’t be able to notice. :face_with_peeking_eye:

I was thinking, “How can I help Steffen debug this without access to the source material?” depth was first came to mind but if you are saying it has no effect…