department-of-veterans-affairs / va.gov-cms

Editor-centered management for Veteran-centered content.
https://prod.cms.va.gov
GNU General Public License v2.0
96 stars 70 forks source link

Make links in fetched paragraphs show the path #6725

Closed swirtSJW closed 2 years ago

swirtSJW commented 2 years ago

Description

As a front end engineer I need the path of a link field to be returned in fetched content rather than the internal uri so that I can build links accordingly. Related discussion: https://dsva.slack.com/archives/C0FQSS30V/p1634656192322600 GraphQL on a link field returns

"fieldLink": {
  "url": {
      "path": "/health-care/after-you-apply"
    },
  "title": "After you apply for VA health care benefits",
   "options": []
}

But when drupal returned the fetched data it looks like

"fieldLink": [
   {
    "uri": "entity:node/703",
    "title": "VA health care copay rates",
    "options": []
  }.
]

Concerns: The alias lookups should be as performant as possible.

Acceptance Criteria

CMS Team

Please leave only the team that will do this work selected. If you're not sure, it's fine to leave both selected.

swirtSJW commented 2 years ago

Testing location for current data https://master-nwlghnqkwe3ftxcgy830jkfejcxjswak.demo.cms.va.gov/graphql/explorer sample query:

fragment registerForCareFragment on NodeVamcSystemRegisterForCare {
  title
  status
  changed
  entityBundle
  entityUrl {
    path
  }
  fieldCcTopOfPageContent {
    fetched
    fetchedBundle
  }
  fieldCcRelatedLinks {
    fetched
    fetchedBundle
  }
  fieldCcBottomOfPageContent {
    fetched
    fetchedBundle
  }
  fieldOffice {
    entity {
      ... on NodeHealthCareRegionPage {
        entityLabel
        title
      }
    }
  }
}
{
  nodeQuery(limit: 500, filter: {conditions: [{field: "type", value: ["vamc_system_register_for_care"]}]}) {
    entities {
      ...registerForCareFragment
    }
  }
}
swirtSJW commented 2 years ago

Patch submitted to the Drupal.org issue and released. https://www.drupal.org/project/entity_field_fetch/releases/1.0.0

When it lands on prod it will make the data look like

{
                  "entity": {
                    "targetId": "77158",
                    "targetRevisionId": "393056",
                    "entityType": "paragraph",
                    "entityBundle": "link_teaser",
                    "pid": "77158",
                    "label": "VAMC System - \"Register for care\" page content > Content > Link teasers",
                    "status": true,
                    "langcode": "en",
                    "fieldLink": [
                      {
                        "uri": "entity:node/709",
                        "title": "Change your address on file with VA",
                        "options": [],
                        "url": {
                          "path": "/change-address"
                        }
                      }
                    ],
                    "fieldLinkSummary": [
                      {
                        "value": "Update your address and other information in your VA.gov profile. This will update your information across several VA benefits and services."
                      }
                    ]
                  }