Problem with GraphQL Query Size Limit

Good afternoon. There was a problem with the Graphql file size limit (almost reached 8 Kb). The project stack is as follows:

  • Next JS
  • graphql-codegen
  • graphql-request (to create a network request and receive a response)

I haven’t fully figured out the project yet (newbie on the project), so maybe I’ll be inaccurate somewhere. The working scheme is as follows. In the pagebypath.query.graphql file describes all possible content models created in Contentful (Navigation, Footer, List of products, Sidebar, etc.). The manager on Contentful creates new content, a Page, and fills it with all available models. All this is displayed on the page.

The problem is that the graphql file contains all the models that are available in Contentful. But not all of them are on a particular page. As a result, there are extra models there. But this file is static, generated using graphql-codegen. And I can’t figure out how to dynamically compose a query so that it contains only those fields (models) that are on a particular page.

Is there any way to solve the problem