text: import { isTest, } from '../util/environment';
  var IntrospectionFragmentMatcher = (function () {
      function IntrospectionFragmentMatcher(options) {
          if (options && options.introspectionQueryResultData) {
              this.possibleTypesMap = this.parseIntrospectionResult(options.introspectionQueryResultData);
              this.isReady = true;
          }
          else {
              this.isReady = false;
          }
          this.match = this.match.bind(this);
      }
      IntrospectionFragmentMatcher.prototype.match = function (idValue, typeCondition, context) {
          if (!this.isReady) {
              throw new Error('FragmentMatcher.match() was called before FragmentMatcher.init()');
          }
          var obj = context.store[idValue.id];
          if (!obj) {
              return false;
          }
          if (!obj.__typename) {
              throw new Error("Cannot match fragment because __typename property is missing: " + JSON.stringify(obj));
          }
          if (obj.__typename === typeCondition) {
              return true;
          }
          var implementingTypes = this.possibleTypesMap[typeCondition];
          if (implementingTypes && implementingTypes.indexOf(obj.__typename) > -1) {
              return true;
          }
          return false;
      };
      IntrospectionFragmentMatcher.prototype.parseIntrospectionResult = function (introspectionResultData) {
          var typeMap = {};
          introspectionResultData.__schema.types.forEach(function (type) {
              if (type.kind === 'UNION' || type.kind === 'INTERFACE') {
                  typeMap[type.name] = type.possibleTypes.map(function (implementingType) { return implementingType.name; });
              }
          });
          return typeMap;
      };
      return IntrospectionFragmentMatcher;
  }());
  export { IntrospectionFragmentMatcher };
  var haveWarned = false;
  var HeuristicFragmentMatcher = (function () {
      function HeuristicFragmentMatcher() {
      }
      HeuristicFragmentMatcher.prototype.ensureReady = function () {
          return Promise.resolve();
      };
      HeuristicFragmentMatcher.prototype.canBypassInit = function () {
          return true;
      };
      HeuristicFragmentMatcher.prototype.match = function (idValue, typeCondition, context) {
          var obj = context.store[idValue.id];
          if (!obj) {
              return false;
          }
          if (!obj.__typename) {
              if (!haveWarned) {
                  console.warn("You're using fragments in your queries, but don't have the addTypename:\n  true option set in Apollo Client. Please turn on that option so that we can accurately\n  match fragments.");
                  if (!isTest()) {
                      haveWarned = true;
                  }
              }
              context.returnPartialData = true;
              return true;
          }
          if (obj.__typename === typeCondition) {
              return true;
          }
          context.returnPartialData = true;
          return true;
      };
      return HeuristicFragmentMatcher;
  }());
  export { HeuristicFragmentMatcher };
  //# sourceMappingURL=fragmentMatcher.js.map