Skip to content

Feat: a way to avoid certain references #25

Description

@Leksat

Problem/Motivation

I was experimenting with Drupal. In most cases the toolkit was just working, which is super cool. Thanks for the great work!

Now I met the first issue when tried to add content translation support. In Drupal, content translations aren't separate entities, they don't have own IDs, just language codes differ. The idea was to fetch all translations of a Drupal entity into a single Gatsby node. However, in Drupal schema, a content entity and it's translations have the same GraphQL type.

Probably better to explain with screenshots :)

Here is my original fragment:
Screenshot_2021-01-14_at_17_21_28

Both entities and entityTranslations fields have [NodeArticle] type. The toolkit's sees the entityTranslations type and replaces the original fields with a reference. This leads to two things:

  1. entityTranslations field's sub-fields are moved to entities field.
  2. Content translations are fetched with separate NODE_ queries. Drupal serve all of them in the default language.

Screenshot_2021-01-14_at_17_18_29

Proposed resolution

Add something like @noReference directive:

fragment NodeArticle on NodeArticle {
  entityId
  entityTranslations @noReference {
    entityLabel
    body {
      summaryProcessed
      processed
    }
    fieldTags {
      entity {
        ...TaxonomyTermTags
      }
    }
    fieldImage {
      entity {
        ...MediaImage
      }
    }
  }
}

Does this proposal sound good?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions