Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-30211

Optimize GraphQL data loading

    XMLWordPrintable

Details

    • Icon: Story Story
    • Resolution: Fixed
    • Icon: High High
    • 2.5.0
    • 2.5.0-beta1
    • Platform > GraphQL
    • None

    Description

      Optimize loading of data in the GraphQL API to avoid multiple loadings of the same item.

      Summary of data loading

      For the following query:

      {
        content {
          blogPosts {
            title
            body { html5 }
          }
        }
      }
      

      data loading goes that way:

      • the blog post content items are loaded using `ContentService::findContentInfo()`
      • for each requested field (title, body), the content item is loaded using contentService::loadContent(), and the field's value is returned.

      This results in an n*m complexity, with n the number of content items and m the number of requested fields.

      Options

      In-memory caching

      Add a data-loader layer that is always used to load items, and have it cache each loaded item in memory, and return that item when it gets loaded.

      Pro
      • Generalizing a data-loader matches the GraphQL server implementation standards
      Cons
      • It adds an extra layer

      Load content instead of content info

      If instead of findContentInfo() we use findContent(), the underlying fields would receive the full `Content` item, and wouldn't have to fetch it again.

      Pros
      • doesn't require an extra layer
      Cons
      • doesn't separate the data loading logic from the resolvers
      • might not always be applicable as it is limited to loading content (content type already has its own in-memory cache)

      Attachments

        Activity

          People

            Unassigned Unassigned
            bertrand.dunogier@ibexa.co Bertrand Dunogier
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: