Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

pfchangs / react-relay   js

Repository URL to install this package:

Version: 0.7.1-ccinternal 

/ lib / isCompatibleRelayFragmentType.js

/**
 * Copyright 2013-2015, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 *
 * @providesModule isCompatibleRelayFragmentType
 * 
 * @typechecks
 */

/**
 * @internal
 *
 * Determine if the given fragment's type is compatible with the given record
 * type. The types are considered compatible if they exactly match or in the
 * following cases:
 * - Types are not recorded for optimistic records; if the record type is null
 *   it is assumed to be compatible with the fragment.
 * - Abstract fragments are assumed to be compatible with all types; being more
 *   precise would require access to the full schema inheritance hierarchy.
 */
'use strict';

function isCompatibleRelayFragmentType(fragment, recordType) {
  return recordType === fragment.getType() || !recordType || fragment.isAbstract();
}

module.exports = isCompatibleRelayFragmentType;