Optimise GraphQuery hitting limit

Moving this post here:

Hey @daf ,

When you say "Which then results in a long GraphQuery file" do you mean you're hitting the 2048 character limit in the query URL?

If so from your example I don't have any other suggestions than removing the whitespace. I think the best course of action is splitting the query up like you suggested and making multiple queries.

Thanks Phil,

I think removing whitespaces ended up being sufficient in the end.

When eventually moving to GraphQL, it will definitely need a larger refactor in how I return queries and structure the data. Though when I come to it, I'll solve that issue.

1 Like

Great, let me know how that goes. :slight_smile:

For future readers, here are some optimisation tips:

For Slices you grab all the info like:

{
  blog {
    body {
      ...on text_block {
        non-repeat {
          ...non-repeatFields
        }
      }
      ...on image_gallery {
        non-repeat {
          ...non-repeatFields
        }
        repeat {
          ...repeatFields
        }
      }
    }
  }
}

We explain that in more detail here:

For removing the whitespace you'll still need the new lines, so it will work like your example here:

{
blog{
body{
...ontext_block{
non-repeat{
...non-repeatFields
}
}
...onimage_gallery{
non-repeat{
...non-repeatFields
}
repeat{
...repeatFields
}
}
}
}
}

You can use this tool to do it for you:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.