413 Request Entity Too Large

Hi,

So it looks like at a certain point you will get a “413 Request Entity Too Large” when using graphQl with a GET request. The URI becomes massive if you have a lot of fragments and in turn slices and eventually you will hit a server limit.

I managed to shave 50% off my URI string by minifying my graphql query strings and stripping out white space etc but i’m worried about the future.

Is there anything that can be done to overcome this?

1 Like

Hey Freddie,

We are aware of this issue and we’re looking in to ways to combat this when we begin working on improvements for the GraphQL, including potentially allowing POST requests and auto-optimising queries.

For the moment what your doing is good practice and breaking up queries by not going to many levels deep can help.

I’ve logged this as a feature request so the team is aware of how you’re facing issue.

It would help to know more about your use case. Can you tell me more about your queries and what you’re building?

Thanks.

Hi Phil,

Thanks for getting back to me and for getting this higher up the priority.

I can divulge a little more about what it is I’m building yes. I’m building a highly custom website for a client. Right now we have a content type called “static page” which is used for the majority of pages. We also have a lot of slices defined in the static page, such as “Hero”, “Contact Form”, “CTA” etc etc. Our slices are meant to be used so that someone with a non-technical background can add sections ( slices ) to any page and in any order. This should be a pretty standard use case of Prismic correct?

In terms of how things actually work we have Laravel taking the URI e.g “about-page” and then combining that string with a .graphqls file. At a certain point, laravel will load the graphql file and replace $uid with the “about-page” from the URI and then ship this off in a GET request by stuffing everything into a new URI string.

 staticpage(uid: "$uid", lang: "en-us") {
    prismic_title
    page_title
    page_description
    body {
      ...Hero
      ...CTA
}}

      $schema = str_replace([
            '$type',
            '$uid',
        ], [
            $type,
            $uid
        ], (file_get_contents(__DIR__ . '/Prismic/' . $schemaFile . '.graphqls')));

        $uri = substr(config('prismic.url'), 0, -7) . '/graphql';

        if ($ref === null) {
            $ref = json_decode((string)$client->get(config('prismic.url'))->getBody())->refs[0]->ref;
        }


        $response = json_decode((string)$client->get($uri, [
            'headers' => ['prismic-ref' => $ref],
            'query' => [
                'query' => ($schema)
            ]])->getBody());

Hope this gives you some insight into how we’re doing things. Above is not the full code but it should demonstrate closely now we are doing things.

Thanks for the extra information Freddie.

This is indeed a standard use case and knowing exactly what your doing and the kind of project structures that are running in to this issue really helps the Dev team to understand the situation better.

I’ve forwarded this to the product team so they can be aware of the situation. If/When they have any update on the situation the will respond to you here.

Thanks.

1 Like