datocms / product-roadmap

This project is now discontinued. For feature requests, please use our community forum.
https://community.datocms.com/
19 stars 1 forks source link

Mixed models in "Multiple Links" field causes a warning #141

Closed hesedel closed 5 years ago

hesedel commented 5 years ago

I mixed two different models for Multiple Links field and although fetching the data works, I'm getting this warning in the console.

one model has a field called contentType, the other one has a field called slideType

screenshot 2019-02-12 at 11 50 43
stefanoverna commented 5 years ago

@hesedel could you share the query that gives you this warning?

sbc3 commented 5 years ago

@hesedel I recently had the same issue. It's an Apollo issue rather than DatoCMS from what I can tell. You need to download your schema and load it into Apollo, this issue will then be solved. See here https://www.apollographql.com/docs/react/advanced/fragments.html#fragment-matcher

hesedel commented 5 years ago

@stefanoverna here's the query:

some stored variables:

const ContentRecord = `
  ... on ContentRecord {
    id
    _modelApiKey
    contentType {
      ... on ContentTypeBannerRecord {
        id
        _modelApiKey
        heading
        buttonText
        href
        backgroundColor {
          ... on ColorField {
            hex
          }
        }
      }
      ... on ContentTypeDefaultRecord {
        id
        _modelApiKey
        layout
        tag
        heading
        subheading
        text
        buttonText
        href
        media {
          ${FileField}
        }
      }
      ... on ContentTypeGalleryRecord {
        id
        _modelApiKey
        layout
        heading
        text
        media {
          ${FileField}
        }
      }
      ... on ContentTypeIframeRecord {
        id
        _modelApiKey
        src
        width
        height
        media {
          ${FileField}
        }
      }
      ... on ContentTypeVideoRecord {
        id
        _modelApiKey
        video {
          ${FileField}
        }
        width
        height
        image {
          ${FileField}
        }
      }
    }
    countryBlacklist {
      ... on CountryRecord {
        id
        _modelApiKey
        name
      }
    }
  }
`;

const SlideRecord = `
  ... on SlideRecord {
    id
    _modelApiKey
    slideType {
      ... on SlideTypeDefaultRecord {
        id
        _modelApiKey
        heading
        buttonText
        href
        media {
          ${FileField}
        }
        cropped
      }
    }
  }
`;

The main query:

    {
      allPages(
        filter: {
          id: {
            eq: "${id}"
          }
        }
      ) {
        id
        _modelApiKey
        title
        hero {
          id
          _modelApiKey
          heroType {
            ... on HeroTypeSliderRecord {
              id
              _modelApiKey
              slides {
                ${SlideRecord}
              }
            }
          }
        }
        content {
          ... on ContentSectionRecord {
            id
            _modelApiKey
            content {
              ${ContentRecord}
              ${SlideRecord}
              ${SliderRecord}
            }
          }
        }
      }
    }
hesedel commented 5 years ago

@sbc3 Thanks for the suggestion, will look into this.

stefanoverna commented 5 years ago

Please reopen this if this is really a bug on our side!