datocms / gatsby-source-datocms

Official GatsbyJS source plugin to pull content from DatoCMS
MIT License
140 stars 50 forks source link

Locale Fallback behavior missing on modular blocks #89

Closed tbrannam closed 4 years ago

tbrannam commented 4 years ago

Given a local fallback of en-GB => [en-GB, en] - I would expect that inspecting a model instance with Block1 defined in en-GB and Block1 and Block2 defined in en - that when the en-GB locale is queried that the results would contain content from Block1 in en-GB and Block2 from en.

Gatsby GraphQL query

query MyQuery {
  datoCmsStringTable(locale: {eq: "en-GB"}) {
    id
    locale
    application {
      __typename
      ... on DatoCmsShippingAddress {
        id
        lineOne
        locale
      }
      ... on DatoCmsConfirmation {
        id
        success
        failure
        locale
      }
    }
    _allApplicationLocales {
      locale
      value {
        __typename
        ... on DatoCmsShippingAddress {
          id
          lineOne
        }
        ... on DatoCmsConfirmation {
          id
          success
          failure
        }
      }
    }
  }
}

results - merging does not occur - secondly - it would be fantastic if the "failure" key of 'en-GB' would also fallback to 'en' as well.


{
  "data": {
    "datoCmsStringTable": {
      "id": "DatoCmsStringTable-2075065-en-GB",
      "locale": "en-GB",
      "application": [
        {
          "__typename": "DatoCmsConfirmation",
          "id": "DatoCmsConfirmation-2075067-en-GB",
          "success": "this is the confirmation from GB",
          "failure": "",
          "locale": "en-GB"
        }
      ],
      "_allApplicationLocales": [
        {
          "locale": "en",
          "value": [
            {
              "__typename": "DatoCmsShippingAddress",
              "id": "DatoCmsShippingAddress-2075158-en",
              "lineOne": "test"
            },
            {
              "__typename": "DatoCmsConfirmation",
              "id": "DatoCmsConfirmation-2075064-en",
              "success": "this is the confirmation",
              "failure": "failure"
            }
          ]
        },
        {
          "locale": "en-GB",
          "value": [
            {
              "__typename": "DatoCmsConfirmation",
              "id": "DatoCmsConfirmation-2075067-en-GB",
              "success": "this is the confirmation from GB",
              "failure": ""
            }
          ]
        }
      ]
    }
  }
}```
tbrannam commented 4 years ago

Closing this issue - I expect that behavior is expected - and that I should just be using a normal models with links