Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add contentForLanguage resolver for nav item content #4913

Merged

Conversation

dancastellon
Copy link
Contributor

Resolves #4912
Impact: minor
Type: bugfix

Issue

The NavigationItemData.content resolver currently filters down the content array by the language argument provided to the navigationTreeById GraphQL query. Instead, it should return the array without filtering for the operator UI, and have a separate resolver that storefront can use to load the translated content string.

Solution

This PR removes the filtering from the content resolver and adds a contentForLanguage resolver that returns the content string in the correct language. If a translation for that language is not available, it defaults to the first content provided.

Breaking changes

None

Testing

  1. Edit a navigation item in the database. Under draftData and data, add a translation to the array:
{
  "language" : "es",
  "value" : "Camisas"
}
  1. Run this query in Graphiql:
{
  primaryShop {
    defaultNavigationTree(language: "es") {
      items {
        navigationItem {
          data {
          	content {
              value
            }
            contentForLanguage
            classNames
            url
            isUrlRelative
            shouldOpenInNewWindow
        	}
          draftData {
          	content {
              value
            }
            contentForLanguage
            classNames
            url
            isUrlRelative
            shouldOpenInNewWindow
        	}
        }
      }
    }
  }
}
  1. Confirm contentForLanguage returns the Spanish content.

Copy link
Member

@kieckhafer kieckhafer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 This provides the translation (if available), or the default english if no translation is available, on the contentForLangauage prop.

The failing test is a timeout issue that we've seen across other branches, and shouldn't block this particular PR.

@kieckhafer kieckhafer merged commit afd3a79 into develop Jan 10, 2019
@kieckhafer kieckhafer deleted the fix-4912-dancastellon-contentForLanguage-nav-item-resolver branch January 10, 2019 21:10
@spencern spencern mentioned this pull request Jan 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants