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

Content Relationship and Multi-languages: Wrong type for custom types #86

Closed
maersu opened this issue Apr 5, 2019 · 6 comments
Closed

Comments

@maersu
Copy link

maersu commented Apr 5, 2019

Setup:

  • "prismic-javascript": "^1.1.5",
  • Two custom types (home_page and tip). tip is used in a slice of home_page
  • Master language is de-ch and a 2nd language fr-ch

If I query the master language the custom types in slice.items is correct ("type": "tip",)

JS:

  const client = await Prismic.api(`https://${repositoryName}.prismic.io/api/v2`, { accessToken })
  const response = await client.query("", {lang: "de-ch"})

Result

{
  "id": "XKXobhAAAJmVNCNu",
  "type": "home_page",
  "lang": "de-ch",
  "data": {
     ...
    "body": [
      {
        "slice_type": "content",
        "items": [
          {
            "tip": {
              "id": "XKbxCxMAACIAP_bb",
              "type": "tip",
              "lang": "de-ch"
            }
          }
        ]
      }
    ]
  }
}

But when I query a non-master language I get "type": "home_page", as type for the custom type

JS:

  const client = await Prismic.api(`https://${repositoryName}.prismic.io/api/v2`, { accessToken })
  const response = await client.query("", {lang: "fr-ch"})

Result

    {
      "id": "XKXzwxAAAByKNFXn",
      "type": "home_page",
      "lang": "fr-ch",
      "data": {
       ...
        "body": [
          {
            "slice_type": "content",
            "slice_label": null,
            "items": [
              {
                "tip": {
                  "type": "home_page",
                  "lang": "fr-ch",
                 }
              }
            ]}
        ]
      }
    },

Any idea why?

Thanks!

@maersu
Copy link
Author

maersu commented Apr 5, 2019

Actually it looks like its a general problem of the REST API and multi-languages. I did a dummy repo to test.

While the master language returns the right type for results.[type="paren"]. data.child.type the 2nd language does not (should be chi and not parent).

@maersu maersu changed the title Slices: Wrong type for custom types Content Relationship and Multi-languages: Wrong type for custom types Apr 5, 2019
@arnaudlewis
Copy link
Member

arnaudlewis commented Apr 5, 2019 via email

@maersu
Copy link
Author

maersu commented Apr 5, 2019

@arnaudlewis it works with a new created repo! Thanks!

@maersu
Copy link
Author

maersu commented Apr 8, 2019

Hi @arnaudlewis

There is still a similar bug with i18n/custom types/Content Relationship. Looks like its related to the Single Type custom type:

master language: https://broken-content.prismic.io/api/v1/documents/search?ref=XKsVyRMAAEqPUjE1#format=json

oah: {
  type: "Link.document"
  value: {
  document: {
    id: "XKsRthMAAO6UUh79"
    type: "child"
    tags: [ ]
    lang: "en-us"
    slug: "child-title-en"
}

2nd language (document object is missing): https://broken-content.prismic.io/api/v1/documents/search?ref=XKsVyRMAAEqPUjE1&lang=de-ch#format=json

{
oah: {
  type: "Link.document"
  value: "=&=033XKsR0hMAAO6UUh96%%parent-single%%"
  }
}

Or do I something wrong?

@arnaudlewis
Copy link
Member

arnaudlewis commented Apr 8, 2019 via email

@arnaudlewis
Copy link
Member

arnaudlewis commented Jun 6, 2019

The fix has been released.

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

No branches or pull requests

2 participants